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

fix enable vpn server environmental variable detection for config gen #1695

Merged
merged 6 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 25 additions & 6 deletions cmd/skywire-cli/commands/config/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ func init() {
gHiddenFlags = append(gHiddenFlags, "noauth")
genConfigCmd.Flags().BoolVarP(&isDmsgHTTP, "dmsghttp", "d", scriptExecBool("${DMSGHTTP:-false}"), "use dmsg connection to skywire services\033[0m")
gHiddenFlags = append(gHiddenFlags, "dmsghttp")
genConfigCmd.Flags().IntVar(&minDmsgSess, "minsess", scriptExecInt("${MINDMSGSESS:-1}"), "number of dmsg servers to connect to (0 = unlimited)\033[0m")
gHiddenFlags = append(gHiddenFlags, "minsess")
genConfigCmd.Flags().BoolVarP(&isEnableAuth, "auth", "e", false, "enable auth on hypervisor UI\033[0m")
gHiddenFlags = append(gHiddenFlags, "auth")
genConfigCmd.Flags().BoolVarP(&isForce, "force", "f", false, "remove pre-existing config\033[0m")
Expand Down Expand Up @@ -127,6 +129,7 @@ func init() {
gHiddenFlags = append(gHiddenFlags, "example-apps")
genConfigCmd.Flags().BoolVarP(&isStdout, "stdout", "n", false, "write config to stdout\033[0m")
gHiddenFlags = append(gHiddenFlags, "stdout")
genConfigCmd.Flags().BoolVarP(&isEnvs, "envs", "q", false, "show the environmental variable settings")
msg = "output config"
if scriptExecString("${OUTPUT}") == "" {
msg += ": " + visorconfig.ConfigName
Expand Down Expand Up @@ -155,7 +158,7 @@ func init() {
gHiddenFlags = append(gHiddenFlags, "sk")
genConfigCmd.Flags().BoolVarP(&isTestEnv, "testenv", "t", scriptExecBool("${TESTENV:-false}"), "use test deployment "+testConf+"\033[0m")
gHiddenFlags = append(gHiddenFlags, "testenv")
genConfigCmd.Flags().BoolVarP(&isVpnServerEnable, "servevpn", "v", scriptExecBool("${SERVEVPN:-false}"), "enable vpn server\033[0m")
genConfigCmd.Flags().BoolVarP(&isVpnServerEnable, "servevpn", "v", scriptExecBool("${VPNSERVER:-false}"), "enable vpn server\033[0m")
gHiddenFlags = append(gHiddenFlags, "servevpn")
genConfigCmd.Flags().BoolVarP(&isHide, "hide", "w", false, "dont print the config to the terminal :: show errors with -n flag\033[0m")
gHiddenFlags = append(gHiddenFlags, "hide")
Expand All @@ -169,30 +172,40 @@ func init() {
gHiddenFlags = append(gHiddenFlags, "stcpr")
genConfigCmd.Flags().IntVar(&sudphPort, "sudph", scriptExecInt("${SUDPHPORT:-0}"), "set udp transport listening port - 0 for random\033[0m")
gHiddenFlags = append(gHiddenFlags, "sudph")
genConfigCmd.Flags().BoolVar(&isAll, "all", false, "show all flags")
genConfigCmd.Flags().StringVar(&binPath, "binpath", scriptExecString("${BINPATH}"), "set bin_path\033[0m")
gHiddenFlags = append(gHiddenFlags, "binpath")
genConfigCmd.Flags().StringVar(&addSkysocksClientSrv, "proxyclientpk", scriptExecString("${PROXYCLIENTPK}"), "set server public key for proxy client")
gHiddenFlags = append(gHiddenFlags, "proxyclientpk")
genConfigCmd.Flags().BoolVar(&enableProxyClientAutostart, "startproxyclient", scriptExecBool("${STARTPROXYCLIENT:-false}"), "autostart proxy client")
gHiddenFlags = append(gHiddenFlags, "startproxyclient")
genConfigCmd.Flags().BoolVar(&disableProxyServerAutostart, "noproxyserver", scriptExecBool("${NOPROXYSERVER:-false}"), "disable autostart of proxy server")
gHiddenFlags = append(gHiddenFlags, "noproxyserver")
genConfigCmd.Flags().StringVar(&proxyServerPass, "proxyserverpass", scriptExecString("${PROXYSEVERPASS}"), "set proxy server password")
gHiddenFlags = append(gHiddenFlags, "proxyserverpass")
genConfigCmd.Flags().StringVar(&proxyClientPass, "proxyclientpass", scriptExecString("${PROXYCLIENTPASS}"), "password for the proxy client to access the server (if needed)")
gHiddenFlags = append(gHiddenFlags, "proxyclientpass")
// TODO: Password for accessing proxy client
genConfigCmd.Flags().StringVar(&setVPNClientKillswitch, "killsw", scriptExecString("${VPNKS}"), "vpn client killswitch")
gHiddenFlags = append(gHiddenFlags, "killsw")
genConfigCmd.Flags().StringVar(&addVPNClientSrv, "addvpn", scriptExecString("${ADDVPNPK}"), "set vpn server public key for vpn client")
gHiddenFlags = append(gHiddenFlags, "addvpn")
genConfigCmd.Flags().StringVar(&addVPNClientPasscode, "vpnpass", scriptExecString("${VPNCLIENTPASS}"), "password for vpn client to access the vpn server (if needed)")
gHiddenFlags = append(gHiddenFlags, "vpnpass")
genConfigCmd.Flags().StringVar(&addVPNServerPasscode, "vpnserverpass", scriptExecString("${VPNSEVERPASS}"), "set password to the vpn server")
gHiddenFlags = append(gHiddenFlags, "vpnserverpass")
genConfigCmd.Flags().StringVar(&setVPNServerSecure, "secure", scriptExecString("${VPNSEVERSECURE}"), "change secure mode status of vpn server")
gHiddenFlags = append(gHiddenFlags, "secure")
genConfigCmd.Flags().StringVar(&setVPNServerNetIfc, "netifc", scriptExecString("${VPNSEVERNETIFC}"), "VPN Server network interface (detected: "+getInterfaceNames()+")")
genConfigCmd.Flags().BoolVarP(&isEnvs, "envs", "q", false, "show the environmental variable settings")
gHiddenFlags = append(gHiddenFlags, "envs")
gHiddenFlags = append(gHiddenFlags, "netifc")
genConfigCmd.Flags().BoolVar(&noFetch, "nofetch", false, "do not fetch the services from the service conf url")
gHiddenFlags = append(gHiddenFlags, "nofetch")
genConfigCmd.Flags().StringVar(&configServicePath, "confpath", "", "path of config-service offline file")
genConfigCmd.Flags().StringVar(&configServicePath, "confpath", "", "specify service conf file (instead of fetching from URL)")
gHiddenFlags = append(gHiddenFlags, "confpath")
genConfigCmd.Flags().BoolVar(&noDefaults, "nodefaults", false, "do not use hardcoded defaults for production / test services")
gHiddenFlags = append(gHiddenFlags, "nodefaults")
genConfigCmd.Flags().StringVar(&ver, "version", scriptExecString("${VERSION}"), "custom version testing override\033[0m")
gHiddenFlags = append(gHiddenFlags, "version")
genConfigCmd.Flags().BoolVar(&isAll, "all", false, "show all flags")

//show all flags on help
if os.Getenv("UNHIDEFLAGS") != "1" {
Expand Down Expand Up @@ -766,7 +779,7 @@ var genConfigCmd = &cobra.Command{

conf.Dmsg = &dmsgc.DmsgConfig{
Discovery: services.DmsgDiscovery,
SessionsCount: 1,
SessionsCount: minDmsgSess,
Servers: []*disc.Entry{},
}
conf.Transport = &visorconfig.Transport{
Expand Down Expand Up @@ -1220,6 +1233,9 @@ const envfileLinux = `#
#-- Use dmsghttp to connect to the production deployment
#DMSGHTTP=true

#-- Number of dmsg serverts to connect to (0 unlimits)
#MINDMSGSESS=8

#-- Start the hypervisor interface for this visor
#ISHYPERVISOR=true

Expand Down Expand Up @@ -1319,6 +1335,9 @@ const envfileWindows = `#
#-- Use dmsghttp to connect to the production deployment
#$DMSGHTTP=true

#-- Number of dmsg serverts to connect to (0 unlimits)
#$MINDMSGSESS=8

#-- Start the hypervisor interface for this visor
#$ISHYPERVISOR=true

Expand Down
1 change: 1 addition & 0 deletions cmd/skywire-cli/commands/config/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ var (
routeSetupNodes string
transportSetupPKs string
isDmsgHTTP bool
minDmsgSess int
isVpnServerEnable bool
isDisableAuth bool
isEnableAuth bool
Expand Down
Loading