mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-17 02:25:14 +00:00
This commit is contained in:
parent
8facaf5a6a
commit
7cb8af9029
@ -11,10 +11,21 @@ import (
|
||||
)
|
||||
|
||||
func GetLans() ([]*net.IPNet, error) {
|
||||
addrs, err := net.InterfaceAddrs()
|
||||
ifs, err := net.Interfaces()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
addrs := []net.Addr{}
|
||||
for _, currentIf := range ifs {
|
||||
if currentIf.Flags&net.FlagUp != net.FlagUp {
|
||||
continue
|
||||
}
|
||||
currentAddrs, err := currentIf.Addrs()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
addrs = append(addrs, currentAddrs...)
|
||||
}
|
||||
|
||||
nets := make([]*net.IPNet, 0, len(addrs))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user