Skip to content

Commit

Permalink
update noise to noises
Browse files Browse the repository at this point in the history
+ type
  • Loading branch information
MHSanaei committed Sep 17, 2024
1 parent 77edea5 commit 6b0c9a5
Show file tree
Hide file tree
Showing 18 changed files with 104 additions and 70 deletions.
6 changes: 3 additions & 3 deletions sub/sub.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ func (s *Server) initRouter() (*gin.Engine, error) {
SubJsonFragment = ""
}

SubJsonNoise, err := s.settingService.GetSubJsonNoise()
SubJsonNoises, err := s.settingService.GetSubJsonNoises()
if err != nil {
SubJsonNoise = ""
SubJsonNoises = ""
}

SubJsonMux, err := s.settingService.GetSubJsonMux()
Expand All @@ -111,7 +111,7 @@ func (s *Server) initRouter() (*gin.Engine, error) {

s.sub = NewSUBController(
g, LinksPath, JsonPath, Encrypt, ShowInfo, RemarkModel, SubUpdates,
SubJsonFragment, SubJsonNoise, SubJsonMux, SubJsonRules)
SubJsonFragment, SubJsonNoises, SubJsonMux, SubJsonRules)

return engine, nil
}
Expand Down
10 changes: 5 additions & 5 deletions sub/subJsonService.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ type SubJsonService struct {
configJson map[string]interface{}
defaultOutbounds []json_util.RawMessage
fragment string
noise string
noises string
mux string

inboundService service.InboundService
SubService *SubService
}

