diff --git a/CHANGELOG.md b/CHANGELOG.md index 38e09e4..49f95f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,11 @@ # Changelog This project adheres to [Semantic Versioning](http://semver.org/). -## tag: 0.1.0 / 2021-09-14 -- First working release + +## tag: 0.2.1 / 2022-09-06 +- (PR #6) Bugfix: switch axis labels for correct heatmap display +- Contributors + - @ahasbini ## tag: 0.2.0 / 2022-07-10 @@ -12,4 +15,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Added `nr-wg-mtu-finder-heatmap` script for generating heatmap from the log file. - This script comes in handy if the original `nr-wg-mtu-finder` crashes mid way. Then a heatmap can be generated from the partial log file (csv) too, barring formatting issues of the log file. - Formatted with black (88 linewidth) and isort (profile=black) -- First release to pypi so it can be installed with `pip install nr-wg-mtu-finder==0.2.0 --upgrade` \ No newline at end of file +- First release to pypi so it can be installed with `pip install nr-wg-mtu-finder==0.2.0 --upgrade` + + +## tag: 0.1.0 / 2021-09-14 +- First working release \ No newline at end of file diff --git a/README.md b/README.md index bf3a81c..b16d670 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ You can have a look at the real-world heatmaps which are posted by users in the #### Project Version ``` -0.2.0 +0.2.1 ``` @@ -62,7 +62,7 @@ Install the following on both the WG server and WG peer * Install the project ```bash # Use your environment manager of choice like virtualenv or conda or poetry to pre-create an environment - pip install nr-wg-mtu-finder==0.2.0 + pip install nr-wg-mtu-finder==0.2.1 --upgrade ``` # Usage @@ -187,20 +187,18 @@ So if you successfully ran the server and peer script, you should find two new f #### nr-wg-mtu-finder ``` $ nr-wg-mtu-finder --help -usage: nr-wg-mtu-finder [-h] --mode MODE --mtu-min MTU_MIN --mtu-max MTU_MAX - --mtu-step MTU_STEP --server-ip SERVER_IP - [--server-port SERVER_PORT] [--interface INTERFACE] - [--conf-file CONF_FILE] +usage: nr-wg-mtu-finder [-h] --mode MODE --mtu-min MTU_MIN --mtu-max MTU_MAX --mtu-step + MTU_STEP --server-ip SERVER_IP [--server-port SERVER_PORT] + [--interface INTERFACE] [--conf-file CONF_FILE] [--peer-skip-errors PEER_SKIP_ERRORS] -nr-wg-mtu-finder - Helps find the optimal Wireguard MTU between Server and -Peer. +nr-wg-mtu-finder - Helps find the optimal Wireguard MTU between a WG Server and a WG Peer. optional arguments: -h, --help show this help message and exit - --mode MODE Mode is 'server' if you are running this script on the - WG Server, else the mode is 'peer' if you are running - this script on the WG Peer. + --mode MODE Mode should be 'server' if you are running this script on the WG + Server. Mode should be 'peer' if you are running this script on + the WG Peer. --mtu-min MTU_MIN Min MTU. Must be in the range [1280, 1500]. --mtu-max MTU_MAX Max MTU. Must be in the range [1280, 1500]. --mtu-step MTU_STEP By how much to increment the MTU between loops. @@ -214,24 +212,41 @@ optional arguments: The path to the interface config file. Default: '/etc/wireguard/wg0.conf' --peer-skip-errors PEER_SKIP_ERRORS - Skip errors when an expected error occurs in peer mode - during MTU loop. + Skip errors when known errors occur in 'peer' mode during the MTU + loop. The known errors are logged and the loop continues without + crashing. Default: 'True'. Example usage: --peer-skip-errors False + + ``` #### nr-wg-mtu-finder-heatmap ``` $ nr-wg-mtu-finder-heatmap --help -usage: nr-wg-mtu-finder-heatmap [-h] --log-filepath LOG_FILEPATH --heatmap-filepath HEATMAP_FILEPATH +usage: nr-wg-mtu-finder-heatmap [-h] --log-filepath LOG_FILEPATH --heatmap-filepath + HEATMAP_FILEPATH -nr-wg-mtu-finder-plot - Generate a heatmap file (png) from a log file (csv) that was created by the `nr-wg-mtu-finder` script. This is useful in case the original script file crashed midway. +nr-wg-mtu-finder-heatmap - Generate a heatmap file (png) from a log file (csv) that was +created by the `nr-wg-mtu-finder` script. This is useful in case the original script file +crashed midway. optional arguments: -h, --help show this help message and exit --log-filepath LOG_FILEPATH - Absolute path to the log file (csv) that was created by the `nr-wg-mtu-finder` script. + Absolute path to the log file (csv) that was created by the `nr-wg- + mtu-finder` script. --heatmap-filepath HEATMAP_FILEPATH - Absolute path to the heatmap file (png) which will be created from the log file (csv). + Absolute path to the heatmap file (png) which will be created from + the log file (csv). + ``` -## License +# Development + +### Publish to pypi.org +* Bump version +* `pip install poetry==1.1.15` +* `poetry build` +* `poetry publish --dry-run` + +# License MIT diff --git a/examples/example.png b/examples/example.png index 6369611..5b4f32c 100644 Binary files a/examples/example.png and b/examples/example.png differ diff --git a/nr_wg_mtu_finder/__init__.py b/nr_wg_mtu_finder/__init__.py index d3ec452..3ced358 100644 --- a/nr_wg_mtu_finder/__init__.py +++ b/nr_wg_mtu_finder/__init__.py @@ -1 +1 @@ -__version__ = "0.2.0" +__version__ = "0.2.1" diff --git a/nr_wg_mtu_finder/main.py b/nr_wg_mtu_finder/main.py index 147faca..6c540f5 100644 --- a/nr_wg_mtu_finder/main.py +++ b/nr_wg_mtu_finder/main.py @@ -1,11 +1,13 @@ import argparse import signal -import time import sys -from pydantic import BaseModel, StrictStr, StrictInt, root_validator +import time +from distutils.util import strtobool + +from pydantic import BaseModel, StrictInt, StrictStr, root_validator from typing_extensions import Literal + from .mtu_finder import MTUFinder -from distutils.util import strtobool def signal_handler(sig, frame): @@ -52,7 +54,9 @@ class ArgsModel(BaseModel): raise ValueError(f"mtu_max: {mtu_max} must be in range [1280, 1500].") if not (mtu_min <= mtu_max): - raise ValueError(f"mtu_min: {mtu_min} must be less than or equal to mtu_max: {mtu_max}") + raise ValueError( + f"mtu_min: {mtu_min} must be less than or equal to mtu_max: {mtu_max}" + ) return values @@ -63,33 +67,50 @@ class ArgsModel(BaseModel): def setup_args(): """Setup args.""" parser = argparse.ArgumentParser( - description="nr-wg-mtu-finder - Helps find the optimal Wireguard MTU between Server and Peer." + description=( + "nr-wg-mtu-finder - Helps find the optimal Wireguard MTU between " + "a WG Server and a WG Peer." + ) ) parser.add_argument( "--mode", help=( - "Mode is 'server' if you are running this script on the WG Server, " - "else the mode is 'peer' if you are running this script on the WG Peer." + "Mode should be 'server' if you are running this script on the WG Server. " + "Mode should be 'peer' if you are running this script on the WG Peer." ), required=True, ) parser.add_argument( - "--mtu-min", help="Min MTU. Must be in the range [1280, 1500].", required=True, + "--mtu-min", + help="Min MTU. Must be in the range [1280, 1500].", + required=True, ) parser.add_argument( - "--mtu-max", help="Max MTU. Must be in the range [1280, 1500].", required=True, + "--mtu-max", + help="Max MTU. Must be in the range [1280, 1500].", + required=True, ) parser.add_argument( - "--mtu-step", help="By how much to increment the MTU between loops.", required=True, + "--mtu-step", + help="By how much to increment the MTU between loops.", + required=True, ) parser.add_argument( - "--server-ip", help="The IP address of the WG server and flask server.", required=True, + "--server-ip", + help="The IP address of the WG server and flask server.", + required=True, ) parser.add_argument( - "--server-port", help="The port for the flask server.", required=False, default=5000, + "--server-port", + help="The port for the flask server. Default: 5000", + required=False, + default=5000, ) parser.add_argument( - "--interface", help="The WG interface name. Default: 'wg0'", required=False, default="wg0" + "--interface", + help="The WG interface name. Default: 'wg0'", + required=False, + default="wg0", ) parser.add_argument( "--conf-file", @@ -99,7 +120,11 @@ def setup_args(): ) parser.add_argument( "--peer-skip-errors", - help="Skip errors when an expected error occurs in peer mode during MTU loop.", + help=( + "Skip errors when known errors occur in 'peer' mode during the MTU loop. " + "The known errors are logged and the loop continues without crashing. " + "Default: 'True'. Example usage: --peer-skip-errors False" + ), required=False, default=True, type=strtobool, diff --git a/poetry.lock b/poetry.lock index dd2ca4a..327f502 100644 --- a/poetry.lock +++ b/poetry.lock @@ -212,8 +212,8 @@ optional = false python-versions = ">=3.7" [package.extras] -docs = ["furo (>=2021.7.5b38)", "proselint (>=0.10.2)", "sphinx-autodoc-typehints (>=1.12)", "sphinx (>=4)"] -test = ["appdirs (==1.4.4)", "pytest-cov (>=2.7)", "pytest-mock (>=3.6)", "pytest (>=6)"] +docs = ["furo (>=2021.7.5b38)", "proselint (>=0.10.2)", "sphinx (>=4)", "sphinx-autodoc-typehints (>=1.12)"] +test = ["appdirs (==1.4.4)", "pytest (>=6)", "pytest-cov (>=2.7)", "pytest-mock (>=3.6)"] [[package]] name = "pydantic" @@ -239,7 +239,7 @@ optional = false python-versions = ">=3.6.8" [package.extras] -diagrams = ["railroad-diagrams", "jinja2"] +diagrams = ["jinja2", "railroad-diagrams"] [[package]] name = "python-dateutil" @@ -336,7 +336,7 @@ optional = false python-versions = "*" [package.extras] -secure = ["pyOpenSSL (>=0.14)", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "certifi", "ipaddress"] +secure = ["certifi", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "ipaddress", "pyOpenSSL (>=0.14)"] socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"] [[package]] @@ -597,8 +597,8 @@ pillow = [ {file = "Pillow-9.2.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:37ff6b522a26d0538b753f0b4e8e164fdada12db6c6f00f62145d732d8a3152e"}, {file = "Pillow-9.2.0-cp310-cp310-win32.whl", hash = "sha256:c79698d4cd9318d9481d89a77e2d3fcaeff5486be641e60a4b49f3d2ecca4e28"}, {file = "Pillow-9.2.0-cp310-cp310-win_amd64.whl", hash = "sha256:254164c57bab4b459f14c64e93df11eff5ded575192c294a0c49270f22c5d93d"}, - {file = "Pillow-9.2.0-cp311-cp311-macosx_10_10_universal2.whl", hash = "sha256:408673ed75594933714482501fe97e055a42996087eeca7e5d06e33218d05aa8"}, - {file = "Pillow-9.2.0-cp311-cp311-macosx_11_0_universal2.whl", hash = "sha256:727dd1389bc5cb9827cbd1f9d40d2c2a1a0c9b32dd2261db522d22a604a6eec9"}, + {file = "Pillow-9.2.0-cp311-cp311-macosx_10_10_x86_64.whl", hash = "sha256:adabc0bce035467fb537ef3e5e74f2847c8af217ee0be0455d4fec8adc0462fc"}, + {file = "Pillow-9.2.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:336b9036127eab855beec9662ac3ea13a4544a523ae273cbf108b228ecac8437"}, {file = "Pillow-9.2.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:50dff9cc21826d2977ef2d2a205504034e3a4563ca6f5db739b0d1026658e004"}, {file = "Pillow-9.2.0-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:cb6259196a589123d755380b65127ddc60f4c64b21fc3bb46ce3a6ea663659b0"}, {file = "Pillow-9.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7b0554af24df2bf96618dac71ddada02420f946be943b181108cac55a7a2dcd4"}, diff --git a/poetry.toml b/poetry.toml new file mode 100644 index 0000000..084377a --- /dev/null +++ b/poetry.toml @@ -0,0 +1,2 @@ +[virtualenvs] +create = false diff --git a/pyproject.toml b/pyproject.toml index bc85113..933e68e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "nr-wg-mtu-finder" -version = "0.2.0" +version = "0.2.1" description = "Scripts to find the optimal MTU for Wireguard server and peers." authors = ["nitred "]