Merge branch 'chore/code'

This commit is contained in:
wweir
2019-02-19 16:53:21 +08:00
4 changed files with 11 additions and 12 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
package util
package dns
import (
"math/rand"
+1 -1
View File
@@ -1,4 +1,4 @@
package util
package dns
import "testing"
+8 -9
View File
@@ -10,7 +10,6 @@ import (
"github.com/miekg/dns"
mem "github.com/wweir/mem-go"
"github.com/wweir/sower/conf"
"github.com/wweir/sower/util"
)
const colon = byte(':')
@@ -28,7 +27,7 @@ func StartDNS(dnsServer, listenIP string) {
go func() {
for {
<-dhcpCh
host := util.GetDefaultDNSServer()
host := GetDefaultDNSServer()
if host == "" {
continue
}
@@ -108,24 +107,24 @@ func (i *intelliSuggest) GetOne(domain interface{}) (iface interface{}, e error)
}
// give local dial a hand, make it not so easy to be added into suggestions
util.HTTPPing(addr, addr, util.Http, i.timeout/20)
HTTPPing(addr, addr, Http, i.timeout/20)
var (
pings = []struct {
viaAddr string
port util.Port
port Port
}{
{addr, util.Http},
{addr, util.Https},
{i.listenIP, util.Http},
{i.listenIP, util.Https},
{addr, Http},
{addr, Https},
{i.listenIP, Http},
{i.listenIP, Https},
}
half = int32(len(pings) / 2)
score = new(int32)
)
for idx := range pings {
go func(idx int) {
err := util.HTTPPing(pings[idx].viaAddr, addr, pings[idx].port, i.timeout)
err := HTTPPing(pings[idx].viaAddr, addr, pings[idx].port, i.timeout)
if err != nil {
// local ping fail
if pings[idx].viaAddr == addr {
+1 -1
View File
@@ -1,4 +1,4 @@
package util
package dns
import (
"bytes"