Chore: merge branch 'with-tun' into plus-pro

This commit is contained in:
yaling888
2022-04-12 00:47:45 +08:00
17 changed files with 323 additions and 261 deletions

View File

@@ -182,7 +182,7 @@ func preHandleMetadata(metadata *C.Metadata) error {
return nil
}
func resolveMetadata(ctx C.PlainContext, metadata *C.Metadata) (proxy C.Proxy, rule C.Rule, err error) {
func resolveMetadata(_ C.PlainContext, metadata *C.Metadata) (proxy C.Proxy, rule C.Rule, err error) {
switch mode {
case Direct:
proxy = proxies["DIRECT"]
@@ -220,7 +220,7 @@ func handleUDPConn(packet *inbound.PacketAdapter) {
handle := func() bool {
pc := natTable.Get(key)
if pc != nil {
handleUDPToRemote(packet, pc, metadata)
_ = handleUDPToRemote(packet, pc, metadata)
return true
}
return false
@@ -289,7 +289,9 @@ func handleUDPConn(packet *inbound.PacketAdapter) {
}
func handleTCPConn(connCtx C.ConnContext) {
defer connCtx.Conn().Close()
defer func(conn net.Conn) {
_ = conn.Close()
}(connCtx.Conn())
metadata := connCtx.Metadata()
if !metadata.Valid() {
@@ -307,7 +309,9 @@ func handleTCPConn(connCtx C.ConnContext) {
if MitmOutbound != nil && metadata.Type != C.MITM {
if remoteConn, err1 := MitmOutbound.DialContext(ctx, metadata); err1 == nil {
remoteConn = statistic.NewSniffing(remoteConn, metadata)
defer remoteConn.Close()
defer func(remoteConn C.Conn) {
_ = remoteConn.Close()
}(remoteConn)
handleSocket(connCtx, remoteConn)
return
@@ -330,7 +334,9 @@ func handleTCPConn(connCtx C.ConnContext) {
return
}
remoteConn = statistic.NewTCPTracker(remoteConn, statistic.DefaultManager, metadata, rule)
defer remoteConn.Close()
defer func(remoteConn C.Conn) {
_ = remoteConn.Close()
}(remoteConn)
switch true {
case rule != nil: