Fix server_ports

This commit is contained in:
armv9 2025-02-24 22:02:46 +09:00
parent 8a6cc26c50
commit 0cf1c81933
2 changed files with 17 additions and 6 deletions

View File

@ -284,7 +284,7 @@ fun buildSingBoxOutboundHysteriaBean(bean: HysteriaBean): MutableMap<String, Any
if (port != null) {
server_port = port
} else {
server_ports = bean.serverPorts
server_ports = hopPortsToSingboxList(bean.serverPorts)
}
hop_interval = "${bean.hopInterval}s"
up_mbps = bean.uploadMbps
@ -323,7 +323,7 @@ fun buildSingBoxOutboundHysteriaBean(bean: HysteriaBean): MutableMap<String, Any
if (port != null) {
server_port = port
} else {
server_ports = bean.serverPorts
server_ports = hopPortsToSingboxList(bean.serverPorts)
}
hop_interval = "${bean.hopInterval}s"
up_mbps = bean.uploadMbps
@ -358,3 +358,14 @@ fun buildSingBoxOutboundHysteriaBean(bean: HysteriaBean): MutableMap<String, Any
else -> mutableMapOf("error_version" to bean.protocolVersion)
}
}
fun hopPortsToSingboxList(s: String): List<String> {
return s.split(",").mapNotNull {
val pRange = it.replace("-", ":")
if (pRange.split(":").size == 2) {
pRange
} else {
null
}
}
}

View File

@ -449,7 +449,7 @@ public class SingBoxOptions {
public OutboundTLSOptions tls;
public String server_ports;
public List<String> server_ports;
public String hop_interval;
@ -575,7 +575,7 @@ public class SingBoxOptions {
public OutboundTLSOptions tls;
public String server_ports;
public List<String> server_ports;
public String hop_interval;
@ -3902,7 +3902,7 @@ public class SingBoxOptions {
public OutboundTLSOptions tls;
public String server_ports;
public List<String> server_ports;
public String hop_interval;
@ -4276,7 +4276,7 @@ public class SingBoxOptions {
public OutboundTLSOptions tls;
public String server_ports;
public List<String> server_ports;
public String hop_interval;