aboutsummaryrefslogtreecommitdiffstats
path: root/src/conn_default.go
diff options
context:
space:
mode:
authorMathias Hall-Andersen <mathias@hall-andersen.dk>2017-11-17 17:25:45 +0100
committerMathias Hall-Andersen <mathias@hall-andersen.dk>2017-11-17 17:25:58 +0100
commitfa399a91d5da9874cbf248e00db8dbd87b587e91 (patch)
tree8aaca42f4a3cc11666c12d5077e8ed5ac35200a8 /src/conn_default.go
parentAllows passing UAPI fd to service (diff)
downloadwireguard-go-fa399a91d5da9874cbf248e00db8dbd87b587e91.tar.xz
wireguard-go-fa399a91d5da9874cbf248e00db8dbd87b587e91.zip
Ported remaining netns.sh
- Ported remaining netns.sh tests - Begin work on generic implementation of bind interface
Diffstat (limited to '')
-rw-r--r--src/conn_default.go35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/conn_default.go b/src/conn_default.go
index 279643e..31cab5c 100644
--- a/src/conn_default.go
+++ b/src/conn_default.go
@@ -6,6 +6,41 @@ import (
"net"
)
+/* This code is meant to be a temporary solution
+ * on platforms for which the sticky socket / source caching behavior
+ * has not yet been implemented.
+ *
+ * See conn_linux.go for an implementation on the linux platform.
+ */
+
+type Endpoint *net.UDPAddr
+
+type NativeBind *net.UDPConn
+
+func CreateUDPBind(port uint16) (UDPBind, uint16, error) {
+
+ // listen
+
+ addr := UDPAddr{
+ Port: int(port),
+ }
+ conn, err := net.ListenUDP("udp", &addr)
+ if err != nil {
+ return nil, 0, err
+ }
+
+ // retrieve port
+
+ laddr := conn.LocalAddr()
+ uaddr, _ = net.ResolveUDPAddr(
+ laddr.Network(),
+ laddr.String(),
+ )
+ return uaddr.Port
+}
+
+func (_ Endpoint) ClearSrc() {}
+
func SetMark(conn *net.UDPConn, value uint32) error {
return nil
}