]> tinc-vpn.org Git - tinc/commitdiff
Appease the linters 1.1
authorGuus Sliepen <guus@tinc-vpn.org>
Sun, 9 Nov 2025 21:59:06 +0000 (22:59 +0100)
committerGuus Sliepen <guus@tinc-vpn.org>
Sun, 9 Nov 2025 21:59:06 +0000 (22:59 +0100)
15 files changed:
INSTALL.md
src/ed25519/ge.c
src/invitation.c
src/sptps_keypair.c
src/utils.c
test/integration/bind_port.py
test/integration/cmd_fsck.py
test/integration/cmd_keys.py
test/integration/device_fd.py
test/integration/device_multicast.py
test/integration/device_tap.py
test/integration/proxy.py
test/integration/testlib/check.py
test/integration/testlib/proc.py
test/integration/variables.py

index 7fbc8b1bc357fa3d0a779e1adfaf300f398b5368..742cdb3e8253a88b6262ace359583b9bdedb4eb2 100644 (file)
@@ -52,11 +52,16 @@ integration test suite:
 
 ## Linux
 
-Depending on the distribution, one of the following commands can be used to install all dependencies:
-- Arch Linux: `sudo pacman --needed --sync base-devel meson ninja pkg-config openssl ncurses readline zlib lzo lz4 texinfo diffutils procps socat openbsd-netcat`
-- Debian: `sudo apt install meson ninja-build pkg-config build-essential libssl-dev libncurses-dev libreadline-dev zlib1g-dev liblzo2-dev liblz4-dev texinfo diffutils procps socat netcat-openbsd`
-- Alpine Linux: `doas apk add meson ninja pkgconf build-base linux-headers openssl-dev ncurses-dev readline-dev zlib-dev lzo-dev lz4-dev texinfo diffutils procps-ng socat netcat-openbsd`
-- Fedora: `sudo dnf install meson ninja-build pkgconf-pkg-config @development-tools openssl-devel ncurses-devel readline-devel zlib-devel lzo-devel lz4-devel texinfo diffutils procps-ng socat netcat`
+Depending on the distribution, one of the following commands can be used to
+install all dependencies:
+- Arch Linux:
+  `sudo pacman --needed --sync base-devel meson ninja pkg-config openssl ncurses readline zlib lzo lz4 texinfo diffutils procps socat openbsd-netcat`
+- Debian:
+  `sudo apt install meson ninja-build pkg-config build-essential libssl-dev libncurses-dev libreadline-dev zlib1g-dev liblzo2-dev liblz4-dev texinfo diffutils procps socat netcat-openbsd`
+- Alpine Linux:
+  `doas apk add meson ninja pkgconf build-base linux-headers openssl-dev ncurses-dev readline-dev zlib-dev lzo-dev lz4-dev texinfo diffutils procps-ng socat netcat-openbsd`
+- Fedora:
+  `sudo dnf install meson ninja-build pkgconf-pkg-config @development-tools openssl-devel ncurses-devel readline-devel zlib-devel lzo-devel lz4-devel texinfo diffutils procps-ng socat netcat`
 
 ## Windows
 
