Compare commits

...

4 Commits

Author SHA1 Message Date
Vxrtrauter 0686c7aec2 Merge branch 'main' of https://github.com/KeksPirates/SoftwareManager 2026-02-06 17:52:21 +01:00
Vxrtrauter 6be1784903 feat: add functionality to retrieve and bind IP address of network interfaces 2026-02-06 17:50:42 +01:00
Vxrtrauter 4589322f0a feat: initialize network interface state and log interface details 2026-02-05 19:15:39 +01:00
shayaa 8132d789ef Add activity section to README
Added activity section with analytics image to README.
2026-02-05 17:35:38 +01:00
6 changed files with 52 additions and 7 deletions
+3
View File
@@ -27,6 +27,9 @@ SoftwareManager is a Python-based GUI/TUI tool that simplifies downloading and m
- If you want to host your own server, clone the server branch of this repo, enter your cookie for rutracker.org and run server.py. Detailed Instructions on how to get your rutracker cookie are in the README of its branch.
- This tool is for educational purposes only. Use it responsibly.
## Activity
![Alt](https://repobeats.axiom.co/api/embed/3a61ea02ffdeb9ed5dd948d974a21e0d6cfae36c.svg "Repobeats analytics image")
## Star History
+12
View File
@@ -1,4 +1,5 @@
from core.utils.general.logs import consoleLog
from core.utils.data.state import state
import psutil
addrs = psutil.net_if_addrs()
@@ -38,3 +39,14 @@ def list_interfaces() -> None:
status = "INACTIVE"
consoleLog(f"Found Interface: {interface} [{status}]")
def init_interfaces():
state.interfaces = list(addrs.keys())
state.active_interfaces = get_active_interfaces()
def get_interface_ip(interface_name):
if interface_name in addrs:
for addr in addrs[interface_name]:
if addr.family == 2: # ipv4
if not addr.address.startswith("127.") and not addr.address.startswith("169.254"):
return addr.address
return None
+25 -2
View File
@@ -1,5 +1,6 @@
import time
from core.utils.general.wrappers import run_thread
from core.network.interface import get_interface_ip
import threading
import libtorrent as lt
from core.utils.data.state import state
@@ -15,6 +16,7 @@ def init_session():
state.dl_session = lt.session()
settings = {
"upload_rate_limit": state.up_speed_limit,
"download_rate_limit": state.down_speed_limit,
@@ -26,8 +28,15 @@ def init_session():
"connections_limit": state.max_connections,
"active_downloads": state.max_downloads
}
if state.bound_interface:
interface_ip = get_interface_ip(state.bound_interface)
if interface_ip:
settings["outgoing_interfaces"] = interface_ip
settings["listen_interfaces"] = f"{interface_ip}:6881"
consoleLog(f"Binding to Interface IP: {interface_ip}")
else:
consoleLog(f"Error finding IP for Interface {state.bound_interface}")
state.dl_session.apply_settings(settings)
@@ -45,7 +54,6 @@ def add_download(magnet_uri, dl_path=state.download_path):
consoleLog("Skipping, download already running...")
return
magnetdl = lt.parse_magnet_uri(magnet_uri)
magnetdl.save_path = dl_path
@@ -98,6 +106,21 @@ def update_settings():
"connections_limit": state.max_connections,
"active_downloads": state.max_downloads
}
if state.bound_interface:
interface_ip = get_interface_ip(state.bound_interface)
if interface_ip:
settings["outgoing_interfaces"] = interface_ip
settings["listen_interfaces"] = f"{interface_ip}:6881"
consoleLog(f"Binding to Interface IP: {interface_ip}")
else:
consoleLog(f"Error finding IP for Interface {state.bound_interface}")
state.dl_session.apply_settings(settings)
def update_bound_interface():
settings = { "outgoing_interfaces": state.bound_interface }
state.dl_session.apply_settings(settings)
+3
View File
@@ -27,6 +27,9 @@ class AppState(QObject):
self.dl_session: Any = None
self.active_downloads: List[str] = {}
self.window_transparency: bool = False
self.interfaces: List = []
self.active_interfaces: List = []
self.bound_interface: str = None
@property
def image_path(self) -> str:
+8 -4
View File
@@ -6,7 +6,8 @@ from core.utils.general.logs import get_download_logs
from core.utils.general.shutdown import closehelper, shutdown_event
from core.utils.general.wrappers import run_thread
from core.utils.general.loghandler import split_data, check_completed
from core.network.interface import list_interfaces
from core.network.interface import list_interfaces, init_interfaces
from core.network.libtorrent_int import update_bound_interface
from core.utils.config.config import read_config
from PySide6 import QtWidgets
from PySide6.QtCore import Qt
@@ -46,14 +47,17 @@ if __name__ == "__main__":
if args.debug:
state.debug = args.debug # override of read_config
signal.signal(signal.SIGINT, keyboardinterrupthandler)
consoleLog("Started check_completed thread")
consoleLog("Fetching Network Interfaces...")
list_interfaces()
consoleLog("Initialiting Interface variables...")
init_interfaces()
consoleLog(f"Current Bound: {state.bound_interface}")
run_thread(threading.Thread(target=send_notification, args=(shutdown_event,), daemon=True))
consoleLog("Started send_notification thread")
run_thread(threading.Thread(target=update_log, args=(shutdown_event,), daemon=True))
consoleLog("Started update_log thread")
run_thread(threading.Thread(target=check_completed, args=(downloads, state.autoresume)))
consoleLog("Started check_completed thread")
consoleLog("Fetching Network Interfaces...")
list_interfaces()
consoleLog("Launching GUI")
run_gui()
+1 -1
View File
@@ -20,7 +20,7 @@ def get_active_interfaces():
get_active_interfaces()
print(list(addrs.keys()))
# print(addrs)
# print()