update tun2socket & remove ipv6 for VpnService
This commit is contained in:
15 files changed
+49
-62
No files matched your search
@@ -4,7 +4,7 @@ go 1.13
|
||||
|
||||
require (
|
||||
github.com/Dreamacro/clash v0.0.0 // local
|
||||
github.com/kr328/tun2socket v0.0.0-20200329184923-76cc473668aa
|
||||
github.com/kr328/tun2socket v0.0.0-20200408030108-2c2effd1201d
|
||||
github.com/miekg/dns v1.1.29
|
||||
)
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@ github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/ad
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr328/tun2socket v0.0.0-20200329184923-76cc473668aa h1:WO6oDyis1HjzAYwv1Eu+wYmo6qzN8ph9ZllUpO3oQfE=
|
||||
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/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=
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package tun
|
||||
|
||||
import "github.com/Dreamacro/clash/log"
|
||||
|
||||
type ClashLogger struct {}
|
||||
|
||||
func (c *ClashLogger) D(format string, args ...interface{}) {
|
||||
log.Debugln(format, args)
|
||||
}
|
||||
|
||||
func (c *ClashLogger) I(format string, args ...interface{}) {
|
||||
log.Infoln(format, args)
|
||||
}
|
||||
|
||||
func (c *ClashLogger) W(format string, args ...interface{}) {
|
||||
log.Warnln(format, args)
|
||||
}
|
||||
|
||||
func (c *ClashLogger) E(format string, args ...interface{}) {
|
||||
log.Errorln(format, args)
|
||||
}
|
||||
|
||||
@@ -56,6 +56,10 @@ func StartTunDevice(fd, mtu int, gateway, mirror, dnsAddress string) error {
|
||||
|
||||
adapter = tun2socket.NewTun2Socket(file, mtu, gatewayIP, mirrorIP.To4())
|
||||
|
||||
adapter.SetLogger(&ClashLogger{})
|
||||
adapter.SetClosedHandler(func() {
|
||||
StopTunDevice()
|
||||
})
|
||||
adapter.SetAllocator(func(length int) []byte {
|
||||
if length <= maxUdpPacketSize {
|
||||
return udpPool.Get().([]byte)[:length]
|
||||
|
||||
@@ -11,7 +11,6 @@ import com.github.kr328.clash.core.model.Traffic
|
||||
import com.github.kr328.clash.core.transact.DoneCallbackImpl
|
||||
import com.github.kr328.clash.core.transact.ProxyCollectionImpl
|
||||
import com.github.kr328.clash.core.transact.ProxyGroupCollectionImpl
|
||||
import com.github.kr328.clash.core.utils.Log
|
||||
import kotlinx.coroutines.CompletableDeferred
|
||||
import java.io.File
|
||||
import java.io.InputStream
|
||||
@@ -51,8 +50,6 @@ object Clash {
|
||||
onNewSocket: (Int) -> Boolean,
|
||||
onTunStop: () -> Unit
|
||||
) {
|
||||
Log.d("$gateway $mirror $dns")
|
||||
|
||||
Bridge.startTunDevice(fd.toLong(), mtu.toLong(), gateway, mirror, dns, object: TunCallback {
|
||||
override fun onCreateSocket(fd: Long) {
|
||||
onNewSocket(fd.toInt())
|
||||
|
||||
Reference in new issue
Block a user