index ca8c39b59e78fd6decf1ddf0a62d777f77591bbb..a69ed9d7e25855e33571e53e064c44d93b5d7436 100644 (file)
@@ -132,11 +132,11 @@ void ge_double_scalarmult_vartime(ge_p2 *r, const unsigned char *a, const ge_p3
 
 static const fe d = {
        -10913610, 13857413, -15372611, 6949391, 114729, -8787816, -6275908, -3247719, -18696448, -12055116
-        };
+};
 
 static const fe sqrtm1 = {
        -32595792, -7943725, 9377950, 3500415, 12389472, -272473, -25146209, -2005654, 326686, 11406482
-        };
+};
 
 int ge_frombytes_negate_vartime(ge_p3 *h, const unsigned char *s) {
        fe u;
@@ -297,7 +297,7 @@ r = p
 
 static const fe d2 = {
        -21827239, -5839606, -30745221, 13898782, 229458, 15978800, -12551817, -6495438, 29715968, 9444199
-        };
+};
 
 void ge_p3_to_cached(ge_cached *r, const ge_p3 *p) {
        fe_add(r->YplusX, p->Y, p->X);
index 46891a3cf5730835debfcb61f07ffbd9854b596d..ecbf1fa703c0aaec92373f8685c8874facf41449 100644 (file)
@@ -1326,6 +1326,7 @@ int cmd_join(int argc, char *argv[]) {
        struct addrinfo *aip = NULL;
 
 next:
+
        if(!aip) {
                aip = ai;
        } else {
index 97d51895a4377c1506743e4c55cde8de5c4564b5..09454f805206a459edb3e63aa85d1a0569d1c6df 100644 (file)
@@ -40,8 +40,8 @@ void logger(debug_t level, int priority, const char *format, ...) {
 static void usage(void) {
        fprintf(stderr, "Usage: %s [options] private_key_file public_key_file\n\n", program_name);
        fprintf(stderr, "Valid options are:\n"
-               "  --help  Display this help and exit.\n"
-               "\n");
+                       "  --help  Display this help and exit.\n"
+                       "\n");
        fprintf(stderr, "Report bugs to tinc@tinc-vpn.org.\n");
 }
 
index 3a3030d1ce3ebfcf8cd0b42e7a5193ab1185b669..47b2a5d779987dbbe164f80b2c20ba38af5d44d2 100644 (file)
@@ -28,22 +28,22 @@ static const char base64_original[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmno
 static const char base64_urlsafe[] =  "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
 static const char base64_decode[256] = {
        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-               -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-               -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, 62, -1, 63,
-               52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,
-               -1,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14,
-               15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, 63,
-               -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
-               41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1,
-               -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-               -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-               -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-               -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-               -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-               -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-               -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-               -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-        };
+       -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+       -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, 62, -1, 63,
+       52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,
+       -1,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14,
+       15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, 63,
+       -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
+       41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1,
+       -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+       -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+       -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+       -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+       -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+       -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+       -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+       -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+};
 
 static uint8_t charhex2bin(char c) {
        uint8_t cu = (uint8_t) c;
index 11fbc4a3b64e8589922ce557091e56ef268a5c66..5ebaefd0e0404b69d5256d88612357748d39f3e4 100755 (executable)
@@ -1,4 +1,5 @@
 #!/usr/bin/env python3
+# pylint: disable=unreachable
 
 """Test binding to ports on localhost."""
 
index e3dfa4374bfb10c15845d607bdec54f791ba20d8..fc8171f2afddaa9bd91cf7a1a48e5a576f6ef2d6 100755 (executable)
@@ -107,7 +107,7 @@ def extract_pem(config: str) -> T.List[str]:
             return result
         if key:
             result.append(line)
-    raise Exception("key not found")
+    raise RuntimeError("key not found")
 
 
 def replace_line(file_path: str, prefix: str, replace: str = "") -> None:
index 079a5036d36c6e8942d6e61c20c3d18a9db09461..825f079e88131e205487779df9853b2d71f7bc75 100755 (executable)
@@ -4,6 +4,7 @@
 """Test key management commands."""
 
 import os
+import typing
 
 from testlib import check, util
 from testlib.log import log
@@ -23,6 +24,10 @@ def try_rsa_keys(priv_path: str, pub_path: str) -> None:
         import cryptography  # type: ignore
         from cryptography.hazmat.primitives import hashes, serialization  # type: ignore
         from cryptography.hazmat.primitives.asymmetric import padding  # type: ignore
+        from cryptography.hazmat.primitives.asymmetric.rsa import (
+            RSAPrivateKey,
+            RSAPublicKey,
+        )  # type: ignore
     except ImportError:
         log.info("cryptography module missing or broken, skipping key checks")
         return
@@ -35,8 +40,11 @@ def try_rsa_keys(priv_path: str, pub_path: str) -> None:
     log.info("loading keys from (%s, %s)", priv_path, pub_path)
     with open(priv_path, "rb") as priv, open(pub_path, "rb") as pub:
         key_pair = (
-            serialization.load_pem_private_key(priv.read(), password=None),
-            serialization.load_pem_public_key(pub.read()),
+            typing.cast(
+                RSAPrivateKey,
+                serialization.load_pem_private_key(priv.read(), password=None),
+            ),
+            typing.cast(RSAPublicKey, serialization.load_pem_public_key(pub.read())),
         )
 
     s_pad = padding.PSS(
index 01955468d74052fe0ce8c7e397c76e18ee5639ff..70b5072e2c65f2f95c8d9c209483ba61943ff4cf 100755 (executable)
@@ -13,7 +13,7 @@ from testlib.log import log
 from testlib.test import Test
 from testlib.proc import Script
 
-JUNK_FRAME = b"\xFF" * 80
+JUNK_FRAME = b"\xff" * 80
 
 
 def start_fd_server(unix: socket.socket, payload: bytes, file_desc: int) -> None:
index 1b46c42ceccd297be8dffe9885d851a8a486cd4e..97dd168137a585df85f3bc9f07b01c53c46d47e8 100755 (executable)
@@ -19,6 +19,8 @@ PORT = 38245
 
 
 class MulticastSupport(enum.Enum):
+    """Enum describing level of support for multicast."""
+
     NO = 0
     BLOCKED = 1
     YES = 2
@@ -104,7 +106,6 @@ def test_device_multicast(ctx: Test) -> None:
         test_rx_tx(foo)
     elif multicast_support == MulticastSupport.BLOCKED:
         log.info("multicast blocked")
-        pass
     else:
         log.info("multicast not supported")
         test_no_mcast_support(foo)
index 07eaf5ffb5f239b129c77fa1fd3f5ba67b4e118a..9449ae957c9a08cbacc41865ae5a6f41d66be52b 100755 (executable)
@@ -30,8 +30,10 @@ def make_up(node: str, address: str) -> str:
     return f"""
     import subprocess as subp
     subp.run(['ip', 'link', 'set', 'dev', '{node}', 'netns', '{node}'], check=True)
-    subp.run(['ip', 'netns', 'exec', '{node}', 'ip', 'addr', 'add', 'dev', '{node}', '{address}/24'], check=True)
-    subp.run(['ip', 'netns', 'exec', '{node}', 'ip', 'link', 'set', '{node}', 'up'], check=True)
+    subp.run(['ip', 'netns', 'exec', '{node}', 'ip', 'addr', 'add', 'dev', '{node}',
+             '{address}/24'], check=True)
+    subp.run(['ip', 'netns', 'exec', '{node}', 'ip', 'link', 'set', '{node}', 'up'],
+             check=True)
     """
 
 
index c0e797108ed8486ebc8e327bf0baa8d4e4e4cb5c..3b22704749c8acb9b2994bc5b116f06ad0ee43a7 100755 (executable)
@@ -402,7 +402,7 @@ def test_proxy(ctx: Test, handler: T.Type[ProxyServer], user="", passw="") -> No
     foo.cmd("set", f"{bar}.Port", str(bar.port))
 
     with ThreadingTCPServer(("127.0.0.1", 0), handler) as server:
-        _, port = server.server_address
+        _, port, *_ = server.server_address
 
         worker = Thread(target=server.serve_forever)
         worker.start()
index 7f70b99f8a171dec4490ea8e335a8d687affd635..651822c6138bb0ae07af7b87dd1133301cfffd95 100755 (executable)
@@ -8,9 +8,10 @@ from .log import log
 
 Val = T.TypeVar("Val")
 Num = T.TypeVar("Num", int, float)
+AnyStr = T.TypeVar("AnyStr", str, bytes)
 
 
-def blank(value: T.AnyStr) -> None:
+def blank(value: AnyStr) -> None:
     """Check that value is an empty or blank string."""
     if not isinstance(value, str) or value.strip():
         raise ValueError(f'expected "{value!r}" to be a blank string')
@@ -52,7 +53,7 @@ def equals(expected: Val, actual: Val) -> None:
         raise ValueError(f'expected "{expected}", got "{actual}"')
 
 
-def has_prefix(text: T.AnyStr, prefix: T.AnyStr) -> None:
+def has_prefix(text: AnyStr, prefix: AnyStr) -> None:
     """Check that text has prefix."""
     if not text.startswith(prefix):
         raise ValueError(f"expected {text!r} to start with {prefix!r}")
@@ -70,7 +71,7 @@ def in_range(value: Num, gte: Num, lte: Num) -> None:
         raise ValueError(f"value {value} must be between {gte} and {lte}")
 
 
-def lines(text: T.AnyStr, num: int) -> None:
+def lines(text: AnyStr, num: int) -> None:
     """Check that text splits into `num` lines."""
     rows = text.splitlines()
     if len(rows) != num:
@@ -92,7 +93,7 @@ def not_in(needle: Val, *haystacks: T.Container[Val]) -> None:
             raise ValueError(f'expected all "{haystacks}" NOT to include "{needle}"')
 
 
-def _read_content(path: T.Union[str, os.PathLike], search: T.AnyStr) -> T.AnyStr:
+def _read_content(path: T.Union[str, os.PathLike], search: AnyStr) -> AnyStr:
     """Read text or binary content, depending on the type of search argument."""
     if isinstance(search, str):
         mode, enc = "r", "utf-8"
@@ -102,12 +103,12 @@ def _read_content(path: T.Union[str, os.PathLike], search: T.AnyStr) -> T.AnyStr
         return f.read()
 
 
-def in_file(path: T.Union[str, os.PathLike], text: T.AnyStr) -> None:
+def in_file(path: T.Union[str, os.PathLike], text: AnyStr) -> None:
     """Check that file contains a string."""
     is_in(text, _read_content(path, text))
 
 
-def not_in_file(path: T.Union[str, os.PathLike], text: T.AnyStr) -> None:
+def not_in_file(path: T.Union[str, os.PathLike], text: AnyStr) -> None:
     """Check that file does not contain a string."""
     not_in(text, _read_content(path, text))
 
index 970c80cc53b1b9a1b6d2291313b5814449a03179..dab335ad3f107f6858f076a9d4a341ca360c4706 100755 (executable)
@@ -240,7 +240,7 @@ class Tinc:
         self,
         *args: str,
         code: T.Optional[int] = 0,
-        stdin: T.Optional[T.AnyStr] = None,
+        stdin: T.Optional[str | bytes] = None,
         timeout: T.Optional[int] = None,
     ) -> T.Tuple[str, str]:
         """Run command through tinc, writes `stdin` to it (if the argument is not None),
index b42fbf5e3734aaf349e46f754bb51381c9bf8719..9ecca0666b113dd00e47b1ed7e67e3c05a4ad755 100755 (executable)
@@ -1,4 +1,5 @@
 #!/usr/bin/env python3
+# pylint: disable=invalid-name
 
 """Test tinc and tincd configuration variables."""