mirror of
https://github.com/daeuniverse/dae.git
synced 2025-01-22 02:07:50 +07:00
chore: log shows dialMode
This commit is contained in:
parent
ecb51e2136
commit
7542884451
@ -405,22 +405,22 @@ func (c *ControlPlane) dnsUpstreamReadyCallback(raw *url.URL, dnsUpstream *dns.U
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *ControlPlane) ChooseDialTarget(outbound consts.OutboundIndex, dst netip.AddrPort, domain string) (dialTarget string) {
|
||||
mode := consts.DialMode_Ip
|
||||
func (c *ControlPlane) ChooseDialTarget(outbound consts.OutboundIndex, dst netip.AddrPort, domain string) (dialTarget string, dialMode consts.DialMode) {
|
||||
dialMode = consts.DialMode_Ip
|
||||
|
||||
if !outbound.IsReserved() && domain != "" {
|
||||
switch c.dialMode {
|
||||
case consts.DialMode_Domain:
|
||||
cache := c.dnsController.LookupDnsRespCache(domain, common.AddrToDnsType(dst.Addr()))
|
||||
if cache != nil && cache.IncludeIp(dst.Addr()) {
|
||||
mode = consts.DialMode_Domain
|
||||
dialMode = consts.DialMode_Domain
|
||||
}
|
||||
case consts.DialMode_DomainPlus:
|
||||
mode = consts.DialMode_Domain
|
||||
dialMode = consts.DialMode_Domain
|
||||
}
|
||||
}
|
||||
|
||||
switch mode {
|
||||
switch dialMode {
|
||||
case consts.DialMode_Ip:
|
||||
dialTarget = dst.String()
|
||||
case consts.DialMode_Domain:
|
||||
@ -430,7 +430,7 @@ func (c *ControlPlane) ChooseDialTarget(outbound consts.OutboundIndex, dst netip
|
||||
"to": dialTarget,
|
||||
}).Debugln("Rewrite dial target to domain")
|
||||
}
|
||||
return dialTarget
|
||||
return dialTarget, dialMode
|
||||
}
|
||||
|
||||
func (c *ControlPlane) ListenAndServe(port uint16) (err error) {
|
||||
|
@ -97,6 +97,7 @@ 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)
|
||||
}
|
||||
|
||||
dialTarget, dialMode := c.ChooseDialTarget(outboundIndex, dst, domain)
|
||||
if c.log.IsLevelEnabled(logrus.InfoLevel) {
|
||||
c.log.WithFields(logrus.Fields{
|
||||
"network": networkType.String(),
|
||||
@ -107,11 +108,12 @@ func (c *ControlPlane) handleConn(lConn net.Conn) (err error) {
|
||||
"pid": routingResult.Pid,
|
||||
"pname": ProcessName2String(routingResult.Pname[:]),
|
||||
"mac": Mac2String(routingResult.Mac[:]),
|
||||
"dialMode": dialMode,
|
||||
}).Infof("%v <-> %v", RefineSourceToShow(src, dst.Addr(), consts.LanWanFlag_NotApplicable), RefineAddrPortToShow(dst))
|
||||
}
|
||||
|
||||
// Dial and relay.
|
||||
rConn, err := d.Dial(MagicNetwork("tcp", routingResult.Mark), c.ChooseDialTarget(outboundIndex, dst, domain))
|
||||
rConn, err := d.Dial(MagicNetwork("tcp", routingResult.Mark), dialTarget)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to dial %v: %w", dst, err)
|
||||
}
|
||||
|
@ -193,7 +193,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).
|
||||
// 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.
|
||||
dialTarget := c.ChooseDialTarget(outboundIndex, realDst, domain)
|
||||
dialTarget, dialMode := c.ChooseDialTarget(outboundIndex, realDst, domain)
|
||||
|
||||
// Get udp endpoint.
|
||||
var ue *UdpEndpoint
|
||||
@ -266,6 +266,7 @@ getNew:
|
||||
"pid": routingResult.Pid,
|
||||
"pname": ProcessName2String(routingResult.Pname[:]),
|
||||
"mac": Mac2String(routingResult.Mac[:]),
|
||||
"dialMode": dialMode,
|
||||
}
|
||||
c.log.WithFields(fields).Infof("%v <-> %v", RefineSourceToShow(realSrc, realDst.Addr(), lanWanFlag), RefineAddrPortToShow(realDst))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user