Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormhsanaei <ho3ein.sanaei@gmail.com>2025-09-20 12:11:30 +0300
committermhsanaei <ho3ein.sanaei@gmail.com>2025-09-20 14:10:57 +0300
commit37c17357fc45b9acec387f3097be5db074ce880d (patch)
treea3a5aa82c7483c0883070185372c491537173c25 /sub/subJsonService.go
parentb35d33966589f428053b77f51a92ec0214bd92fb (diff)
undo vnext for vmess
Diffstat (limited to 'sub/subJsonService.go')
-rw-r--r--sub/subJsonService.go68
1 files changed, 52 insertions, 16 deletions
diff --git a/sub/subJsonService.go b/sub/subJsonService.go
index f440ab65..86a7a405 100644
--- a/sub/subJsonService.go
+++ b/sub/subJsonService.go
@@ -174,12 +174,12 @@ func (s *SubJsonService) getConfig(inbound *model.Inbound, client model.Client,
case "tls":
if newStream["security"] != "tls" {
newStream["security"] = "tls"
- newStream["tslSettings"] = map[string]any{}
+ newStream["tlsSettings"] = map[string]any{}
}
case "none":
if newStream["security"] != "none" {
newStream["security"] = "none"
- delete(newStream, "tslSettings")
+ delete(newStream, "tlsSettings")
}
}
streamSettings, _ := json.MarshalIndent(newStream, "", " ")
@@ -188,13 +188,9 @@ func (s *SubJsonService) getConfig(inbound *model.Inbound, client model.Client,
switch inbound.Protocol {
case "vmess":
- newOutbounds = append(newOutbounds, s.genVnext(inbound, streamSettings, client, ""))
+ newOutbounds = append(newOutbounds, s.genVnext(inbound, streamSettings, client))
case "vless":
- var vlessSettings model.VLESSSettings
- _ = json.Unmarshal([]byte(inbound.Settings), &vlessSettings)
-
- newOutbounds = append(newOutbounds,
- s.genVnext(inbound, streamSettings, client, vlessSettings.Encryption))
+ newOutbounds = append(newOutbounds, s.genVless(inbound, streamSettings, client))
case "trojan", "shadowsocks":
newOutbounds = append(newOutbounds, s.genServer(inbound, streamSettings, client))
}
@@ -293,7 +289,35 @@ func (s *SubJsonService) realityData(rData map[string]any) map[string]any {
return rltyData
}
-func (s *SubJsonService) genVnext(inbound *model.Inbound, streamSettings json_util.RawMessage, client model.Client, encryption string) json_util.RawMessage {
+func (s *SubJsonService) genVnext(inbound *model.Inbound, streamSettings json_util.RawMessage, client model.Client) json_util.RawMessage {
+ outbound := Outbound{}
+ usersData := make([]UserVnext, 1)
+
+ usersData[0].ID = client.ID
+ usersData[0].Email = client.Email
+ usersData[0].Security = client.Security
+ vnextData := make([]VnextSetting, 1)
+ vnextData[0] = VnextSetting{
+ Address: inbound.Listen,
+ Port: inbound.Port,
+ Users: usersData,
+ }
+
+ outbound.Protocol = string(inbound.Protocol)
+ outbound.Tag = "proxy"
+ if s.mux != "" {
+ outbound.Mux = json_util.RawMessage(s.mux)
+ }
+ outbound.StreamSettings = streamSettings
+ outbound.Settings = map[string]any{
+ "vnext": vnextData,
+ }
+
+ result, _ := json.MarshalIndent(outbound, "", " ")
+ return result
+}
+
+func (s *SubJsonService) genVless(inbound *model.Inbound, streamSettings json_util.RawMessage, client model.Client) json_util.RawMessage {
outbound := Outbound{}
outbound.Protocol = string(inbound.Protocol)
outbound.Tag = "proxy"
@@ -301,20 +325,22 @@ func (s *SubJsonService) genVnext(inbound *model.Inbound, streamSettings json_ut
outbound.Mux = json_util.RawMessage(s.mux)
}
outbound.StreamSettings = streamSettings
- // Emit flattened settings inside Settings to match new Xray format
settings := make(map[string]any)
settings["address"] = inbound.Listen
settings["port"] = inbound.Port
settings["id"] = client.ID
- if inbound.Protocol == model.VLESS {
+ if client.Flow != "" {
settings["flow"] = client.Flow
- settings["encryption"] = encryption
}
- if inbound.Protocol == model.VMESS {
- settings["security"] = client.Security
+
+ // Add encryption for VLESS outbound from inbound settings
+ var inboundSettings map[string]any
+ json.Unmarshal([]byte(inbound.Settings), &inboundSettings)
+ if encryption, ok := inboundSettings["encryption"].(string); ok {
+ settings["encryption"] = encryption
}
- outbound.Settings = settings
+ outbound.Settings = settings
result, _ := json.MarshalIndent(outbound, "", " ")
return result
}
@@ -366,7 +392,17 @@ type Outbound struct {
Settings map[string]any `json:"settings,omitempty"`
}
-// Legacy vnext-related structs removed for flattened schema
+type VnextSetting struct {
+ Address string `json:"address"`
+ Port int `json:"port"`
+ Users []UserVnext `json:"users"`
+}
+
+type UserVnext struct {
+ ID string `json:"id"`
+ Email string `json:"email,omitempty"`
+ Security string `json:"security,omitempty"`
+}
type ServerSetting struct {
Password string `json:"password"`