/install/get_default_addresses -- now it gives out list of interfaces
This commit is contained in:
parent
924afea22b
commit
34e14930de
23
control.go
23
control.go
|
@ -700,10 +700,11 @@ type ipport struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type firstRunData struct {
|
type firstRunData struct {
|
||||||
Web ipport `json:"web"`
|
Web ipport `json:"web"`
|
||||||
DNS ipport `json:"dns"`
|
DNS ipport `json:"dns"`
|
||||||
Username string `json:"username,omitempty"`
|
Username string `json:"username,omitempty"`
|
||||||
Password string `json:"password,omitempty"`
|
Password string `json:"password,omitempty"`
|
||||||
|
Interfaces map[string]interface{} `json:"interfaces"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleGetDefaultAddresses(w http.ResponseWriter, r *http.Request) {
|
func handleGetDefaultAddresses(w http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -718,16 +719,13 @@ func handleGetDefaultAddresses(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// find an interface with an ipv4 address
|
// fill out the fields
|
||||||
addr := findIPv4IfaceAddr(ifaces)
|
|
||||||
if len(addr) == 0 {
|
|
||||||
httpError(w, http.StatusServiceUnavailable, "Couldn't find any interface with IPv4, plase try again later")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
data.Web.IP = addr
|
|
||||||
data.DNS.IP = addr
|
|
||||||
data.Web.Port = 3000 // TODO: find out if port 80 is available -- if not, fall back to 3000
|
data.Web.Port = 3000 // TODO: find out if port 80 is available -- if not, fall back to 3000
|
||||||
data.DNS.Port = 53 // TODO: find out if port 53 is available -- if not, show a big warning
|
data.DNS.Port = 53 // TODO: find out if port 53 is available -- if not, show a big warning
|
||||||
|
data.Interfaces = make(map[string]interface{})
|
||||||
|
for _, iface := range ifaces {
|
||||||
|
data.Interfaces[iface.Name] = iface
|
||||||
|
}
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
err = json.NewEncoder(w).Encode(data)
|
err = json.NewEncoder(w).Encode(data)
|
||||||
|
@ -746,6 +744,7 @@ func handleSetAllSettings(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
spew.Dump(newSettings)
|
spew.Dump(newSettings)
|
||||||
|
// TODO: validate that hosts and ports are bindable
|
||||||
config.firstRun = false
|
config.firstRun = false
|
||||||
config.BindHost = newSettings.Web.IP
|
config.BindHost = newSettings.Web.IP
|
||||||
config.BindPort = newSettings.Web.Port
|
config.BindPort = newSettings.Web.Port
|
||||||
|
|
Loading…
Reference in New Issue