mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-29 14:45:07 +03:00
Merge branch 'develop' of https://github.com/yggdrasil-network/yggdrasil-go into yggdrasil-v0.4.6.1-develop
This commit is contained in:
commit
69d59458d8
6 changed files with 30 additions and 11 deletions
|
@ -87,7 +87,7 @@ func (m *Mesh) StartJSON(configjson []byte) error {
|
|||
Beacon: intf.Beacon,
|
||||
Listen: intf.Listen,
|
||||
Port: intf.Port,
|
||||
Priority: intf.Priority,
|
||||
Priority: uint8(intf.Priority),
|
||||
})
|
||||
}
|
||||
m.multicast, err = multicast.New(m.core, logger, options...)
|
||||
|
@ -115,7 +115,19 @@ func (m *Mesh) Send(p []byte) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Recv waits for and reads a packet coming from Mesh. It
|
||||
// Send sends a packet from given buffer to Yggdrasil. From first byte up to length.
|
||||
func (m *Mesh) SendBuffer(p []byte, length int) error {
|
||||
if m.iprwc == nil {
|
||||
return nil
|
||||
}
|
||||
if len(p) < length {
|
||||
return nil
|
||||
}
|
||||
_, _ = m.iprwc.Write(p[:length])
|
||||
return nil
|
||||
}
|
||||
|
||||
// Recv waits for and reads a packet coming from Yggdrasil. It
|
||||
// will be a fully formed IPv6 packet
|
||||
func (m *Mesh) Recv() ([]byte, error) {
|
||||
if m.iprwc == nil {
|
||||
|
@ -126,6 +138,15 @@ func (m *Mesh) Recv() ([]byte, error) {
|
|||
return buf[:n], nil
|
||||
}
|
||||
|
||||
// Recv waits for and reads a packet coming from Yggdrasil to given buffer, returning size of packet
|
||||
func (m *Yggdrasil) RecvBuffer(buf []byte) (int, error) {
|
||||
if m.iprwc == nil {
|
||||
return 0, nil
|
||||
}
|
||||
n, _ := m.iprwc.Read(buf)
|
||||
return n, nil
|
||||
}
|
||||
|
||||
// Stop the mobile Mesh instance
|
||||
func (m *Mesh) Stop() error {
|
||||
logger := log.New(m.log, "", 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue