diff --git a/backend/api/api.go b/backend/api/api.go
index 8b16e82..7a5dd0a 100644
--- a/backend/api/api.go
+++ b/backend/api/api.go
@@ -3,6 +3,7 @@ package api
import (
"s-ui/logger"
"s-ui/service"
+ "s-ui/util"
"strconv"
"strings"
@@ -95,6 +96,10 @@ func (a *APIHandler) postHandler(c *gin.Context) {
case "restartApp":
err = a.PanelService.RestartPanel(3)
jsonMsg(c, "restartApp", err)
+ case "linkConvert":
+ link := c.Request.FormValue("link")
+ result, _, err := util.GetOutbound(link, 0)
+ jsonObj(c, result, err)
default:
jsonMsg(c, "API call", nil)
}
diff --git a/backend/util/linkToJson.go b/backend/util/linkToJson.go
index d78324d..549d8e2 100644
--- a/backend/util/linkToJson.go
+++ b/backend/util/linkToJson.go
@@ -109,7 +109,9 @@ func vmess(data string, i int) (*map[string]interface{}, string, error) {
}
}
tag, _ := dataJson["ps"].(string)
- tag = fmt.Sprintf("%d.%s", i, tag)
+ if i > 0 {
+ tag = fmt.Sprintf("%d.%s", i, tag)
+ }
alter_id, ok := dataJson["aid"].(int)
if !ok {
alter_id = 0
@@ -141,7 +143,10 @@ func vless(u *url.URL, i int) (*map[string]interface{}, string, error) {
}
}
tp_type := query.Get("type")
- tag := fmt.Sprintf("%d.%s", i, u.Fragment)
+ tag := u.Fragment
+ if i > 0 {
+ tag = fmt.Sprintf("%d.%s", i, u.Fragment)
+ }
vless := map[string]interface{}{
"type": "vless",
"tag": tag,
@@ -168,7 +173,10 @@ func trojan(u *url.URL, i int) (*map[string]interface{}, string, error) {
}
}
tp_type := query.Get("type")
- tag := fmt.Sprintf("%d.%s", i, u.Fragment)
+ tag := u.Fragment
+ if i > 0 {
+ tag = fmt.Sprintf("%d.%s", i, u.Fragment)
+ }
trojan := map[string]interface{}{
"type": "trojan",
"tag": tag,
@@ -202,7 +210,10 @@ func hy(u *url.URL, i int) (*map[string]interface{}, string, error) {
tls["insecure"] = true
}
- tag := fmt.Sprintf("%d.%s", i, u.Fragment)
+ tag := u.Fragment
+ if i > 0 {
+ tag = fmt.Sprintf("%d.%s", i, u.Fragment)
+ }
hy := map[string]interface{}{
"type": "hysteria",
"tag": tag,
@@ -252,7 +263,10 @@ func hy2(u *url.URL, i int) (*map[string]interface{}, string, error) {
tls["insecure"] = true
}
- tag := fmt.Sprintf("%d.%s", i, u.Fragment)
+ tag := u.Fragment
+ if i > 0 {
+ tag = fmt.Sprintf("%d.%s", i, u.Fragment)
+ }
hy2 := map[string]interface{}{
"type": "hysteria2",
"tag": tag,
@@ -304,7 +318,10 @@ func tuic(u *url.URL, i int) (*map[string]interface{}, string, error) {
tls["disable_sni"] = true
}
- tag := fmt.Sprintf("%d.%s", i, u.Fragment)
+ tag := u.Fragment
+ if i > 0 {
+ tag = fmt.Sprintf("%d.%s", i, u.Fragment)
+ }
password, _ := u.User.Password()
tuic := map[string]interface{}{
"type": "tuic",
@@ -340,7 +357,10 @@ func ss(u *url.URL, i int) (*map[string]interface{}, string, error) {
}
}
- tag := fmt.Sprintf("%d.%s", i, u.Fragment)
+ tag := u.Fragment
+ if i > 0 {
+ tag = fmt.Sprintf("%d.%s", i, u.Fragment)
+ }
ss := map[string]interface{}{
"type": "shadowsocks",
"tag": tag,
diff --git a/frontend/src/layouts/modals/Outbound.vue b/frontend/src/layouts/modals/Outbound.vue
index 3067886..cc56eec 100644
--- a/frontend/src/layouts/modals/Outbound.vue
+++ b/frontend/src/layouts/modals/Outbound.vue
@@ -5,61 +5,84 @@
{{ $t('actions.' + title) + " " + $t('objects.outbound') }}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+ {{ $t('client.basics') }}
+ {{ $t('client.external') }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ $t('submit') }}
+
+
+
+
+
@@ -106,6 +129,7 @@ import Tor from '@/components/protocols/Tor.vue'
import Ssh from '@/components/protocols/Ssh.vue'
import Selector from '@/components/protocols/Selector.vue'
import UrlTest from '@/components/protocols/UrlTest.vue'
+import HttpUtils from '@/plugins/httputil'
export default {
props: ['visible', 'data', 'id', 'stats', 'tags'],
emits: ['close', 'save'],
@@ -113,6 +137,8 @@ export default {
return {
outbound: createOutbound("direct",{ "tag": "" }),
title: "add",
+ tab: "t1",
+ link: "",
loading: false,
outTypes: OutTypes,
outboundStats: false,
@@ -149,6 +175,17 @@ export default {
this.$emit('save', this.outbound, this.outboundStats)
this.loading = false
},
+ async linkConvert() {
+ if (this.link.length>0){
+ this.loading = true
+ const msg = await HttpUtils.post('api/linkConvert', { link: this.link })
+ this.loading = false
+ if (msg.success) {
+ this.outbound = msg.obj
+ this.tab = "t1"
+ }
+ }
+ }
},
watch: {
visible(newValue) {