Root admin stuff
This commit is contained in:
parent
4303c43db7
commit
b0d222768a
16 changed files with 217 additions and 46 deletions
|
@ -558,7 +558,7 @@ func (n *Node) Roots() []*Root {
|
|||
}
|
||||
}
|
||||
roots = append(roots, &Root{
|
||||
DNSName: C.GoString(root.dnsName),
|
||||
Name: C.GoString(root.dnsName),
|
||||
Identity: id,
|
||||
Addresses: addrs,
|
||||
Preferred: (root.preferred != 0),
|
||||
|
@ -571,6 +571,42 @@ func (n *Node) Roots() []*Root {
|
|||
return roots
|
||||
}
|
||||
|
||||
// SetRoot sets or updates a root.
|
||||
// Name can be a DNS name (preferably secure) for DNS fetched locators or can be
|
||||
// the empty string for static roots. If the name is empty then the locator must
|
||||
// be non-nil.
|
||||
func (n *Node) SetRoot(name string, locator *Locator) error {
|
||||
if len(name) == 0 {
|
||||
if locator == nil {
|
||||
return ErrInvalidParameter
|
||||
}
|
||||
name = locator.Identity.address.String()
|
||||
}
|
||||
var lb []byte
|
||||
if locator != nil {
|
||||
lb = locator.Bytes()
|
||||
}
|
||||
var lbp unsafe.Pointer
|
||||
if len(lb) > 0 {
|
||||
lbp = unsafe.Pointer(&lb[0])
|
||||
}
|
||||
cn := C.CString(name)
|
||||
defer C.free(unsafe.Pointer(cn))
|
||||
if C.ZT_Node_setRoot(n.zn, cn, lbp, C.uint(len(lb))) != 0 {
|
||||
return ErrInternal
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// RemoveRoot removes a root.
|
||||
// For static roots the name should be the ZeroTier address.
|
||||
func (n *Node) RemoveRoot(name string) {
|
||||
cn := C.CString(name)
|
||||
defer C.free(unsafe.Pointer(cn))
|
||||
C.ZT_Node_removeRoot(n.zn, cn)
|
||||
return
|
||||
}
|
||||
|
||||
// Peers retrieves a list of current peers
|
||||
func (n *Node) Peers() []*Peer {
|
||||
var peers []*Peer
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue