mirror of
https://github.com/MatsuriDayo/NekoBoxForAndroid.git
synced 2025-12-19 14:40:06 +08:00
UOT option for naive & socks
This commit is contained in:
parent
9d78e4f287
commit
1f59432337
@ -13,8 +13,8 @@ object Executable {
|
||||
"libtrojan.so",
|
||||
"libtrojan-go.so",
|
||||
"libnaive.so",
|
||||
"libhysteria.so",
|
||||
"libwg.so"
|
||||
"libtuic.so",
|
||||
"libhysteria.so"
|
||||
)
|
||||
|
||||
fun killAll(alsoKillBg: Boolean = false) {
|
||||
|
||||
@ -372,8 +372,7 @@ fun buildConfig(
|
||||
globalOutbounds[proxyEntity.id] = tagOut
|
||||
}
|
||||
|
||||
// Chain outbound
|
||||
if (proxyEntity.needExternal()) {
|
||||
if (proxyEntity.needExternal()) { // externel outbound
|
||||
val localPort = mkPort()
|
||||
externalChainMap[localPort] = proxyEntity
|
||||
currentOutbound = Outbound_SocksOptions().apply {
|
||||
@ -381,9 +380,7 @@ fun buildConfig(
|
||||
server = LOCALHOST
|
||||
server_port = localPort
|
||||
}.asMap()
|
||||
} else {
|
||||
// internal outbound
|
||||
|
||||
} else { // internal outbound
|
||||
currentOutbound = when (bean) {
|
||||
is ConfigBean ->
|
||||
gson.fromJson(bean.config, currentOutbound.javaClass)
|
||||
@ -430,6 +427,18 @@ fun buildConfig(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// internal & external
|
||||
currentOutbound.apply {
|
||||
// udp over tcp
|
||||
try {
|
||||
val sUoT = bean.javaClass.getField("sUoT").get(bean)
|
||||
if (sUoT is Boolean && sUoT == true) {
|
||||
currentOutbound["udp_over_tcp"] = true
|
||||
}
|
||||
} catch (_: Exception) {
|
||||
}
|
||||
|
||||
// custom JSON merge
|
||||
if (bean.customOutboundJson.isNotBlank()) {
|
||||
|
||||
@ -23,6 +23,9 @@ public class NaiveBean extends AbstractBean {
|
||||
public String certificates;
|
||||
public Integer insecureConcurrency;
|
||||
|
||||
// sing-box socks
|
||||
public Boolean sUoT;
|
||||
|
||||
@Override
|
||||
public void initializeDefaultValues() {
|
||||
if (serverPort == null) serverPort = 443;
|
||||
@ -34,11 +37,12 @@ public class NaiveBean extends AbstractBean {
|
||||
if (certificates == null) certificates = "";
|
||||
if (sni == null) sni = "";
|
||||
if (insecureConcurrency == null) insecureConcurrency = 0;
|
||||
if (sUoT == null) sUoT = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(ByteBufferOutput output) {
|
||||
output.writeInt(2);
|
||||
output.writeInt(3);
|
||||
super.serialize(output);
|
||||
output.writeString(proto);
|
||||
output.writeString(username);
|
||||
@ -48,6 +52,7 @@ public class NaiveBean extends AbstractBean {
|
||||
output.writeString(certificates);
|
||||
output.writeString(sni);
|
||||
output.writeInt(insecureConcurrency);
|
||||
output.writeBoolean(sUoT);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -65,6 +70,9 @@ public class NaiveBean extends AbstractBean {
|
||||
if (version >= 1) {
|
||||
insecureConcurrency = input.readInt();
|
||||
}
|
||||
if (version >= 3) {
|
||||
sUoT = input.readBoolean();
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@ -50,6 +50,13 @@ public class ShadowsocksBean extends AbstractBean {
|
||||
sUoT = input.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyFeatureSettings(AbstractBean other) {
|
||||
if (!(other instanceof ShadowsocksBean)) return;
|
||||
ShadowsocksBean bean = ((ShadowsocksBean) other);
|
||||
bean.sUoT = sUoT;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ShadowsocksBean clone() {
|
||||
|
||||
@ -114,11 +114,6 @@ fun buildSingBoxOutboundShadowsocksBean(bean: ShadowsocksBean): SingBoxOptions.O
|
||||
server_port = bean.serverPort
|
||||
password = bean.password
|
||||
method = bean.method
|
||||
if (bean.sUoT) {
|
||||
udp_over_tcp = SingBoxOptions.UDPOverTCPOptions().apply {
|
||||
enabled = true
|
||||
}
|
||||
}
|
||||
if (bean.plugin.isNotBlank()) {
|
||||
plugin = bean.plugin.substringBefore(";")
|
||||
plugin_opts = bean.plugin.substringAfter(";")
|
||||
|
||||
@ -14,6 +14,8 @@ public class SOCKSBean extends AbstractBean {
|
||||
|
||||
public Integer protocol;
|
||||
|
||||
public Boolean sUoT;
|
||||
|
||||
public int protocolVersion() {
|
||||
switch (protocol) {
|
||||
case 0:
|
||||
@ -66,15 +68,17 @@ public class SOCKSBean extends AbstractBean {
|
||||
if (protocol == null) protocol = PROTOCOL_SOCKS5;
|
||||
if (username == null) username = "";
|
||||
if (password == null) password = "";
|
||||
if (sUoT == null) sUoT = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(ByteBufferOutput output) {
|
||||
output.writeInt(1);
|
||||
output.writeInt(2);
|
||||
super.serialize(output);
|
||||
output.writeInt(protocol);
|
||||
output.writeString(username);
|
||||
output.writeString(password);
|
||||
output.writeBoolean(sUoT);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -86,6 +90,9 @@ public class SOCKSBean extends AbstractBean {
|
||||
}
|
||||
username = input.readString();
|
||||
password = input.readString();
|
||||
if (version >= 2) {
|
||||
sUoT = input.readBoolean();
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@ -24,6 +24,7 @@ class NaiveSettingsActivity : ProfileSettingsActivity<NaiveBean>() {
|
||||
DataStore.serverCertificates = certificates
|
||||
DataStore.serverHeaders = extraHeaders
|
||||
DataStore.serverInsecureConcurrency = insecureConcurrency
|
||||
DataStore.profileCacheStore.putBoolean("sUoT", sUoT)
|
||||
}
|
||||
|
||||
override fun NaiveBean.serialize() {
|
||||
@ -37,6 +38,7 @@ class NaiveSettingsActivity : ProfileSettingsActivity<NaiveBean>() {
|
||||
certificates = DataStore.serverCertificates
|
||||
extraHeaders = DataStore.serverHeaders.replace("\r\n", "\n")
|
||||
insecureConcurrency = DataStore.serverInsecureConcurrency
|
||||
sUoT = DataStore.profileCacheStore.getBoolean("sUoT")
|
||||
}
|
||||
|
||||
override fun PreferenceFragmentCompat.createPreferences(
|
||||
|
||||
@ -21,6 +21,8 @@ class SocksSettingsActivity : ProfileSettingsActivity<SOCKSBean>() {
|
||||
DataStore.serverProtocolVersion = protocol
|
||||
DataStore.serverUsername = username
|
||||
DataStore.serverPassword = password
|
||||
|
||||
DataStore.profileCacheStore.putBoolean("sUoT", sUoT)
|
||||
}
|
||||
|
||||
override fun SOCKSBean.serialize() {
|
||||
@ -31,6 +33,8 @@ class SocksSettingsActivity : ProfileSettingsActivity<SOCKSBean>() {
|
||||
protocol = DataStore.serverProtocolVersion
|
||||
username = DataStore.serverUsername
|
||||
password = DataStore.serverPassword
|
||||
|
||||
sUoT = DataStore.profileCacheStore.getBoolean("sUoT")
|
||||
}
|
||||
|
||||
override fun PreferenceFragmentCompat.createPreferences(
|
||||
|
||||
@ -61,5 +61,9 @@
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
</PreferenceCategory>
|
||||
|
||||
|
||||
<PreferenceCategory app:title="sing-box server">
|
||||
<SwitchPreference
|
||||
app:key="sUoT"
|
||||
app:title="UDP over TCP" />
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
@ -38,4 +38,9 @@
|
||||
app:title="@string/password_opt" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory app:title="sing-box server">
|
||||
<SwitchPreference
|
||||
app:key="sUoT"
|
||||
app:title="UDP over TCP" />
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
Loading…
Reference in New Issue
Block a user