diff options
| author | mhsanaei <ho3ein.sanaei@gmail.com> | 2024-08-29 12:27:43 +0300 |
|---|---|---|
| committer | mhsanaei <ho3ein.sanaei@gmail.com> | 2024-08-29 12:27:43 +0300 |
| commit | fa43248e3043932a31bc93ff86a2d4a3f1314491 (patch) | |
| tree | ed9e83e4f352de96e50ebb1f98ec4b525d787307 /sub | |
| parent | cb3da25bc82b818018476d53fe534aba3a55e1aa (diff) | |
New - Noise
freedom
Diffstat (limited to 'sub')
| -rw-r--r-- | sub/sub.go | 7 | ||||
| -rw-r--r-- | sub/subController.go | 3 | ||||
| -rw-r--r-- | sub/subJsonService.go | 8 |
3 files changed, 15 insertions, 3 deletions
@@ -92,6 +92,11 @@ func (s *Server) initRouter() (*gin.Engine, error) { SubJsonFragment = "" } + SubJsonNoise, err := s.settingService.GetSubJsonNoise() + if err != nil { + SubJsonNoise = "" + } + SubJsonMux, err := s.settingService.GetSubJsonMux() if err != nil { SubJsonMux = "" @@ -106,7 +111,7 @@ func (s *Server) initRouter() (*gin.Engine, error) { s.sub = NewSUBController( g, LinksPath, JsonPath, Encrypt, ShowInfo, RemarkModel, SubUpdates, - SubJsonFragment, SubJsonMux, SubJsonRules) + SubJsonFragment, SubJsonNoise, SubJsonMux, SubJsonRules) return engine, nil } diff --git a/sub/subController.go b/sub/subController.go index 4f23c424..9afbc8da 100644 --- a/sub/subController.go +++ b/sub/subController.go @@ -27,6 +27,7 @@ func NewSUBController( rModel string, update string, jsonFragment string, + jsonNoise string, jsonMux string, jsonRules string, ) *SUBController { @@ -38,7 +39,7 @@ func NewSUBController( updateInterval: update, subService: sub, - subJsonService: NewSubJsonService(jsonFragment, jsonMux, jsonRules, sub), + subJsonService: NewSubJsonService(jsonFragment, jsonNoise, jsonMux, jsonRules, sub), } a.initRouter(g) return a diff --git a/sub/subJsonService.go b/sub/subJsonService.go index 8d90876f..cbda594a 100644 --- a/sub/subJsonService.go +++ b/sub/subJsonService.go @@ -21,13 +21,14 @@ type SubJsonService struct { configJson map[string]interface{} defaultOutbounds []json_util.RawMessage fragment string + noise string mux string inboundService service.InboundService SubService *SubService } -func NewSubJsonService(fragment string, mux string, rules string, subService *SubService) *SubJsonService { +func NewSubJsonService(fragment string, noise string, mux string, rules string, subService *SubService) *SubJsonService { var configJson map[string]interface{} var defaultOutbounds []json_util.RawMessage json.Unmarshal([]byte(defaultJson), &configJson) @@ -52,10 +53,15 @@ func NewSubJsonService(fragment string, mux string, rules string, subService *Su defaultOutbounds = append(defaultOutbounds, json_util.RawMessage(fragment)) } + if noise != "" { + defaultOutbounds = append(defaultOutbounds, json_util.RawMessage(noise)) + } + return &SubJsonService{ configJson: configJson, defaultOutbounds: defaultOutbounds, fragment: fragment, + noise: noise, mux: mux, SubService: subService, } |
