mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-07 13:03:45 +02:00
Forgot one spot.
This commit is contained in:
parent
60fa07bff2
commit
c0e86de6db
2 changed files with 13 additions and 4 deletions
|
@ -456,11 +456,15 @@ func createAPIServer(basePath string, node *Node) (*http.Server, *http.Server, e
|
||||||
if apiReadObj(out, req, &nw) == nil {
|
if apiReadObj(out, req, &nw) == nil {
|
||||||
n := node.GetNetwork(nw.ID)
|
n := node.GetNetwork(nw.ID)
|
||||||
if n == nil {
|
if n == nil {
|
||||||
n, err := node.Join(nw.ID, nw.Settings, nil)
|
if nw.ControllerFingerprint != nil && nw.ControllerFingerprint.Address != nw.ID.Controller() {
|
||||||
if err != nil {
|
_ = apiSendObj(out, req, http.StatusBadRequest, &APIErr{"fingerprint's address does not match what should be the controller's address"})
|
||||||
_ = apiSendObj(out, req, http.StatusBadRequest, &APIErr{"only individual networks can be added or modified with POST/PUT"})
|
|
||||||
} else {
|
} else {
|
||||||
_ = apiSendObj(out, req, http.StatusOK, apiNetworkFromNetwork(n))
|
n, err := node.Join(nw.ID, nw.ControllerFingerprint, nw.Settings, nil)
|
||||||
|
if err != nil {
|
||||||
|
_ = apiSendObj(out, req, http.StatusBadRequest, &APIErr{"only individual networks can be added or modified with POST/PUT"})
|
||||||
|
} else {
|
||||||
|
_ = apiSendObj(out, req, http.StatusOK, apiNetworkFromNetwork(n))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if nw.Settings != nil {
|
if nw.Settings != nil {
|
||||||
|
|
|
@ -43,6 +43,11 @@ func NewNetworkIDFromBytes(b []byte) (NetworkID, error) {
|
||||||
return NetworkID(binary.BigEndian.Uint64(b)), nil
|
return NetworkID(binary.BigEndian.Uint64(b)), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Controller gets the Address of this network's controller.
|
||||||
|
func (n NetworkID) Controller() Address {
|
||||||
|
return Address(uint64(n) >> 24)
|
||||||
|
}
|
||||||
|
|
||||||
// String returns this network ID's 16-digit hex identifier
|
// String returns this network ID's 16-digit hex identifier
|
||||||
func (n NetworkID) String() string {
|
func (n NetworkID) String() string {
|
||||||
return fmt.Sprintf("%.16x", uint64(n))
|
return fmt.Sprintf("%.16x", uint64(n))
|
||||||
|
|
Loading…
Add table
Reference in a new issue