mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-30 01:08:33 +00:00
Style: format code by gofumpt (#761)
This commit is contained in:
parent
d77be80b40
commit
e286cdcaa8
111 changed files with 293 additions and 291 deletions
|
@ -25,9 +25,7 @@ import (
|
|||
"github.com/xtls/xray-core/transport/pipe"
|
||||
)
|
||||
|
||||
var (
|
||||
errSniffingTimeout = newError("timeout on sniffing")
|
||||
)
|
||||
var errSniffingTimeout = newError("timeout on sniffing")
|
||||
|
||||
type cachedReader struct {
|
||||
sync.Mutex
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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"
|
||||
)
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -11,9 +11,7 @@ type HandlerCreatorOptions struct {
|
|||
|
||||
type HandlerCreator func(LogType, HandlerCreatorOptions) (log.Handler, error)
|
||||
|
||||
var (
|
||||
handlerCreatorMap = make(map[LogType]HandlerCreator)
|
||||
)
|
||||
var handlerCreatorMap = make(map[LogType]HandlerCreator)
|
||||
|
||||
func RegisterHandlerCreator(logType LogType, f HandlerCreator) error {
|
||||
if f == nil {
|
||||
|
|
|
@ -482,6 +482,7 @@ func (w *dsWorker) Proxy() proxy.Inbound {
|
|||
func (w *dsWorker) Port() net.Port {
|
||||
return net.Port(0)
|
||||
}
|
||||
|
||||
func (w *dsWorker) Start() error {
|
||||
ctx := context.Background()
|
||||
hub, err := internet.ListenUnix(ctx, w.address, w.stream, func(conn stat.Connection) {
|
||||
|
|
|
@ -9,8 +9,7 @@ type BalancingStrategy interface {
|
|||
PickOutbound([]string) string
|
||||
}
|
||||
|
||||
type RandomStrategy struct {
|
||||
}
|
||||
type RandomStrategy struct{}
|
||||
|
||||
func (s *RandomStrategy) PickOutbound(tags []string) string {
|
||||
n := len(tags)
|
||||
|
|
|
@ -186,6 +186,4 @@ func (c *GeoIPMatcherContainer) Add(geoip *GeoIP) (*GeoIPMatcher, error) {
|
|||
return m, nil
|
||||
}
|
||||
|
||||
var (
|
||||
globalGeoIPContainer GeoIPMatcherContainer
|
||||
)
|
||||
var globalGeoIPContainer GeoIPMatcherContainer
|
||||
|
|
|
@ -89,7 +89,8 @@ func TestGeoIPMatcher(t *testing.T) {
|
|||
{
|
||||
Input: "192.0.1.0",
|
||||
Output: false,
|
||||
}, {
|
||||
},
|
||||
{
|
||||
Input: "0.1.0.0",
|
||||
Output: true,
|
||||
},
|
||||
|
|
|
@ -84,7 +84,6 @@ func (rr *RoutingRule) BuildCondition() (Condition, error) {
|
|||
newError("MphDomainMatcher is enabled for ", len(rr.Domain), " domain rule(s)").AtDebug().WriteToLog()
|
||||
conds.Add(matcher)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if len(rr.UserEmail) > 0 {
|
||||
|
|
|
@ -80,7 +80,6 @@ func (r *Router) PickRoute(ctx routing.Context) (routing.Route, error) {
|
|||
}
|
||||
|
||||
func (r *Router) pickRouteInternal(ctx routing.Context) (*Rule, routing.Context, error) {
|
||||
|
||||
// SkipDNSResolve is set from DNS module.
|
||||
// the DOH remote server maybe a domain name,
|
||||
// this prevents cycle resolving dead loop
|
||||
|
|
|
@ -2,9 +2,10 @@ package router_test
|
|||
|
||||
import (
|
||||
"context"
|
||||
"github.com/xtls/xray-core/features/dns"
|
||||
"testing"
|
||||
|
||||
"github.com/xtls/xray-core/features/dns"
|
||||
|
||||
"github.com/golang/mock/gomock"
|
||||
|
||||
. "github.com/xtls/xray-core/app/router"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue