mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 03:32:33 +08:00
Android: patch
This commit is contained in:
parent
5cca3569e9
commit
a7040af346
|
@ -7,20 +7,10 @@ import (
|
|||
"syscall"
|
||||
)
|
||||
|
||||
type TunnelDialer func(context context.Context, network, address string) (net.Conn, error)
|
||||
type SocketControl func(network, address string, conn syscall.RawConn) error
|
||||
|
||||
var DefaultTunnelDialer TunnelDialer
|
||||
var DefaultSocketHook SocketControl
|
||||
|
||||
func DialTunnelContext(ctx context.Context, network, address string) (net.Conn, error) {
|
||||
if dialer := DefaultTunnelDialer; dialer != nil {
|
||||
return dialer(ctx, network, address)
|
||||
}
|
||||
|
||||
return DialContext(ctx, network, address)
|
||||
}
|
||||
|
||||
func dialContextHooked(ctx context.Context, network string, destination netip.Addr, port string) (net.Conn, error) {
|
||||
dialer := &net.Dialer{
|
||||
Control: DefaultSocketHook,
|
||||
|
|
|
@ -27,6 +27,8 @@ func HandleTcp(address string) (conn net.Conn, err error) {
|
|||
metadata.Type = C.INNER
|
||||
metadata.DNSMode = C.DNSNormal
|
||||
metadata.Process = C.ClashName
|
||||
metadata.RawSrcAddr = conn1.RemoteAddr()
|
||||
metadata.RawDstAddr = conn1.LocalAddr()
|
||||
if h, port, err := net.SplitHostPort(address); err == nil {
|
||||
if port, err := strconv.ParseUint(port, 10, 16); err == nil {
|
||||
metadata.DstPort = uint16(port)
|
||||
|
|
Loading…
Reference in New Issue
Block a user