File tree Expand file tree Collapse file tree 3 files changed +31
-10
lines changed
Expand file tree Collapse file tree 3 files changed +31
-10
lines changed Original file line number Diff line number Diff line change @@ -72,14 +72,36 @@ object Hysteria2Fmt : FmtBase() {
7272 dicQuery[" mport" ] = config.portHopping.orEmpty()
7373 }
7474 if (config.portHoppingInterval.isNotNullEmpty()) {
75- var portHoppingInterval = config.portHoppingInterval.orEmpty()
76- if (portHoppingInterval.contains(' -' )) {
77- // interval range
78- portHoppingInterval = portHoppingInterval.substringBefore(' -' )
75+ val rawInterval = config.portHoppingInterval?.trim().nullIfBlank()
76+ val interval = if (rawInterval == null ) {
77+ null
78+ } else {
79+ val singleValue = rawInterval.toIntOrNull()
80+ if (singleValue != null ) {
81+ if (singleValue < 5 ) {
82+ null
83+ } else {
84+ rawInterval
85+ }
86+ } else {
87+ val parts = rawInterval.split(' -' )
88+ if (parts.size == 2 ) {
89+ val start = parts[0 ].trim().toIntOrNull()
90+ val end = parts[1 ].trim().toIntOrNull()
91+ if (start != null && end != null ) {
92+ val minStart = maxOf(5 , start)
93+ val minEnd = maxOf(minStart, end)
94+ (minStart + minEnd) / 2
95+ } else {
96+ null
97+ }
98+ } else {
99+ null
100+ }
101+ }
79102 }
80- val trimmedPortHoppingInterval = portHoppingInterval.trim()
81- if (trimmedPortHoppingInterval.isNotEmpty()) {
82- dicQuery[" mportHopInt" ] = trimmedPortHoppingInterval
103+ if (interval != null ) {
104+ dicQuery[" mportHopInt" ] = interval.toString()
83105 }
84106 }
85107 if (config.pinnedCA256.isNotNullEmpty()) {
Original file line number Diff line number Diff line change @@ -543,7 +543,7 @@ class ServerActivity : BaseActivity() {
543543 } else if (config.configType == EConfigType .HYSTERIA2 ) {
544544 config.obfsPassword = et_obfs_password?.text?.toString()
545545 config.portHopping = et_port_hop?.text?.toString()
546- config.portHoppingInterval = et_port_hop_interval?.text?.toString()
546+ config.portHoppingInterval = et_port_hop_interval?.text?.toString()?.trim()
547547 config.bandwidthDown = et_bandwidth_down?.text?.toString()
548548 config.bandwidthUp = et_bandwidth_up?.text?.toString()
549549 }
Original file line number Diff line number Diff line change 8585 <EditText
8686 android : id =" @+id/et_port_hop_interval"
8787 android : layout_width =" match_parent"
88- android : layout_height =" wrap_content"
89- android : inputType =" number" />
88+ android : layout_height =" wrap_content" />
9089
9190 </LinearLayout >
9291
You can’t perform that action at this time.
0 commit comments