summaryrefslogtreecommitdiffhomepage
path: root/src/conn.go
diff options
context:
space:
mode:
authorMathias Hall-Andersen <mathias@hall-andersen.dk>2017-11-18 23:34:02 +0100
committerMathias Hall-Andersen <mathias@hall-andersen.dk>2017-11-18 23:34:02 +0100
commitd10126f883ad39567248540347b5469956ab8b2e (patch)
treea83329093198bd5dd2c7770835a3851e6d23d880 /src/conn.go
parentfa399a91d5da9874cbf248e00db8dbd87b587e91 (diff)
Moved endpoint into interface and simplified peer
Diffstat (limited to 'src/conn.go')
-rw-r--r--src/conn.go20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/conn.go b/src/conn.go
index 3cf00ab..74bb075 100644
--- a/src/conn.go
+++ b/src/conn.go
@@ -7,26 +7,28 @@ import (
"net"
)
-type UDPBind interface {
+/* A Bind handles listening on a port for both IPv6 and IPv4 UDP traffic
+ */
+type Bind interface {
SetMark(value uint32) error
- ReceiveIPv6(buff []byte, end *Endpoint) (int, error)
- ReceiveIPv4(buff []byte, end *Endpoint) (int, error)
- Send(buff []byte, end *Endpoint) error
+ ReceiveIPv6(buff []byte) (int, Endpoint, error)
+ ReceiveIPv4(buff []byte) (int, Endpoint, error)
+ Send(buff []byte, end Endpoint) error
Close() error
}
/* An Endpoint maintains the source/destination caching for a peer
*
- * dst : the remote address of a peer
+ * dst : the remote address of a peer ("endpoint" in uapi terminology)
* src : the local address from which datagrams originate going to the peer
- *
*/
-type UDPEndpoint interface {
+type Endpoint interface {
ClearSrc() // clears the source address
ClearDst() // clears the destination address
SrcToString() string // returns the local source address (ip:port)
DstToString() string // returns the destination address (ip:port)
DstToBytes() []byte // used for mac2 cookie calculations
+ SetDst(string) error // used for manually setting the endpoint (uapi)
DstIP() net.IP
SrcIP() net.IP
}
@@ -107,7 +109,9 @@ func UpdateUDPListener(device *Device) error {
for _, peer := range device.peers {
peer.mutex.Lock()
- peer.endpoint.value.ClearSrc()
+ if peer.endpoint != nil {
+ peer.endpoint.ClearSrc()
+ }
peer.mutex.Unlock()
}