mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-10 08:40:28 +00:00
Fight me Swift and your hexadecimal strings
This commit is contained in:
parent
5a36b4723a
commit
00bf71a09a
@ -3,6 +3,7 @@
|
|||||||
package yggdrasil
|
package yggdrasil
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"log"
|
"log"
|
||||||
@ -94,12 +95,24 @@ func (c *Core) RouterSendPacket(buf []byte) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Core) AWDLCreateInterface(boxPubKey []byte, sigPubKey []byte, name string) {
|
func (c *Core) AWDLCreateInterface(boxPubKey string, sigPubKey string, name string) error {
|
||||||
var box crypto.BoxPubKey
|
var boxPub crypto.BoxPubKey
|
||||||
var sig crypto.SigPubKey
|
var sigPub crypto.SigPubKey
|
||||||
copy(box[:crypto.BoxPubKeyLen], boxPubKey[:])
|
boxPubHex, err := hex.DecodeString(boxPubKey)
|
||||||
copy(sig[:crypto.SigPubKeyLen], sigPubKey[:])
|
if err != nil {
|
||||||
c.awdl.create(&box, &sig, name)
|
return err
|
||||||
|
}
|
||||||
|
sigPubHex, err := hex.DecodeString(sigPubKey)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
copy(boxPub[:], boxPubHex)
|
||||||
|
copy(sigPub[:], sigPubHex)
|
||||||
|
if intf := c.awdl.create(&boxPub, &sigPub, name); intf != nil {
|
||||||
|
return nil
|
||||||
|
} else {
|
||||||
|
return errors.New("No interface was created")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Core) AWDLRecvPacket(identity string) ([]byte, error) {
|
func (c *Core) AWDLRecvPacket(identity string) ([]byte, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user