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