Skip to content

Commit

Permalink
backport: 20230317
Browse files Browse the repository at this point in the history
  • Loading branch information
arm64v8a committed Apr 17, 2023
1 parent 9dec873 commit adb20c4
Show file tree
Hide file tree
Showing 20 changed files with 36 additions and 38 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ build/
local.properties
/app/libs/
/app/src/main/assets/v2ray
/app/src/main/assets/sing-box
/service_account_credentials.json
jniLibs/
/library/libcore_build/
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/io/nekohasekai/sagernet/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ object Key {
const val RESOLVE_DESTINATION = "resolveDestination"

const val BYPASS_LAN = "bypassLan"
const val BYPASS_LAN_IN_CORE_ONLY = "bypassLanInCoreOnly"
const val BYPASS_LAN_IN_CORE = "bypassLanInCore"

const val SOCKS_PORT = "socksPort"
const val ALLOW_ACCESS = "allowAccess"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/io/nekohasekai/sagernet/bg/VpnService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class VpnService : BaseVpnService(),
builder.addAddress(PRIVATE_VLAN6_CLIENT, 126)
}

if (DataStore.bypassLan && !DataStore.bypassLanInCoreOnly) {
if (DataStore.bypassLan) {
resources.getStringArray(R.array.bypass_private_route).forEach {
val subnet = Subnet.fromString(it)!!
builder.addRoute(subnet.address.hostAddress!!, subnet.prefixSize)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ object DataStore : OnPreferenceDataStoreChangeListener {
var mtu by configurationStore.stringToInt(Key.MTU) { 9000 }

var bypassLan by configurationStore.boolean(Key.BYPASS_LAN)
var bypassLanInCoreOnly by configurationStore.boolean(Key.BYPASS_LAN_IN_CORE_ONLY)
var bypassLanInCore by configurationStore.boolean(Key.BYPASS_LAN_IN_CORE)

var allowAccess by configurationStore.boolean(Key.ALLOW_ACCESS)
var speedInterval by configurationStore.stringToInt(Key.SPEED_INTERVAL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ fun buildV2RayConfig(

rules.addAll(wsRules.values)

if (!forTest && DataStore.bypassLan && (requireHttp || DataStore.bypassLanInCoreOnly)) {
if (!forTest && (requireHttp || DataStore.bypassLanInCore)) {
rules.add(RoutingObject.RuleObject().apply {
type = "field"
outboundTag = TAG_BYPASS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ public String displayAddress() {
return super.displayAddress();
}

@Override
public boolean canTCPing() {
return false;
}

@NotNull
@Override
public HysteriaBean clone() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ public void deserialize(ByteBufferInput input) {
}
}

@Override
public boolean canTCPing() {
return false;
}

@NotNull
@Override
public TuicBean clone() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ public void deserialize(ByteBufferInput input) {
}
}

@Override
public boolean canTCPing() {
return false;
}

@NotNull
@Override
public WireGuardBean clone() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,7 @@ class SettingsPreferenceFragment : PreferenceFragmentCompat() {
val tcpKeepAliveInterval = findPreference<EditTextPreference>(Key.TCP_KEEP_ALIVE_INTERVAL)!!

val bypassLan = findPreference<SwitchPreference>(Key.BYPASS_LAN)!!
val bypassLanInCoreOnly = findPreference<SwitchPreference>(Key.BYPASS_LAN_IN_CORE_ONLY)!!

bypassLanInCoreOnly.isEnabled = bypassLan.isChecked
bypassLan.setOnPreferenceChangeListener { _, newValue ->
bypassLanInCoreOnly.isEnabled = newValue as Boolean
needReload()
true
}
val bypassLanInCore = findPreference<SwitchPreference>(Key.BYPASS_LAN_IN_CORE)!!

val remoteDns = findPreference<EditTextPreference>(Key.REMOTE_DNS)!!
val directDns = findPreference<EditTextPreference>(Key.DIRECT_DNS)!!
Expand Down Expand Up @@ -268,7 +261,8 @@ class SettingsPreferenceFragment : PreferenceFragmentCompat() {
trafficSniffing.onPreferenceChangeListener = reloadListener
muxConcurrency.onPreferenceChangeListener = reloadListener
tcpKeepAliveInterval.onPreferenceChangeListener = reloadListener
bypassLanInCoreOnly.onPreferenceChangeListener = reloadListener
bypassLan.onPreferenceChangeListener = reloadListener
bypassLanInCore.onPreferenceChangeListener = reloadListener
mtu.onPreferenceChangeListener = reloadListener

remoteDns.onPreferenceChangeListener = reloadListener
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/menu/main_drawer_menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
android:checkableBehavior="single">
<item
android:id="@+id/nav_tuiguang"
android:icon="@drawable/ic_baseline_airplanemode_active_24"
android:title="推广" />
android:icon="@drawable/ic_social_share"
android:title="@string/ads" />
<item
android:id="@+id/nav_faq"
android:icon="@drawable/ic_device_data_usage"
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,6 @@
<string name="group_basic">أساسي</string>
<string name="trojan_provider">Trojan مزود</string>
<string name="protocol_settings">إعدادات البروتوكول</string>
<string name="bypass_lan_in_core_only_sum">إذا لم يعمل Lineage\'s السماح لعملاء نقطة الاتصال باستخدام شبكات VPN، فجرّب ذلك.</string>
<string name="bypass_lan_in_core_only">تجاوز LAN في النواة فقط</string>
<string name="append_http_proxy_sum">سيتم استخدام بروکسی HTTP مباشرة من (المتصفح/ بعض التطبيقات المدعومة)، دون المرور عبر جهاز NIC الافتراضي (Android 10+)</string>
<string name="append_http_proxy">إلحاق بروکسی HTTP ب VPN</string>
<string name="connection_test_timeout">نفذ الوقت</string>
Expand Down
6 changes: 2 additions & 4 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -330,10 +330,8 @@
<string name="connection_test_unreachable">Inalcanzable</string>
<string name="connection_test_timeout">Se acabó el tiempo</string>
<string name="append_http_proxy">Añadir proxy HTTP a la VPN</string>
<string name="append_http_proxy_sum">El proxy HTTP se utilizará directamente desde (navegador/algunas aplicaciones compatibles), sin pasar por el dispositivo NIC virtual (Android 10+)</string>
<string name="bypass_lan_in_core_only">Omitir LAN solo en núcleo</string>
<string name="bypass_lan_in_core_only_sum">Si la opción "Permitir que los clientes de hotspot usen VPN" de Lineage no funciona, intente esto.</string>
<string name="protocol_settings">Ajustes de protocolo</string>
<string name="append_http_proxy_sum">El proxy HTTP se utilizará directamente desde (navegador/algunas aplicaciones compatibles), sin pasar por el dispositivo NIC virtual (Android 10+)</string>
<string name="protocol_settings">Ajustes de protocolo</string>
<string name="trojan_provider">Proveedor Trojan</string>
<string name="group_basic">Básico</string>
<string name="group_settings">Ajustes de grupo</string>
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/values-fa/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,6 @@
<string name="connection_test_timeout">تایم اوت</string>
<string name="append_http_proxy">پروکسی HTTP را به VPN اضافه کنید</string>
<string name="append_http_proxy_sum">پروکسی HTTP مستقیماً از (مرورگر/برخی برنامه‌های پشتیبانی‌شده) بدون استفاده از دستگاه NIC مجازی (Android 10+) استفاده می‌شود.</string>
<string name="bypass_lan_in_core_only">دور زدن LAN در Core</string>
<string name="bypass_lan_in_core_only_sum">اگر Lineage \"اجازه دادن به سرویس گیرندگان هات اسپات برای استفاده از VPN\" کار نمی کند، این را امتحان کنید.</string>
<string name="protocol_settings">تنظیمات پروتکل</string>
<string name="trojan_provider">ارائه دهنده تروجان</string>
<string name="group_basic">پایه ای</string>
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/values-nb-rNO/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,6 @@
<string name="group_basic">Grunnleggende</string>
<string name="trojan_provider">Trojansk leverandør</string>
<string name="protocol_settings">Protokollinnstillinger</string>
<string name="bypass_lan_in_core_only_sum">Hvis Lineage\'s Tillat hotspot -klienter å bruke VPN -er ikke fungerer, kan du prøve dette.</string>
<string name="bypass_lan_in_core_only">Omgå LAN i Core bare</string>
<string name="append_http_proxy_sum">HTTP -proxy brukes direkte fra (nettleser/ noen støttede apper), uten å gå gjennom den virtuelle NIC -enheten (Android 10+)</string>
<string name="append_http_proxy">Legg til HTTP -proxy til VPN</string>
<string name="connection_test_unreachable">Uoppnåelig</string>
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,6 @@
<string name="group_basic">Базовый</string>
<string name="trojan_provider">Провайдер Trojan</string>
<string name="protocol_settings">Настройки протокола</string>
<string name="bypass_lan_in_core_only_sum">Если в LineageOS не работает функция \"Разрешить клиентам точки доступа использовать VPN\", попробуйте включить эту настройку.</string>
<string name="bypass_lan_in_core_only">Обход LAN только в ядре</string>
<string name="append_http_proxy_sum">HTTP-прокси будет использоваться напрямую из (браузера / некоторых поддерживаемых приложений), без использования виртуального сетевого интерфейса (Android 10+)</string>
<string name="append_http_proxy">Добавить HTTP-прокси к VPN</string>
<string name="connection_test_timeout">Тайм-аут</string>
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/values-tr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,6 @@
<string name="hysteria_stream_receive_window">QUIC Akış Alım Penceresi</string>
<string name="experimental_no_termination_signal">Duplex sonlandırma sinyalini VMess kullanırken TCP bağlantısı için yollama. Bu bazı uygulamaları bozacaktır.</string>
<string name="force_resolve_sum">Güncelleme yaparken bütün alan adlarının IP adreslerini çöz. Mümkünse sunucu ve SNI otomatik olarak eklenir</string>
<string name="bypass_lan_in_core_only_sum">Eğer Lineage\'in Hotspot istemcilerinin VPN kullanmasına izin ver özelliği çalışmıyorsa bunu deneyin.</string>
<string name="bypass_lan_in_core_only">Yerel Ağı Sadece Çekirdekte Atlat</string>
<string name="always_show_address_sum">Yapılandırma kartının üzerinde her zaman sunucu adresini göster</string>
<string name="probe_interval">Dengeleyici gözlem aralığı</string>
<string name="insecure_warn_sum">Qv2ray Geliştirici Topluluğu Tarafından Sağlanmıştır</string>
Expand Down
7 changes: 5 additions & 2 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,6 @@
<string name="append_http_proxy">追加 HTTP 代理至 VPN</string>
<string name="append_http_proxy_sum">浏览器 / 一些支持的应用 将直接使用 HTTP 代理, 而不经过虚拟网卡设备 (Android 10+)</string>
<string name="connection_test_icmp_ping_unavailable">ICMPing 不可用</string>
<string name="bypass_lan_in_core_only">仅在 Core 中绕过局域网</string>
<string name="bypass_lan_in_core_only_sum">如果 Lineage 之 \"允许热点客户端使用 VPN\" 无法使用, 尝试启用此项.</string>
<string name="protocol_settings">协议设置</string>
<string name="trojan_provider">Trojan 提供程序</string>
<string name="group_basic">基本</string>
Expand Down Expand Up @@ -469,6 +467,7 @@
<string name="experimental_reduced_iv_head_entropy">这是 GFWReport 针对 GFW 上观察到的类似随机流的协议阻塞行为提出的对策。 这个选项将 IV 的前 6 个字节重新映射为可打印的字符,启用后,特权网络路径上的任何人都有可能识别该协议。</string>
<string name="exe_prefer_provider">首选插件提供者</string>
<string name="create_shortcut">创建快捷方式</string>
<string name="app_tls_version">订阅最低 TLS 版本</string>
<string name="hop_interval">端口跳跃间隔(秒)</string>
<string name="dns_network">DNS 查询类型</string>
<string name="tuic_disable_sni">禁用 SNI</string>
Expand All @@ -478,4 +477,8 @@
<string name="tuic_congestion_controller">拥塞控制</string>
<string name="tuic_udp_relay_mode">UDP 转发模式</string>
<string name="tuic_token">令牌</string>
<string name="show_bottom_bar">像 SagerNet 一样显示底栏</string>
<string name="utls_fingerprint">uTLS 指纹</string>
<string name="bypass_lan_in_core">在核心中绕过 LAN</string>
<string name="ads">推广</string>
</resources>
2 changes: 0 additions & 2 deletions app/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,6 @@
<string name="connection_test_timeout">逾時</string>
<string name="append_http_proxy">為 VPN 附加 HTTP 代理</string>
<string name="append_http_proxy_sum">HTTP 代理將直接被支援的瀏覽器/應用程式使用,而無需經過虛擬網路卡(Android 10+)</string>
<string name="bypass_lan_in_core_only">僅在 Core 中繞過區域網路</string>
<string name="bypass_lan_in_core_only_sum">如果 LineageOS 的“允許熱點客戶端使用此裝置的 VPN”無法使用,嘗試啟用此選項。</string>
<string name="trojan_provider">Trojan 提供程式</string>
<string name="protocol_settings">協議設定</string>
<string name="group_basic">基本</string>
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,6 @@
<string name="connection_test_timeout">Timeout</string>
<string name="append_http_proxy">Append HTTP Proxy to VPN</string>
<string name="append_http_proxy_sum">HTTP proxy will be used directly from (browser/ some supported apps), without going through the virtual NIC device (Android 10+)</string>
<string name="bypass_lan_in_core_only">Bypass LAN in Core Only</string>
<string name="bypass_lan_in_core_only_sum">If Lineage\'s "Allow hotspot clients to use VPNs" does not work, try this.</string>
<string name="protocol_settings">Protocol Settings</string>
<string name="trojan_provider">Trojan Provider</string>
<string name="group_basic">Basic</string>
Expand Down Expand Up @@ -521,5 +519,7 @@ Anyone can write advanced plugins, which can control Matsuri. please download an
<string name="dns_network">DNS query type</string>
<string name="show_bottom_bar">Show bottom bar like SagerNet</string>
<string name="utls_fingerprint">uTLS fingerprint</string>
<string name="bypass_lan_in_core">Bypass LAN in Core</string>
<string name="ads">Ads</string>

</resources>
5 changes: 2 additions & 3 deletions app/src/main/res/xml/global_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,8 @@
app:key="bypassLan"
app:title="@string/route_opt_bypass_lan" />
<SwitchPreference
android:summary="@string/bypass_lan_in_core_only_sum"
app:key="bypassLanInCoreOnly"
app:title="@string/bypass_lan_in_core_only" />
app:key="bypassLanInCore"
app:title="@string/bypass_lan_in_core" />
<com.takisoft.preferencex.SimpleMenuPreference
app:defaultValue="AsIs"
app:entries="@array/domain_strategy"
Expand Down

0 comments on commit adb20c4

Please sign in to comment.