Skip to content

Commit

Permalink
Merge pull request awgh#4 from awgh/vyrus
Browse files Browse the repository at this point in the history
fixes to importer and admin
  • Loading branch information
awgh authored Sep 2, 2018
2 parents 1130dc3 + e3b8638 commit 2a00829
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
11 changes: 9 additions & 2 deletions nodes/ram/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"time"

"github.com/awgh/bencrypt/bc"
"github.com/awgh/bencrypt/ecc"
"github.com/awgh/ratnet/api"
)

Expand Down Expand Up @@ -284,8 +285,14 @@ func (node *Node) Start() error {
}

// init crypto keys
node.contentKey.GenerateKey()
node.routingKey.GenerateKey()
if node.contentKey == nil {
node.contentKey = new(ecc.KeyPair)
node.contentKey.GenerateKey()
}
if node.routingKey == nil {
node.routingKey = new(ecc.KeyPair)
node.routingKey.GenerateKey()
}

// start the signal monitor
node.signalMonitor()
Expand Down
26 changes: 14 additions & 12 deletions nodes/ram/importer.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,22 @@ func (node *Node) Import(jsonConfig []byte) error {
return err
}
// setup content and routing keys
v, ok := bencrypt.KeypairTypes[nj.ContentType]
if !ok {
return errors.New("Unknown Content Keypair Type in Import")
}
node.contentKey = v()
v, ok = bencrypt.KeypairTypes[nj.RoutingType]
if !ok {
return errors.New("Unknown Routing Keypair Type in Import")
}
node.routingKey = v()

if len(nj.ContentKey) > 0 {
v, ok := bencrypt.KeypairTypes[nj.ContentType]
if !ok {
return errors.New("Unknown Content Keypair Type in Import")
}
node.contentKey = v()
if err := node.contentKey.FromB64(nj.ContentKey); err != nil {
return err
}
}
if len(nj.RoutingKey) > 0 {
v, ok := bencrypt.KeypairTypes[nj.RoutingType]
if !ok {
return errors.New("Unknown Routing Keypair Type in Import")
}
node.routingKey = v()
if err := node.routingKey.FromB64(nj.RoutingKey); err != nil {
return err
}
Expand Down Expand Up @@ -112,7 +111,10 @@ func (node *Node) Import(jsonConfig []byte) error {
node.profiles[cp.Name] = cp
}

node.SetRouter(ratnet.NewRouterFromMap(nj.Router))
if len(nj.Router) < 0 {
node.SetRouter(ratnet.NewRouterFromMap(nj.Router))
}

for _, p := range nj.Policies {
// extract the inner Transport first
t := p["Transport"].(map[string]interface{})
Expand Down

0 comments on commit 2a00829

Please sign in to comment.