Skip to content

Commit

Permalink
fix: Make turncat build on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
levaitamas committed Jan 9, 2024
1 parent c40128c commit 4564009
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
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)
})
}
12 changes: 12 additions & 0 deletions uri_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 uri_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)
})
}

0 comments on commit 4564009

Please sign in to comment.