Enable raw packet manipulation as library code #126
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I maintain a project that uses wireguard-go as library code for userspace Wireguard functionality. My project had a need to modify some options and functionality of the low-level networking functionality that this library offers, but which is currently not exposed when used as a library import. Since that flexibility might be useful to other projects as well I'm submitting this PR for consideration.
This PR provides 3 changes:
Stack()method that provides access to the privatenet.stackobjectEndpoint()method that provides access to the privatenet.endpointobjectCreateNetTUNwithOptions()function that is exactly the same as theCreateNetTUN()function except it allows arbitrary stack options to be passed in;CreateNetTUN()then calls the new function with the current default options, which avoids breaking any existing code.Edit ~2 hours after initial PR: figured out a much cleaner way to expose stack options, updated this description to match the new commit.