Browse Source

apply coding style

Shelikhoo 4 years ago
parent
commit
9a03b425c9
4 changed files with 4 additions and 6 deletions
  1. 1 3
      app/dns/dns.go
  2. 1 1
      app/reverse/portal.go
  3. 1 1
      features/routing/dns/context.go
  4. 1 1
      proxy/freedom/freedom.go

+ 1 - 3
app/dns/dns.go

@@ -200,9 +200,7 @@ func (s *DNS) lookupIPInternal(domain string, option dns.IPOption) ([]net.IP, er
 	}
 
 	// Normalize the FQDN form query
-	if strings.HasSuffix(domain, ".") {
-		domain = domain[:len(domain)-1]
-	}
+	domain = strings.TrimSuffix(domain, ".")
 
 	// Static host lookup
 	switch addrs := s.hosts.Lookup(domain, option); {

+ 1 - 1
app/reverse/portal.go

@@ -154,7 +154,7 @@ func (p *StaticMuxPicker) PickAvailable() (*mux.ClientWorker, error) {
 		return nil, newError("empty worker list")
 	}
 
-	var minIdx int = -1
+	var minIdx = -1
 	var minConn uint32 = 9999
 	for i, w := range p.workers {
 		if w.draining {

+ 1 - 1
features/routing/dns/context.go

@@ -26,7 +26,7 @@ func (ctx *ResolvableContext) GetTargetIPs() []net.IP {
 	}
 
 	if domain := ctx.GetTargetDomain(); len(domain) != 0 {
-		var lookupFunc func(string) ([]net.IP, error) = ctx.dnsClient.LookupIP
+		var lookupFunc = ctx.dnsClient.LookupIP
 		ipOption := &dns.IPOption{
 			IPv4Enable: true,
 			IPv6Enable: true,

+ 1 - 1
proxy/freedom/freedom.go

@@ -66,7 +66,7 @@ func (h *Handler) resolveIP(ctx context.Context, domain string, localAddr net.Ad
 		newError("DNS client doesn't implement ClientWithIPOption")
 	}
 
-	var lookupFunc func(string) ([]net.IP, error) = h.dns.LookupIP
+	var lookupFunc = h.dns.LookupIP
 	if h.config.DomainStrategy == Config_USE_IP4 || (localAddr != nil && localAddr.Family().IsIPv4()) {
 		if lookupIPv4, ok := h.dns.(dns.IPv4Lookup); ok {
 			lookupFunc = lookupIPv4.LookupIPv4