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

chore(pkg/wireguard): replace bash script with native code #161

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

uhthomas
Copy link
Collaborator

@uhthomas uhthomas commented May 9, 2024

There is no reason to use bash, or even to call out to the shell for most of what was happening. Replacing it allows for better error handling, clarity and reliability.

Fixes: #79

@uhthomas uhthomas force-pushed the 79-pkg-wireguard branch 2 times, most recently from bc379e4 to 7946165 Compare May 9, 2024 09:05
go.mod Outdated
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

whew - I ran go mod tidy because of the new golang.org/x/sys dependency 😅

return nil

if _, err := os.Stat("/dev/net/tun"); os.IsNotExist(err) {
if err := unix.Mknod("/dev/net/tun", unix.S_IFIFO|0o600, int(unix.Mkdev(10, 100))); err != nil {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Owner

Choose a reason for hiding this comment

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

LGTM; It would be useful to try it out. We have basic integration-tests that runs on each PR but it only tests creating the resources. It doesn't really test connecting to the VPN and making sure connectivity works as expected :( https://github.com/jodevsa/wireguard-operator/blob/main/internal/it/it_test.go#L39

Copy link
Owner

Choose a reason for hiding this comment

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

Also, the default behaviour is to use kernal implementation of WG. I guess the environment where the IT runs supports the kernal implementation of WG. we can use https://github.com/jodevsa/wireguard-operator/blob/main/cmd/agent/main.go#L26
--wg-use-userspace-implementation to test this feature manually or write an IT for it. What are your thoughts on this?

Copy link
Owner

Choose a reason for hiding this comment

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

btw, you can easily manually test your changes by building a release from your branch. You can access the following workflow which would do all the building for you :). You only need to run this workflow https://github.com/jodevsa/wireguard-operator/actions/workflows/manual-dev-release-workflow.yaml

Copy link
Owner

Choose a reason for hiding this comment

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

Screenshot 2024-05-09 at 13 01 49

here is an example :)

Copy link
Owner

Choose a reason for hiding this comment

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

after the workflow completes you can access the release.yaml file that you can apply to a your kubernetes cluster

Screenshot 2024-05-09 at 13 06 58

Copy link
Owner

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks - I think that seems reasonable. Will try and test something this evening maybe.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@jodevsa I tested this and it seems to work the same as the kernel version, such I can successfully connect to my router (192.168.1.1) from 5G through a wireguard tunnel.

Copy link
Owner

@jodevsa jodevsa May 11, 2024

Choose a reason for hiding this comment

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

thanks a lot!

@uhthomas uhthomas force-pushed the 79-pkg-wireguard branch 2 times, most recently from 7396427 to 5e18011 Compare May 9, 2024 09:12
@uhthomas uhthomas changed the title chore(pkg/wireguard): replace createLinkUsingUserspaceImpl bash scrip… chore(pkg/wireguard): replace bash script with native code May 9, 2024
There is no reason to use bash, or even to call out to the shell for
most of what was happening. Replacing it allows for better error
handling, clarity and reliability.

Fixes: jodevsa#79
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.

Remove dependency on bash
2 participants