-
Notifications
You must be signed in to change notification settings - Fork 188
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
Add Error Message when wireguard-go
not found.
#232
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, the docker test is failing correctly.
We can find
wireguard-go
directly in the previous code because it's in thePATH
. But now if we treat it as aPathBuf
and call.exists()
on it, we're asking if there's awireguard-go
file in the default working directory of the container. So this function is returning anError
, the container exits, and our docker test fails to find the peer container because it exited and disappeared.We'll have to re-think how we detect if it's there or not. Maybe we just run the command and detect if we encounter an error, or maybe we use the which crate or something else to find the full path of the binary, or something else entirely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yeah, maybe we want to rethink this as simply providing better output when we run the command in
start_userspace_wireguard()
. Personally I don't think the benefits of adding a dependency are worth it compared to adding a better "wireguard-go failed to execute - is it installed?" type message to the user.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think there is a switch for
--version
inwireguard-go
. We could try to executewireguard-go --version
. If that succeeds, thenwireguard-go
exists in the path.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@noyez I don't think that's necessary: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=d93bf64dbf49743403648a4dfebf8b46
We can just check the result of
output()
and the result will be:when the binary is missing :).
So I think this PR is more about modifying
start_userspace_wireguard()
to provide more informative error messages up the chain for the user.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if the
output()
fails it could meanwireguard-go
doesn't exists, or perhaps there's another error with the configurations. Instart_userspace_wireguard()
you already check ifoutput()
returns an error status, if so it returnsErr(io::ErrorKind::AddrNotAvailable.int())
.Do you know to differentiate the different error codes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@noyez at first glance this looks reasonable, we can simplify it a bit and I think we don't want to return
io::ErrorKind::AddrNotAvailable
if we get an error running the command (nooutput
was produced)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I actually also don't get why we're returning
io::ErrorKind::AddrNotAvailable
for all errors, but I can fix that up in another PR since it's not related to wireguard-go being missing altogether and was already in the code.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, i didn't know what else to return, that's what was getting returned previously in the
start_userspace_wireguard
function so i kept it, but can def be changed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think that one is my bad ;). It'd make this PR less "short and sweet" but I feel like maybe the right thing to do is to pack into the error the return code as well as possibly the
stderr
output so that we can output it to the user.Feel free to take that on if you wish, otherwise I can address it in a later PR since it's my oversight.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous code had a question mark operator:
innernet/wireguard-control/src/backends/userspace.rs
Line 278 in 376ab64
So
ErrorKind::AddrNotAvailable
is only returned when there's not a success status code after running the command. But you're right that we should return all the details to the caller.