diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7ff23d4..b3a9b80 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -186,23 +186,16 @@ jobs: steps: - uses: actions/checkout@v2 - # This is a pretty big hammer, but gets the windows compile moving - - name: Hack up a fake autoconf - run: | - echo true >autogen.sh - cp scripts/hack_fakeautoconf configure - shell: bash - - name: generate a makefile and use it to install more packages run: | - ./autogen.sh - ./configure + # This is a pretty big hammer, but gets the windows compile moving + ./scripts/hack_fakeautoconf.sh make build-dep shell: bash - - name: Run the real configure step + - name: Run a configure step run: | - CFLAGS="-fprofile-arcs -ftest-coverage" LDFLAGS="--coverage" ./configure --with-zstd + CFLAGS="-fprofile-arcs -ftest-coverage" LDFLAGS="--coverage" ./scripts/hack_fakeautoconf.sh shell: bash - name: Run embedded tests @@ -325,7 +318,7 @@ jobs: - name: Configure and Build shell: bash run: | - ./scripts/hack_fakeautoconf + ./scripts/hack_fakeautoconf.sh make - name: Create binary dir diff --git a/Makefile.in b/Makefile.in index 5db00f4..3d87dc8 100644 --- a/Makefile.in +++ b/Makefile.in @@ -187,7 +187,7 @@ test: tools lint: lint.python lint.ccode lint.shell lint.python: - flake8 scripts/n2nctl scripts/n2nhttpd + flake8 scripts/n2n-ctl scripts/n2n-httpd lint.ccode: scripts/indent.sh $(LINT_CCODE) diff --git a/doc/Building.md b/doc/Building.md index 37ed2ad..ccd0d39 100644 --- a/doc/Building.md +++ b/doc/Building.md @@ -109,7 +109,7 @@ applied as of 2021-09-29. - All the remaining commands must be run from inside a bash shell ("C:\Program Files\Git\usr\bin\bash.exe") - git clone $THIS_REPO - cd n2n - - ./scripts/hack_fakeautoconf + - ./scripts/hack_fakeautoconf.sh - make - make test diff --git a/doc/Routing.md b/doc/Routing.md index ec2c18a..c4d57f2 100644 --- a/doc/Routing.md +++ b/doc/Routing.md @@ -19,7 +19,7 @@ On the client side, the easiest way to configure routing is via the `-n` option. 10.0.0.1 is the IP address of the gateway to use to route the specified network. It should correspond to the IP address of the `server` within n2n. Multiple `-n` options can be specified. -As an alternative to the `-n` option, the `ip route` linux command can be manually used. See the [n2n_gateway.sh](doc/n2n_gateway.sh) script for an example. See also the following description of other use cases and in depth explanation. +As an alternative to the `-n` option, the `ip route` linux command can be manually used. See the [n2n-gateway.sh](scripts/n2n-gateway.sh) script for an example. See also the following description of other use cases and in depth explanation. ## Special Scenarios diff --git a/doc/Scripts.md b/doc/Scripts.md index f108b68..f2ac2eb 100644 --- a/doc/Scripts.md +++ b/doc/Scripts.md @@ -7,7 +7,7 @@ may be installed with n2n as part of your operating system package. Short descriptions of these scripts are below. -## `scripts/hack_fakeautoconf` +## `scripts/hack_fakeautoconf.sh` This shell script is used during development to help build on Windows systems. An example of how to use it is shown in @@ -23,7 +23,7 @@ the automated lint checks. This shell script is used to run automated tests during development. -## `scripts/n2nctl` +## `scripts/n2n-ctl` This python script provides an easy command line interface to the running n2n processes. It uses UDP communications to talk to the Management API. @@ -31,10 +31,10 @@ By specifying the right UDP port, it can talk to both the edge and the supernode daemons. Example: -- `scripts/n2nctl --help` -- `scripts/n2nctl help` +- `scripts/n2n-ctl --help` +- `scripts/n2n-ctl help` -## `scripts/n2nhttpd` +## `scripts/n2n-httpd` This python script is a simple http gateway to the running edge. It provides a proxy for REST-like HTTP requests to talk to the Management API. @@ -46,5 +46,10 @@ run with default settings can be seen at http://localhost:8080/ (Also a http://localhost:8080/supernode.html page for the supernode) Example: -- `scripts/n2nhttpd --help` -- `scripts/n2nhttpd 8087` +- `scripts/n2n-httpd --help` +- `scripts/n2n-httpd 8087` + +## `scripts/n2n-gateway.sh` + +A sample script to route all the host traffic towards a remote gateway, +which is reachable via the n2n virtual interface. diff --git a/scripts/hack_fakeautoconf b/scripts/hack_fakeautoconf.sh similarity index 84% rename from scripts/hack_fakeautoconf rename to scripts/hack_fakeautoconf.sh index dd8ff69..8ec8c82 100755 --- a/scripts/hack_fakeautoconf +++ b/scripts/hack_fakeautoconf.sh @@ -3,7 +3,7 @@ # Specifically for windows, where installing autoconf looks suspiciously # like boiling the ocean. -cat Makefile.in | sed \ +sed \ -e "s%@N2N_VERSION_SHORT@%FIXME%g" \ -e "s%@GIT_COMMITS@%FIXME%g" \ -e "s%@CC@%gcc%g" \ @@ -11,11 +11,11 @@ cat Makefile.in | sed \ -e "s%@CFLAGS@%$CFLAGS%g" \ -e "s%@LDFLAGS@%$LDFLAGS%g" \ -e "s%@N2N_LIBS@%$LDLIBS%g" \ - > Makefile + < Makefile.in > Makefile -cat tools/Makefile.in | sed \ +sed \ -e "s%@ADDITIONAL_TOOLS@%%g" \ - > tools/Makefile + < tools/Makefile.in > tools/Makefile cat <include/config.h #define PACKAGE_VERSION "FIXME" diff --git a/scripts/n2nctl b/scripts/n2n-ctl similarity index 100% rename from scripts/n2nctl rename to scripts/n2n-ctl diff --git a/doc/n2n_gateway.sh b/scripts/n2n-gateway.sh similarity index 89% rename from doc/n2n_gateway.sh rename to scripts/n2n-gateway.sh index 2bf4b84..0990d3a 100755 --- a/doc/n2n_gateway.sh +++ b/scripts/n2n-gateway.sh @@ -40,7 +40,7 @@ if ! ip route get $N2N_GATEWAY | grep -q $N2N_INTERFACE ; then fi # Determine the current internet gateway -internet_gateway=`ip route get 8.8.8.8 | head -n1 | awk '{ print $3 }'` +internet_gateway=$(ip route get 8.8.8.8 | head -n1 | awk '{ print $3 }') # Backup the DNS resolver configuration and use the specified server cp /etc/resolv.conf /etc/resolv.conf.my_bak @@ -49,7 +49,7 @@ echo "nameserver $DNS_SERVER" > /etc/resolv.conf # The public IP of the supernode must be reachable via the internet gateway # Whereas all the other traffic will go through the new VPN gateway. -ip route add $N2N_SUPERNODE via $internet_gateway +ip route add $N2N_SUPERNODE via "$internet_gateway" ip route del default echo "Forwarding traffic via $N2N_GATEWAY" ip route add default via $N2N_GATEWAY @@ -57,10 +57,10 @@ ip route add default via $N2N_GATEWAY function stopService { echo "Deleting custom routes" ip route del default - ip route del $N2N_SUPERNODE via $internet_gateway + ip route del $N2N_SUPERNODE via "$internet_gateway" echo "Restoring original gateway $internet_gateway" - ip route add default via $internet_gateway + ip route add default via "$internet_gateway" echo "Restoring original DNS" mv /etc/resolv.conf.my_bak /etc/resolv.conf diff --git a/scripts/n2nhttpd b/scripts/n2n-httpd similarity index 100% rename from scripts/n2nhttpd rename to scripts/n2n-httpd