mirror of https://github.com/Dreamacro/clash.git
Chore: show the source ip in log (#2284)
Co-authored-by: Li Feng <fengli@smartx.com>
This commit is contained in:
parent
22b9befbda
commit
4f291fa513
|
@ -233,9 +233,15 @@ func handleUDPConn(packet *inbound.PacketAdapter) {
|
|||
rawPc, err := proxy.ListenPacketContext(ctx, metadata.Pure())
|
||||
if err != nil {
|
||||
if rule == nil {
|
||||
log.Warnln("[UDP] dial %s to %s error: %s", proxy.Name(), metadata.RemoteAddress(), err.Error())
|
||||
log.Warnln(
|
||||
"[UDP] dial %s %s --> %s error: %s",
|
||||
proxy.Name(),
|
||||
metadata.SourceAddress(),
|
||||
metadata.RemoteAddress(),
|
||||
err.Error(),
|
||||
)
|
||||
} else {
|
||||
log.Warnln("[UDP] dial %s (match %s/%s) to %s error: %s", proxy.Name(), rule.RuleType().String(), rule.Payload(), metadata.RemoteAddress(), err.Error())
|
||||
log.Warnln("[UDP] dial %s (match %s/%s) %s --> %s error: %s", proxy.Name(), rule.RuleType().String(), rule.Payload(), metadata.SourceAddress(), metadata.RemoteAddress(), err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -244,13 +250,24 @@ func handleUDPConn(packet *inbound.PacketAdapter) {
|
|||
|
||||
switch true {
|
||||
case rule != nil:
|
||||
log.Infoln("[UDP] %s --> %s match %s(%s) using %s", metadata.SourceAddress(), metadata.RemoteAddress(), rule.RuleType().String(), rule.Payload(), rawPc.Chains().String())
|
||||
log.Infoln(
|
||||
"[UDP] %s --> %s match %s(%s) using %s",
|
||||
metadata.SourceAddress(),
|
||||
metadata.RemoteAddress(),
|
||||
rule.RuleType().String(),
|
||||
rule.Payload(),
|
||||
rawPc.Chains().String(),
|
||||
)
|
||||
case mode == Global:
|
||||
log.Infoln("[UDP] %s --> %s using GLOBAL", metadata.SourceAddress(), metadata.RemoteAddress())
|
||||
case mode == Direct:
|
||||
log.Infoln("[UDP] %s --> %s using DIRECT", metadata.SourceAddress(), metadata.RemoteAddress())
|
||||
default:
|
||||
log.Infoln("[UDP] %s --> %s doesn't match any rule using DIRECT", metadata.SourceAddress(), metadata.RemoteAddress())
|
||||
log.Infoln(
|
||||
"[UDP] %s --> %s doesn't match any rule using DIRECT",
|
||||
metadata.SourceAddress(),
|
||||
metadata.RemoteAddress(),
|
||||
)
|
||||
}
|
||||
|
||||
oAddr, _ := netip.AddrFromSlice(metadata.DstIP)
|
||||
|
@ -287,9 +304,15 @@ func handleTCPConn(connCtx C.ConnContext) {
|
|||
remoteConn, err := proxy.DialContext(ctx, metadata.Pure())
|
||||
if err != nil {
|
||||
if rule == nil {
|
||||
log.Warnln("[TCP] dial %s to %s error: %s", proxy.Name(), metadata.RemoteAddress(), err.Error())
|
||||
log.Warnln(
|
||||
"[TCP] dial %s %s --> %s error: %s",
|
||||
proxy.Name(),
|
||||
metadata.SourceAddress(),
|
||||
metadata.RemoteAddress(),
|
||||
err.Error(),
|
||||
)
|
||||
} else {
|
||||
log.Warnln("[TCP] dial %s (match %s/%s) to %s error: %s", proxy.Name(), rule.RuleType().String(), rule.Payload(), metadata.RemoteAddress(), err.Error())
|
||||
log.Warnln("[TCP] dial %s (match %s/%s) %s --> %s error: %s", proxy.Name(), rule.RuleType().String(), rule.Payload(), metadata.SourceAddress(), metadata.RemoteAddress(), err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -298,13 +321,24 @@ func handleTCPConn(connCtx C.ConnContext) {
|
|||
|
||||
switch true {
|
||||
case rule != nil:
|
||||
log.Infoln("[TCP] %s --> %s match %s(%s) using %s", metadata.SourceAddress(), metadata.RemoteAddress(), rule.RuleType().String(), rule.Payload(), remoteConn.Chains().String())
|
||||
log.Infoln(
|
||||
"[TCP] %s --> %s match %s(%s) using %s",
|
||||
metadata.SourceAddress(),
|
||||
metadata.RemoteAddress(),
|
||||
rule.RuleType().String(),
|
||||
rule.Payload(),
|
||||
remoteConn.Chains().String(),
|
||||
)
|
||||
case mode == Global:
|
||||
log.Infoln("[TCP] %s --> %s using GLOBAL", metadata.SourceAddress(), metadata.RemoteAddress())
|
||||
case mode == Direct:
|
||||
log.Infoln("[TCP] %s --> %s using DIRECT", metadata.SourceAddress(), metadata.RemoteAddress())
|
||||
default:
|
||||
log.Infoln("[TCP] %s --> %s doesn't match any rule using DIRECT", metadata.SourceAddress(), metadata.RemoteAddress())
|
||||
log.Infoln(
|
||||
"[TCP] %s --> %s doesn't match any rule using DIRECT",
|
||||
metadata.SourceAddress(),
|
||||
metadata.RemoteAddress(),
|
||||
)
|
||||
}
|
||||
|
||||
handleSocket(connCtx, remoteConn)
|
||||
|
|
Loading…
Reference in New Issue