func NewSubJsonService(fragment string, noise string, mux string, rules string, subService *SubService) *SubJsonService {
func NewSubJsonService(fragment string, noises string, mux string, rules string, subService *SubService) *SubJsonService {
var configJson map[string]interface{}
var defaultOutbounds []json_util.RawMessage
json.Unmarshal([]byte(defaultJson), &configJson)
Expand All @@ -53,15 +53,15 @@ func NewSubJsonService(fragment string, noise string, mux string, rules string,
defaultOutbounds = append(defaultOutbounds, json_util.RawMessage(fragment))
}

if noise != "" {
defaultOutbounds = append(defaultOutbounds, json_util.RawMessage(noise))
if noises != "" {
defaultOutbounds = append(defaultOutbounds, json_util.RawMessage(noises))
}

return &SubJsonService{
configJson: configJson,
defaultOutbounds: defaultOutbounds,
fragment: fragment,
noise: noise,
noises: noises,
mux: mux,
SubService: subService,
}
Expand Down
20 changes: 13 additions & 7 deletions web/assets/js/model/outbound.js
Original file line number Diff line number Diff line change
Expand Up @@ -854,14 +854,14 @@ Outbound.FreedomSettings = class extends CommonClass {
timeout = 10,
redirect = '',
fragment = {},
noise = {}
noises = {}
) {
super();
this.domainStrategy = domainStrategy;
this.timeout = timeout;
this.redirect = redirect;
this.fragment = fragment;
this.noise = noise;
this.noises = noises;
}

static fromJson(json = {}) {
Expand All @@ -870,7 +870,7 @@ Outbound.FreedomSettings = class extends CommonClass {
json.timeout,
json.redirect,
json.fragment ? Outbound.FreedomSettings.Fragment.fromJson(json.fragment) : undefined,
json.noise ? Outbound.FreedomSettings.Noise.fromJson(json.noise) : undefined,
json.noises ? Outbound.FreedomSettings.Noises.fromJson(json.noises) : undefined,
);
}

Expand All @@ -880,7 +880,7 @@ Outbound.FreedomSettings = class extends CommonClass {
timeout: this.timeout,
redirect: this.redirect,
fragment: Object.keys(this.fragment).length === 0 ? undefined : this.fragment,
noise: Object.keys(this.noise).length === 0 ? undefined : this.noise,
noises: Object.keys(this.noises).length === 0 ? undefined : this.noises,
};
}
};
Expand All @@ -900,15 +900,21 @@ Outbound.FreedomSettings.Fragment = class extends CommonClass {
);
}
};
Outbound.FreedomSettings.Noise = class extends CommonClass {
constructor(packet = 'rand:100-200', delay = '10-20') {
Outbound.FreedomSettings.Noises = class extends CommonClass {
constructor(
type = 'rand',
packet = '10-20',
delay = '10-16'
) {
super();
this.type = type;
this.packet = packet;
this.delay = delay;
}

static fromJson(json = {}) {
return new Outbound.FreedomSettings.Noise(
return new Outbound.FreedomSettings.Noises(
json.type,
json.packet,
json.delay,
);
Expand Down
2 changes: 1 addition & 1 deletion web/assets/js/model/setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class AllSetting {
this.subURI = "";
this.subJsonURI = "";
this.subJsonFragment = "";
this.subJsonNoise = "";
this.subJsonNoises = "";
this.subJsonMux = "";
this.subJsonRules = "";

Expand Down
2 changes: 1 addition & 1 deletion web/entity/entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,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"`
SubJsonNoises string `json:"subJsonNoises" form:"subJsonNoises"`
SubJsonMux string `json:"subJsonMux" form:"subJsonMux"`
SubJsonRules string `json:"subJsonRules" form:"subJsonRules"`
Datepicker string `json:"datepicker" form:"datepicker"`
Expand Down
15 changes: 10 additions & 5 deletions web/html/xui/form/outbound.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,20 @@
<a-input v-model.trim="outbound.settings.fragment.interval"></a-input>
</a-form-item>
</template>
<a-form-item label='Noise'>
<a-switch :checked="Object.keys(outbound.settings.noise).length >0" @change="checked => outbound.settings.noise = checked ? new Outbound.FreedomSettings.Noise() : {}"></a-switch>
<a-form-item label='Noises'>
<a-switch :checked="Object.keys(outbound.settings.noises).length >0" @change="checked => outbound.settings.noises = checked ? new Outbound.FreedomSettings.Noises() : {}"></a-switch>
</a-form-item>
<template v-if="Object.keys(outbound.settings.noise).length >0">
<template v-if="Object.keys(outbound.settings.noises).length >0">
<a-form-item label='Type'>
<a-select v-model="outbound.settings.noises.type" :dropdown-class-name="themeSwitcher.currentTheme">
<a-select-option v-for="s in ['rand','base64','str']" :value="s">[[ s ]]</a-select-option>
</a-select>
</a-form-item>
<a-form-item label='Packet'>
<a-input v-model.trim="outbound.settings.noise.packet"></a-input>
<a-input v-model.trim="outbound.settings.noises.packet"></a-input>
</a-form-item>
<a-form-item label='Delay'>
<a-input v-model.trim="outbound.settings.noise.delay"></a-input>
<a-input v-model.trim="outbound.settings.noises.delay"></a-input>
</a-form-item>
</template>
</template>
Expand Down
73 changes: 48 additions & 25 deletions web/html/xui/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -305,18 +305,30 @@
<a-list-item style="padding: 20px">
<a-row>
<a-col :lg="24" :xl="12">
<a-list-item-meta title='Noise'>
<template slot="description">{{ i18n "pages.settings.noiseDesc"}}</template>
<a-list-item-meta title='Noises'>
<template slot="description">{{ i18n "pages.settings.noisesDesc"}}</template>
</a-list-item-meta>
</a-col>
<a-col :lg="24" :xl="12">
<a-switch v-model="noise"></a-switch>
<a-switch v-model="noises"></a-switch>
</a-col>
</a-row>
<a-collapse v-if="noise" style="margin-top: 14px;">
<a-collapse-panel header='{{ i18n "pages.settings.noiseSett"}}' v-if="noise">
<setting-list-item style="padding: 10px 20px" type="text" title='Packet (ms)' v-model="noisePacket" placeholder="rand:5-10"></setting-list-item>
<setting-list-item style="padding: 10px 20px" type="text" title='Delay (ms)' v-model="noiseDelay" placeholder="10-20"></setting-list-item>
<a-collapse v-if="noises" style="margin-top: 14px;">
<a-collapse-panel header='{{ i18n "pages.settings.noisesSett"}}' v-if="noises">
<a-list-item style="padding: 10px 20px">
<a-row>
<a-col :lg="24" :xl="12">
<a-list-item-meta title='Type'></a-list-item-meta>
</a-col>
<a-col :lg="24" :xl="12">
<a-select v-model="noisesType" style="width: 100%" :dropdown-class-name="themeSwitcher.currentTheme">
<a-select-option :value="p" :label="p" v-for="p in ['rand', 'base64', 'str']"> [[ p ]] </a-select-option>
</a-select>
</a-col>
</a-row>
</a-list-item>
<setting-list-item style="padding: 10px 20px" type="text" title='Packet (ms)' v-model="noisesPacket" placeholder="5-10"></setting-list-item>
<setting-list-item style="padding: 10px 20px" type="text" title='Delay (ms)' v-model="noisesDelay" placeholder="10-20"></setting-list-item>
</a-collapse-panel>
</a-collapse>
</a-list-item>
Expand Down Expand Up @@ -419,14 +431,15 @@
}
}
},
defaultNoise: {
tag: "noise",
defaultNoises: {
tag: "noises",
protocol: "freedom",
settings: {
domainStrategy: "AsIs",
noise: {
packet: "rand:5-10",
delay: "10-20",
noises: {
type: "rand",
packet: "10-20",
delay: "10-16",
}
},
},
Expand Down Expand Up @@ -629,29 +642,39 @@
}
}
},
noise: {
get: function () { return this.allSetting?.subJsonNoise != ""; },
noises: {
get: function () { return this.allSetting?.subJsonNoises != ""; },
set: function (v) {
this.allSetting.subJsonNoise = v ? JSON.stringify(this.defaultNoise) : "";
this.allSetting.subJsonNoises = v ? JSON.stringify(this.defaultNoises) : "";
}
},
noisesType: {
get: function () { return this.noises ? JSON.parse(this.allSetting.subJsonNoises).settings.noises.type : ""; },
set: function (v) {
if (v != "") {
newNoises = JSON.parse(this.allSetting.subJsonNoises);
newNoises.settings.noises.type = v;
this.allSetting.subJsonNoises = JSON.stringify(newNoises);
}
}
},
noisePacket: {
get: function () { return this.noise ? JSON.parse(this.allSetting.subJsonNoise).settings.noise.packet : ""; },
noisesPacket: {
get: function () { return this.noises ? JSON.parse(this.allSetting.subJsonNoises).settings.noises.packet : ""; },
set: function (v) {
if (v != "") {
newNoise = JSON.parse(this.allSetting.subJsonNoise);
newNoise.settings.noise.packet = v;
this.allSetting.subJsonNoise = JSON.stringify(newNoise);
newNoises = JSON.parse(this.allSetting.subJsonNoises);
newNoises.settings.noises.packet = v;
this.allSetting.subJsonNoises = JSON.stringify(newNoises);
}
}
},
noiseDelay: {
get: function () { return this.noise ? JSON.parse(this.allSetting.subJsonNoise).settings.noise.delay : ""; },
noisesDelay: {
get: function () { return this.noises ? JSON.parse(this.allSetting.subJsonNoises).settings.noises.delay : ""; },
set: function (v) {
if (v != "") {
newNoise = JSON.parse(this.allSetting.subJsonNoise);
newNoise.settings.noise.delay = v;
this.allSetting.subJsonNoise = JSON.stringify(newNoise);
newNoises = JSON.parse(this.allSetting.subJsonNoises);
newNoises.settings.noises.delay = v;
this.allSetting.subJsonNoises = JSON.stringify(newNoises);
}
}
},
Expand Down
6 changes: 3 additions & 3 deletions web/service/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ var defaultValueMap = map[string]string{
"subJsonPath": "/json/",
"subJsonURI": "",
"subJsonFragment": "",
"subJsonNoise": "",
"subJsonNoises": "",
"subJsonMux": "",
"subJsonRules": "",
"datepicker": "gregorian",
Expand Down Expand Up @@ -459,8 +459,8 @@ func (s *SettingService) GetSubJsonFragment() (string, error) {
return s.getString("subJsonFragment")
}

func (s *SettingService) GetSubJsonNoise() (string, error) {
return s.getString("subJsonNoise")
func (s *SettingService) GetSubJsonNoises() (string, error) {
return s.getString("subJsonNoises")
}

func (s *SettingService) GetSubJsonMux() (string, error) {
Expand Down
4 changes: 2 additions & 2 deletions web/translation/translate.en_US.toml
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,8 @@
"fragment" = "Fragmentation"
"fragmentDesc" = "Enable fragmentation for TLS hello packet."
"fragmentSett" = "Fragmentation Settings"
"noiseDesc" = "Enable Noise."
"noiseSett" = "Noise Settings"
"noisesDesc" = "Enable Noises."
"noisesSett" = "Noises Settings"
"mux" = "Mux"
"muxDesc" = "Transmit multiple independent data streams within an established data stream."
"muxSett" = "Mux Settings"
Expand Down
4 changes: 2 additions & 2 deletions web/translation/translate.es_ES.toml
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,8 @@
"fragment" = "Fragmentación"
"fragmentDesc" = "Habilitar la fragmentación para el paquete de saludo de TLS"
"fragmentSett" = "Configuración de Fragmentación"
"noiseDesc" = "Activar Noise."
"noiseSett" = "Configuración de Noise"
"noisesDesc" = "Activar Noises."
"noisesSett" = "Configuración de Noises"
"mux" = "Mux"
"muxDesc" = "Transmite múltiples flujos de datos independientes dentro de un flujo de datos establecido."
"muxSett" = "Configuración Mux"
Expand Down
4 changes: 2 additions & 2 deletions web/translation/translate.fa_IR.toml
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,8 @@
"fragment" = "فرگمنت"
"fragmentDesc" = "فعال کردن فرگمنت برای بسته‌ی نخست تی‌ال‌اس"
"fragmentSett" = "تنظیمات فرگمنت"
"noiseDesc" = "فعال کردن Noise."
"noiseSett" = "تنظیمات Noise"
"noisesDesc" = "فعال کردن Noises."
"noisesSett" = "تنظیمات Noises"
"mux" = "ماکس"
"muxDesc" = "چندین جریان داده مستقل را در یک جریان داده ثابت منتقل می کند"
"muxSett" = "تنظیمات ماکس"
Expand Down
4 changes: 2 additions & 2 deletions web/translation/translate.id_ID.toml
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,8 @@
"fragment" = "Fragmentasi"
"fragmentDesc" = "Aktifkan fragmentasi untuk paket hello TLS"
"fragmentSett" = "Pengaturan Fragmentasi"
"noiseDesc" = "Aktifkan Noise."
"noiseSett" = "Pengaturan Noise"
"noisesDesc" = "Aktifkan Noises."
"noisesSett" = "Pengaturan Noises"
"mux" = "Mux"
"muxDesc" = "Mengirimkan beberapa aliran data independen dalam aliran data yang sudah ada."
"muxSett" = "Pengaturan Mux"
Expand Down
4 changes: 2 additions & 2 deletions web/translation/translate.pt_BR.toml
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,8 @@
"fragment" = "Fragmentação"
"fragmentDesc" = "Ativa a fragmentação para o pacote TLS hello."
"fragmentSett" = "Configurações de Fragmentação"
"noiseDesc" = "Ativar Noise."
"noiseSett" = "Configurações de Noise"
"noisesDesc" = "Ativar Noises."
"noisesSett" = "Configurações de Noises"
"mux" = "Mux"
"muxDesc" = "Transmitir múltiplos fluxos de dados independentes dentro de um fluxo de dados estabelecido."
"muxSett" = "Configurações de Mux"
Expand Down
4 changes: 2 additions & 2 deletions web/translation/translate.ru_RU.toml
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,8 @@
"fragment" = "Фрагментация"
"fragmentDesc" = "Включить фрагментацию для пакета приветствия TLS"
"fragmentSett" = "Настройки фрагментации"
"noiseDesc" = "Включить Noise."
"noiseSett" = "Настройки Noise"
"noisesDesc" = "Включить Noises."
"noisesSett" = "Настройки Noises"
"mux" = "Mux"
"muxDesc" = "Передача нескольких независимых потоков данных в рамках установленного потока данных."
"muxSett" = "Mux Настройки"
Expand Down
4 changes: 2 additions & 2 deletions web/translation/translate.tr_TR.toml
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,8 @@
"fragment" = "Parçalama"
"fragmentDesc" = "TLS merhaba paketinin parçalanmasını etkinleştir."
"fragmentSett" = "Parçalama Ayarları"
"noiseDesc" = "Noise'i Etkinleştir."
"noiseSett" = "Noise Ayarları"
"noisesDesc" = "Noises'i Etkinleştir."
"noisesSett" = "Noises Ayarları"
"mux" = "Mux"
"muxDesc" = "Kurulmuş bir veri akışında birden çok bağımsız veri akışını iletir."
"muxSett" = "Mux Ayarları"
Expand Down
4 changes: 2 additions & 2 deletions web/translation/translate.uk_UA.toml
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,8 @@
"fragment" = "Фрагментація"
"fragmentDesc" = "Увімкнути фрагментацію для пакету привітання TLS"
"fragmentSett" = "Параметри фрагментації"
"noiseDesc" = "Увімкнути Noise."
"noiseSett" = "Налаштування Noise"
"noisesDesc" = "Увімкнути Noises."
"noisesSett" = "Налаштування Noises"
"mux" = "Mux"
"muxDesc" = "Передавати кілька незалежних потоків даних у межах встановленого потоку даних."
"muxSett" = "Налаштування Mux"
Expand Down
4 changes: 2 additions & 2 deletions web/translation/translate.vi_VN.toml
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,8 @@
"fragment" = "Sự phân mảnh"
"fragmentDesc" = "Kích hoạt phân mảnh cho gói TLS hello"
"fragmentSett" = "Cài đặt phân mảnh"
"noiseDesc" = "Bật Noise."
"noiseSett" = "Cài đặt Noise"
"noisesDesc" = "Bật Noises."
"noisesSett" = "Cài đặt Noises"
"mux" = "Mux"
"muxDesc" = "Truyền nhiều luồng dữ liệu độc lập trong luồng dữ liệu đã thiết lập."
"muxSett" = "Mux Cài đặt"
Expand Down
Loading

0 comments on commit 6b0c9a5

Please sign in to comment.