diff --git a/sub/sub.go b/sub/sub.go
index 8fe025bc..dc8e9c5e 100644
--- a/sub/sub.go
+++ b/sub/sub.go
@@ -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 2385b76b..3abd7f1e 100644
--- a/sub/subController.go
+++ b/sub/subController.go
@@ -26,6 +26,7 @@ func NewSUBController(
rModel string,
update string,
jsonFragment string,
+ jsonNoise string,
jsonMux string,
jsonRules string,
) *SUBController {
@@ -37,7 +38,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 cd5f92c0..9ffaa4a0 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,
}
diff --git a/web/assets/js/model/outbound.js b/web/assets/js/model/outbound.js
index b700e1c4..01bd539f 100644
--- a/web/assets/js/model/outbound.js
+++ b/web/assets/js/model/outbound.js
@@ -824,23 +824,34 @@ Outbound.Settings = class extends CommonClass {
}
};
Outbound.FreedomSettings = class extends CommonClass {
- constructor(domainStrategy='', fragment={}) {
+ constructor(
+ domainStrategy = '',
+ redirect = '',
+ fragment = {},
+ noise = {}
+ ) {
super();
this.domainStrategy = domainStrategy;
+ this.redirect = redirect;
this.fragment = fragment;
+ this.noise = noise;
}
- static fromJson(json={}) {
+ static fromJson(json = {}) {
return new Outbound.FreedomSettings(
json.domainStrategy,
+ json.redirect,
json.fragment ? Outbound.FreedomSettings.Fragment.fromJson(json.fragment) : undefined,
+ json.noise ? Outbound.FreedomSettings.Noise.fromJson(json.noise) : undefined,
);
}
toJson() {
return {
domainStrategy: ObjectUtil.isEmpty(this.domainStrategy) ? undefined : this.domainStrategy,
+ redirect: this.redirect,
fragment: Object.keys(this.fragment).length === 0 ? undefined : this.fragment,
+ noise: Object.keys(this.noise).length === 0 ? undefined : this.noise,
};
}
};
@@ -860,6 +871,20 @@ Outbound.FreedomSettings.Fragment = class extends CommonClass {
);
}
};
+Outbound.FreedomSettings.Noise = class extends CommonClass {
+ constructor(packets = '', delay = '') {
+ super();
+ this.packets = packets;
+ this.delay = delay;
+ }
+
+ static fromJson(json = {}) {
+ return new Outbound.FreedomSettings.Noise(
+ json.packets,
+ json.delay,
+ );
+ }
+};
Outbound.BlackholeSettings = class extends CommonClass {
constructor(type) {
super();
diff --git a/web/assets/js/model/setting.js b/web/assets/js/model/setting.js
index a60c0df6..dd7effe2 100644
--- a/web/assets/js/model/setting.js
+++ b/web/assets/js/model/setting.js
@@ -34,6 +34,7 @@ class AllSetting {
this.subURI = "";
this.subJsonURI = "";
this.subJsonFragment = "";
+ this.subJsonNoise = "";
this.subJsonMux = "";
this.subJsonRules = "";
diff --git a/web/entity/entity.go b/web/entity/entity.go
index cb173394..8975afd0 100644
--- a/web/entity/entity.go
+++ b/web/entity/entity.go
@@ -50,6 +50,7 @@ type AllSetting struct {
SubJsonPath string `json:"subJsonPath" form:"subJsonPath"`
SubJsonURI string `json:"subJsonURI" form:"subJsonURI"`
SubJsonFragment string `json:"subJsonFragment" form:"subJsonFragment"`
+ SubJsonNoise string `json:"subJsonNoise" form:"subJsonNoise"`
SubJsonMux string `json:"subJsonMux" form:"subJsonMux"`
SubJsonRules string `json:"subJsonRules" form:"subJsonRules"`
}
diff --git a/web/html/xui/form/outbound.html b/web/html/xui/form/outbound.html
index e211d1c5..5241dfe1 100644
--- a/web/html/xui/form/outbound.html
+++ b/web/html/xui/form/outbound.html
@@ -45,6 +45,20 @@
+
+ outbound.settings.noise = checked ? new Outbound.FreedomSettings.Noise() : {}">
+
+
+
+
+
+
+
+
+
+
diff --git a/web/html/xui/settings.html b/web/html/xui/settings.html
index 6936843d..f8aed6ef 100644
--- a/web/html/xui/settings.html
+++ b/web/html/xui/settings.html
@@ -209,6 +209,7 @@
+
@@ -218,6 +219,10 @@
+
+
+
+
@@ -296,6 +301,17 @@
}
}
},
+ defaultNoise: {
+ tag: "noise",
+ protocol: "freedom",
+ settings: {
+ domainStrategy: "AsIs",
+ noise: {
+ packets: "rand:5-10",
+ delay: "5-10",
+ }
+ },
+ },
defaultMux: {
enabled: true,
concurrency: 8,
@@ -447,6 +463,32 @@
}
}
},
+ enableNoise: {
+ get: function () { return this.allSetting?.subJsonNoise != ""; },
+ set: function (v) {
+ this.allSetting.subJsonNoise = v ? JSON.stringify(this.defaultNoise) : "";
+ }
+ },
+ noisePackets: {
+ get: function () { return this.enableNoise ? JSON.parse(this.allSetting.subJsonNoise).settings.noise.packets : ""; },
+ set: function (v) {
+ if (v != "") {
+ newNoise = JSON.parse(this.allSetting.subJsonNoise);
+ newNoise.settings.noise.packets = v;
+ this.allSetting.subJsonNoise = JSON.stringify(newNoise);
+ }
+ }
+ },
+ noiseDelay: {
+ get: function () { return this.enableNoise ? JSON.parse(this.allSetting.subJsonNoise).settings.noise.delay : ""; },
+ set: function (v) {
+ if (v != "") {
+ newNoise = JSON.parse(this.allSetting.subJsonNoise);
+ newNoise.settings.noise.delay = v;
+ this.allSetting.subJsonNoise = JSON.stringify(newNoise);
+ }
+ }
+ },
enableMux: {
get: function() { return this.allSetting?.subJsonMux != ""; },
set: function (v) {
diff --git a/web/service/setting.go b/web/service/setting.go
index 43105411..4dcc3614 100644
--- a/web/service/setting.go
+++ b/web/service/setting.go
@@ -59,6 +59,7 @@ var defaultValueMap = map[string]string{
"subJsonPath": "/json/",
"subJsonURI": "",
"subJsonFragment": "",
+ "subJsonNoise": "",
"subJsonMux": "",
"subJsonRules": "",
"warp": "",
@@ -405,6 +406,10 @@ func (s *SettingService) GetSubJsonFragment() (string, error) {
return s.getString("subJsonFragment")
}
+func (s *SettingService) GetSubJsonNoise() (string, error) {
+ return s.getString("subJsonNoise")
+}
+
func (s *SettingService) GetSubJsonMux() (string, error) {
return s.getString("subJsonMux")
}