4
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2025-06-16 10:06:05 +00:00

Fix session bug, fix dummy adapter, fix mobile framework builds

This commit is contained in:
Neil Alexander
2019-04-01 19:59:50 +01:00
parent 047717abf2
commit 58f5cc88d0
5 changed files with 58 additions and 45 deletions

View File

@ -2,6 +2,7 @@ package yggdrasil
import (
"encoding/hex"
"errors"
"io/ioutil"
"net"
"time"
@ -170,13 +171,15 @@ func BuildVersion() string {
// the router. The adapter must implement the standard
// adapter.adapterImplementation interface and should extend the adapter.Adapter
// struct.
func (c *Core) SetRouterAdapter(adapter interface{}) {
func (c *Core) SetRouterAdapter(adapter interface{}) error {
// We do this because adapterImplementation is not a valid type for the
// gomobile bindings so we just ask for a generic interface and try to cast it
// to adapterImplementation instead
if a, ok := adapter.(adapterImplementation); ok {
c.router.adapter = a
return nil
}
return errors.New("unsuitable adapter")
}
// Start starts up Yggdrasil using the provided config.NodeConfig, and outputs

View File

@ -277,7 +277,9 @@ func (ss *sessions) createSession(theirPermKey *crypto.BoxPubKey) *sessionInfo {
sinfo.mySesPriv = *priv
sinfo.myNonce = *crypto.NewBoxNonce()
sinfo.theirMTU = 1280
sinfo.myMTU = uint16(ss.core.router.adapter.MTU())
if ss.core.router.adapter != nil {
sinfo.myMTU = uint16(ss.core.router.adapter.MTU())
}
now := time.Now()
sinfo.time = now
sinfo.mtuTime = now