Files
weave-scope/common/network/interface.go
Tom Wilkie 9885706402 Multi-tenant backends for app.
Add DynamoDB based collector
    - Store compressed reports in dynamodb

    Add SQS based control router.
    - Uses a queue per probe and a queue per UI for control requests & responses.

    Add Consul-based, horizontally-scalable, multi-tenant pipe router.
    - Uses consul to coordinate each end of pipe connections replicas of a pipe service.
2016-03-23 15:41:37 +00:00

30 lines
549 B
Go

package network
import (
"fmt"
"net"
)
// GetFirstAddressOf returns the first address of the supplied interface name.
func GetFirstAddressOf(name string) (string, error) {
inf, err := net.InterfaceByName(name)
if err != nil {
return "", err
}
addrs, err := inf.Addrs()
if err != nil {
return "", err
}
if len(addrs) <= 0 {
return "", fmt.Errorf("No address found for %s", name)
}
switch v := addrs[0].(type) {
case *net.IPNet:
return v.IP.String(), nil
default:
return "", fmt.Errorf("No address found for %s", name)
}
}