mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-12-22 23:57:26 +08:00
fix: RawSrcAddr and RawSrcAddr in metadata
This commit is contained in:
parent
f8557f5fd8
commit
417d709d60
@ -11,6 +11,8 @@ import (
|
||||
func NewHTTPS(request *http.Request, conn net.Conn, additions ...Addition) (net.Conn, *C.Metadata) {
|
||||
metadata := parseHTTPAddr(request)
|
||||
metadata.Type = C.HTTPS
|
||||
metadata.RawSrcAddr = conn.RemoteAddr()
|
||||
metadata.RawDstAddr = conn.LocalAddr()
|
||||
ApplyAdditions(metadata, WithSrcAddr(conn.RemoteAddr()), WithInAddr(conn.LocalAddr()))
|
||||
ApplyAdditions(metadata, additions...)
|
||||
return conn, metadata
|
||||
|
@ -129,6 +129,12 @@ func (h *ListenerHandler) NewConnection(ctx context.Context, conn net.Conn, meta
|
||||
NetWork: C.TCP,
|
||||
Type: h.Type,
|
||||
}
|
||||
if metadata.Source.IsIP() && metadata.Source.Fqdn == "" {
|
||||
cMetadata.RawSrcAddr = metadata.Source.Unwrap().TCPAddr()
|
||||
}
|
||||
if metadata.Destination.IsIP() && metadata.Destination.Fqdn == "" {
|
||||
cMetadata.RawDstAddr = metadata.Destination.Unwrap().TCPAddr()
|
||||
}
|
||||
inbound.ApplyAdditions(cMetadata, inbound.WithDstAddr(metadata.Destination), inbound.WithSrcAddr(metadata.Source), inbound.WithInAddr(conn.LocalAddr()))
|
||||
inbound.ApplyAdditions(cMetadata, getAdditions(ctx)...)
|
||||
inbound.ApplyAdditions(cMetadata, h.Additions...)
|
||||
@ -185,6 +191,12 @@ func (h *ListenerHandler) NewPacketConnection(ctx context.Context, conn network.
|
||||
NetWork: C.UDP,
|
||||
Type: h.Type,
|
||||
}
|
||||
if metadata.Source.IsIP() && metadata.Source.Fqdn == "" {
|
||||
cMetadata.RawSrcAddr = metadata.Source.Unwrap().UDPAddr()
|
||||
}
|
||||
if dest.IsIP() && dest.Fqdn == "" {
|
||||
cMetadata.RawDstAddr = dest.Unwrap().UDPAddr()
|
||||
}
|
||||
inbound.ApplyAdditions(cMetadata, inbound.WithDstAddr(dest), inbound.WithSrcAddr(metadata.Source), inbound.WithInAddr(conn.LocalAddr()))
|
||||
inbound.ApplyAdditions(cMetadata, getAdditions(ctx)...)
|
||||
inbound.ApplyAdditions(cMetadata, h.Additions...)
|
||||
|
Loading…
Reference in New Issue
Block a user