From 629d6ad757027b89e6a6a8df20cb5367c123bb23 Mon Sep 17 00:00:00 2001 From: keyiflerolsun Date: Wed, 7 Aug 2024 12:44:01 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=95=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🕊 --- KeeneticPy/__init__.py | 9 +++++++++ setup.py | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/KeeneticPy/__init__.py b/KeeneticPy/__init__.py index f0a34ae..df9909f 100644 --- a/KeeneticPy/__init__.py +++ b/KeeneticPy/__init__.py @@ -157,6 +157,15 @@ def get_static_routes(self) -> list[dict[str, str]]: json = {"show":{"ip":{"route":{}}}} ).json().get("ip", {}).get("route", []) + @staticmethod + def cidr_to_mask(cidr): + """ https://bgp.tools/as/32934#prefixes """ + ip, prefix = cidr.split("/") + prefix = int(prefix) + mask = (0xFFFFFFFF >> (32 - prefix)) << (32 - prefix) + + return f"{(mask >> 24) & 0xFF}.{(mask >> 16) & 0xFF}.{(mask >> 8) & 0xFF}.{mask & 0xFF}" + def add_static_route(self, comment:str, host:str=None, network:str=None, mask:str=None, interface:str="Wireguard2") -> bool: payload = None diff --git a/setup.py b/setup.py index 25b054f..5d1aa42 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup( # ? Genel Bilgiler name = "KeeneticPy", - version = "0.8", + version = "0.9", url = "https://github.com/keyiflerolsun/KeeneticPy", description = "Python Lib for Keenetic Routers", keywords = ["KeeneticPy", "KekikAkademi", "keyiflerolsun"],