Add hijack_dns for tun

This commit is contained in:
世界
2022-07-10 09:15:01 +08:00
parent a34057753c
commit ddfae8cd07
15 changed files with 220 additions and 99 deletions

View File

@@ -20,6 +20,9 @@ func NewTransport(ctx context.Context, dialer N.Dialer, logger log.Logger, addre
return nil, err
}
host := serverURL.Hostname()
if host == "" {
host = address
}
port := serverURL.Port()
switch serverURL.Scheme {
case "tls":

View File

@@ -87,7 +87,7 @@ func (t *TCPTransport) newConnection(conn *dnsConnection) {
}
})
conn.err = err
if err != nil {
if err != nil && !E.IsClosed(err) {
t.logger.Debug("connection closed: ", err)
}
}

View File

@@ -95,7 +95,7 @@ func (t *TLSTransport) newConnection(conn *dnsConnection) {
}
})
conn.err = err
if err != nil {
if err != nil && !E.IsClosed(err) {
t.logger.Debug("connection closed: ", err)
}
}

View File

@@ -8,6 +8,7 @@ import (
"github.com/sagernet/sing-box/log"
"github.com/sagernet/sing/common"
"github.com/sagernet/sing/common/buf"
E "github.com/sagernet/sing/common/exceptions"
M "github.com/sagernet/sing/common/metadata"
N "github.com/sagernet/sing/common/network"
"github.com/sagernet/sing/common/task"
@@ -83,7 +84,7 @@ func (t *UDPTransport) newConnection(conn *dnsConnection) {
}
})
conn.err = err
if err != nil {
if err != nil && !E.IsClosed(err) {
t.logger.Debug("connection closed: ", err)
}
}