Create a session on write if one does not exist

This commit is contained in:
Neil Alexander 2020-07-01 19:41:01 +01:00
parent aed13e6d50
commit 41ce47d6d7
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944

View file

@ -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")
} }