8 // BuilderConfig represents the builder container configuration
9 type BuilderConfig struct {
11 Port string `json:"port"`
12 SyncThingID string `json:"syncThingID"`
15 // NewBuilderConfig creates a new BuilderConfig instance
16 func NewBuilderConfig(stID string) (BuilderConfig, error) {
17 // Do we really need it ? may be not accessible from client side
18 ip, err := getLocalIP()
20 return BuilderConfig{}, err
24 IP: ip, // TODO currently not used
25 Port: "", // TODO currently not used
31 // Copy makes a real copy of BuilderConfig
32 func (c *BuilderConfig) Copy(n BuilderConfig) {
36 func getLocalIP() (string, error) {
37 addrs, err := net.InterfaceAddrs()
41 for _, address := range addrs {
42 // check the address type and if it is not a loopback the display it
43 if ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
44 if ipnet.IP.To4() != nil {
45 return ipnet.IP.String(), nil
49 return "", errors.New("Cannot determined local IP")