Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Make turncat build on Windows #111

Merged
merged 2 commits into from
Jan 9, 2024
Merged

fix: Make turncat build on Windows #111

merged 2 commits into from
Jan 9, 2024

Conversation

levaitamas
Copy link
Member

As it was mentioned in #81, turncat fails to build on windows.

The build error:

$ CGO_ENABLED=0 go build -ldflags="-s -w" -o turncat cmd/turncat/main.go
# github.com/l7mp/stunner
.\uri.go:172:29: cannot use int(descriptor) (value of type int) as syscall.Handle value in argument to syscall.SetsockoptInt

Proposed fix:
Split system specific code and control build process with //go:build directives.
Build works on linux/windows. Tested on Windows 10 22H2 and go 1.21.5.

Comments and testers are welcome. :)

@levaitamas
Copy link
Member Author

I will rerun tests once github is back online.. (https://www.githubstatus.com/)

@levaitamas
Copy link
Member Author

levaitamas commented Jan 9, 2024

I will rerun tests once github is back online.. (https://www.githubstatus.com/)

done

@levaitamas levaitamas requested a review from rg0now January 9, 2024 14:28

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick question: wouldn't syscall.Handle(descriptor) work on UNIX too? Maybe that's the portable way to use syscalls

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be great. Unfortunately, Handle is defined for windows only.

@levaitamas levaitamas merged commit 0a94ce5 into main Jan 9, 2024
2 of 3 checks passed
@levaitamas levaitamas deleted the turncat-windows branch January 9, 2024 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants