Chore: use custom dialer

This commit is contained in:
Dreamacro
2020-02-09 17:02:48 +08:00
parent a55be58c01
commit afc9f3f59a
10 changed files with 68 additions and 5 deletions

View File

@ -4,6 +4,7 @@ import (
"context"
"net"
"github.com/Dreamacro/clash/component/dialer"
C "github.com/Dreamacro/clash/constant"
)
@ -26,7 +27,7 @@ func (d *Direct) DialContext(ctx context.Context, metadata *C.Metadata) (C.Conn,
}
func (d *Direct) DialUDP(metadata *C.Metadata) (C.PacketConn, error) {
pc, err := net.ListenPacket("udp", "")
pc, err := dialer.ListenPacket("udp", "")
if err != nil {
return nil, err
}

View File

@ -9,6 +9,7 @@ import (
"strconv"
"github.com/Dreamacro/clash/common/structure"
"github.com/Dreamacro/clash/component/dialer"
obfs "github.com/Dreamacro/clash/component/simple-obfs"
"github.com/Dreamacro/clash/component/socks5"
v2rayObfs "github.com/Dreamacro/clash/component/v2ray-plugin"
@ -83,7 +84,7 @@ func (ss *ShadowSocks) DialContext(ctx context.Context, metadata *C.Metadata) (C
}
func (ss *ShadowSocks) DialUDP(metadata *C.Metadata) (C.PacketConn, error) {
pc, err := net.ListenPacket("udp", "")
pc, err := dialer.ListenPacket("udp", "")
if err != nil {
return nil, err
}

View File

@ -9,6 +9,7 @@ import (
"net"
"strconv"
"github.com/Dreamacro/clash/component/dialer"
"github.com/Dreamacro/clash/component/socks5"
C "github.com/Dreamacro/clash/constant"
)
@ -96,7 +97,7 @@ func (ss *Socks5) DialUDP(metadata *C.Metadata) (_ C.PacketConn, err error) {
return
}
pc, err := net.ListenPacket("udp", "")
pc, err := dialer.ListenPacket("udp", "")
if err != nil {
return
}

View File

@ -11,6 +11,7 @@ import (
"sync"
"time"
"github.com/Dreamacro/clash/component/dialer"
"github.com/Dreamacro/clash/component/socks5"
C "github.com/Dreamacro/clash/constant"
"github.com/Dreamacro/clash/dns"
@ -107,7 +108,7 @@ func dialContext(ctx context.Context, network, address string) (net.Conn, error)
var primary, fallback dialResult
startRacer := func(ctx context.Context, host string, ipv6 bool) {
dialer := net.Dialer{}
dialer := dialer.Dialer()
result := dialResult{ipv6: ipv6, done: true}
defer func() {
select {