Merge pull request #29 from HorayNarea/master
use net.JoinHostPort() instead of string-join directly
This commit is contained in:
commit
7d1f6af220
|
@ -2,6 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
@ -93,9 +94,9 @@ func (r *Resolver) Lookup(net string, req *dns.Msg) (message *dns.Msg, err error
|
||||||
func (r *Resolver) Nameservers() (ns []string) {
|
func (r *Resolver) Nameservers() (ns []string) {
|
||||||
for _, server := range r.config.Servers {
|
for _, server := range r.config.Servers {
|
||||||
if i := strings.IndexByte(server, '#'); i > 0 {
|
if i := strings.IndexByte(server, '#'); i > 0 {
|
||||||
server = server[:i] + ":" + server[i+1:]
|
server = net.JoinHostPort(server[:i], server[i+1:])
|
||||||
} else {
|
} else {
|
||||||
server = server + ":" + r.config.Port
|
server = net.JoinHostPort(server, r.config.Port)
|
||||||
}
|
}
|
||||||
ns = append(ns, server)
|
ns = append(ns, server)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -15,11 +16,10 @@ type Server struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) Addr() string {
|
func (s *Server) Addr() string {
|
||||||
return s.host + ":" + strconv.Itoa(s.port)
|
return net.JoinHostPort(s.host, strconv.Itoa(s.port))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) Run() {
|
func (s *Server) Run() {
|
||||||
|
|
||||||
Handler := NewHandler()
|
Handler := NewHandler()
|
||||||
|
|
||||||
tcpHandler := dns.NewServeMux()
|
tcpHandler := dns.NewServeMux()
|
||||||
|
|
Loading…
Reference in New Issue