mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-30 07:05:06 +03:00
Create a session on write if one does not exist
This commit is contained in:
parent
aed13e6d50
commit
41ce47d6d7
1 changed files with 3 additions and 0 deletions
|
@ -53,6 +53,9 @@ func (c *PacketConn) WriteTo(b []byte, addr net.Addr) (int, error) {
|
||||||
|
|
||||||
session, ok := c.sessions.getByTheirPerm(boxPubKey)
|
session, ok := c.sessions.getByTheirPerm(boxPubKey)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
session = c.sessions.createSession(boxPubKey)
|
||||||
|
}
|
||||||
|
if session == nil {
|
||||||
return 0, errors.New("expected a session but there was none")
|
return 0, errors.New("expected a session but there was none")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue