mirror of
https://github.com/netbirdio/netbird.git
synced 2024-12-14 02:41:34 +01:00
37 lines
511 B
Go
37 lines
511 B
Go
|
package stdnet
|
||
|
|
||
|
import (
|
||
|
"net"
|
||
|
|
||
|
"github.com/pion/transport/v2"
|
||
|
)
|
||
|
|
||
|
type pionDiscover struct {
|
||
|
}
|
||
|
|
||
|
func (d pionDiscover) iFaces() ([]*transport.Interface, error) {
|
||
|
ifs := []*transport.Interface{}
|
||
|
|
||
|
oifs, err := net.Interfaces()
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
|
||
|
for _, oif := range oifs {
|
||
|
ifc := transport.NewInterface(oif)
|
||
|
|
||
|
addrs, err := oif.Addrs()
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
|
||
|
for _, addr := range addrs {
|
||
|
ifc.AddAddress(addr)
|
||
|
}
|
||
|
|
||
|
ifs = append(ifs, ifc)
|
||
|
}
|
||
|
|
||
|
return ifs, nil
|
||
|
}
|