mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-29 14:45:07 +03:00
have listener return a net.Conn, adjust yggdrasil.Conn to match this interface
This commit is contained in:
parent
d307ad4c91
commit
cb40874f97
4 changed files with 12 additions and 11 deletions
|
@ -3,6 +3,7 @@ package yggdrasil
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"time"
|
||||
|
||||
"github.com/yggdrasil-network/yggdrasil-go/src/crypto"
|
||||
|
@ -348,14 +349,14 @@ func (c *Conn) Close() (err error) {
|
|||
|
||||
// LocalAddr returns the complete node ID of the local side of the connection.
|
||||
// This is always going to return your own node's node ID.
|
||||
func (c *Conn) LocalAddr() crypto.NodeID {
|
||||
return *crypto.GetNodeID(&c.core.boxPub)
|
||||
func (c *Conn) LocalAddr() net.Addr {
|
||||
return crypto.GetNodeID(&c.core.boxPub)
|
||||
}
|
||||
|
||||
// RemoteAddr returns the complete node ID of the remote side of the connection.
|
||||
func (c *Conn) RemoteAddr() crypto.NodeID {
|
||||
func (c *Conn) RemoteAddr() net.Addr {
|
||||
// RemoteAddr is set during the dial or accept, and isn't changed, so it's safe to access directly
|
||||
return *c.nodeID
|
||||
return c.nodeID
|
||||
}
|
||||
|
||||
// SetDeadline is equivalent to calling both SetReadDeadline and
|
||||
|
|
|
@ -13,7 +13,7 @@ type Listener struct {
|
|||
}
|
||||
|
||||
// Accept blocks until a new incoming session is received
|
||||
func (l *Listener) Accept() (*Conn, error) {
|
||||
func (l *Listener) Accept() (net.Conn, error) {
|
||||
select {
|
||||
case c, ok := <-l.conn:
|
||||
if !ok {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue