From e59cb10329df7fcb728caf25f0ba034abfcfd6cd Mon Sep 17 00:00:00 2001 From: Krzysztof Burghardt Date: Mon, 2 Sep 2024 09:25:17 +0200 Subject: [PATCH 1/3] Fixes required to enable pre-commit. --- .cirrus.yml | 4 ++-- README.md | 2 +- easy-wg-quick | 8 ++++---- tests/loopback_ping.bash | 2 ++ tests/mtu.bats | 2 +- tests/port_randomness.bats | 6 +++--- tests/random_network_addresses.bats | 12 ++++++------ tests/setup_loopback_ping.bash | 2 ++ tests/teardown_loopback_ping.bash | 2 ++ 9 files changed, 23 insertions(+), 17 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 9d3b018..0fa010a 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -20,9 +20,9 @@ test_task: - cd tests && ./runtests.bash configure_script: - echo none > fwtype.txt - 1st_test_run_script: + first_test_run_script: - ./easy-wg-quick - 2nd_test_run_script: + second_test_run_script: - ./easy-wg-quick named_client dump_configuration_script: - head *.txt *.key *.conf diff --git a/README.md b/README.md index 6aac36e..b292403 100644 --- a/README.md +++ b/README.md @@ -231,7 +231,7 @@ set interface name in `extnetif.txt` file with command: By default `easy-wg-quick` uses IP address of interface that has default routing done over it as external IP address of VPN hub. This might not be true if hub is behind firewall or NAT/PAT/masquarading is done. User can set -prefered IP address in `extnetip.txt` file with command: +preferred IP address in `extnetip.txt` file with command: echo 192.168.1.2 > extnetip.txt diff --git a/easy-wg-quick b/easy-wg-quick index 8841dd1..f423b8a 100755 --- a/easy-wg-quick +++ b/easy-wg-quick @@ -465,7 +465,7 @@ MTU = $INT_NET_MTU [Peer] PublicKey = $(wg pubkey < wghub.key) PresharedKey = $(wg genpsk | tee "wgclient_$CONF_NAME.psk") -AllowedIPs = $INT_NET_CLINET_ALLOWEDIPS +AllowedIPs = $INT_NET_CLIENT_ALLOWEDIPS Endpoint = $EXT_NET_IP:$EXT_NET_PORT PersistentKeepalive = 25 EOF @@ -496,7 +496,7 @@ $($NET6 && echo " list dns '$INT_NET6_DNS'") option mtu '$INT_NET_MTU' config wireguard_wg0 -$(allowedips_to_uci_list "$INT_NET_CLINET_ALLOWEDIPS") +$(allowedips_to_uci_list "$INT_NET_CLIENT_ALLOWEDIPS") option route_allowed_ips '1' option endpoint_host '$EXT_NET_IP' option endpoint_port '$EXT_NET_PORT' @@ -612,7 +612,7 @@ write_initial_configuration() { INT_NET_ADDRESS_MASK="/32" INT_NET_HUB_IP="${INT_NET_ADDRESS}1" test -f intnetallowedips.txt || create_client_allowedips - INT_NET_CLINET_ALLOWEDIPS="$(get_client_allowedips)" + INT_NET_CLIENT_ALLOWEDIPS="$(get_client_allowedips)" test -f fwtype.txt || create_fw_type FW_TYPE="$(get_fw_type)" @@ -643,7 +643,7 @@ write_initial_configuration() { } print_usage() { - echo "Usage: $0 [client_name] - create new clinet with optional [client_name]" + echo "Usage: $0 [client_name] - create new client with optional [client_name]" echo " $0 --init - create initial configuration without any clients" echo " $0 --clear - clear the configuration and start over" exit 1 diff --git a/tests/loopback_ping.bash b/tests/loopback_ping.bash index 3bcfede..29ed035 100755 --- a/tests/loopback_ping.bash +++ b/tests/loopback_ping.bash @@ -1,3 +1,5 @@ +#!/usr/bin/env bash + # create configuration sudo ip netns exec hub ../easy-wg-quick loop diff --git a/tests/mtu.bats b/tests/mtu.bats index f94be9d..4e54d4b 100755 --- a/tests/mtu.bats +++ b/tests/mtu.bats @@ -13,7 +13,7 @@ load teardown setup [[ "$status" -eq 0 ]] } -@test "run with too smal MTU set" { +@test "run with too small MTU set" { echo 1200 > intnetmtu.txt run ../easy-wg-quick toosmalmtu [[ "$status" -eq 1 ]] diff --git a/tests/port_randomness.bats b/tests/port_randomness.bats index 15cabcb..7604167 100755 --- a/tests/port_randomness.bats +++ b/tests/port_randomness.bats @@ -6,11 +6,11 @@ load teardown setup run ../easy-wg-quick [[ "$status" -eq 0 ]] [[ "${#lines[@]}" -gt 3 ]] - RANDOM_PORT_1ST="$(grep ListenPort wghub.conf | awk '{ print $3 }')" + RANDOM_PORT_FIRST="$(grep ListenPort wghub.conf | awk '{ print $3 }')" teardown run ../easy-wg-quick [[ "$status" -eq 0 ]] [[ "${#lines[@]}" -gt 3 ]] - RANDOM_PORT_2ND="$(grep ListenPort wghub.conf | awk '{ print $3 }')" - [[ "${RANDOM_PORT_1ST}" -ne "${RANDOM_PORT_2ND}" ]] + RANDOM_PORT_SECOND="$(grep ListenPort wghub.conf | awk '{ print $3 }')" + [[ "${RANDOM_PORT_FIRST}" -ne "${RANDOM_PORT_SECOND}" ]] } diff --git a/tests/random_network_addresses.bats b/tests/random_network_addresses.bats index 8703517..b0a64ea 100755 --- a/tests/random_network_addresses.bats +++ b/tests/random_network_addresses.bats @@ -7,7 +7,7 @@ load teardown setup [[ "$status" -eq 0 ]] [[ "${#lines[@]}" -gt 10 ]] run cat intnetaddress.txt - saved_1st_output="$output" + saved_first_output="$output" [[ "$status" -eq 0 ]] [[ "${#lines[@]}" -eq 1 ]] @@ -16,11 +16,11 @@ load teardown setup [[ "$status" -eq 0 ]] [[ "${#lines[@]}" -gt 10 ]] run cat intnetaddress.txt - saved_2nd_output="$output" + saved_second_output="$output" [[ "$status" -eq 0 ]] [[ "${#lines[@]}" -eq 1 ]] - [[ "$saved_1st_output" != "$saved_2nd_output" ]] + [[ "$saved_first_output" != "$saved_second_output" ]] } @test "run to create random IPv6 network address" { @@ -29,7 +29,7 @@ load teardown setup [[ "$status" -eq 0 ]] [[ "${#lines[@]}" -gt 10 ]] run cat intnet6address.txt - saved_1st_output="$output" + saved_first_output="$output" [[ "$status" -eq 0 ]] [[ "${#lines[@]}" -eq 1 ]] @@ -38,9 +38,9 @@ load teardown setup [[ "$status" -eq 0 ]] [[ "${#lines[@]}" -gt 10 ]] run cat intnet6address.txt - saved_2nd_output="$output" + saved_second_output="$output" [[ "$status" -eq 0 ]] [[ "${#lines[@]}" -eq 1 ]] - [[ "$saved_1st_output" != "$saved_2nd_output" ]] + [[ "$saved_first_output" != "$saved_second_output" ]] } diff --git a/tests/setup_loopback_ping.bash b/tests/setup_loopback_ping.bash index f005682..2011254 100755 --- a/tests/setup_loopback_ping.bash +++ b/tests/setup_loopback_ping.bash @@ -1,3 +1,5 @@ +#!/usr/bin/env bash + # create namespaces sudo ip netns add hub sudo ip netns add client diff --git a/tests/teardown_loopback_ping.bash b/tests/teardown_loopback_ping.bash index 4d48b6d..aeed7bd 100755 --- a/tests/teardown_loopback_ping.bash +++ b/tests/teardown_loopback_ping.bash @@ -1,3 +1,5 @@ +#!/usr/bin/env bash + # cleanup sudo ip link delete veth_hub sudo ip link delete veth_client From 90508d4ea7b9e4dddd4939cd3e2303ca5c530310 Mon Sep 17 00:00:00 2001 From: Krzysztof Burghardt Date: Mon, 2 Sep 2024 09:36:16 +0200 Subject: [PATCH 2/3] Marked shell script with shebangs as executables. --- .github/actions/bats/entrypoint.sh | 0 .github/actions/checkbashisms/entrypoint.sh | 0 .github/actions/shellcheck/entrypoint.sh | 0 .github/actions/shfmt/entrypoint.sh | 0 4 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 .github/actions/bats/entrypoint.sh mode change 100644 => 100755 .github/actions/checkbashisms/entrypoint.sh mode change 100644 => 100755 .github/actions/shellcheck/entrypoint.sh mode change 100644 => 100755 .github/actions/shfmt/entrypoint.sh diff --git a/.github/actions/bats/entrypoint.sh b/.github/actions/bats/entrypoint.sh old mode 100644 new mode 100755 diff --git a/.github/actions/checkbashisms/entrypoint.sh b/.github/actions/checkbashisms/entrypoint.sh old mode 100644 new mode 100755 diff --git a/.github/actions/shellcheck/entrypoint.sh b/.github/actions/shellcheck/entrypoint.sh old mode 100644 new mode 100755 diff --git a/.github/actions/shfmt/entrypoint.sh b/.github/actions/shfmt/entrypoint.sh old mode 100644 new mode 100755 From 4193107f14859f9dbc4da4b5a3aaf0be7ab07a77 Mon Sep 17 00:00:00 2001 From: Krzysztof Burghardt Date: Mon, 2 Sep 2024 09:41:57 +0200 Subject: [PATCH 3/3] Add .pre-commit-config.yaml --- .pre-commit-config.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..5275b87 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,13 @@ +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + - id: check-added-large-files + - id: check-case-conflict + - id: check-executables-have-shebangs + - id: check-shebang-scripts-are-executable + - id: detect-private-key + - id: end-of-file-fixer + - id: fix-byte-order-marker + - id: mixed-line-ending + - id: trailing-whitespace