Skip to content

Commit

Permalink
fix: fixed id_like field error for debian & others
Browse files Browse the repository at this point in the history
  • Loading branch information
Aviksaikat committed Nov 7, 2024
1 parent 863ba09 commit 8f9ccad
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 38 deletions.
2 changes: 1 addition & 1 deletion src/nipe_py/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@

__all__ = ["Device", "Install", "Status", "Restart", "Start", "Stop"]

__version__ = "0.1.5"
__version__ = "0.1.6"
20 changes: 5 additions & 15 deletions src/nipe_py/engine/Start.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,23 +116,13 @@ def start(self) -> bool:
if t == "nat":
self.target = f"REDIRECT --to-ports {self.transfer_port}"

subprocess.check_call(
f"iptables -t {t} -A OUTPUT -p tcp -j {self.target}", shell=True
)
subprocess.check_call(f"iptables -t {t} -A OUTPUT -p tcp -j {self.target}", shell=True)

subprocess.check_call(
"iptables -t filter -A OUTPUT -p udp -j REJECT", shell=True
)
subprocess.check_call(
"iptables -t filter -A OUTPUT -p icmp -j REJECT", shell=True
)
subprocess.check_call("iptables -t filter -A OUTPUT -p udp -j REJECT", shell=True)
subprocess.check_call("iptables -t filter -A OUTPUT -p icmp -j REJECT", shell=True)

subprocess.check_call(
"sysctl -w net.ipv6.conf.all.disable_ipv6=1 >/dev/null", shell=True
)
subprocess.check_call(
"sysctl -w net.ipv6.conf.default.disable_ipv6=1 >/dev/null", shell=True
)
subprocess.check_call("sysctl -w net.ipv6.conf.all.disable_ipv6=1 >/dev/null", shell=True)
subprocess.check_call("sysctl -w net.ipv6.conf.default.disable_ipv6=1 >/dev/null", shell=True)

return True
except subprocess.CalledProcessError:
Expand Down
13 changes: 4 additions & 9 deletions src/nipe_py/utils/Device.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ def read_release_file() -> namedtuple:
keys, values = zip(
*[
(k.lower(), v.strip("'\""))
for (k, v) in (
line.strip().split("=", 1) for line in f.read().strip().split("\n")
)
for (k, v) in (line.strip().split("=", 1) for line in f.read().strip().split("\n"))
]
)
r = namedtuple("OSRelease", keys)(*values)
Expand All @@ -19,19 +17,16 @@ def read_release_file() -> namedtuple:
class Device:
def __init__(self):
config = read_release_file()
id_like = config.id_like if config.id_like else ""
id_distro = config.id if config.id else "ID"
id_like = getattr(config, "id_like", "")
id_distro = getattr(config, "id", "ID")

self.device = {"username": "debian-tor", "distribution": "debian"}

if "fedora" in id_like.lower() or "fedora" in id_distro.lower():
self.device["username"] = "toranon"
self.device["distribution"] = "fedora"

elif any(
dist in id_like.lower() or dist in id_distro.lower()
for dist in ["arch", "centos"]
):
elif any(dist in id_like.lower() or dist in id_distro.lower() for dist in ["arch", "centos"]):
self.device["username"] = "tor"
self.device["distribution"] = "arch"

Expand Down
16 changes: 3 additions & 13 deletions src/nipe_py/utils/Status.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,13 @@ def __init__(self):
check_tor = "true" if data["IsTor"] else "false"

if check_tor == "true":
print(
Panel.fit(
f"[magenta][+] Status: [green]Active[/green] \n[+] Ip: [/magenta][yellow]{check_ip}"
)
)
print(Panel.fit(f"[magenta][+] Status: [green]Active[/green] \n[+] Ip: [/magenta][yellow]{check_ip}"))
self.status = True
else:
print(
Panel.fit(
f"[magenta][+] Status: [red]Not Active[/red] \n[+] Ip: [/magenta][yellow]{check_ip}"
)
)
print(Panel.fit(f"[magenta][+] Status: [red]Not Active[/red] \n[+] Ip: [/magenta][yellow]{check_ip}"))
self.status = False
else:
print(
Panel.fit(
"[red][!] ERROR: sorry, it was not possible to establish a connection to the server.[/red]"
)
Panel.fit("[red][!] ERROR: sorry, it was not possible to establish a connection to the server.[/red]")
)
self.status = False

0 comments on commit 8f9ccad

Please sign in to comment.