Skip to content

Commit 8a7cd65

Browse files
committed
Merge branch 'dns' into dns-geo
2 parents 946a7a2 + f4a048a commit 8a7cd65

35 files changed

Lines changed: 455 additions & 177 deletions

app/dns/nameserver_local_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313

1414
func TestLocalNameServer(t *testing.T) {
1515
s := NewLocalNameServer()
16-
ctx, cancel := context.WithTimeout(context.Background(), time.Second*2)
16+
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
1717
ips, err := s.QueryIP(ctx, "google.com", net.IP{}, dns.IPOption{
1818
IPv4Enable: true,
1919
IPv6Enable: true,

app/dns/nameserver_quic.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ import (
2727
// by selecting the ALPN token "dq" in the crypto handshake.
2828
const NextProtoDQ = "doq-i00"
2929

30-
const handshakeTimeout = time.Second * 8
31-
3230
// QUICNameServer implemented DNS over QUIC
3331
type QUICNameServer struct {
3432
sync.RWMutex
@@ -373,9 +371,7 @@ func (s *QUICNameServer) getSession() (quic.Session, error) {
373371

374372
func (s *QUICNameServer) openSession() (quic.Session, error) {
375373
tlsConfig := tls.Config{}
376-
quicConfig := &quic.Config{
377-
HandshakeTimeout: handshakeTimeout,
378-
}
374+
quicConfig := &quic.Config{}
379375

380376
session, err := quic.DialAddrContext(context.Background(), s.destination.NetAddr(), tlsConfig.GetTLSConfig(tls.WithNextProto("http/1.1", http2.NextProtoTLS, NextProtoDQ)), quicConfig)
381377
if err != nil {

app/dns/nameserver_quic_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func TestQUICNameServer(t *testing.T) {
1919
common.Must(err)
2020
s, err := NewQUICNameServer(url)
2121
common.Must(err)
22-
ctx, cancel := context.WithTimeout(context.Background(), time.Second*2)
22+
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
2323
ips, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns_feature.IPOption{
2424
IPv4Enable: true,
2525
IPv6Enable: true,
@@ -36,7 +36,7 @@ func TestQUICNameServerWithCache(t *testing.T) {
3636
common.Must(err)
3737
s, err := NewQUICNameServer(url)
3838
common.Must(err)
39-
ctx, cancel := context.WithTimeout(context.Background(), time.Second*2)
39+
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
4040
ips, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns_feature.IPOption{
4141
IPv4Enable: true,
4242
IPv6Enable: true,
@@ -47,7 +47,7 @@ func TestQUICNameServerWithCache(t *testing.T) {
4747
t.Error("expect some ips, but got 0")
4848
}
4949

50-
ctx2, cancel := context.WithTimeout(context.Background(), time.Second*2)
50+
ctx2, cancel := context.WithTimeout(context.Background(), time.Second*5)
5151
ips2, err := s.QueryIP(ctx2, "google.com", net.IP(nil), dns_feature.IPOption{
5252
IPv4Enable: true,
5353
IPv6Enable: true,

common/buf/buffer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func NewExisted(b []byte) *Buffer {
3838

3939
oLen := len(b)
4040
if oLen < Size {
41-
b = append(b, make([]byte, Size-oLen)...)
41+
b = b[:Size]
4242
}
4343

4444
return &Buffer{

core/config.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,25 @@ func getFormat(filename string) string {
8080
func LoadConfig(formatName string, input interface{}) (*Config, error) {
8181
switch v := input.(type) {
8282
case cmdarg.Arg:
83-
8483
formats := make([]string, len(v))
8584
hasProtobuf := false
8685
for i, file := range v {
87-
f := getFormat(file)
88-
if f == "" {
86+
var f string
87+
88+
if formatName == "auto" {
89+
if file != "stdin:" {
90+
f = getFormat(file)
91+
} else {
92+
f = "json"
93+
}
94+
} else {
8995
f = formatName
9096
}
97+
98+
if f == "" {
99+
return nil, newError("Failed to get format of ", file).AtWarning()
100+
}
101+
91102
if f == "protobuf" {
92103
hasProtobuf = true
93104
}

core/core.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
)
1919

2020
var (
21-
version = "1.4.0"
21+
version = "1.4.2"
2222
build = "Custom"
2323
codename = "Xray, Penetrates Everything."
2424
intro = "A unified platform for anti-censorship."

go.mod

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,23 @@ go 1.16
55
require (
66
github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32
77
github.com/golang/mock v1.5.0
8-
github.com/golang/protobuf v1.4.3
8+
github.com/golang/protobuf v1.5.2
99
github.com/google/go-cmp v0.5.5
1010
github.com/gorilla/websocket v1.4.2
11-
github.com/lucas-clemente/quic-go v0.19.3
12-
github.com/miekg/dns v1.1.40
11+
github.com/lucas-clemente/quic-go v0.20.0
12+
github.com/miekg/dns v1.1.41
1313
github.com/pelletier/go-toml v1.8.1
1414
github.com/pires/go-proxyproto v0.5.0
15+
github.com/refraction-networking/utls v0.0.0-20201210053706-2179f286686b
1516
github.com/seiflotfy/cuckoofilter v0.0.0-20201222105146-bc6005554a0c
1617
github.com/stretchr/testify v1.7.0
1718
github.com/xtls/go v0.0.0-20201118062508-3632bf3b7499
1819
go.starlark.net v0.0.0-20210312235212-74c10e2c17dc
19-
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83
20-
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110
20+
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2
21+
golang.org/x/net v0.0.0-20210330230544-e57232859fb2
2122
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
22-
golang.org/x/sys v0.0.0-20210313202042-bd2e13477e9c
23-
google.golang.org/grpc v1.36.0
24-
google.golang.org/protobuf v1.25.0
23+
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44
24+
google.golang.org/grpc v1.36.1
25+
google.golang.org/protobuf v1.26.0
2526
h12.io/socks v1.0.2
2627
)

0 commit comments

Comments
 (0)