mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-04-26 17:36:15 +00:00
sub json fix fragment noises effect
Co-Authored-By: Alireza Ahmadi <alireza7@gmail.com>
This commit is contained in:
parent
2983ac3f8e
commit
0fd0389d5c
2 changed files with 46 additions and 54 deletions
|
|
@ -22,8 +22,7 @@ var defaultJson string
|
||||||
type SubJsonService struct {
|
type SubJsonService struct {
|
||||||
configJson map[string]any
|
configJson map[string]any
|
||||||
defaultOutbounds []json_util.RawMessage
|
defaultOutbounds []json_util.RawMessage
|
||||||
fragment string
|
fragmentOrNoises bool
|
||||||
noises string
|
|
||||||
mux string
|
mux string
|
||||||
|
|
||||||
inboundService service.InboundService
|
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 != "" {
|
if rules != "" {
|
||||||
var newRules []any
|
var newRules []any
|
||||||
routing, _ := configJson["routing"].(map[string]any)
|
routing, _ := configJson["routing"].(map[string]any)
|
||||||
|
|
@ -52,19 +76,10 @@ func NewSubJsonService(fragment string, noises string, mux string, rules string,
|
||||||
configJson["routing"] = routing
|
configJson["routing"] = routing
|
||||||
}
|
}
|
||||||
|
|
||||||
if fragment != "" {
|
|
||||||
defaultOutbounds = append(defaultOutbounds, json_util.RawMessage(fragment))
|
|
||||||
}
|
|
||||||
|
|
||||||
if noises != "" {
|
|
||||||
defaultOutbounds = append(defaultOutbounds, json_util.RawMessage(noises))
|
|
||||||
}
|
|
||||||
|
|
||||||
return &SubJsonService{
|
return &SubJsonService{
|
||||||
configJson: configJson,
|
configJson: configJson,
|
||||||
defaultOutbounds: defaultOutbounds,
|
defaultOutbounds: defaultOutbounds,
|
||||||
fragment: fragment,
|
fragmentOrNoises: fragmentOrNoises,
|
||||||
noises: noises,
|
|
||||||
mux: mux,
|
mux: mux,
|
||||||
SubService: subService,
|
SubService: subService,
|
||||||
}
|
}
|
||||||
|
|
@ -224,8 +239,8 @@ func (s *SubJsonService) streamData(stream string) map[string]any {
|
||||||
}
|
}
|
||||||
delete(streamSettings, "sockopt")
|
delete(streamSettings, "sockopt")
|
||||||
|
|
||||||
if s.fragment != "" {
|
if s.fragmentOrNoises {
|
||||||
streamSettings["sockopt"] = json_util.RawMessage(`{"dialerProxy": "fragment", "tcpKeepAliveIdle": 100, "tcpMptcp": true, "penetrate": true}`)
|
streamSettings["sockopt"] = json_util.RawMessage(`{"dialerProxy": "direct_out", "tcpKeepAliveIdle": 100}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove proxy protocol
|
// remove proxy protocol
|
||||||
|
|
|
||||||
|
|
@ -129,35 +129,14 @@
|
||||||
datepickerList: [{ name: 'Gregorian (Standard)', value: 'gregorian' }, { name: 'Jalalian (شمسی)', value: 'jalalian' }],
|
datepickerList: [{ name: 'Gregorian (Standard)', value: 'gregorian' }, { name: 'Jalalian (شمسی)', value: 'jalalian' }],
|
||||||
remarkSample: '',
|
remarkSample: '',
|
||||||
defaultFragment: {
|
defaultFragment: {
|
||||||
tag: "fragment",
|
packets: "tlshello",
|
||||||
protocol: "freedom",
|
length: "100-200",
|
||||||
settings: {
|
interval: "10-20",
|
||||||
domainStrategy: "AsIs",
|
maxSplit: "300-400"
|
||||||
fragment: {
|
|
||||||
packets: "tlshello",
|
|
||||||
length: "100-200",
|
|
||||||
interval: "10-20",
|
|
||||||
maxSplit: "300-400"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
streamSettings: {
|
|
||||||
sockopt: {
|
|
||||||
tcpKeepAliveIdle: 100,
|
|
||||||
tcpMptcp: true,
|
|
||||||
penetrate: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
defaultNoises: {
|
|
||||||
tag: "noises",
|
|
||||||
protocol: "freedom",
|
|
||||||
settings: {
|
|
||||||
domainStrategy: "AsIs",
|
|
||||||
noises: [
|
|
||||||
{ type: "rand", packet: "10-20", delay: "10-16", applyTo: "ip" },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
defaultNoises: [
|
||||||
|
{ type: "rand", packet: "10-20", delay: "10-16", applyTo: "ip" }
|
||||||
|
],
|
||||||
defaultMux: {
|
defaultMux: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
concurrency: 8,
|
concurrency: 8,
|
||||||
|
|
@ -451,41 +430,41 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
fragmentPackets: {
|
fragmentPackets: {
|
||||||
get: function () { return this.fragment ? JSON.parse(this.allSetting.subJsonFragment).settings.fragment.packets : ""; },
|
get: function () { return this.fragment ? JSON.parse(this.allSetting.subJsonFragment).packets : ""; },
|
||||||
set: function (v) {
|
set: function (v) {
|
||||||
if (v != "") {
|
if (v != "") {
|
||||||
newFragment = JSON.parse(this.allSetting.subJsonFragment);
|
newFragment = JSON.parse(this.allSetting.subJsonFragment);
|
||||||
newFragment.settings.fragment.packets = v;
|
newFragment.packets = v;
|
||||||
this.allSetting.subJsonFragment = JSON.stringify(newFragment);
|
this.allSetting.subJsonFragment = JSON.stringify(newFragment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
fragmentLength: {
|
fragmentLength: {
|
||||||
get: function () { return this.fragment ? JSON.parse(this.allSetting.subJsonFragment).settings.fragment.length : ""; },
|
get: function () { return this.fragment ? JSON.parse(this.allSetting.subJsonFragment).length : ""; },
|
||||||
set: function (v) {
|
set: function (v) {
|
||||||
if (v != "") {
|
if (v != "") {
|
||||||
newFragment = JSON.parse(this.allSetting.subJsonFragment);
|
newFragment = JSON.parse(this.allSetting.subJsonFragment);
|
||||||
newFragment.settings.fragment.length = v;
|
newFragment.length = v;
|
||||||
this.allSetting.subJsonFragment = JSON.stringify(newFragment);
|
this.allSetting.subJsonFragment = JSON.stringify(newFragment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
fragmentInterval: {
|
fragmentInterval: {
|
||||||
get: function () { return this.fragment ? JSON.parse(this.allSetting.subJsonFragment).settings.fragment.interval : ""; },
|
get: function () { return this.fragment ? JSON.parse(this.allSetting.subJsonFragment).interval : ""; },
|
||||||
set: function (v) {
|
set: function (v) {
|
||||||
if (v != "") {
|
if (v != "") {
|
||||||
newFragment = JSON.parse(this.allSetting.subJsonFragment);
|
newFragment = JSON.parse(this.allSetting.subJsonFragment);
|
||||||
newFragment.settings.fragment.interval = v;
|
newFragment.interval = v;
|
||||||
this.allSetting.subJsonFragment = JSON.stringify(newFragment);
|
this.allSetting.subJsonFragment = JSON.stringify(newFragment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
fragmentMaxSplit: {
|
fragmentMaxSplit: {
|
||||||
get: function () { return this.fragment ? JSON.parse(this.allSetting.subJsonFragment).settings.fragment.maxSplit : ""; },
|
get: function () { return this.fragment ? JSON.parse(this.allSetting.subJsonFragment).maxSplit : ""; },
|
||||||
set: function (v) {
|
set: function (v) {
|
||||||
if (v != "") {
|
if (v != "") {
|
||||||
newFragment = JSON.parse(this.allSetting.subJsonFragment);
|
newFragment = JSON.parse(this.allSetting.subJsonFragment);
|
||||||
newFragment.settings.fragment.maxSplit = v;
|
newFragment.maxSplit = v;
|
||||||
this.allSetting.subJsonFragment = JSON.stringify(newFragment);
|
this.allSetting.subJsonFragment = JSON.stringify(newFragment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -504,13 +483,11 @@
|
||||||
},
|
},
|
||||||
noisesArray: {
|
noisesArray: {
|
||||||
get() {
|
get() {
|
||||||
return this.noises ? JSON.parse(this.allSetting.subJsonNoises).settings.noises : [];
|
return this.noises ? JSON.parse(this.allSetting.subJsonNoises) : [];
|
||||||
},
|
},
|
||||||
set(value) {
|
set(value) {
|
||||||
if (this.noises) {
|
if (this.noises) {
|
||||||
const newNoises = JSON.parse(this.allSetting.subJsonNoises);
|
this.allSetting.subJsonNoises = JSON.stringify(value);
|
||||||
newNoises.settings.noises = value;
|
|
||||||
this.allSetting.subJsonNoises = JSON.stringify(newNoises);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue