2023-04-13 17:00:01 +02:00
|
|
|
package stdnet
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net"
|
|
|
|
|
2023-12-20 23:02:42 +01:00
|
|
|
"github.com/pion/transport/v3"
|
2023-04-13 17:00:01 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|