mirror of
https://github.com/daeuniverse/dae.git
synced 2025-07-04 15:27:55 +07:00
style: beautify log
This commit is contained in:
@ -138,8 +138,9 @@ func (a *AliveDialerSet) NotifyLatencyChange(dialer *Dialer, alive bool) {
|
|||||||
// Dialer: not alive -> alive.
|
// Dialer: not alive -> alive.
|
||||||
if index == -NotAlive {
|
if index == -NotAlive {
|
||||||
a.log.WithFields(logrus.Fields{
|
a.log.WithFields(logrus.Fields{
|
||||||
|
"dialer": dialer.property.Name,
|
||||||
"group": a.dialerGroupName,
|
"group": a.dialerGroupName,
|
||||||
}).Infof("[NOT ALIVE --%v-> ALIVE] %v", a.CheckTyp.String(), dialer.property.Name)
|
}).Infof("[NOT ALIVE --%v-> ALIVE]", a.CheckTyp.String())
|
||||||
}
|
}
|
||||||
a.dialerToIndex[dialer] = len(a.inorderedAliveDialerSet)
|
a.dialerToIndex[dialer] = len(a.inorderedAliveDialerSet)
|
||||||
a.inorderedAliveDialerSet = append(a.inorderedAliveDialerSet, dialer)
|
a.inorderedAliveDialerSet = append(a.inorderedAliveDialerSet, dialer)
|
||||||
@ -149,8 +150,9 @@ func (a *AliveDialerSet) NotifyLatencyChange(dialer *Dialer, alive bool) {
|
|||||||
if index >= 0 {
|
if index >= 0 {
|
||||||
// Dialer: alive -> not alive.
|
// Dialer: alive -> not alive.
|
||||||
a.log.WithFields(logrus.Fields{
|
a.log.WithFields(logrus.Fields{
|
||||||
|
"dialer": dialer.property.Name,
|
||||||
"group": a.dialerGroupName,
|
"group": a.dialerGroupName,
|
||||||
}).Infof("[ALIVE --%v-> NOT ALIVE] %v", a.CheckTyp.String(), dialer.property.Name)
|
}).Infof("[ALIVE --%v-> NOT ALIVE]", a.CheckTyp.String())
|
||||||
// Remove the dialer from inorderedAliveDialerSet.
|
// Remove the dialer from inorderedAliveDialerSet.
|
||||||
if index >= len(a.inorderedAliveDialerSet) {
|
if index >= len(a.inorderedAliveDialerSet) {
|
||||||
a.log.Panicf("index:%v >= len(a.inorderedAliveDialerSet):%v", index, len(a.inorderedAliveDialerSet))
|
a.log.Panicf("index:%v >= len(a.inorderedAliveDialerSet):%v", index, len(a.inorderedAliveDialerSet))
|
||||||
|
@ -31,12 +31,13 @@ func (c *controlPlaneCore) OutboundAliveChangeCallback(outbound uint8) func(aliv
|
|||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
if !isInit || c.log.IsLevelEnabled(logrus.TraceLevel) {
|
if !isInit || c.log.IsLevelEnabled(logrus.TraceLevel) {
|
||||||
|
strAlive := "NOT ALIVE"
|
||||||
|
if alive {
|
||||||
|
strAlive = "ALIVE"
|
||||||
|
}
|
||||||
c.log.WithFields(logrus.Fields{
|
c.log.WithFields(logrus.Fields{
|
||||||
"alive": alive,
|
|
||||||
"network": networkType.StringWithoutDns(),
|
|
||||||
"outboundId": outbound,
|
"outboundId": outbound,
|
||||||
"outbound": c.outboundId2Name[outbound],
|
}).Warnf("Outbound <%v> %v -> %v, notify the kernel program.", c.outboundId2Name[outbound], networkType.StringWithoutDns(), strAlive)
|
||||||
}).Warnf("Outbound alive state changed, notify the kernel program.")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
value := uint32(0)
|
value := uint32(0)
|
||||||
|
@ -190,7 +190,7 @@ loop:
|
|||||||
// Update DnsCache.
|
// Update DnsCache.
|
||||||
if c.log.IsLevelEnabled(logrus.TraceLevel) {
|
if c.log.IsLevelEnabled(logrus.TraceLevel) {
|
||||||
c.log.WithFields(logrus.Fields{
|
c.log.WithFields(logrus.Fields{
|
||||||
"qname": q.Name,
|
"_qname": q.Name,
|
||||||
"rcode": msg.RCode,
|
"rcode": msg.RCode,
|
||||||
"ans": FormatDnsRsc(msg.Answers),
|
"ans": FormatDnsRsc(msg.Answers),
|
||||||
"auth": FormatDnsRsc(msg.Authorities),
|
"auth": FormatDnsRsc(msg.Authorities),
|
||||||
@ -571,7 +571,7 @@ func (c *DnsController) dialSend(req *udpRequest, data []byte, id uint16, upstre
|
|||||||
"outbound": dialArgument.bestOutbound.Name,
|
"outbound": dialArgument.bestOutbound.Name,
|
||||||
"policy": dialArgument.bestOutbound.GetSelectionPolicy(),
|
"policy": dialArgument.bestOutbound.GetSelectionPolicy(),
|
||||||
"dialer": dialArgument.bestDialer.Property().Name,
|
"dialer": dialArgument.bestDialer.Property().Name,
|
||||||
"qname": qname,
|
"_qname": qname,
|
||||||
"qtype": qtype,
|
"qtype": qtype,
|
||||||
"pid": req.routingResult.Pid,
|
"pid": req.routingResult.Pid,
|
||||||
"pname": ProcessName2String(req.routingResult.Pname[:]),
|
"pname": ProcessName2String(req.routingResult.Pname[:]),
|
||||||
|
@ -101,19 +101,19 @@ func (c *ControlPlane) handleConn(lConn net.Conn) (err error) {
|
|||||||
return fmt.Errorf("failed to select dialer from group %v (%v): %w", outbound.Name, networkType.String(), err)
|
return fmt.Errorf("failed to select dialer from group %v (%v): %w", outbound.Name, networkType.String(), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
dialTarget, dialMode := c.ChooseDialTarget(outboundIndex, dst, domain)
|
dialTarget, _ := c.ChooseDialTarget(outboundIndex, dst, domain)
|
||||||
if c.log.IsLevelEnabled(logrus.InfoLevel) {
|
if c.log.IsLevelEnabled(logrus.InfoLevel) {
|
||||||
c.log.WithFields(logrus.Fields{
|
c.log.WithFields(logrus.Fields{
|
||||||
"network": networkType.String(),
|
"network": networkType.String(),
|
||||||
"outbound": outbound.Name,
|
"outbound": outbound.Name,
|
||||||
"policy": outbound.GetSelectionPolicy(),
|
"policy": outbound.GetSelectionPolicy(),
|
||||||
"dialer": d.Property().Name,
|
"dialer": d.Property().Name,
|
||||||
"domain": domain,
|
"sniffed": domain,
|
||||||
|
"ip": RefineAddrPortToShow(dst),
|
||||||
"pid": routingResult.Pid,
|
"pid": routingResult.Pid,
|
||||||
"pname": ProcessName2String(routingResult.Pname[:]),
|
"pname": ProcessName2String(routingResult.Pname[:]),
|
||||||
"mac": Mac2String(routingResult.Mac[:]),
|
"mac": Mac2String(routingResult.Mac[:]),
|
||||||
"dialMode": dialMode,
|
}).Infof("%v <-> %v", RefineSourceToShow(src, dst.Addr(), consts.LanWanFlag_NotApplicable), dialTarget)
|
||||||
}).Infof("%v <-> %v", RefineSourceToShow(src, dst.Addr(), consts.LanWanFlag_NotApplicable), RefineAddrPortToShow(dst))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dial and relay.
|
// Dial and relay.
|
||||||
|
@ -197,7 +197,7 @@ func (c *ControlPlane) handlePkt(lConn *net.UDPConn, data []byte, src, pktDst, r
|
|||||||
// TODO: Rewritten domain should not use full-cone (such as VMess Packet Addr).
|
// TODO: Rewritten domain should not use full-cone (such as VMess Packet Addr).
|
||||||
// Maybe we should set up a mapping for UDP: Dialer + Target Domain => Remote Resolved IP.
|
// Maybe we should set up a mapping for UDP: Dialer + Target Domain => Remote Resolved IP.
|
||||||
// However, games may not use QUIC for communication, thus we cannot use domain to dial, which is fine.
|
// However, games may not use QUIC for communication, thus we cannot use domain to dial, which is fine.
|
||||||
dialTarget, dialMode := c.ChooseDialTarget(outboundIndex, realDst, domain)
|
dialTarget, _ := c.ChooseDialTarget(outboundIndex, realDst, domain)
|
||||||
|
|
||||||
// Get udp endpoint.
|
// Get udp endpoint.
|
||||||
var ue *UdpEndpoint
|
var ue *UdpEndpoint
|
||||||
@ -273,12 +273,12 @@ getNew:
|
|||||||
"policy": outbound.GetSelectionPolicy(),
|
"policy": outbound.GetSelectionPolicy(),
|
||||||
"dialer": ue.Dialer.Property().Name,
|
"dialer": ue.Dialer.Property().Name,
|
||||||
"domain": domain,
|
"domain": domain,
|
||||||
|
"ip": RefineAddrPortToShow(realDst),
|
||||||
"pid": routingResult.Pid,
|
"pid": routingResult.Pid,
|
||||||
"pname": ProcessName2String(routingResult.Pname[:]),
|
"pname": ProcessName2String(routingResult.Pname[:]),
|
||||||
"mac": Mac2String(routingResult.Mac[:]),
|
"mac": Mac2String(routingResult.Mac[:]),
|
||||||
"dialMode": dialMode,
|
|
||||||
}
|
}
|
||||||
c.log.WithFields(fields).Infof("%v <-> %v", RefineSourceToShow(realSrc, realDst.Addr(), lanWanFlag), RefineAddrPortToShow(realDst))
|
c.log.WithFields(fields).Infof("%v <-> %v", RefineSourceToShow(realSrc, realDst.Addr(), lanWanFlag), dialTarget)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user