Bladeren bron

update noise to noises

+ type
mhsanaei 1 maand geleden
bovenliggende
commit
6b0c9a5fad

+ 3 - 3
sub/sub.go

@@ -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()
@@ -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
 }

+ 5 - 5
sub/subJsonService.go

@@ -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)
@@ -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,
 	}

+ 13 - 7
web/assets/js/model/outbound.js

@@ -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 = {}) {
@@ -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,
         );
     }
 
@@ -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,
         };
     }
 };
@@ -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,
         );

+ 1 - 1
web/assets/js/model/setting.js

@@ -38,7 +38,7 @@ class AllSetting {
         this.subURI = "";
         this.subJsonURI = "";
         this.subJsonFragment = "";
-        this.subJsonNoise = "";
+        this.subJsonNoises = "";
         this.subJsonMux = "";
         this.subJsonRules = "";
 

+ 1 - 1
web/entity/entity.go

@@ -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"`

+ 10 - 5
web/html/xui/form/outbound.html

@@ -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>

+ 48 - 25
web/html/xui/settings.html

@@ -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>
@@ -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",
           }
         },
       },
@@ -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);
           }
         }
       },

+ 3 - 3
web/service/setting.go

@@ -62,7 +62,7 @@ var defaultValueMap = map[string]string{
 	"subJsonPath":        "/json/",
 	"subJsonURI":         "",
 	"subJsonFragment":    "",
-	"subJsonNoise":       "",
+	"subJsonNoises":      "",
 	"subJsonMux":         "",
 	"subJsonRules":       "",
 	"datepicker":         "gregorian",
@@ -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) {

+ 2 - 2
web/translation/translate.en_US.toml

@@ -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"

+ 2 - 2
web/translation/translate.es_ES.toml

@@ -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"

+ 2 - 2
web/translation/translate.fa_IR.toml

@@ -309,8 +309,8 @@
 "fragment" = "فرگمنت"
 "fragmentDesc" = "فعال کردن فرگمنت برای بسته‌ی نخست تی‌ال‌اس"
 "fragmentSett" = "تنظیمات فرگمنت"
-"noiseDesc" = "فعال کردن Noise."
-"noiseSett" = "تنظیمات Noise"
+"noisesDesc" = "فعال کردن Noises."
+"noisesSett" = "تنظیمات Noises"
 "mux" = "ماکس"
 "muxDesc" = "چندین جریان داده مستقل را در یک جریان داده ثابت منتقل می کند"
 "muxSett" = "تنظیمات ماکس"

+ 2 - 2
web/translation/translate.id_ID.toml

@@ -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"

+ 2 - 2
web/translation/translate.pt_BR.toml

@@ -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"

+ 2 - 2
web/translation/translate.ru_RU.toml

@@ -309,8 +309,8 @@
 "fragment" = "Фрагментация"
 "fragmentDesc" = "Включить фрагментацию для пакета приветствия TLS"
 "fragmentSett" = "Настройки фрагментации"
-"noiseDesc" = "Включить Noise."
-"noiseSett" = "Настройки Noise"
+"noisesDesc" = "Включить Noises."
+"noisesSett" = "Настройки Noises"
 "mux" = "Mux"
 "muxDesc" = "Передача нескольких независимых потоков данных в рамках установленного потока данных."
 "muxSett" = "Mux Настройки"

+ 2 - 2
web/translation/translate.tr_TR.toml

@@ -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ı"

+ 2 - 2
web/translation/translate.uk_UA.toml

@@ -309,8 +309,8 @@
 "fragment" = "Фрагментація"
 "fragmentDesc" = "Увімкнути фрагментацію для пакету привітання TLS"
 "fragmentSett" = "Параметри фрагментації"
-"noiseDesc" = "Увімкнути Noise."
-"noiseSett" = "Налаштування Noise"
+"noisesDesc" = "Увімкнути Noises."
+"noisesSett" = "Налаштування Noises"
 "mux" = "Mux"
 "muxDesc" = "Передавати кілька незалежних потоків даних у межах встановленого потоку даних."
 "muxSett" = "Налаштування Mux"

+ 2 - 2
web/translation/translate.vi_VN.toml

@@ -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"

+ 2 - 2
web/translation/translate.zh_CN.toml

@@ -309,8 +309,8 @@
 "fragment" = "分片"
 "fragmentDesc" = "启用 TLS hello 数据包分片"
 "fragmentSett" = "设置"
-"noiseDesc" = "启用 Noise."
-"noiseSett" = "Noise 设置"
+"noisesDesc" = "启用 Noises."
+"noisesSett" = "Noises 设置"
 "mux" = "多路复用器"
 "muxDesc" = "在已建立的数据流内传输多个独立的数据流"
 "muxSett" = "复用器设置"