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

Tunnel mode selection feature for agent mode. #544

Merged
merged 2 commits into from
Jan 14, 2025

Conversation

stoktamisoglu
Copy link
Contributor

With this change ENABLE_GO_IOS_AGENT can be set to "user" or "kernel" to start selective mode tunnel.

@shamanec
Copy link
Collaborator

shamanec commented Jan 8, 2025

lgtm, but maybe @danielpaulus or @dmissmann should approve as well

@stoktamisoglu
Copy link
Contributor Author

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.

Comment on lines 67 to 75
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...)...)
}
Copy link
Collaborator

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

Suggested change
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)
}

Copy link
Contributor Author

@stoktamisoglu stoktamisoglu Jan 13, 2025

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]>
@dmissmann dmissmann merged commit 99b19bc into danielpaulus:main Jan 14, 2025
2 checks passed
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.

3 participants