Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
yinqiwen committed Oct 12, 2017
1 parent 025d6f0 commit 498f306
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions common/helper/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ func Socks5ProxyDial(proxyURL string, addr string, timeout time.Duration) (net.C
return c, nil
}

var localIPSet = make(map[string]bool)
var localIPv4 []string

func GetLocalIPv4() []string {
Expand All @@ -476,6 +477,22 @@ func GetLocalIPv4() []string {
}
return localIPv4
}
func GetLocalIPSet() map[string]bool {
if len(localIPSet) > 0 {
return localIPSet
}
addrs, err := net.InterfaceAddrs()
if err != nil {
logger.Error("[ERROR]Failed to get local ip:%v", err)
return localIPSet
}
for _, a := range addrs {
if ipnet, ok := a.(*net.IPNet); ok {
localIPSet[ipnet.IP.String()] = true
}
}
return localIPSet
}

// Setup a bare-bones TLS config for the server
func GenerateTLSConfig() *tls.Config {
Expand Down

0 comments on commit 498f306

Please sign in to comment.