Nits
This commit is contained in:
parent
a384011e71
commit
d700ab6085
|
@ -13,10 +13,7 @@ import (
|
|||
|
||||
type CaptivePortalEntryips []net.IP
|
||||
|
||||
type CaptivePortalEntry struct {
|
||||
name string
|
||||
ips CaptivePortalEntryips
|
||||
}
|
||||
type CaptivePortalMap map[string]CaptivePortalEntryips
|
||||
|
||||
type CaptivePortalHandler struct {
|
||||
cancelChannels []chan struct{}
|
||||
|
@ -25,11 +22,11 @@ type CaptivePortalHandler struct {
|
|||
func (captivePortalHandler *CaptivePortalHandler) Stop() {
|
||||
for _, cancelChannel := range captivePortalHandler.cancelChannels {
|
||||
cancelChannel <- struct{}{}
|
||||
_ = <-cancelChannel
|
||||
<-cancelChannel
|
||||
}
|
||||
}
|
||||
|
||||
func handleColdStartClient(clientPc *net.UDPConn, cancelChannel chan struct{}, ipsMap *map[string]CaptivePortalEntryips) bool {
|
||||
func handleColdStartClient(clientPc *net.UDPConn, cancelChannel chan struct{}, ipsMap *CaptivePortalMap) bool {
|
||||
buffer := make([]byte, MaxDNSPacketSize-1)
|
||||
clientPc.SetDeadline(time.Now().Add(time.Duration(1) * time.Second))
|
||||
length, clientAddr, err := clientPc.ReadFrom(buffer)
|
||||
|
@ -105,7 +102,7 @@ func handleColdStartClient(clientPc *net.UDPConn, cancelChannel chan struct{}, i
|
|||
return false
|
||||
}
|
||||
|
||||
func addColdStartListener(proxy *Proxy, ipsMap *map[string]CaptivePortalEntryips, listenAddrStr string, cancelChannel chan struct{}) error {
|
||||
func addColdStartListener(proxy *Proxy, ipsMap *CaptivePortalMap, listenAddrStr string, cancelChannel chan struct{}) error {
|
||||
listenUDPAddr, err := net.ResolveUDPAddr("udp", listenAddrStr)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -132,7 +129,7 @@ func ColdStart(proxy *Proxy) (*CaptivePortalHandler, error) {
|
|||
dlog.Warn(err)
|
||||
return nil, err
|
||||
}
|
||||
ipsMap := make(map[string]CaptivePortalEntryips)
|
||||
ipsMap := make(CaptivePortalMap)
|
||||
for lineNo, line := range strings.Split(string(bin), "\n") {
|
||||
line = TrimAndStripInlineComments(line)
|
||||
if len(line) == 0 {
|
||||
|
|
|
@ -16,7 +16,6 @@ import (
|
|||
|
||||
"github.com/VividCortex/ewma"
|
||||
"github.com/jedisct1/dlog"
|
||||
"github.com/jedisct1/go-dnsstamps"
|
||||
stamps "github.com/jedisct1/go-dnsstamps"
|
||||
"github.com/miekg/dns"
|
||||
"golang.org/x/crypto/ed25519"
|
||||
|
@ -59,7 +58,7 @@ type ServerInfo struct {
|
|||
SharedKey [32]byte
|
||||
MagicQuery [8]byte
|
||||
knownBugs ServerBugs
|
||||
Proto dnsstamps.StampProtoType
|
||||
Proto stamps.StampProtoType
|
||||
useGet bool
|
||||
}
|
||||
|
||||
|
@ -99,8 +98,6 @@ func (LBStrategyRandom) getCandidate(serversCount int) int {
|
|||
|
||||
var DefaultLBStrategy = LBStrategyP2{}
|
||||
|
||||
type ODoHRelay struct{}
|
||||
|
||||
type DNSCryptRelay struct {
|
||||
RelayUDPAddr *net.UDPAddr
|
||||
RelayTCPAddr *net.TCPAddr
|
||||
|
@ -260,7 +257,7 @@ func fetchServerInfo(proxy *Proxy, name string, stamp stamps.ServerStamp, isNew
|
|||
} else if stamp.Proto == stamps.StampProtoTypeDoH {
|
||||
return fetchDoHServerInfo(proxy, name, stamp, isNew)
|
||||
}
|
||||
return ServerInfo{}, errors.New(fmt.Sprintf("Unsupported protocol for [%s]: [%s]", name, stamp.Proto.String()))
|
||||
return ServerInfo{}, fmt.Errorf("Unsupported protocol for [%s]: [%s]", name, stamp.Proto.String())
|
||||
}
|
||||
|
||||
func route(proxy *Proxy, name string) (*Relay, error) {
|
||||
|
|
Loading…
Reference in New Issue