mirror of
https://github.com/wweir/sower.git
synced 2024-04-21 12:42:15 +00:00
Merge branch 'chore/code'
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
package util
|
||||
package dns
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
@@ -1,4 +1,4 @@
|
||||
package util
|
||||
package dns
|
||||
|
||||
import "testing"
|
||||
|
||||
+8
-9
@@ -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,4 +1,4 @@
|
||||
package util
|
||||
package dns
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
Reference in New Issue
Block a user