-
-
Notifications
You must be signed in to change notification settings - Fork 202
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
Tunnel mode selection feature for agent mode. #544
Tunnel mode selection feature for agent mode. #544
Conversation
lgtm, but maybe @danielpaulus or @dmissmann should approve as well |
Hi @danielpaulus , @dmissmann , would you please look at it at your convivences? I'll submit another PR which is ready for the issue #543 . Thx. |
ios/tunnel/tunnel_api.go
Outdated
var cmd *exec.Cmd | ||
|
||
if mode == "kernel" { | ||
cmd = exec.Command(ex, append([]string{"tunnel", "start"}, args...)...) | ||
} | ||
|
||
if mode == "user" { | ||
cmd = exec.Command(ex, append([]string{"tunnel", "start", "--userspace"}, args...)...) | ||
} |
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.
lets verify that we get one of the expected parameters, otherwise it would panic
var cmd *exec.Cmd | |
if mode == "kernel" { | |
cmd = exec.Command(ex, append([]string{"tunnel", "start"}, args...)...) | |
} | |
if mode == "user" { | |
cmd = exec.Command(ex, append([]string{"tunnel", "start", "--userspace"}, args...)...) | |
} | |
var cmd *exec.Cmd | |
switch mode { | |
case "kernel": | |
cmd = exec.Command(ex, append([]string{"tunnel", "start"}, args...)...) | |
case "user": | |
cmd = exec.Command(ex, append([]string{"tunnel", "start", "--userspace"}, args...)...) | |
default: | |
return fmt.Errorf("RunAgent: unknown mode: %s. Only 'kernel' and 'user' are supported", mode) | |
} |
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've modified with the suggestion. Initial code implemented like the old code for checking only 'yes' value and if only for that value it was calling RunAgent(). Similar, initial code was calling RunAgent() only for 'kernel' and 'user' values. However what @dmissmann suggested is better practice to handle panic independent of the caller. Modified accordingly.
Handling unexpected env. variable value Co-authored-by: dmissmann <[email protected]>
With this change ENABLE_GO_IOS_AGENT can be set to "user" or "kernel" to start selective mode tunnel.