chore: add loopback detect for direct outbound

This commit is contained in:
wwqgtxx
2023-12-20 13:11:00 +08:00
parent 518c31dd0e
commit 429a03d986
4 changed files with 148 additions and 4 deletions

View File

@@ -148,8 +148,8 @@ type Metadata struct {
SpecialRules string `json:"specialRules"`
RemoteDst string `json:"remoteDestination"`
RawSrcAddr net.Addr `json:"-"`
RawDstAddr net.Addr `json:"-"`
RawSrcAddr net.Addr `json:"-"`
RawDstAddr net.Addr `json:"-"`
// Only domain rule
SniffHost string `json:"sniffHost"`
}
@@ -162,6 +162,10 @@ func (m *Metadata) SourceAddress() string {
return net.JoinHostPort(m.SrcIP.String(), strconv.FormatUint(uint64(m.SrcPort), 10))
}
func (m *Metadata) SourceAddrPort() netip.AddrPort {
return netip.AddrPortFrom(m.SrcIP.Unmap(), m.SrcPort)
}
func (m *Metadata) SourceDetail() string {
if m.Type == INNER {
return fmt.Sprintf("%s", MihomoName)