mirror of
https://github.com/daeuniverse/dae.git
synced 2024-12-22 21:14:59 +07:00
fix(socks5): udp problem (#148)
This commit is contained in:
parent
b36b56ce6d
commit
4fa582e079
56
component/outbound/dialer/socks/socks_test.go
Normal file
56
component/outbound/dialer/socks/socks_test.go
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright (c) 2023, daeuniverse Organization <dae@v2raya.org>
|
||||
*/
|
||||
|
||||
package socks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/daeuniverse/dae/common/netutils"
|
||||
"github.com/daeuniverse/dae/component/outbound/dialer"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/net/dns/dnsmessage"
|
||||
"net/netip"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestSocks5(t *testing.T) {
|
||||
c, err := ParseSocksURL("socks5://192.168.31.6:1081")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
log := logrus.StandardLogger()
|
||||
d, err := c.Dialer(&dialer.GlobalOption{
|
||||
Log: log,
|
||||
TcpCheckOptionRaw: dialer.TcpCheckOptionRaw{
|
||||
Log: log,
|
||||
Raw: []string{"http://gstatic.com/generate_204"},
|
||||
ResolverNetwork: "udp",
|
||||
Method: "HEAD",
|
||||
},
|
||||
CheckDnsOptionRaw: dialer.CheckDnsOptionRaw{
|
||||
Raw: []string{"dns.google.com:53"},
|
||||
ResolverNetwork: "udp",
|
||||
},
|
||||
CheckInterval: 10 * time.Second,
|
||||
CheckTolerance: 0,
|
||||
CheckDnsTcp: true,
|
||||
AllowInsecure: false,
|
||||
TlsImplementation: "",
|
||||
UtlsImitate: "",
|
||||
}, dialer.InstanceOption{
|
||||
CheckEnabled: false,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
addrs, err := netutils.ResolveNetip(ctx, d, netip.MustParseAddrPort("8.8.8.8:53"), "apple.com", dnsmessage.TypeA, "udp")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(addrs)
|
||||
}
|
2
go.mod
2
go.mod
@ -11,7 +11,7 @@ require (
|
||||
github.com/gorilla/websocket v1.5.0
|
||||
github.com/json-iterator/go v1.1.12
|
||||
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826
|
||||
github.com/mzz2017/softwind v0.0.0-20230604132739-86b8bb994aff
|
||||
github.com/mzz2017/softwind v0.0.0-20230617041556-c341d431c575
|
||||
github.com/okzk/sdnotify v0.0.0-20180710141335-d9becc38acbd
|
||||
github.com/safchain/ethtool v0.0.0-20230116090318-67cc41908669
|
||||
github.com/sirupsen/logrus v1.9.0
|
||||
|
4
go.sum
4
go.sum
@ -78,8 +78,8 @@ github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9
|
||||
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8=
|
||||
github.com/mzz2017/disk-bloom v1.0.1 h1:rEF9MiXd9qMW3ibRpqcerLXULoTgRlM21yqqJl1B90M=
|
||||
github.com/mzz2017/disk-bloom v1.0.1/go.mod h1:JLHETtUu44Z6iBmsqzkOtFlRvXSlKnxjwiBRDapizDI=
|
||||
github.com/mzz2017/softwind v0.0.0-20230604132739-86b8bb994aff h1:vwwRmi3l6Fk5h0eb+mpkfD22lwP2VTNez98aS52xcew=
|
||||
github.com/mzz2017/softwind v0.0.0-20230604132739-86b8bb994aff/go.mod h1:1hn+ZsP9fLm17yEx0jyqxHkIKm5u2gBXVGIrnKsE1fY=
|
||||
github.com/mzz2017/softwind v0.0.0-20230617041556-c341d431c575 h1:SdmqtK60s2yi9qghZ0CyECRkXDOGhp2wvhFxISi1spU=
|
||||
github.com/mzz2017/softwind v0.0.0-20230617041556-c341d431c575/go.mod h1:1hn+ZsP9fLm17yEx0jyqxHkIKm5u2gBXVGIrnKsE1fY=
|
||||
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
|
||||
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
|
||||
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
|
||||
|
Loading…
Reference in New Issue
Block a user