mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-29 14:45:07 +03:00
Add AWDL calls to exposed API, handle proto traffic first
This commit is contained in:
parent
3878197a59
commit
5a36b4723a
2 changed files with 32 additions and 0 deletions
|
@ -4,6 +4,7 @@ package yggdrasil
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"log"
|
||||
"os"
|
||||
"regexp"
|
||||
|
@ -100,3 +101,19 @@ func (c *Core) AWDLCreateInterface(boxPubKey []byte, sigPubKey []byte, name stri
|
|||
copy(sig[:crypto.SigPubKeyLen], sigPubKey[:])
|
||||
c.awdl.create(&box, &sig, name)
|
||||
}
|
||||
|
||||
func (c *Core) AWDLRecvPacket(identity string) ([]byte, error) {
|
||||
if intf := c.awdl.getInterface(identity); intf != nil {
|
||||
return <-intf.recv, nil
|
||||
}
|
||||
return nil, errors.New("identity not known: " + identity)
|
||||
}
|
||||
|
||||
func (c *Core) AWDLSendPacket(identity string, buf []byte) error {
|
||||
packet := append(util.GetBytes(), buf[:]...)
|
||||
if intf := c.awdl.getInterface(identity); intf != nil {
|
||||
intf.send <- packet
|
||||
return nil
|
||||
}
|
||||
return errors.New("identity not known: " + identity)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue