Skip to content

Commit

Permalink
🕊
Browse files Browse the repository at this point in the history
🕊
  • Loading branch information
keyiflerolsun committed Aug 7, 2024
1 parent 31449ff commit 8ace1b7
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 38 deletions.
5 changes: 3 additions & 2 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Bu araç @keyiflerolsun tarafından | @KekikAkademi için yazılmıştır.

github: keyiflerolsun
custom: ['https://keyiflerolsun.me/Kahve']
github : keyiflerolsun
buy_me_a_coffee : keyiflerolsun
custom : ["https://keyiflerolsun.me/Kahve"]
34 changes: 21 additions & 13 deletions .github/workflows/pypiYukle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

name: KekikAkademi PyPI Yükleyici

concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: true

on:
workflow_dispatch:
push:
branches:
- "main"
Expand All @@ -13,27 +18,30 @@ jobs:

strategy:
matrix:
python-version: ["3.10.8"]
python-version: ["3.11.8"]

steps:
- name: Depo Kontrolü
uses: actions/checkout@v2
- name : Depo Kontrolü
uses : actions/checkout@v4

- name: Python ${{ matrix.python-version }} Sürümü Yükleniyor
uses: actions/setup-python@v2
with:
- name : Python ${{ matrix.python-version }} Sürümü Yükleniyor
uses : actions/setup-python@v5
with :
python-version: ${{ matrix.python-version }}

- name: Python Sürümünü Göster
run: python -c "import sys; print(sys.version)"
- name : Python Sürümünü Göster
run : python -c "import sys; print(sys.version)"

- name : Gereksinimleri Yükle
run : |
python -m pip install --upgrade pip
pip install -U setuptools wheel twine
- name: Kütüphaneyi PyPI'ye Yükle
env:
- name : Kütüphaneyi PyPI'ye Yükle
env :
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
run : |
python setup.py bdist_wheel sdist
twine check dist/*
python -m twine upload dist/*
Expand Down
72 changes: 71 additions & 1 deletion KeeneticPy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,74 @@ def backup(self, maksimum_yedek=5) -> str:

konsol.log(f"[green][+] {zip_dosyasi} başarıyla oluşturuldu!")

return zip_dosyasi
return zip_dosyasi

def get_static_routes(self) -> list[dict[str, str]]:
return self.__oturum.get(
url = f"{self.__rci}",
json = {"show":{"ip":{"route":{}}}}
).json().get("ip", {}).get("route", [])

def add_static_route(self, comment:str, host:str=None, network:str=None, mask:str=None, interface:str="Wireguard2") -> bool:
payload = None

if host:
payload = {
"comment" : comment,
"interface" : interface,
"host" : host
}

if network and mask:
payload = {
"comment" : comment,
"interface" : interface,
"network" : network,
"mask" : mask
}

if not payload:
assert False, "Lütfen host ya da network ve mask bilgisini girin."

istek = self.__oturum.post(
url = f"{self.__rci}",
json = [
{"ip":{"route":payload}},
{"system":{"configuration":{"save":{}}}}
]
)

return istek.status_code == 200

def del_static_route(self, comment:str, host:str=None, network:str=None, mask:str=None, interface:str="Wireguard2") -> bool:
payload = None

if host:
payload = {
"comment" : comment,
"interface" : interface,
"host" : host
}

if network and mask:
payload = {
"comment" : comment,
"interface" : interface,
"network" : network,
"mask" : mask
}

if not payload:
assert False, "Lütfen host ya da network ve mask bilgisini girin."

payload["no"] = True
print(payload)
istek = self.__oturum.post(
url = f"{self.__rci}",
json = [
{"ip":{"route":payload}},
{"system":{"configuration":{"save":{}}}}
]
)

return istek.status_code == 200
60 changes: 39 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
# KeeneticPy

![Repo Boyutu](https://img.shields.io/github/repo-size/keyiflerolsun/KeeneticPy?logo=git&logoColor=white)
![Görüntülenme](https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https://github.com/keyiflerolsun/KeeneticPy&title=Görüntülenme)
[![Boyut](https://img.shields.io/github/repo-size/keyiflerolsun/KeeneticPy?logo=git&logoColor=white&label=Boyut)](#)
[![Görüntülenme](https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https://github.com/keyiflerolsun/KeeneticPy&title=Görüntülenme)](#)
<a href="https://KekikAkademi.org/Kahve" target="_blank"><img src="https://img.shields.io/badge/☕️-Kahve Ismarla-ffdd00" title="☕️ Kahve Ismarla" style="padding-left:5px;"></a>

![Python Version](https://img.shields.io/pypi/pyversions/KeeneticPy?logo=python&logoColor=white)
![License](https://img.shields.io/pypi/l/KeeneticPy?logo=gnu&logoColor=white)
![Status](https://img.shields.io/pypi/status/KeeneticPy?logo=windowsterminal&logoColor=white)
[![PyPI](https://img.shields.io/pypi/v/KeeneticPy?logo=pypi&logoColor=white&label=PyPI)](https://pypi.org/project/KeeneticPy)
[![PyPI - Yüklenme](https://img.shields.io/pypi/dm/KeeneticPy?logo=pypi&logoColor=white&label=Yüklenme)](https://pypi.org/project/KeeneticPy)
[![PyPI - Wheel](https://img.shields.io/pypi/wheel/KeeneticPy?logo=pypi&logoColor=white&label=Wheel)](https://pypi.org/project/KeeneticPy)

![PyPI](https://img.shields.io/pypi/v/KeeneticPy?logo=pypi&logoColor=white)
![PyPI - Downloads](https://img.shields.io/pypi/dm/KeeneticPy?logo=pypi&logoColor=white)
![PyPI - Wheel](https://img.shields.io/pypi/wheel/KeeneticPy?logo=pypi&logoColor=white)
[![Python Version](https://img.shields.io/pypi/pyversions/KeeneticPy?logo=python&logoColor=white&label=Python)](#)
[![Lisans](https://img.shields.io/pypi/l/KeeneticPy?logo=gnu&logoColor=white&label=Lisans)](#)
[![Durum](https://img.shields.io/pypi/status/KeeneticPy?logo=windowsterminal&logoColor=white&label=Durum)](#)

[![PyPI Yükle](https://github.com/keyiflerolsun/KeeneticPy/actions/workflows/pypiYukle.yml/badge.svg)](https://github.com/keyiflerolsun/KeeneticPy/actions/workflows/pypiYukle.yml)

**Python Lib for Keenetic Routers**

> _`RCI` / `PROC`_
[![ForTheBadge made-with-python](http://ForTheBadge.com/images/badges/made-with-python.svg)](https://www.python.org/)
[![ForTheBadge built-with-love](http://ForTheBadge.com/images/badges/built-with-love.svg)](https://GitHub.com/keyiflerolsun/)
[![ForTheBadge made-with-python](https://ForTheBadge.com/images/badges/made-with-python.svg)](https://www.python.org/)
[![ForTheBadge built-with-love](https://ForTheBadge.com/images/badges/built-with-love.svg)](https://GitHub.com/keyiflerolsun/)

## 🚀 Kurulum

Expand All @@ -35,23 +37,39 @@ pip install -U KeeneticPy
from Kekik.cli import konsol
from KeeneticPy import Keenetic

hero = Keenetic(sifre="cokomellisifre")
modem = Keenetic(sifre="cokomellisifre")

modem.backup(maksimum_yedek=2)

konsol.print(modem.system())
konsol.print(modem.version())

konsol.print(modem.interface()["Dsl0"])
konsol.print(modem.interface()["PPPoE0"])

konsol.print(modem.global_ip())

konsol.print("\n".join(modem.dsl_stats()["parse"]["message"]))

konsol.print(modem.hosts())

hero.backup(maksimum_yedek=2)
konsol.print(modem.dsl_reset())

konsol.print(hero.system())
konsol.print(hero.version())
konsol.print(modem.get_static_routes())

konsol.print(hero.interface()["Dsl0"])
konsol.print(hero.interface()["PPPoE0"])
konsol.print(modem.add_static_route(comment="bakalim.io", host="145.53.10.71", interface="Wireguard2"))

konsol.print(hero.global_ip())
konsol.print(modem.add_static_route(comment="bakalim.io", network="145.53.10.0", mask="255.255.255.0", interface="Wireguard2"))

konsol.print("\n".join(hero.dsl_stats()["parse"]["message"]))
konsol.print(modem.del_static_route(comment="bakalim.io", network="145.53.10.0", mask="255.255.255.0", interface="Wireguard2"))

konsol.print(hero.hosts())
konsol.print(modem.del_static_route(comment="bakalim.io", host="145.53.10.71", interface="Wireguard2"))

konsol.print(hero.dsl_reset())
for route in modem.get_static_routes():
konsol.log(route)
if route.get("comment") == "bakalim.io":
konsol.print(modem.del_static_route(**route))
break
```

## 💸 Bağış Yap
Expand All @@ -69,4 +87,4 @@ konsol.print(hero.dsl_reset())

##

> **[@KekikAkademi](https://t.me/KekikAkademi)** *için yazılmıştır..*
> **[@KekikAkademi](https://t.me/KekikAkademi)** *için yazılmıştır..*
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
setup(
# ? Genel Bilgiler
name = "KeeneticPy",
version = "0.6",
version = "0.7",
url = "https://github.com/keyiflerolsun/KeeneticPy",
description = "Python Lib for Keenetic Routers",
keywords = ["KeeneticPy", "KekikAkademi", "keyiflerolsun"],
Expand Down

0 comments on commit 8ace1b7

Please sign in to comment.