7 "github.com/iotbzh/xds-server/lib/xsapiv1"
10 // NewBuilderConfig creates a new BuilderConfig instance
11 func NewBuilderConfig(stID string) (xsapiv1.BuilderConfig, error) {
12 // Do we really need it ? may be not accessible from client side
13 ip, err := getLocalIP()
15 return xsapiv1.BuilderConfig{}, err
18 b := xsapiv1.BuilderConfig{
19 IP: ip, // TODO currently not used
20 Port: "", // TODO currently not used
28 func getLocalIP() (string, error) {
29 addrs, err := net.InterfaceAddrs()
33 for _, address := range addrs {
34 // check the address type and if it is not a loopback the display it
35 if ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
36 if ipnet.IP.To4() != nil {
37 return ipnet.IP.String(), nil
41 return "", errors.New("Cannot determined local IP")