mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2025-12-24 13:38:05 +08:00
chore: better log
This commit is contained in:
@@ -70,7 +70,9 @@ func (d *DNSDialer) DialContext(ctx context.Context, network, addr string) (net.
|
||||
} else {
|
||||
var ok bool
|
||||
proxyAdapter, ok = Proxies()[proxyName]
|
||||
if !ok {
|
||||
if ok {
|
||||
metadata.SpecialProxy = proxyName // just for log
|
||||
} else {
|
||||
opts = append(opts, dialer.WithInterface(proxyName))
|
||||
}
|
||||
}
|
||||
@@ -158,7 +160,9 @@ func (d *DNSDialer) ListenPacket(ctx context.Context, network, addr string) (net
|
||||
} else {
|
||||
var ok bool
|
||||
proxyAdapter, ok = Proxies()[proxyName]
|
||||
if !ok {
|
||||
if ok {
|
||||
metadata.SpecialProxy = proxyName // just for log
|
||||
} else {
|
||||
opts = append(opts, dialer.WithInterface(proxyName))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -627,7 +627,7 @@ func logMetadataErr(metadata *C.Metadata, rule C.Rule, proxy C.ProxyAdapter, err
|
||||
func logMetadata(metadata *C.Metadata, rule C.Rule, remoteConn C.Connection) {
|
||||
switch {
|
||||
case metadata.SpecialProxy != "":
|
||||
log.Infoln("[%s] %s --> %s using %s", strings.ToUpper(metadata.NetWork.String()), metadata.SourceDetail(), metadata.RemoteAddress(), metadata.SpecialProxy)
|
||||
log.Infoln("[%s] %s --> %s using %s", strings.ToUpper(metadata.NetWork.String()), metadata.SourceDetail(), metadata.RemoteAddress(), remoteConn.Chains().String())
|
||||
case rule != nil:
|
||||
if rule.Payload() != "" {
|
||||
log.Infoln("[%s] %s --> %s match %s using %s", strings.ToUpper(metadata.NetWork.String()), metadata.SourceDetail(), metadata.RemoteAddress(), fmt.Sprintf("%s(%s)", rule.RuleType().String(), rule.Payload()), remoteConn.Chains().String())
|
||||
@@ -639,7 +639,7 @@ func logMetadata(metadata *C.Metadata, rule C.Rule, remoteConn C.Connection) {
|
||||
case mode == Direct:
|
||||
log.Infoln("[%s] %s --> %s using DIRECT", strings.ToUpper(metadata.NetWork.String()), metadata.SourceDetail(), metadata.RemoteAddress())
|
||||
default:
|
||||
log.Infoln("[%s] %s --> %s doesn't match any rule using %s", strings.ToUpper(metadata.NetWork.String()), metadata.SourceDetail(), metadata.RemoteAddress(), remoteConn.Chains().Last())
|
||||
log.Infoln("[%s] %s --> %s doesn't match any rule using %s", strings.ToUpper(metadata.NetWork.String()), metadata.SourceDetail(), metadata.RemoteAddress(), remoteConn.Chains().String())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user