mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2025-12-20 00:50:06 +08:00
fix: missing metadata in mieru inbound
Some checks are pending
Test / test (1.20, macos-15-intel) (push) Waiting to run
Test / test (1.20, macos-latest) (push) Waiting to run
Test / test (1.20, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.20, ubuntu-latest) (push) Waiting to run
Test / test (1.20, windows-latest) (push) Waiting to run
Test / test (1.21, macos-15-intel) (push) Waiting to run
Test / test (1.21, macos-latest) (push) Waiting to run
Test / test (1.21, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.21, ubuntu-latest) (push) Waiting to run
Test / test (1.21, windows-latest) (push) Waiting to run
Test / test (1.22, macos-15-intel) (push) Waiting to run
Test / test (1.22, macos-latest) (push) Waiting to run
Test / test (1.22, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.22, ubuntu-latest) (push) Waiting to run
Test / test (1.22, windows-latest) (push) Waiting to run
Test / test (1.23, macos-15-intel) (push) Waiting to run
Test / test (1.23, macos-latest) (push) Waiting to run
Test / test (1.23, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.23, ubuntu-latest) (push) Waiting to run
Test / test (1.23, windows-latest) (push) Waiting to run
Test / test (1.24, macos-15-intel) (push) Waiting to run
Test / test (1.24, macos-latest) (push) Waiting to run
Test / test (1.24, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.24, ubuntu-latest) (push) Waiting to run
Test / test (1.24, windows-latest) (push) Waiting to run
Test / test (1.25, macos-15-intel) (push) Waiting to run
Test / test (1.25, macos-latest) (push) Waiting to run
Test / test (1.25, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.25, ubuntu-latest) (push) Waiting to run
Test / test (1.25, windows-latest) (push) Waiting to run
Trigger CMFA Update / trigger-CMFA-update (push) Waiting to run
Some checks are pending
Test / test (1.20, macos-15-intel) (push) Waiting to run
Test / test (1.20, macos-latest) (push) Waiting to run
Test / test (1.20, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.20, ubuntu-latest) (push) Waiting to run
Test / test (1.20, windows-latest) (push) Waiting to run
Test / test (1.21, macos-15-intel) (push) Waiting to run
Test / test (1.21, macos-latest) (push) Waiting to run
Test / test (1.21, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.21, ubuntu-latest) (push) Waiting to run
Test / test (1.21, windows-latest) (push) Waiting to run
Test / test (1.22, macos-15-intel) (push) Waiting to run
Test / test (1.22, macos-latest) (push) Waiting to run
Test / test (1.22, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.22, ubuntu-latest) (push) Waiting to run
Test / test (1.22, windows-latest) (push) Waiting to run
Test / test (1.23, macos-15-intel) (push) Waiting to run
Test / test (1.23, macos-latest) (push) Waiting to run
Test / test (1.23, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.23, ubuntu-latest) (push) Waiting to run
Test / test (1.23, windows-latest) (push) Waiting to run
Test / test (1.24, macos-15-intel) (push) Waiting to run
Test / test (1.24, macos-latest) (push) Waiting to run
Test / test (1.24, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.24, ubuntu-latest) (push) Waiting to run
Test / test (1.24, windows-latest) (push) Waiting to run
Test / test (1.25, macos-15-intel) (push) Waiting to run
Test / test (1.25, macos-latest) (push) Waiting to run
Test / test (1.25, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.25, ubuntu-latest) (push) Waiting to run
Test / test (1.25, windows-latest) (push) Waiting to run
Trigger CMFA Update / trigger-CMFA-update (push) Waiting to run
This commit is contained in:
parent
644c04fdc9
commit
0df2f79ece
@ -31,12 +31,23 @@ func Handle(conn net.Conn, tunnel C.Tunnel, request *mierumodel.Request, additio
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Handle the connection with tunnel.
|
// Handle the connection with tunnel.
|
||||||
metadata := mieruRequestToMetadata(request)
|
switch request.Command {
|
||||||
inbound.ApplyAdditions(&metadata, additions...)
|
case mieruconstant.Socks5ConnectCmd: // TCP
|
||||||
switch metadata.NetWork {
|
metadata := &C.Metadata{
|
||||||
case C.TCP:
|
NetWork: C.TCP,
|
||||||
tunnel.HandleTCPConn(conn, &metadata)
|
Type: C.MIERU,
|
||||||
case C.UDP:
|
DstPort: uint16(request.DstAddr.Port),
|
||||||
|
}
|
||||||
|
if request.DstAddr.FQDN != "" {
|
||||||
|
metadata.Host = request.DstAddr.FQDN
|
||||||
|
} else if request.DstAddr.IP != nil {
|
||||||
|
metadata.DstIP, _ = netip.AddrFromSlice(request.DstAddr.IP)
|
||||||
|
metadata.DstIP = metadata.DstIP.Unmap()
|
||||||
|
}
|
||||||
|
inbound.ApplyAdditions(metadata, inbound.WithSrcAddr(conn.RemoteAddr()), inbound.WithInAddr(conn.LocalAddr()))
|
||||||
|
inbound.ApplyAdditions(metadata, additions...)
|
||||||
|
tunnel.HandleTCPConn(conn, metadata)
|
||||||
|
case mieruconstant.Socks5UDPAssociateCmd: // UDP
|
||||||
pc := mierucommon.NewPacketOverStreamTunnel(conn)
|
pc := mierucommon.NewPacketOverStreamTunnel(conn)
|
||||||
ep := N.NewEnhancePacketConn(pc)
|
ep := N.NewEnhancePacketConn(pc)
|
||||||
for {
|
for {
|
||||||
@ -67,24 +78,6 @@ func Handle(conn net.Conn, tunnel C.Tunnel, request *mierumodel.Request, additio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func mieruRequestToMetadata(request *mierumodel.Request) C.Metadata {
|
|
||||||
m := C.Metadata{
|
|
||||||
DstPort: uint16(request.DstAddr.Port),
|
|
||||||
}
|
|
||||||
switch request.Command {
|
|
||||||
case mieruconstant.Socks5ConnectCmd:
|
|
||||||
m.NetWork = C.TCP
|
|
||||||
case mieruconstant.Socks5UDPAssociateCmd:
|
|
||||||
m.NetWork = C.UDP
|
|
||||||
}
|
|
||||||
if request.DstAddr.FQDN != "" {
|
|
||||||
m.Host = request.DstAddr.FQDN
|
|
||||||
} else if request.DstAddr.IP != nil {
|
|
||||||
m.DstIP, _ = netip.AddrFromSlice(request.DstAddr.IP)
|
|
||||||
}
|
|
||||||
return m
|
|
||||||
}
|
|
||||||
|
|
||||||
type packet struct {
|
type packet struct {
|
||||||
pc net.PacketConn
|
pc net.PacketConn
|
||||||
addr net.Addr // source (i.e. remote) IP & Port of the packet
|
addr net.Addr // source (i.e. remote) IP & Port of the packet
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user