From adae9504cd312f119bd95dd01bb5ce716894dfd5 Mon Sep 17 00:00:00 2001 From: l0k18 Date: Tue, 20 Jun 2023 09:26:06 +0100 Subject: [PATCH] some more detailed info on how to use the scripts for development --- cmd/indra/client/client.go | 1 + cmd/indra/relay/relay.go | 28 +++++++++++++++++++++++++--- scripts/cdwork | 4 ---- scripts/cdwork.sh | 7 +++++++ scripts/readme.md | 11 +++++++++++ scripts/run.sh | 3 +++ scripts/test.sh | 2 +- scripts/testpkg.sh | 2 +- scripts/trace.sh | 3 +++ 9 files changed, 52 insertions(+), 9 deletions(-) delete mode 100755 scripts/cdwork create mode 100755 scripts/cdwork.sh create mode 100644 scripts/readme.md create mode 100755 scripts/run.sh create mode 100755 scripts/trace.sh diff --git a/cmd/indra/client/client.go b/cmd/indra/client/client.go index 25b49e37..d1a074c5 100644 --- a/cmd/indra/client/client.go +++ b/cmd/indra/client/client.go @@ -14,5 +14,6 @@ var clientCommand = &cobra.Command{ Long: "Runs indra as a client, providing a wireguard tunnel and socks5 " + "proxy as connectivity options", Run: func(cmd *cobra.Command, args []string) { + }, } diff --git a/cmd/indra/relay/relay.go b/cmd/indra/relay/relay.go index 8a884a6c..848ec974 100644 --- a/cmd/indra/relay/relay.go +++ b/cmd/indra/relay/relay.go @@ -1,17 +1,39 @@ package relay import ( + "github.com/indra-labs/indra" + log2 "github.com/indra-labs/indra/pkg/proc/log" "github.com/spf13/cobra" ) +var ( + log = log2.GetLogger() + check = log.E.Chk +) + +var ( + wireguardEnable bool + wireguardCIDR string + socksEnable bool + socksListener string +) + func Init(c *cobra.Command) { + relayCommand.PersistentFlags().BoolVarP(&wireguardEnable, "wireguard", + "w", false, "enable wiregfuard tunnel") + relayCommand.PersistentFlags().BoolVarP(&socksEnable, "socks", + "s", false, "enable socks proxy") + relayCommand.PersistentFlags().StringVar(&socksListener, "socks-listener", + "localhost:8080", "set address for socks 5 proxy listener") + c.AddCommand(relayCommand) } var relayCommand = &cobra.Command{ Use: "relay", Short: "run a relay", - Long: "Runs indra as a full relay, with optional client", - Run: func(cmd *cobra.Command, args []string) { - }, + Long: "Runs indra as a full relay, with optional client.", + Run: func(cmd *cobra.Command, args []string) { + log.I.Ln(log2.App.Load(), indra.SemVer) + }, } diff --git a/scripts/cdwork b/scripts/cdwork deleted file mode 100755 index 05476202..00000000 --- a/scripts/cdwork +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/zsh -cd /home/loki/work/loki/indra-labs/indra -export PATH=/home/loki/work/loki/indra-labs/indra/scripts:$PATH -zsh \ No newline at end of file diff --git a/scripts/cdwork.sh b/scripts/cdwork.sh new file mode 100755 index 00000000..4cd89112 --- /dev/null +++ b/scripts/cdwork.sh @@ -0,0 +1,7 @@ +#!/usr/bin/zsh +# populate ~/.workpath thus: `cd path/to/repo/root; pwd>~/.workpath +export INDRAROOT=$(cat ~/.workpath) +export PATH=$INDRAROOT/scripts:$PATH +# put the path of the root of the repository in ./scripts/path +cd $INDRAROOT +zsh \ No newline at end of file diff --git a/scripts/readme.md b/scripts/readme.md new file mode 100644 index 00000000..8a613059 --- /dev/null +++ b/scripts/readme.md @@ -0,0 +1,11 @@ +# scripts + +populate ~/.workpath thus: `cd path/to/repo/root; pwd>~/.workpath` + +add this to your `~/.bashrc` or `~/.zshrc`: + + export PATH=$(cat ~/.workpath)/scripts:$HOME/sdk/go1.19.10/bin:$PATH + export GOBIN=$HOME/.local/bin + +`source` the `rc` file or open a new terminal session and type `cdwork.sh` and you will have a number of useful commands +that handle paths and special build parameters to make the code locations work without hard coding them anywhere. \ No newline at end of file diff --git a/scripts/run.sh b/scripts/run.sh new file mode 100755 index 00000000..39ec4aab --- /dev/null +++ b/scripts/run.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env zsh +reset +go run -tags local -gcflags "all=-trimpath=$INDRAROOT" $1 --logs-level=trace $2 $3 $4 $5 \ No newline at end of file diff --git a/scripts/test.sh b/scripts/test.sh index 25cd4939..b95aff8f 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -1,3 +1,3 @@ #!/usr/bin/env zsh reset -go test -v -tags local -gcflags "all=-trimpath=/home/loki/work/loki/indra-labs/indra" $1 $2 $3 $4 $5 \ No newline at end of file +go test -v -tags local -gcflags "all=-trimpath=$INDRAROOT" $1 $2 $3 $4 $5 \ No newline at end of file diff --git a/scripts/testpkg.sh b/scripts/testpkg.sh index 9c8a2b0e..ce636cd2 100755 --- a/scripts/testpkg.sh +++ b/scripts/testpkg.sh @@ -1,3 +1,3 @@ #!/usr/bin/env zsh cd pkg -go test -v -tags local -gcflags "all=-trimpath=/home/loki/work/loki/indra-labs/indra" ./... \ No newline at end of file +go test -v -tags local -gcflags "all=-trimpath=$INDRAROOT" ./... \ No newline at end of file diff --git a/scripts/trace.sh b/scripts/trace.sh new file mode 100755 index 00000000..298e9733 --- /dev/null +++ b/scripts/trace.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env zsh +reset +go run -tags local -gcflags "all=-trimpath=$INDRAROOT" $1 $2 $3 $4 $5 \ No newline at end of file