fix broadcast on sysstack
This commit is contained in:
6 files changed
+50
-16
No files matched your search
+2
-2
@@ -13,8 +13,8 @@ android {
|
||||
applicationId "com.github.kr328.clash"
|
||||
minSdkVersion 24
|
||||
targetSdkVersion 29
|
||||
versionCode 10021
|
||||
versionName "1.0.21-alpha"
|
||||
versionCode 10025
|
||||
versionName "1.0.25-alpha"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
|
||||
@@ -40,6 +40,8 @@ class ClashStartService : Service() {
|
||||
startForeground(NOTIFICATION_ID, notification)
|
||||
|
||||
thread {
|
||||
Thread.sleep(5000)
|
||||
|
||||
ServiceUtils.startProxyService(this)
|
||||
|
||||
stopSelf()
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"strconv"
|
||||
"syscall"
|
||||
|
||||
"github.com/Dreamacro/clash/dns"
|
||||
"github.com/Dreamacro/clash/global"
|
||||
"github.com/Dreamacro/clash/log"
|
||||
"github.com/Dreamacro/clash/proxy/tun"
|
||||
@@ -16,9 +15,8 @@ type Callback interface {
|
||||
}
|
||||
|
||||
var tunInstance *tun.TUN
|
||||
var dnsGateway net.IP
|
||||
|
||||
func StartTunDevice(fd, mtu int, gateway string, dns string, callback Callback) error {
|
||||
func StartTunDevice(fd, mtu int, gateway string, dnsGateway string, callback Callback) error {
|
||||
if tunInstance != nil {
|
||||
return nil
|
||||
}
|
||||
@@ -41,7 +39,9 @@ func StartTunDevice(fd, mtu int, gateway string, dns string, callback Callback)
|
||||
})
|
||||
}
|
||||
|
||||
t, err := tun.NewTunProxy("fd://"+strconv.Itoa(fd)+"?mtu="+strconv.Itoa(mtu), *n)
|
||||
dnsGatewayIP := net.ParseIP(dnsGateway)
|
||||
|
||||
t, err := tun.NewTunProxy("fd://"+strconv.Itoa(fd)+"?mtu="+strconv.Itoa(mtu), *n, dnsGatewayIP)
|
||||
|
||||
if err != nil {
|
||||
global.DefaultDialer.Control = nil
|
||||
@@ -51,8 +51,6 @@ func StartTunDevice(fd, mtu int, gateway string, dns string, callback Callback)
|
||||
}
|
||||
tunInstance = t
|
||||
|
||||
dnsGateway = net.ParseIP(dns)
|
||||
|
||||
ResetDnsRedirect()
|
||||
|
||||
log.Infoln("Android tun started")
|
||||
@@ -79,5 +77,5 @@ func ResetDnsRedirect() {
|
||||
return
|
||||
}
|
||||
|
||||
tunInstance.ReCreateDNSServer(dns.DefaultResolver, dnsGateway)
|
||||
tunInstance.ResetDnsServer()
|
||||
}
|
||||
@@ -3,7 +3,6 @@ package com.github.kr328.clash.core
|
||||
import android.content.Context
|
||||
import bridge.Bridge
|
||||
import bridge.EventPoll
|
||||
import bridge.Logs
|
||||
import com.github.kr328.clash.core.event.BandwidthEvent
|
||||
import com.github.kr328.clash.core.event.LogEvent
|
||||
import com.github.kr328.clash.core.event.ProcessEvent
|
||||
@@ -77,7 +76,13 @@ class Clash(
|
||||
loadDefault()
|
||||
}
|
||||
|
||||
fun startTunDevice(fd: Int, mtu: Int, gateway: String, dns: String, onSocket: (Int) -> Unit) {
|
||||
fun startTunDevice(
|
||||
fd: Int,
|
||||
mtu: Int,
|
||||
gateway: String,
|
||||
dns: String,
|
||||
onSocket: (Int) -> Unit
|
||||
) {
|
||||
enforceStarted()
|
||||
|
||||
Bridge.startTunDevice(fd.toLong(), mtu.toLong(), gateway, dns) {
|
||||
|
||||
@@ -15,7 +15,7 @@ class TunService : VpnService(), IClashEventObserver {
|
||||
companion object {
|
||||
// from https://github.com/shadowsocks/shadowsocks-android/blob/master/core/src/main/java/com/github/shadowsocks/bg/VpnService.kt
|
||||
private const val VPN_MTU = 1500
|
||||
private const val PRIVATE_VLAN_DNS = "172.19.0.2" // sync with tun/tun.go/dnsServerAddress
|
||||
private const val PRIVATE_VLAN_DNS = "172.19.0.2"
|
||||
private const val PRIVATE_VLAN4_CLIENT = "172.19.0.1"
|
||||
}
|
||||
|
||||
@@ -112,14 +112,16 @@ class TunService : VpnService(), IClashEventObserver {
|
||||
start = false
|
||||
|
||||
if ( settings.isDnsHijackingEnabled ) {
|
||||
clash.clash.startTunDevice(fileDescriptor.fd, VPN_MTU,
|
||||
clash.clash.startTunDevice(
|
||||
fileDescriptor.fd, VPN_MTU,
|
||||
"$PRIVATE_VLAN4_CLIENT/30", "0.0.0.0"
|
||||
) {
|
||||
protect(it.toInt())
|
||||
}
|
||||
}
|
||||
else {
|
||||
clash.clash.startTunDevice(fileDescriptor.fd, VPN_MTU,
|
||||
clash.clash.startTunDevice(
|
||||
fileDescriptor.fd, VPN_MTU,
|
||||
"$PRIVATE_VLAN4_CLIENT/30", PRIVATE_VLAN_DNS
|
||||
) {
|
||||
protect(it.toInt())
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
<item>160.0.0.0/5</item>
|
||||
<item>168.0.0.0/6</item>
|
||||
<item>172.0.0.0/12</item>
|
||||
<item>172.19.0.0/30</item>
|
||||
<item>172.32.0.0/11</item>
|
||||
<item>172.64.0.0/10</item>
|
||||
<item>172.128.0.0/9</item>
|
||||
@@ -38,7 +37,35 @@
|
||||
<item>196.0.0.0/6</item>
|
||||
<item>200.0.0.0/5</item>
|
||||
<item>208.0.0.0/4</item>
|
||||
<item>224.0.0.0/3</item>
|
||||
<item>224.0.0.0/4</item>
|
||||
<item>240.0.0.0/5</item>
|
||||
<item>248.0.0.0/6</item>
|
||||
<item>252.0.0.0/7</item>
|
||||
<item>254.0.0.0/8</item>
|
||||
<item>255.0.0.0/9</item>
|
||||
<item>255.128.0.0/10</item>
|
||||
<item>255.192.0.0/11</item>
|
||||
<item>255.224.0.0/12</item>
|
||||
<item>255.240.0.0/13</item>
|
||||
<item>255.248.0.0/14</item>
|
||||
<item>255.252.0.0/15</item>
|
||||
<item>255.254.0.0/16</item>
|
||||
<item>255.255.0.0/17</item>
|
||||
<item>255.255.128.0/18</item>
|
||||
<item>255.255.192.0/19</item>
|
||||
<item>255.255.224.0/20</item>
|
||||
<item>255.255.240.0/21</item>
|
||||
<item>255.255.248.0/22</item>
|
||||
<item>255.255.252.0/23</item>
|
||||
<item>255.255.254.0/24</item>
|
||||
<item>255.255.255.0/25</item>
|
||||
<item>255.255.255.128/26</item>
|
||||
<item>255.255.255.192/27</item>
|
||||
<item>255.255.255.224/28</item>
|
||||
<item>255.255.255.240/29</item>
|
||||
<item>255.255.255.248/30</item>
|
||||
<item>255.255.255.252/31</item>
|
||||
<item>255.255.255.254/32</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="default_disallow_application">
|
||||
|
||||
Reference in new issue
Block a user