chore: add android feature and patch

This commit is contained in:
Steve Johnson
2023-11-17 13:19:24 +08:00
parent b73382f60a
commit d9cfdc3242
6 changed files with 67 additions and 17 deletions

View File

@@ -12,6 +12,8 @@ import (
"time"
"github.com/metacubex/mihomo/component/resolver"
"github.com/metacubex/mihomo/constant/features"
"golang.org/x/exp/slices"
)
type dialFunc func(ctx context.Context, network string, ips []netip.Addr, port string, opt *option) (net.Conn, error)
@@ -70,6 +72,10 @@ func DialContext(ctx context.Context, network, address string, options ...Option
}
func ListenPacket(ctx context.Context, network, address string, options ...Option) (net.PacketConn, error) {
if slices.Contains(features.TAGS, "cmfa") {
return listenPacketHooked(ctx, network, address)
}
cfg := applyOptions(options...)
lc := &net.ListenConfig{}
@@ -114,6 +120,10 @@ func GetTcpConcurrent() bool {
}
func dialContext(ctx context.Context, network string, destination netip.Addr, port string, opt *option) (net.Conn, error) {
if slices.Contains(features.TAGS, "cmfa") {
return dialContextHooked(ctx, network, destination, port)
}
address := net.JoinHostPort(destination.String(), port)
netDialer := opt.netDialer

View File

@@ -0,0 +1,17 @@
// +build !cmfa
package dialer
import (
"context"
"net"
"net/netip"
)
func dialContextHooked(ctx context.Context, network string, destination netip.Addr, port string) (net.Conn, error) {
return nil, nil
}
func listenPacketHooked(ctx context.Context, network, address string) (net.PacketConn, error) {
return nil, nil
}