fix access control & remove context support in fetch.go

This commit is contained in:
Kr328 committed 2020-04-14 23:44:41 +08:00
1 parent 640cf3e75c
commit 260ebc83ff
5 files changed
+9 -16

No files matched your search

+2 -2
View File
@@ -10,8 +10,8 @@ buildscript {
this["gMinSdkVersion"] = 24
this["gTargetSdkVersion"] = 29
this["gVersionCode"] = 10200
this["gVersionName"] = "1.2.0"
this["gVersionCode"] = 10201
this["gVersionName"] = "1.2.1"
this["gKotlinVersion"] = kotlinVersion
this["gKotlinCoroutineVersion"] = "1.3.5"
-11
View File
@@ -31,17 +31,6 @@ var client = &http.Client{
tunnel.Add(inbound.NewSocket(socks5.ParseAddr(address), server, constant.HTTP, constant.TCP))
go func() {
if ctx == nil || ctx.Done() == nil {
return
}
<-ctx.Done()
_ = client.Close()
_ = server.Close()
}()
return client, nil
},
},
+1 -1
View File
@@ -4,7 +4,7 @@ go 1.13
require (
github.com/Dreamacro/clash v0.0.0 // local
github.com/kr328/tun2socket v0.0.0-20200408030108-2c2effd1201d
github.com/kr328/tun2socket v0.0.0-20200414144428-a5c90c3acc29
github.com/miekg/dns v1.1.29
)
+4
View File
@@ -16,6 +16,10 @@ github.com/kr328/tun2socket v0.0.0-20200329184923-76cc473668aa h1:WO6oDyis1HjzAY
github.com/kr328/tun2socket v0.0.0-20200329184923-76cc473668aa/go.mod h1:FWfSixjrLgtK+dHkDoN6lHMNhvER24gnjUZd/wt8Z9o=
github.com/kr328/tun2socket v0.0.0-20200408030108-2c2effd1201d h1:+IU9AD+eA0tbMdl9TdxAqvbOWU8SnOQtbsPAMYqeXtU=
github.com/kr328/tun2socket v0.0.0-20200408030108-2c2effd1201d/go.mod h1:FWfSixjrLgtK+dHkDoN6lHMNhvER24gnjUZd/wt8Z9o=
github.com/kr328/tun2socket v0.0.0-20200414143005-3c2b6a0e2baa h1:0kdJd6G6eMhU/bj3rIDI+LWOAtWn4X+d8WSqM0lQh+E=
github.com/kr328/tun2socket v0.0.0-20200414143005-3c2b6a0e2baa/go.mod h1:FWfSixjrLgtK+dHkDoN6lHMNhvER24gnjUZd/wt8Z9o=
github.com/kr328/tun2socket v0.0.0-20200414144428-a5c90c3acc29 h1:grdaTKqrP64fflliNWnQIysryupmk3dN0a0saMs37+w=
github.com/kr328/tun2socket v0.0.0-20200414144428-a5c90c3acc29/go.mod h1:FWfSixjrLgtK+dHkDoN6lHMNhvER24gnjUZd/wt8Z9o=
github.com/miekg/dns v1.1.29 h1:xHBEhR+t5RzcFJjBLJlax2daXOrTYtr9z4WdKEfWFzg=
github.com/miekg/dns v1.1.29/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM=
github.com/oschwald/geoip2-golang v1.4.0 h1:5RlrjCgRyIGDz/mBmPfnAF4h8k0IAcRv9PvrpOfz+Ug=
@@ -137,13 +137,13 @@ class TunService : VpnService(), CoroutineScope by MainScope() {
override val allowApplications: List<String>
get() {
return if (settings.get(ServiceSettings.ACCESS_CONTROL_MODE) == ServiceSettings.ACCESS_CONTROL_MODE_WHITELIST) {
settings.get(ServiceSettings.ACCESS_CONTROL_PACKAGES).toList()
(settings.get(ServiceSettings.ACCESS_CONTROL_PACKAGES) + packageName).toList()
} else emptyList()
}
override val disallowApplication: List<String>
get() {
return if (settings.get(ServiceSettings.ACCESS_CONTROL_MODE) == ServiceSettings.ACCESS_CONTROL_MODE_BLACKLIST) {
settings.get(ServiceSettings.ACCESS_CONTROL_PACKAGES).toList()
(settings.get(ServiceSettings.ACCESS_CONTROL_PACKAGES) - packageName).toList()
} else emptyList()
}
}