Skip to content

Commit

Permalink
fix(turncat): Fix build on Windows (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
levaitamas authored Jan 9, 2024
1 parent d7448e6 commit 0a94ce5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
12 changes: 12 additions & 0 deletions reuseaddr_unix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//go:build unix

package stunner

import "syscall"

func reuseAddr(network, address string, conn syscall.RawConn) error {
return conn.Control(func(descriptor uintptr) {
_ = syscall.SetsockoptInt(int(descriptor), syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1)
// syscall.SetsockoptInt(int(descriptor), syscall.SOL_SOCKET, syscall.SO_REUSEPORT, 1)
})
}
12 changes: 12 additions & 0 deletions reuseaddr_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//go:build windows

package stunner

import "syscall"

func reuseAddr(network, address string, conn syscall.RawConn) error {
return conn.Control(func(descriptor uintptr) {
_ = syscall.SetsockoptInt(syscall.Handle(descriptor), syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1)
// syscall.SetsockoptInt(syscall.Handle(descriptor), syscall.SOL_SOCKET, syscall.SO_REUSEPORT, 1)
})
}
8 changes: 0 additions & 8 deletions uri.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"os"
"strconv"
"strings"
"syscall"

"github.com/l7mp/stunner/internal/util"
stnrv1 "github.com/l7mp/stunner/pkg/apis/v1"
Expand Down Expand Up @@ -166,10 +165,3 @@ func getStunnerProtoForURI(u *url.URL) (string, error) {

return "", fmt.Errorf("Invalid scheme/protocol in URI %q", u.String())
}

func reuseAddr(network, address string, conn syscall.RawConn) error {
return conn.Control(func(descriptor uintptr) {
_ = syscall.SetsockoptInt(int(descriptor), syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1)
// syscall.SetsockoptInt(int(descriptor), syscall.SOL_SOCKET, syscall.SO_REUSEPORT, 1)
})
}

0 comments on commit 0a94ce5

Please sign in to comment.