Refactor: tun config
This commit is contained in:
@@ -269,7 +269,7 @@ func handleUDPConn(packet *inbound.PacketAdapter) {
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), C.DefaultUDPTimeout)
|
||||
defer cancel()
|
||||
rawPc, err := proxy.ListenPacketContext(ctx, metadata.Pure())
|
||||
rawPc, err := proxy.ListenPacketContext(ctx, metadata.Pure(false))
|
||||
if err != nil {
|
||||
if rule == nil {
|
||||
log.Warnln("[UDP] dial %s to %s error: %s", proxy.Name(), metadata.RemoteAddress(), err.Error())
|
||||
@@ -321,14 +321,11 @@ func handleTCPConn(connCtx C.ConnContext) {
|
||||
return
|
||||
}
|
||||
|
||||
mtd := metadata
|
||||
if proxy != mitmProxy {
|
||||
mtd = metadata.Pure()
|
||||
}
|
||||
isMitmOutbound := proxy == mitmProxy
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), C.DefaultTCPTimeout)
|
||||
defer cancel()
|
||||
remoteConn, err := proxy.DialContext(ctx, mtd)
|
||||
remoteConn, err := proxy.DialContext(ctx, metadata.Pure(isMitmOutbound))
|
||||
if err != nil {
|
||||
if rule == nil {
|
||||
log.Warnln("[TCP] dial %s to %s error: %s", proxy.Name(), metadata.RemoteAddress(), err.Error())
|
||||
@@ -338,7 +335,7 @@ func handleTCPConn(connCtx C.ConnContext) {
|
||||
return
|
||||
}
|
||||
|
||||
if remoteConn.Chains().Last() != "REJECT" && proxy != mitmProxy {
|
||||
if remoteConn.Chains().Last() != "REJECT" && !isMitmOutbound {
|
||||
remoteConn = statistic.NewTCPTracker(remoteConn, statistic.DefaultManager, metadata, rule)
|
||||
}
|
||||
|
||||
@@ -347,7 +344,7 @@ func handleTCPConn(connCtx C.ConnContext) {
|
||||
}(remoteConn)
|
||||
|
||||
switch true {
|
||||
case proxy == mitmProxy:
|
||||
case isMitmOutbound:
|
||||
break
|
||||
case rule != nil:
|
||||
log.Infoln("[TCP] %s(%s) --> %s match %s(%s) using %s", metadata.SourceAddress(), metadata.Process, metadata.RemoteAddress(), rule.RuleType().String(), rule.Payload(), remoteConn.Chains().String())
|
||||
|
||||
Reference in New Issue
Block a user