mirror of
https://github.com/golang/go
synced 2024-11-24 02:10:11 -07:00
net: update docs on network interface API
This change documents that the InterfaceAddrs function is less usable on multi-homed IP nodes because of the lack of network interface identification information. Also updates documentation on exposed network interface API. Fixes #14518. Change-Id: I5e86606f8019ab475eb5d385bd797b052cba395d Reviewed-on: https://go-review.googlesource.com/31371 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
2a85578b0e
commit
79c036238d
@ -69,7 +69,8 @@ func (f Flags) String() string {
|
|||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
// Addrs returns interface addresses for a specific interface.
|
// Addrs returns a list of unicast interface addresses for a specific
|
||||||
|
// interface.
|
||||||
func (ifi *Interface) Addrs() ([]Addr, error) {
|
func (ifi *Interface) Addrs() ([]Addr, error) {
|
||||||
if ifi == nil {
|
if ifi == nil {
|
||||||
return nil, &OpError{Op: "route", Net: "ip+net", Source: nil, Addr: nil, Err: errInvalidInterface}
|
return nil, &OpError{Op: "route", Net: "ip+net", Source: nil, Addr: nil, Err: errInvalidInterface}
|
||||||
@ -81,8 +82,8 @@ func (ifi *Interface) Addrs() ([]Addr, error) {
|
|||||||
return ifat, err
|
return ifat, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// MulticastAddrs returns multicast, joined group addresses for
|
// MulticastAddrs returns a list of multicast, joined group addresses
|
||||||
// a specific interface.
|
// for a specific interface.
|
||||||
func (ifi *Interface) MulticastAddrs() ([]Addr, error) {
|
func (ifi *Interface) MulticastAddrs() ([]Addr, error) {
|
||||||
if ifi == nil {
|
if ifi == nil {
|
||||||
return nil, &OpError{Op: "route", Net: "ip+net", Source: nil, Addr: nil, Err: errInvalidInterface}
|
return nil, &OpError{Op: "route", Net: "ip+net", Source: nil, Addr: nil, Err: errInvalidInterface}
|
||||||
@ -106,8 +107,11 @@ func Interfaces() ([]Interface, error) {
|
|||||||
return ift, nil
|
return ift, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// InterfaceAddrs returns a list of the system's network interface
|
// InterfaceAddrs returns a list of the system's unicast interface
|
||||||
// addresses.
|
// addresses.
|
||||||
|
//
|
||||||
|
// The returned list does not identify the associated interface; use
|
||||||
|
// Interfaces and Interface.Addrs for more detail.
|
||||||
func InterfaceAddrs() ([]Addr, error) {
|
func InterfaceAddrs() ([]Addr, error) {
|
||||||
ifat, err := interfaceAddrTable(nil)
|
ifat, err := interfaceAddrTable(nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user