Skip to content

Commit

Permalink
Merge pull request #146 from burghardt/enable_pre-commit
Browse files Browse the repository at this point in the history
Enable pre commit
  • Loading branch information
burghardt authored Sep 2, 2024
2 parents 81936e9 + 4193107 commit 7624a99
Show file tree
Hide file tree
Showing 14 changed files with 36 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Empty file modified .github/actions/bats/entrypoint.sh
100644 → 100755
Empty file.
Empty file modified .github/actions/checkbashisms/entrypoint.sh
100644 → 100755
Empty file.
Empty file modified .github/actions/shellcheck/entrypoint.sh
100644 → 100755
Empty file.
Empty file modified .github/actions/shfmt/entrypoint.sh
100644 → 100755
Empty file.
13 changes: 13 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions easy-wg-quick
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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)"
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions tests/loopback_ping.bash
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env bash

# create configuration
sudo ip netns exec hub ../easy-wg-quick loop

Expand Down
2 changes: 1 addition & 1 deletion tests/mtu.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]]
Expand Down
6 changes: 3 additions & 3 deletions tests/port_randomness.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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}" ]]
}
12 changes: 6 additions & 6 deletions tests/random_network_addresses.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]]

Expand All @@ -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" {
Expand All @@ -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 ]]

Expand All @@ -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" ]]
}
2 changes: 2 additions & 0 deletions tests/setup_loopback_ping.bash
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env bash

# create namespaces
sudo ip netns add hub
sudo ip netns add client
Expand Down
2 changes: 2 additions & 0 deletions tests/teardown_loopback_ping.bash
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env bash

# cleanup
sudo ip link delete veth_hub
sudo ip link delete veth_client
Expand Down

0 comments on commit 7624a99

Please sign in to comment.