diff options
| author | MHSanaei <ho3ein.sanaei@gmail.com> | 2026-04-21 21:02:39 +0300 |
|---|---|---|
| committer | MHSanaei <ho3ein.sanaei@gmail.com> | 2026-04-21 21:02:39 +0300 |
| commit | 0fd0389d5c4bb616bbea2558bbb7de4ae0d3bf51 (patch) | |
| tree | 519ce238a94011538e76d73a6b7102e383b05e3b /sub/subJsonService.go | |
| parent | 2983ac3f8eb40499a5dbb8c0fd450fdc8a43ee08 (diff) | |
sub json fix fragment noises effect
Co-Authored-By: Alireza Ahmadi <alireza7@gmail.com>
Diffstat (limited to 'sub/subJsonService.go')
| -rw-r--r-- | sub/subJsonService.go | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/sub/subJsonService.go b/sub/subJsonService.go index 7ce93e22..acb8e05f 100644 --- a/sub/subJsonService.go +++ b/sub/subJsonService.go @@ -22,8 +22,7 @@ var defaultJson string type SubJsonService struct { configJson map[string]any defaultOutbounds []json_util.RawMessage - fragment string - noises string + fragmentOrNoises bool mux string inboundService service.InboundService @@ -42,6 +41,31 @@ func NewSubJsonService(fragment string, noises string, mux string, rules string, } } + fragmentOrNoises := false + if fragment != "" || noises != "" { + fragmentOrNoises = true + defaultOutboundsSettings := map[string]interface{}{ + "domainStrategy": "UseIP", + "redirect": "", + } + + if fragment != "" { + defaultOutboundsSettings["fragment"] = json_util.RawMessage(fragment) + } + + if noises != "" { + defaultOutboundsSettings["noises"] = json_util.RawMessage(noises) + } + + defaultDirectOutbound := map[string]interface{}{ + "protocol": "freedom", + "settings": defaultOutboundsSettings, + "tag": "direct_out", + } + jsonBytes, _ := json.MarshalIndent(defaultDirectOutbound, "", " ") + defaultOutbounds = append(defaultOutbounds, jsonBytes) + } + if rules != "" { var newRules []any routing, _ := configJson["routing"].(map[string]any) @@ -52,19 +76,10 @@ func NewSubJsonService(fragment string, noises string, mux string, rules string, configJson["routing"] = routing } - if fragment != "" { - defaultOutbounds = append(defaultOutbounds, json_util.RawMessage(fragment)) - } - - if noises != "" { - defaultOutbounds = append(defaultOutbounds, json_util.RawMessage(noises)) - } - return &SubJsonService{ configJson: configJson, defaultOutbounds: defaultOutbounds, - fragment: fragment, - noises: noises, + fragmentOrNoises: fragmentOrNoises, mux: mux, SubService: subService, } @@ -224,8 +239,8 @@ func (s *SubJsonService) streamData(stream string) map[string]any { } delete(streamSettings, "sockopt") - if s.fragment != "" { - streamSettings["sockopt"] = json_util.RawMessage(`{"dialerProxy": "fragment", "tcpKeepAliveIdle": 100, "tcpMptcp": true, "penetrate": true}`) + if s.fragmentOrNoises { + streamSettings["sockopt"] = json_util.RawMessage(`{"dialerProxy": "direct_out", "tcpKeepAliveIdle": 100}`) } // remove proxy protocol |
