Style: format code by gofumpt (#761)

This commit is contained in:
yuhan6665 2021-10-19 12:57:14 -04:00 committed by GitHub
parent d77be80b40
commit e286cdcaa8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
111 changed files with 293 additions and 291 deletions

View file

@ -21,8 +21,7 @@ import (
"github.com/xtls/xray-core/testing/servers/udp"
)
type staticHandler struct {
}
type staticHandler struct{}
func (*staticHandler) ServeDNS(w dns.ResponseWriter, r *dns.Msg) {
ans := new(dns.Msg)

View file

@ -54,9 +54,7 @@ func isNewer(baseRec *IPRecord, newRec *IPRecord) bool {
return baseRec.Expire.Before(newRec.Expire)
}
var (
errRecordNotFound = errors.New("record not found")
)
var errRecordNotFound = errors.New("record not found")
type dnsRequest struct {
reqType dnsmessage.Type

View file

@ -50,20 +50,28 @@ func Test_parseResponse(t *testing.T) {
want *IPRecord
wantErr bool
}{
{"empty",
{
"empty",
&IPRecord{0, []net.Address(nil), time.Time{}, dnsmessage.RCodeSuccess},
false,
},
{"error",
{
"error",
nil,
true,
},
{"a record",
&IPRecord{1, []net.Address{net.ParseAddress("8.8.8.8"), net.ParseAddress("8.8.4.4")},
time.Time{}, dnsmessage.RCodeSuccess},
{
"a record",
&IPRecord{
1,
[]net.Address{net.ParseAddress("8.8.8.8"), net.ParseAddress("8.8.4.4")},
time.Time{},
dnsmessage.RCodeSuccess,
},
false,
},
{"aaaa record",
{
"aaaa record",
&IPRecord{2, []net.Address{net.ParseAddress("2001::123:8888"), net.ParseAddress("2001::123:8844")}, time.Time{}, dnsmessage.RCodeSuccess},
false,
},

View file

@ -79,13 +79,13 @@ func (fkdns *Holder) GetFakeIPForDomain(domain string) []net.Address {
if v, ok := fkdns.domainToIP.Get(domain); ok {
return []net.Address{v.(net.Address)}
}
var currentTimeMillis = uint64(time.Now().UnixNano() / 1e6)
currentTimeMillis := uint64(time.Now().UnixNano() / 1e6)
ones, bits := fkdns.ipRange.Mask.Size()
rooms := bits - ones
if rooms < 64 {
currentTimeMillis %= (uint64(1) << rooms)
}
var bigIntIP = big.NewInt(0).SetBytes(fkdns.ipRange.IP)
bigIntIP := big.NewInt(0).SetBytes(fkdns.ipRange.IP)
bigIntIP = bigIntIP.Add(bigIntIP, new(big.Int).SetUint64(currentTimeMillis))
var ip net.Address
for {

View file

@ -11,9 +11,7 @@ import (
"github.com/xtls/xray-core/features/dns"
)
var (
ipPrefix = "198.18."
)
var ipPrefix = "198.18."
func TestNewFakeDnsHolder(_ *testing.T) {
_, err := NewFakeDNSHolder()

View file

@ -2,9 +2,10 @@ package dns
import (
"context"
"github.com/xtls/xray-core/features/dns"
"strings"
"github.com/xtls/xray-core/features/dns"
"github.com/xtls/xray-core/common/net"
"github.com/xtls/xray-core/features/dns/localdns"
)

View file

@ -2,10 +2,11 @@ package dns_test
import (
"context"
"github.com/xtls/xray-core/common/net"
"testing"
"time"
"github.com/xtls/xray-core/common/net"
. "github.com/xtls/xray-core/app/dns"
"github.com/xtls/xray-core/common"
"github.com/xtls/xray-core/features/dns"

View file

@ -2,11 +2,12 @@ package dns_test
import (
"context"
"github.com/xtls/xray-core/features/dns"
"net/url"
"testing"
"time"
"github.com/xtls/xray-core/features/dns"
"github.com/google/go-cmp/cmp"
. "github.com/xtls/xray-core/app/dns"