mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-29 14:45:07 +03:00
Various API changes and simplifications to fix mobile builds
This commit is contained in:
parent
9b99f0b5e4
commit
de1005e4fa
13 changed files with 63 additions and 122 deletions
|
@ -290,18 +290,6 @@ func (c *Core) ListenTCP(uri string) (*TcpListener, error) {
|
|||
return c.link.tcp.listen(uri)
|
||||
}
|
||||
|
||||
// NewEncryptionKeys generates a new encryption keypair. The encryption keys are
|
||||
// used to encrypt traffic and to derive the IPv6 address/subnet of the node.
|
||||
func (c *Core) NewEncryptionKeys() (*crypto.BoxPubKey, *crypto.BoxPrivKey) {
|
||||
return crypto.NewBoxKeys()
|
||||
}
|
||||
|
||||
// NewSigningKeys generates a new signing keypair. The signing keys are used to
|
||||
// derive the structure of the spanning tree.
|
||||
func (c *Core) NewSigningKeys() (*crypto.SigPubKey, *crypto.SigPrivKey) {
|
||||
return crypto.NewSigKeys()
|
||||
}
|
||||
|
||||
// NodeID gets the node ID.
|
||||
func (c *Core) NodeID() *crypto.NodeID {
|
||||
return crypto.GetNodeID(&c.boxPub)
|
||||
|
@ -343,12 +331,6 @@ func (c *Core) Subnet() *net.IPNet {
|
|||
return &net.IPNet{IP: subnet, Mask: net.CIDRMask(64, 128)}
|
||||
}
|
||||
|
||||
// RouterAddresses returns the raw address and subnet types as used by the
|
||||
// router
|
||||
func (c *Core) RouterAddresses() (address.Address, address.Subnet) {
|
||||
return c.router.addr, c.router.subnet
|
||||
}
|
||||
|
||||
// NodeInfo gets the currently configured nodeinfo.
|
||||
func (c *Core) MyNodeInfo() nodeinfoPayload {
|
||||
return c.router.nodeinfo.getNodeInfo()
|
||||
|
@ -473,6 +455,16 @@ func (c *Core) DisconnectPeer(port uint64) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// RouterAddress returns the raw address as used by the router.
|
||||
func (c *Core) RouterAddress() address.Address {
|
||||
return c.router.addr
|
||||
}
|
||||
|
||||
// RouterSubnet returns the raw address as used by the router.
|
||||
func (c *Core) RouterSubnet() address.Subnet {
|
||||
return c.router.subnet
|
||||
}
|
||||
|
||||
// GetAllowedEncryptionPublicKeys returns the public keys permitted for incoming
|
||||
// peer connections.
|
||||
func (c *Core) GetAllowedEncryptionPublicKeys() []string {
|
||||
|
|
|
@ -35,8 +35,17 @@ func (e *ConnError) Temporary() bool {
|
|||
// PacketTooBig returns in response to sending a packet that is too large, and
|
||||
// if so, the maximum supported packet size that should be used for the
|
||||
// connection.
|
||||
func (e *ConnError) PacketTooBig() (bool, int) {
|
||||
return e.maxsize > 0, e.maxsize
|
||||
func (e *ConnError) PacketTooBig() bool {
|
||||
return e.maxsize > 0
|
||||
}
|
||||
|
||||
// PacketMaximumSize returns the maximum supported packet size. This will only
|
||||
// return a non-zero value if ConnError.PacketTooBig() returns true.
|
||||
func (e *ConnError) PacketMaximumSize() int {
|
||||
if !e.PacketTooBig() {
|
||||
return 0
|
||||
}
|
||||
return e.maxsize
|
||||
}
|
||||
|
||||
// Closed returns if the session is already closed and is now unusable.
|
||||
|
|
|
@ -45,7 +45,7 @@ func (c *Core) init() error {
|
|||
c.log = log.New(ioutil.Discard, "", 0)
|
||||
}
|
||||
|
||||
current, _ := c.config.Get()
|
||||
current := c.config.GetCurrent()
|
||||
|
||||
boxPrivHex, err := hex.DecodeString(current.EncryptionPrivateKey)
|
||||
if err != nil {
|
||||
|
@ -94,7 +94,7 @@ func (c *Core) init() error {
|
|||
func (c *Core) addPeerLoop() {
|
||||
for {
|
||||
// the peers from the config - these could change!
|
||||
current, _ := c.config.Get()
|
||||
current := c.config.GetCurrent()
|
||||
|
||||
// Add peers from the Peers section
|
||||
for _, peer := range current.Peers {
|
||||
|
|
|
@ -132,7 +132,7 @@ func (r *router) mainLoop() {
|
|||
case f := <-r.admin:
|
||||
f()
|
||||
case e := <-r.reconfigure:
|
||||
current, _ := r.core.config.Get()
|
||||
current := r.core.config.GetCurrent()
|
||||
e <- r.nodeinfo.setNodeInfo(current.NodeInfo, current.NodeInfoPrivacy)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue