mirror of
https://github.com/yggdrasil-network/yggdrasil-go
synced 2024-11-10 15:30:34 +03:00
Add AWDL calls to exposed API, handle proto traffic first
This commit is contained in:
parent
3878197a59
commit
5a36b4723a
@ -74,9 +74,24 @@ func (l *awdl) shutdown(identity string) {
|
|||||||
|
|
||||||
func (ai *awdlInterface) handler() {
|
func (ai *awdlInterface) handler() {
|
||||||
for {
|
for {
|
||||||
|
/*timerInterval := tcp_ping_interval
|
||||||
|
timer := time.NewTimer(timerInterval)
|
||||||
|
defer timer.Stop()*/
|
||||||
select {
|
select {
|
||||||
case p := <-ai.peer.linkOut:
|
case p := <-ai.peer.linkOut:
|
||||||
ai.send <- p
|
ai.send <- p
|
||||||
|
continue
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
/*timer.Stop()
|
||||||
|
select {
|
||||||
|
case <-timer.C:
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
timer.Reset(timerInterval)*/
|
||||||
|
select {
|
||||||
|
//case _ = <-timer.C:
|
||||||
|
// ai.send <- nil
|
||||||
case r := <-ai.recv: // traffic received from AWDL
|
case r := <-ai.recv: // traffic received from AWDL
|
||||||
ai.peer.handlePacket(r)
|
ai.peer.handlePacket(r)
|
||||||
case <-ai.shutdown:
|
case <-ai.shutdown:
|
||||||
|
@ -4,6 +4,7 @@ package yggdrasil
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
@ -100,3 +101,19 @@ func (c *Core) AWDLCreateInterface(boxPubKey []byte, sigPubKey []byte, name stri
|
|||||||
copy(sig[:crypto.SigPubKeyLen], sigPubKey[:])
|
copy(sig[:crypto.SigPubKeyLen], sigPubKey[:])
|
||||||
c.awdl.create(&box, &sig, name)
|
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…
Reference in New Issue
Block a user