multinet/interface.go
Dmitrii Stepanov 5298ec4295 [#4] dialer: Add hostname resolve tests
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
2023-10-26 11:13:42 +03:00

33 lines
609 B
Go

package multinet
import "net"
// Interface provides information about net.Interface.
type Interface interface {
Name() string
Addrs() ([]net.Addr, error)
}
type netInterface struct {
iface net.Interface
}
func (i *netInterface) Name() string {
return i.iface.Name
}
func (i *netInterface) Addrs() ([]net.Addr, error) {
return i.iface.Addrs()
}
func systemInterfaces() ([]Interface, error) {
ifaces, err := net.Interfaces()
if err != nil {
return nil, err
}
var result []Interface
for _, iface := range ifaces {
result = append(result, &netInterface{iface: iface})
}
return result, nil
}