aboutsummaryrefslogtreecommitdiffstats
path: root/src/uapi_windows.go
diff options
context:
space:
mode:
authorMathias Hall-Andersen <mathias@hall-andersen.dk>2017-08-27 15:41:00 +0200
committerMathias Hall-Andersen <mathias@hall-andersen.dk>2017-08-27 15:41:00 +0200
commit6f5ef153c3b578da99501cfcbe4f2e4a84d44708 (patch)
tree5fcdda37f8cde8be8b2f2afb3ebd6b337b0652ed /src/uapi_windows.go
parentAdded fwmark code (diff)
downloadwireguard-go-6f5ef153c3b578da99501cfcbe4f2e4a84d44708.tar.xz
wireguard-go-6f5ef153c3b578da99501cfcbe4f2e4a84d44708.zip
Added code from windows branch
Diffstat (limited to '')
-rw-r--r--src/uapi_windows.go44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/uapi_windows.go b/src/uapi_windows.go
new file mode 100644
index 0000000..d56e965
--- /dev/null
+++ b/src/uapi_windows.go
@@ -0,0 +1,44 @@
+package main
+
+/* UAPI on windows uses a bidirectional named pipe
+ */
+
+import (
+ "fmt"
+ "github.com/Microsoft/go-winio"
+ "golang.org/x/sys/windows"
+ "net"
+)
+
+const (
+ ipcErrorIO = -int64(windows.ERROR_BROKEN_PIPE)
+ ipcErrorNotDefined = -int64(windows.ERROR_SERVICE_SPECIFIC_ERROR)
+ ipcErrorProtocol = -int64(windows.ERROR_SERVICE_SPECIFIC_ERROR)
+ ipcErrorInvalid = -int64(windows.ERROR_SERVICE_SPECIFIC_ERROR)
+)
+
+const PipeNameFmt = "\\\\.\\pipe\\wireguard-ipc-%s"
+
+type UAPIListener struct {
+ listener net.Listener
+}
+
+func (uapi *UAPIListener) Accept() (net.Conn, error) {
+ return nil, nil
+}
+
+func (uapi *UAPIListener) Close() error {
+ return uapi.listener.Close()
+}
+
+func (uapi *UAPIListener) Addr() net.Addr {
+ return nil
+}
+
+func NewUAPIListener(name string) (net.Listener, error) {
+ path := fmt.Sprintf(PipeNameFmt, name)
+ return winio.ListenPipe(path, &winio.PipeConfig{
+ InputBufferSize: 2048,
+ OutputBufferSize: 2048,
+ })
+}