line formatted for better reading
This commit is contained in:
parent
f9ecd54e0a
commit
f6204c9071
31
.idea/workspace.xml
generated
31
.idea/workspace.xml
generated
@ -7,6 +7,10 @@
|
||||
<list default="true" id="940e1630-c825-4d4c-be80-bc11f543c122" name="Changes" comment=" - Update Translate Files">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/cls_mth_fc.py" beforeDir="false" afterPath="$PROJECT_DIR$/cls_mth_fc.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ssl_decrypt.py" beforeDir="false" afterPath="$PROJECT_DIR$/ssl_decrypt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ssl_encrypt.py" beforeDir="false" afterPath="$PROJECT_DIR$/ssl_encrypt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/start_wg.py" beforeDir="false" afterPath="$PROJECT_DIR$/start_wg.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/wirepy.py" beforeDir="false" afterPath="$PROJECT_DIR$/wirepy.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@ -48,6 +52,7 @@
|
||||
"keyToString": {
|
||||
"ASKED_ADD_EXTERNAL_FILES": "true",
|
||||
"Python.INSTALL.executor": "Run",
|
||||
"Python.cls_mth_fc.executor": "Run",
|
||||
"Python.install.executor": "Run",
|
||||
"Python.main.executor": "Run",
|
||||
"Python.messagebox.executor": "Run",
|
||||
@ -55,6 +60,7 @@
|
||||
"Python.testtheme.executor": "Run",
|
||||
"Python.wg_func.executor": "Run",
|
||||
"Python.wg_main.executor": "Run",
|
||||
"Python.wirepy.executor": "Run",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"RunOnceActivity.git.unshallow": "true",
|
||||
"Shell Script.install.executor": "Run",
|
||||
@ -76,7 +82,7 @@
|
||||
<recent name="$PROJECT_DIR$/wire-py" />
|
||||
</key>
|
||||
</component>
|
||||
<component name="RunManager" selected="Python.wg_main">
|
||||
<component name="RunManager" selected="Python.wirepy">
|
||||
<configuration name="start_wg" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
||||
<module name="wire-py" />
|
||||
<option name="ENV_FILES" value="" />
|
||||
@ -121,8 +127,31 @@
|
||||
<option name="INPUT_FILE" value="" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="wirepy" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
||||
<module name="wire-py" />
|
||||
<option name="ENV_FILES" value="" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/wirepy.py" />
|
||||
<option name="PARAMETERS" value="" />
|
||||
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||
<option name="EMULATE_TERMINAL" value="false" />
|
||||
<option name="MODULE_MODE" value="false" />
|
||||
<option name="REDIRECT_INPUT" value="false" />
|
||||
<option name="INPUT_FILE" value="" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<recent_temporary>
|
||||
<list>
|
||||
<item itemvalue="Python.wirepy" />
|
||||
<item itemvalue="Python.start_wg" />
|
||||
</list>
|
||||
</recent_temporary>
|
||||
|
Binary file not shown.
@ -47,9 +47,7 @@ class Create:
|
||||
|
||||
else:
|
||||
sett.touch()
|
||||
sett.write_text(
|
||||
"[UPDATES]\non\n[THEME]\nlight\n[TOOLTIP]\nTrue\n[AUTOSTART ON]\noff\n"
|
||||
)
|
||||
sett.write_text("[UPDATES]\non\n[THEME]\nlight\n[TOOLTIP]\nTrue\n[AUTOSTART ON]\noff\n")
|
||||
|
||||
if ks.exists():
|
||||
pass
|
||||
@ -72,11 +70,9 @@ class Create:
|
||||
|
||||
else:
|
||||
wg_ser.touch()
|
||||
wg_ser.write_text(
|
||||
"[Unit]\nDescription=Automatic Tunnel Start\nAfter=network-online.target"
|
||||
"\n\n[Service]\nType=oneshot\nExecStartPre=/bin/sleep 5\nExecStart=/usr/"
|
||||
"local/bin/start_wg.py\n[Install]\nWantedBy=default.target"
|
||||
)
|
||||
wg_ser.write_text("[Unit]\nDescription=Automatic Tunnel Start\nAfter=network-online.target\n\n[Service]\n"
|
||||
"Type=oneshot\nExecStartPre=/bin/sleep 5\nExecStart=/usr/local/bin/start_wg.py\n[Install]"
|
||||
"\nWantedBy=default.target")
|
||||
check_call(["systemctl", "--user", "enable", "wg_start.service"])
|
||||
|
||||
@staticmethod
|
||||
@ -94,12 +90,8 @@ class Create:
|
||||
"""
|
||||
This start ssl_decrypt file
|
||||
"""
|
||||
process = subprocess.run(
|
||||
["pkexec", "/usr/local/bin/ssl_decrypt.py"],
|
||||
stdout=subprocess.PIPE,
|
||||
text=True,
|
||||
check=True,
|
||||
)
|
||||
process = subprocess.run(["pkexec", "/usr/local/bin/ssl_decrypt.py"], stdout=subprocess.PIPE, text=True,
|
||||
check=True)
|
||||
path = Path.home() / ".config/wire_py/"
|
||||
file_in_path = list(path.rglob("*.dat"))
|
||||
if file_in_path:
|
||||
@ -115,12 +107,8 @@ class Create:
|
||||
"""
|
||||
this start ssl_encrypt file
|
||||
"""
|
||||
process = subprocess.run(
|
||||
["pkexec", "/usr/local/bin/ssl_encrypt.py"],
|
||||
stdout=subprocess.PIPE,
|
||||
text=True,
|
||||
check=True,
|
||||
)
|
||||
process = subprocess.run(["pkexec", "/usr/local/bin/ssl_encrypt.py"], stdout=subprocess.PIPE, text=True,
|
||||
check=True)
|
||||
print(process.stdout)
|
||||
if process.returncode == 0:
|
||||
print("All Files successfully encrypted...")
|
||||
@ -241,9 +229,7 @@ class LxTools(tk.Tk):
|
||||
# End program for certain signals, report to others only reception
|
||||
if signum in (signal.SIGINT, signal.SIGTERM):
|
||||
exit_code = 1
|
||||
print(
|
||||
f"\nSignal {signame} {(signum)} received. => Aborting with exit code {exit_code}."
|
||||
)
|
||||
print(f"\nSignal {signame} {(signum)} received. => Aborting with exit code {exit_code}.")
|
||||
LxTools.clean_files(dirname, file)
|
||||
print("Breakdown by user...")
|
||||
sys.exit(exit_code)
|
||||
@ -380,11 +366,7 @@ class Tunnel:
|
||||
"""
|
||||
Shows the Active Tunnel
|
||||
"""
|
||||
active = (
|
||||
os.popen('nmcli con show --active | grep -iPo "(.*)(wireguard)"')
|
||||
.read()
|
||||
.split()
|
||||
)
|
||||
active = (os.popen('nmcli con show --active | grep -iPo "(.*)(wireguard)"').read().split())
|
||||
if not active:
|
||||
active = ""
|
||||
else:
|
||||
@ -485,16 +467,8 @@ class Tooltip:
|
||||
tw.wm_overrideredirect(True)
|
||||
tw.wm_geometry(f"+{x}+{y}")
|
||||
|
||||
label = tk.Label(
|
||||
tw,
|
||||
text=self.text,
|
||||
background="lightgreen",
|
||||
foreground="black",
|
||||
relief="solid",
|
||||
borderwidth=1,
|
||||
padx=5,
|
||||
pady=5,
|
||||
)
|
||||
label = tk.Label(tw, text=self.text, background="lightgreen", foreground="black", relief="solid", borderwidth=1,
|
||||
padx=5, pady=5)
|
||||
label.grid()
|
||||
|
||||
def hide_tooltip(self, event=None):
|
||||
|
@ -18,19 +18,7 @@ PKEYFILE = "/usr/local/etc/ssl/pwgk.pem"
|
||||
|
||||
if not keyfile.is_file():
|
||||
|
||||
check_call(
|
||||
[
|
||||
"openssl",
|
||||
"rsa",
|
||||
"-in",
|
||||
PKEYFILE,
|
||||
"-out",
|
||||
keyfile,
|
||||
"-outform",
|
||||
"PEM",
|
||||
"-pubout",
|
||||
]
|
||||
)
|
||||
check_call(["openssl", "rsa", "-in", PKEYFILE, "-out", keyfile, "-outform", "PEM", "-pubout"])
|
||||
shutil.chown(keyfile, 1000, 1000)
|
||||
|
||||
dirname2 = f"/home/{logname}/.config/wire_py/"
|
||||
@ -43,17 +31,5 @@ if os.path.exists(f"{dirname2}pbwgk.pem"):
|
||||
for detunnels in detl:
|
||||
tlname2 = f"{detunnels[:-4]}.conf"
|
||||
extpath = f"{dirname}/{tlname2}"
|
||||
check_call(
|
||||
[
|
||||
"openssl",
|
||||
"pkeyutl",
|
||||
"-decrypt",
|
||||
"-inkey",
|
||||
PKEYFILE,
|
||||
"-in",
|
||||
detunnels,
|
||||
"-out",
|
||||
extpath,
|
||||
]
|
||||
)
|
||||
check_call(["openssl", "pkeyutl", "-decrypt", "-inkey", PKEYFILE, "-in", detunnels, "-out", extpath])
|
||||
shutil.chown(extpath, 1000, 1000)
|
||||
|
@ -17,19 +17,7 @@ PKEYFILE = "/usr/local/etc/ssl/pwgk.pem"
|
||||
|
||||
if not keyfile.is_file():
|
||||
|
||||
check_call(
|
||||
[
|
||||
"openssl",
|
||||
"rsa",
|
||||
"-in",
|
||||
PKEYFILE,
|
||||
"-out",
|
||||
keyfile,
|
||||
"-outform",
|
||||
"PEM",
|
||||
"-pubout",
|
||||
]
|
||||
)
|
||||
check_call(["openssl", "rsa", "-in", PKEYFILE, "-out", keyfile, "-outform", "PEM", "-pubout"])
|
||||
shutil.chown(keyfile, 1000, 1000)
|
||||
|
||||
if dirname.exists():
|
||||
@ -41,20 +29,8 @@ if not keyfile.is_file():
|
||||
for tunnels in tl:
|
||||
sourcetl = f"{dirname}/{tunnels}"
|
||||
tlname = f"{CRYPTFILES}{tunnels[:-5]}.dat"
|
||||
check_call(
|
||||
[
|
||||
"openssl",
|
||||
"pkeyutl",
|
||||
"-encrypt",
|
||||
"-inkey",
|
||||
keyfile,
|
||||
"-pubin",
|
||||
"-in",
|
||||
sourcetl,
|
||||
"-out",
|
||||
tlname,
|
||||
]
|
||||
)
|
||||
check_call(["openssl", "pkeyutl", "-encrypt", "-inkey", keyfile, "-pubin", "-in", sourcetl, "-out",
|
||||
tlname,])
|
||||
|
||||
else:
|
||||
|
||||
@ -68,16 +44,4 @@ else:
|
||||
sourcetl = f"{dirname}/{tunnels}"
|
||||
tlname = f"{CRYPTFILES}{tunnels[:-5]}.dat"
|
||||
check_call(
|
||||
[
|
||||
"openssl",
|
||||
"pkeyutl",
|
||||
"-encrypt",
|
||||
"-inkey",
|
||||
keyfile,
|
||||
"-pubin",
|
||||
"-in",
|
||||
sourcetl,
|
||||
"-out",
|
||||
tlname,
|
||||
]
|
||||
)
|
||||
["openssl", "pkeyutl", "-encrypt", "-inkey", keyfile, "-pubin", "-in", sourcetl, "-out", tlname])
|
||||
|
@ -9,7 +9,7 @@ path_to_file = Path(Path.home() / ".config/wire_py/settings")
|
||||
|
||||
with open(path_to_file, "r", encoding="utf-8") as a_con:
|
||||
|
||||
# This funtion is for the independent autostart of the previously selected tunnel
|
||||
# This function is for the independent autostarted of the previously selected tunnel
|
||||
lines = a_con.readlines()
|
||||
a_con = lines[7].strip()
|
||||
if a_con != "off":
|
||||
|
326
wirepy.py
326
wirepy.py
@ -30,9 +30,7 @@ userfile = Path("/tmp/.loguser")
|
||||
# 1 = 1. Year, 09 = Month of the Year, 2924 = Day and Year of the Year
|
||||
VERSION = "v. 2.04.1725"
|
||||
|
||||
res = GiteaUpdate.api_down(
|
||||
"https://git.ilunix.de/api/v1/repos/punix/Wire-Py/releases", VERSION, set_file
|
||||
)
|
||||
res = GiteaUpdate.api_down("https://git.ilunix.de/api/v1/repos/punix/Wire-Py/releases", VERSION, set_file)
|
||||
|
||||
# Translate
|
||||
APP = "wirepy"
|
||||
@ -60,9 +58,7 @@ class Wirepy(tk.Tk):
|
||||
self.monitor_center_y = int(self.winfo_screenheight() / 2 - (self.y_height / 2))
|
||||
self.resizable(width=False, height=False)
|
||||
self.title("Wire-Py")
|
||||
self.geometry(
|
||||
f"{self.x_width}x{self.y_height}+{self.monitor_center_x}+{self.monitor_center_y}"
|
||||
)
|
||||
self.geometry(f"{self.x_width}x{self.y_height}+{self.monitor_center_x}+{self.monitor_center_y}")
|
||||
self.columnconfigure(0, weight=1)
|
||||
self.rowconfigure(0, weight=1)
|
||||
|
||||
@ -98,22 +94,14 @@ class FrameWidgets(ttk.Frame):
|
||||
self.dns = None
|
||||
self.address = None
|
||||
self.auto_con = None
|
||||
self.wg_vpn_start = tk.PhotoImage(
|
||||
file=r"/usr/share/icons/lx-icons/48/wg_vpn-start.png"
|
||||
)
|
||||
self.wg_vpn_stop = tk.PhotoImage(
|
||||
file=r"/usr/share/icons/lx-icons/48/wg_vpn-stop.png"
|
||||
)
|
||||
self.wg_vpn_start = tk.PhotoImage(file=r"/usr/share/icons/lx-icons/48/wg_vpn-start.png")
|
||||
self.wg_vpn_stop = tk.PhotoImage(file=r"/usr/share/icons/lx-icons/48/wg_vpn-stop.png")
|
||||
self.imp_pic = tk.PhotoImage(file=r"/usr/share/icons/lx-icons/48/wg_import.png")
|
||||
self.tr_pic = tk.PhotoImage(file=r"/usr/share/icons/lx-icons/48/wg_trash.png")
|
||||
self.exp_pic = tk.PhotoImage(file=r"/usr/share/icons/lx-icons/48/wg_export.png")
|
||||
self.warning_pic = tk.PhotoImage(file=r"/usr/share/icons/lx-icons/64/error.png")
|
||||
self.wg_vpn_start = tk.PhotoImage(
|
||||
file=r"/usr/share/icons/lx-icons/48/wg_vpn-start.png"
|
||||
)
|
||||
self.wg_vpn_stop = tk.PhotoImage(
|
||||
file=r"/usr/share/icons/lx-icons/48/wg_vpn-stop.png"
|
||||
)
|
||||
self.wg_vpn_start = tk.PhotoImage(file=r"/usr/share/icons/lx-icons/48/wg_vpn-start.png")
|
||||
self.wg_vpn_stop = tk.PhotoImage(file=r"/usr/share/icons/lx-icons/48/wg_vpn-stop.png")
|
||||
|
||||
def update():
|
||||
"""
|
||||
@ -185,12 +173,10 @@ class FrameWidgets(ttk.Frame):
|
||||
iw = r"/usr/share/icons/lx-icons/48/wg_vpn.png"
|
||||
ii = r"/usr/share/icons/lx-icons/48/wg_msg.png"
|
||||
wt = _("Info")
|
||||
msg_t = _(
|
||||
"Wire-Py a simple Wireguard Gui for Linux systems.\n\n"
|
||||
"Wire-Py is open source software written in Python.\n\n"
|
||||
"Email: polunga40@unity-mail.de also likes for donation.\n\n"
|
||||
"Use without warranty!\n"
|
||||
)
|
||||
msg_t = _("Wire-Py a simple Wireguard Gui for Linux systems.\n\n"
|
||||
"Wire-Py is open source software written in Python.\n\n"
|
||||
"Email: polunga40@unity-mail.de also likes for donation.\n\n"
|
||||
"Use without warranty!\n")
|
||||
txt2 = _("Go to Wire-Py git")
|
||||
com = link_btn
|
||||
|
||||
@ -217,12 +203,8 @@ class FrameWidgets(ttk.Frame):
|
||||
set_tip = tk.BooleanVar()
|
||||
self.settings = tk.Menu(self, relief="flat")
|
||||
self.options_btn.configure(menu=self.settings, style="Toolbutton")
|
||||
self.settings.add_checkbutton(
|
||||
label=_("Disable Updates"), command=update, variable=set_update
|
||||
)
|
||||
self.settings.add_checkbutton(
|
||||
label=_("Disable Tooltips"), command=tooltip, variable=set_tip
|
||||
)
|
||||
self.settings.add_checkbutton(label=_("Disable Updates"), command=update, variable=set_update)
|
||||
self.settings.add_checkbutton(label=_("Disable Tooltips"), command=tooltip, variable=set_tip)
|
||||
self.settings.add_command(label=_("Light"), command=theme_change_light)
|
||||
self.settings.add_command(label=_("Dark"), command=theme_change_dark)
|
||||
|
||||
@ -272,13 +254,9 @@ class FrameWidgets(ttk.Frame):
|
||||
self.update_btn.configure(menu=self.download, style="Toolbutton")
|
||||
self.download.add_command(
|
||||
label=_("Download"),
|
||||
command=lambda: GiteaUpdate.download(
|
||||
f"https://git.ilunix.de/punix/Wire-Py/archive/{res}.zip",
|
||||
r"/usr/share/icons/lx-icons/48/wg_vpn.png",
|
||||
r"/usr/share/icons/lx-icons/48/wg_msg.png",
|
||||
res,
|
||||
),
|
||||
)
|
||||
command=lambda: GiteaUpdate.download(f"https://git.ilunix.de/punix/Wire-Py/archive/{res}.zip",
|
||||
r"/usr/share/icons/lx-icons/48/wg_vpn.png",
|
||||
r"/usr/share/icons/lx-icons/48/wg_msg.png", res))
|
||||
|
||||
# Show active Tunnel
|
||||
self.a = Tunnel.active()
|
||||
@ -301,8 +279,7 @@ class FrameWidgets(ttk.Frame):
|
||||
# Bottom Frame 4
|
||||
self.lb_frame3 = ttk.Frame(self)
|
||||
self.lb_frame3.configure(relief="flat")
|
||||
self.lb_frame3.grid(column=0, row=5, columnspan=4, sticky="snew",
|
||||
padx=2, pady=2)
|
||||
self.lb_frame3.grid(column=0, row=5, columnspan=4, sticky="snew", padx=2, pady=2)
|
||||
|
||||
# Bottom Frame 5
|
||||
self.lb_frame4 = ttk.Frame(self)
|
||||
@ -346,9 +323,7 @@ class FrameWidgets(ttk.Frame):
|
||||
self.l_box.grid(column=1, rowspan=4, row=0, sticky="ns")
|
||||
self.l_box.event_add("<<ClickEvent>>", "<Button-1>")
|
||||
self.l_box.bind("<<ClickEvent>>", enable_check_box)
|
||||
self.scrollbar = ttk.Scrollbar(
|
||||
self.lb_frame_btn_lbox, orient="vertical", command=self.l_box.yview
|
||||
)
|
||||
self.scrollbar = ttk.Scrollbar(self.lb_frame_btn_lbox, orient="vertical", command=self.l_box.yview)
|
||||
self.scrollbar.grid(column=1, rowspan=4, row=0, sticky="nse")
|
||||
self.l_box.configure(yscrollcommand=self.scrollbar.set)
|
||||
|
||||
@ -379,8 +354,7 @@ class FrameWidgets(ttk.Frame):
|
||||
self.show_data()
|
||||
|
||||
# Button Import
|
||||
self.btn_i = ttk.Button(self.lb_frame_btn_lbox, image=self.imp_pic,
|
||||
command=self.import_sl, padding=0)
|
||||
self.btn_i = ttk.Button(self.lb_frame_btn_lbox, image=self.imp_pic, command=self.import_sl, padding=0)
|
||||
self.btn_i.grid(column=0, row=1, padx=15, pady=8)
|
||||
|
||||
Tooltip(self.btn_i, _("Click to import a Wireguard Tunnel"), tips)
|
||||
@ -392,8 +366,7 @@ class FrameWidgets(ttk.Frame):
|
||||
try:
|
||||
self.select_tunnel = self.l_box.curselection()
|
||||
select_tl = self.l_box.get(self.select_tunnel[0])
|
||||
with open(f"/tmp/tlecdcwg/{select_tl}.conf", "r+", encoding="utf-8"
|
||||
) as file2:
|
||||
with open(f"/tmp/tlecdcwg/{select_tl}.conf", "r+", encoding="utf-8") as file2:
|
||||
key = Tunnel.con_to_dict(file2)
|
||||
pre_key = key[3]
|
||||
check_call(["nmcli", "connection", "delete", select_tl])
|
||||
@ -427,7 +400,8 @@ class FrameWidgets(ttk.Frame):
|
||||
if self.l_box.size() == 0:
|
||||
self.wg_autostart.configure(state="disabled")
|
||||
self.lb_rename.configure(state="disabled")
|
||||
Tooltip(self.wg_autostart, _("You must have at least one\ntunnel in the list,to use the autostart"), tips)
|
||||
Tooltip(self.wg_autostart, _("You must have at least one\ntunnel in the list,to use the autostart")
|
||||
, tips)
|
||||
|
||||
Tooltip(self.btn_exp, _("No Tunnels in List for Export"), tips)
|
||||
Tooltip(self.btn_stst, _("No tunnels to start in the list"), tips)
|
||||
@ -465,36 +439,23 @@ class FrameWidgets(ttk.Frame):
|
||||
LxTools.msg_window(iw, ii, wt, msg_t)
|
||||
|
||||
# Button Trash
|
||||
self.btn_tr = ttk.Button(
|
||||
self.lb_frame_btn_lbox,
|
||||
image=self.tr_pic,
|
||||
command=delete,
|
||||
padding=0,
|
||||
style="CButton.TButton",
|
||||
)
|
||||
self.btn_tr = ttk.Button(self.lb_frame_btn_lbox, image=self.tr_pic, command=delete, padding=0,
|
||||
style="CButton.TButton")
|
||||
self.btn_tr.grid(column=0, row=2, padx=15, pady=8)
|
||||
|
||||
if self.l_box.size() == 0:
|
||||
Tooltip(self.btn_tr, _("No tunnels to delete in the list"), tips)
|
||||
else:
|
||||
Tooltip(self.btn_tr, _("Click to delete a Wireguard Tunnel\nSelect from the list!"),
|
||||
tips,
|
||||
)
|
||||
Tooltip(self.btn_tr, _("Click to delete a Wireguard Tunnel\nSelect from the list!"), tips)
|
||||
|
||||
# Button Export
|
||||
self.btn_exp = ttk.Button(
|
||||
self.lb_frame_btn_lbox, image=self.exp_pic, command=Tunnel.export, padding=0
|
||||
)
|
||||
self.btn_exp = ttk.Button(self.lb_frame_btn_lbox, image=self.exp_pic, command=Tunnel.export, padding=0)
|
||||
self.btn_exp.grid(column=0, row=3, padx=15, pady=8)
|
||||
|
||||
if self.l_box.size() == 0:
|
||||
Tooltip(self.btn_exp, _("No Tunnels in List for Export"), tips)
|
||||
else:
|
||||
Tooltip(
|
||||
self.btn_exp,
|
||||
_("Click to export all\nWireguard Tunnel to Zipfile"),
|
||||
tips,
|
||||
)
|
||||
Tooltip(self.btn_exp, _("Click to export all\nWireguard Tunnel to Zipfile"), tips)
|
||||
|
||||
# Label Entry
|
||||
self.lb_rename = ttk.Entry(self.lb_frame4, width=20)
|
||||
@ -503,17 +464,9 @@ class FrameWidgets(ttk.Frame):
|
||||
self.lb_rename.config(state="disable")
|
||||
|
||||
if self.l_box.size() != 0:
|
||||
Tooltip(
|
||||
self.lb_rename,
|
||||
_("To rename a tunnel, you need to\nselect a tunnel from the list"),
|
||||
tips,
|
||||
)
|
||||
Tooltip(self.lb_rename, _("To rename a tunnel, you need to\nselect a tunnel from the list"), tips)
|
||||
else:
|
||||
Tooltip(
|
||||
self.lb_rename,
|
||||
_("To rename a tunnel, at least one must be in the list"),
|
||||
tips,
|
||||
)
|
||||
Tooltip(self.lb_rename, _("To rename a tunnel, at least one must be in the list"), tips)
|
||||
|
||||
def tl_rename():
|
||||
|
||||
@ -543,9 +496,7 @@ class FrameWidgets(ttk.Frame):
|
||||
iw = r"/usr/share/icons/lx-icons/64/info.png"
|
||||
ii = r"/usr/share/icons/lx-icons/48/wg_msg.png"
|
||||
wt = _("Renaming not possible")
|
||||
msg_t = _(
|
||||
"No valid sign. These must not be used.\nBlank, Slash, Backslash and { }\n"
|
||||
)
|
||||
msg_t = _("No valid sign. These must not be used.\nBlank, Slash, Backslash and { }\n")
|
||||
LxTools.msg_window(iw, ii, wt, msg_t)
|
||||
|
||||
else:
|
||||
@ -555,16 +506,7 @@ class FrameWidgets(ttk.Frame):
|
||||
select_tl = self.l_box.get(self.select_tunnel[0])
|
||||
|
||||
# nmcli connection modify old connection.id iphone
|
||||
check_call(
|
||||
[
|
||||
"nmcli",
|
||||
"connection",
|
||||
"modify",
|
||||
select_tl,
|
||||
"connection.id",
|
||||
self.lb_rename.get(),
|
||||
]
|
||||
)
|
||||
check_call(["nmcli", "connection", "modify", select_tl, "connection.id", self.lb_rename.get()])
|
||||
source = Path(f"/tmp/tlecdcwg/{select_tl}.conf")
|
||||
destination = source.with_name(f"{self.lb_rename.get()}.conf")
|
||||
source.replace(destination)
|
||||
@ -580,10 +522,7 @@ class FrameWidgets(ttk.Frame):
|
||||
self.str_var.set(value=self.a)
|
||||
with open(set_file, "r", encoding="utf-8") as set_f5:
|
||||
lines5 = set_f5.readlines()
|
||||
if (
|
||||
select_tl == lines5[7].strip()
|
||||
and "off\n" not in lines5[7].strip()
|
||||
):
|
||||
if select_tl == lines5[7].strip() and "off\n" not in lines5[7].strip():
|
||||
lines5[7] = new_a_connect
|
||||
with open(set_file, "w", encoding="utf-8") as theme_set5:
|
||||
theme_set5.writelines(lines5)
|
||||
@ -601,14 +540,8 @@ class FrameWidgets(ttk.Frame):
|
||||
LxTools.msg_window(iw, ii, wt, msg_t)
|
||||
|
||||
# Button Rename
|
||||
self.btn_rename = ttk.Button(
|
||||
self.lb_frame4,
|
||||
text=_("Rename"),
|
||||
state="disable",
|
||||
command=tl_rename,
|
||||
padding=4,
|
||||
style="RnButton.TButton",
|
||||
)
|
||||
self.btn_rename = ttk.Button(self.lb_frame4, text=_("Rename"), state="disable", command=tl_rename, padding=4,
|
||||
style="RnButton.TButton")
|
||||
self.btn_rename.grid(column=3, row=0, padx=5, pady=10, sticky="ne")
|
||||
|
||||
# Check Buttons
|
||||
@ -617,40 +550,22 @@ class FrameWidgets(ttk.Frame):
|
||||
self.autoconnect_var.set(self.auto_con)
|
||||
|
||||
# Frame for Labels, Entry and Button
|
||||
self.autoconnect = ttk.Label(
|
||||
self.lb_frame3, textvariable=self.autoconnect_var, width=15
|
||||
)
|
||||
self.autoconnect = ttk.Label(self.lb_frame3, textvariable=self.autoconnect_var, width=15)
|
||||
self.autoconnect.config(font=("Ubuntu", 11))
|
||||
self.autoconnect.grid(column=1, row=0, sticky="e", pady=19)
|
||||
self.wg_autostart = ttk.Checkbutton(
|
||||
self.lb_frame3,
|
||||
text=_("Autoconnect on:"),
|
||||
variable=self.selected_option,
|
||||
command=self.box_set,
|
||||
)
|
||||
self.wg_autostart = ttk.Checkbutton(self.lb_frame3, text=_("Autoconnect on:"), variable=self.selected_option,
|
||||
command=self.box_set)
|
||||
self.wg_autostart.grid(column=0, row=0, pady=15, padx=15, sticky="nw")
|
||||
|
||||
if self.l_box.size() >= 1 and len(self.l_box.curselection()) >= 1:
|
||||
Tooltip(
|
||||
self.wg_autostart, _("To use the autostart, enable this Checkbox"), tips
|
||||
)
|
||||
Tooltip(self.wg_autostart, _("To use the autostart, enable this Checkbox"), tips)
|
||||
|
||||
if self.l_box.size() == 0:
|
||||
Tooltip(
|
||||
self.wg_autostart,
|
||||
_(
|
||||
"You must have at least one\ntunnel in the list,to use the autostart"
|
||||
),
|
||||
tips,
|
||||
)
|
||||
Tooltip(self.wg_autostart, _("You must have at least one\ntunnel in the list,to use the autostart"), tips)
|
||||
|
||||
else:
|
||||
|
||||
Tooltip(
|
||||
self.wg_autostart,
|
||||
_("To use the autostart, a tunnel must be selected from the list"),
|
||||
tips,
|
||||
)
|
||||
Tooltip(self.wg_autostart, _("To use the autostart, a tunnel must be selected from the list"), tips)
|
||||
|
||||
self.on_off()
|
||||
|
||||
@ -672,11 +587,8 @@ class FrameWidgets(ttk.Frame):
|
||||
Create.dir_and_files()
|
||||
|
||||
try:
|
||||
filepath = filedialog.askopenfilename(
|
||||
initialdir=f"{Path.home()}",
|
||||
title=_("Select Wireguard config File"),
|
||||
filetypes=[(_("WG config files"), "*.conf")],
|
||||
)
|
||||
filepath = filedialog.askopenfilename(initialdir=f"{Path.home()}", title=_("Select Wireguard config File"),
|
||||
filetypes=[(_("WG config files"), "*.conf")])
|
||||
|
||||
with open(filepath, "r", encoding="utf-8") as file:
|
||||
read = file.read()
|
||||
@ -684,11 +596,7 @@ class FrameWidgets(ttk.Frame):
|
||||
path_split1 = path_split[-1]
|
||||
self.a = Tunnel.active()
|
||||
|
||||
if (
|
||||
"PrivateKey = " in read
|
||||
and "PublicKey = " in read
|
||||
and "Endpoint =" in read
|
||||
):
|
||||
if "PrivateKey = " in read and "PublicKey = " in read and "Endpoint =" in read:
|
||||
with open(filepath, "r", encoding="utf-8") as file:
|
||||
key = Tunnel.con_to_dict(file)
|
||||
pre_key = key[3]
|
||||
@ -701,9 +609,7 @@ class FrameWidgets(ttk.Frame):
|
||||
iw = r"/usr/share/icons/lx-icons/64/error.png"
|
||||
ii = r"/usr/share/icons/lx-icons/48/wg_msg.png"
|
||||
wt = _("Import Error")
|
||||
msg_t = _(
|
||||
"Tunnel already available!\nPlease use another file for import"
|
||||
)
|
||||
msg_t = _("Tunnel already available!\nPlease use another file for import")
|
||||
LxTools.msg_window(iw, ii, wt, msg_t)
|
||||
|
||||
else:
|
||||
@ -712,64 +618,26 @@ class FrameWidgets(ttk.Frame):
|
||||
keyfile.write(f"{pre_key}\r")
|
||||
if len(path_split1) > 17:
|
||||
p1 = shutil.copy(filepath, "/tmp/tlecdcwg/")
|
||||
path_split = path_split1[
|
||||
len(path_split1) - 17:
|
||||
]
|
||||
os.rename(
|
||||
p1, f"/tmp/tlecdcwg/{path_split}"
|
||||
)
|
||||
path_split = path_split1[len(path_split1) - 17:]
|
||||
os.rename(p1, f"/tmp/tlecdcwg/{path_split}")
|
||||
new_conf = f"/tmp/tlecdcwg/{path_split}"
|
||||
if self.a != "":
|
||||
check_call(
|
||||
[
|
||||
"nmcli",
|
||||
"connection",
|
||||
"down",
|
||||
Tunnel.active(),
|
||||
]
|
||||
)
|
||||
check_call(["nmcli", "connection", "down", Tunnel.active()])
|
||||
self.label_empty()
|
||||
|
||||
subprocess.check_output(
|
||||
[
|
||||
"nmcli",
|
||||
"connection",
|
||||
"import",
|
||||
"type",
|
||||
"wireguard",
|
||||
"file",
|
||||
new_conf,
|
||||
],
|
||||
text=True,
|
||||
)
|
||||
subprocess.check_output(["nmcli", "connection", "import", "type",
|
||||
"wireguard", "file", new_conf], text=True)
|
||||
|
||||
Create.encrypt()
|
||||
|
||||
else:
|
||||
shutil.copy(filepath, "/tmp/tlecdcwg/")
|
||||
if self.a != "":
|
||||
check_call(
|
||||
[
|
||||
"nmcli",
|
||||
"connection",
|
||||
"down",
|
||||
Tunnel.active(),
|
||||
]
|
||||
)
|
||||
check_call(["nmcli", "connection", "down", Tunnel.active()])
|
||||
self.label_empty()
|
||||
|
||||
subprocess.check_output(
|
||||
[
|
||||
"nmcli",
|
||||
"connection",
|
||||
"import",
|
||||
"type",
|
||||
"wireguard",
|
||||
"file",
|
||||
filepath,
|
||||
],
|
||||
text=True,
|
||||
)
|
||||
subprocess.check_output(["nmcli", "connection", "import", "type",
|
||||
"wireguard", "file", filepath], text=True)
|
||||
|
||||
Create.encrypt()
|
||||
|
||||
@ -781,40 +649,18 @@ class FrameWidgets(ttk.Frame):
|
||||
self.l_box.update()
|
||||
self.l_box.selection_set(0)
|
||||
|
||||
Tooltip(
|
||||
self.wg_autostart,
|
||||
_("To use the autostart, enable this Checkbox"),
|
||||
tips,
|
||||
)
|
||||
Tooltip(self.wg_autostart, _("To use the autostart, enable this Checkbox"), tips)
|
||||
|
||||
# Tooltip(self.l_box, _("List of available tunnels"))
|
||||
|
||||
Tooltip(
|
||||
self.btn_tr,
|
||||
_(
|
||||
"Click to delete a Wireguard Tunnel\n"
|
||||
"Select from the list!"
|
||||
),
|
||||
tips,
|
||||
)
|
||||
Tooltip(self.btn_tr, _("Click to delete a Wireguard Tunnel\nSelect from the list!")
|
||||
, tips,)
|
||||
|
||||
Tooltip(
|
||||
self.btn_exp,
|
||||
_(
|
||||
" Click to export all\n"
|
||||
"Wireguard Tunnel to Zipfile"
|
||||
),
|
||||
tips,
|
||||
)
|
||||
Tooltip(self.btn_exp, _(" Click to export all\nWireguard Tunnel to Zipfile")
|
||||
, tips)
|
||||
|
||||
Tooltip(
|
||||
self.btn_rename,
|
||||
_(
|
||||
"To rename a tunnel, you need to\n"
|
||||
"select a tunnel from the list"
|
||||
),
|
||||
tips,
|
||||
)
|
||||
Tooltip(self.btn_rename, _("To rename a tunnel, you need to\nselect a tunnel from"
|
||||
" the list"), tips)
|
||||
|
||||
self.lb_rename.insert(0, "Max. 12 characters!")
|
||||
self.str_var = tk.StringVar()
|
||||
@ -822,24 +668,13 @@ class FrameWidgets(ttk.Frame):
|
||||
self.color_label()
|
||||
self.stop()
|
||||
wg_read = f"/tmp/tlecdcwg/{self.a}.conf"
|
||||
with open(
|
||||
wg_read, "r", encoding="utf-8"
|
||||
) as file_for_key:
|
||||
with open(wg_read, "r", encoding="utf-8") as file_for_key:
|
||||
data = Tunnel.con_to_dict(file_for_key)
|
||||
|
||||
# Address Label
|
||||
self.init_and_report(data)
|
||||
self.show_data()
|
||||
check_call(
|
||||
[
|
||||
"nmcli",
|
||||
"con",
|
||||
"mod",
|
||||
self.a,
|
||||
"connection.autoconnect",
|
||||
"no",
|
||||
]
|
||||
)
|
||||
check_call(["nmcli", "con", "mod", self.a, "connection.autoconnect", "no"])
|
||||
Path.chmod(wg_read, 0o600)
|
||||
|
||||
if ("PrivateKey = " in read) and ("Endpoint = " in read):
|
||||
@ -850,9 +685,7 @@ class FrameWidgets(ttk.Frame):
|
||||
iw = r"/usr/share/icons/lx-icons/64/error.png"
|
||||
ii = r"/usr/share/icons/lx-icons/48/wg_msg.png"
|
||||
wt = _("Import Error")
|
||||
msg_t = _(
|
||||
"Oh... no valid Wireguard File!\nPlease select a valid Wireguard File"
|
||||
)
|
||||
msg_t = _("Oh... no valid Wireguard File!\nPlease select a valid Wireguard File")
|
||||
LxTools.msg_window(iw, ii, wt, msg_t)
|
||||
|
||||
except EOFError as e:
|
||||
@ -921,12 +754,7 @@ class FrameWidgets(ttk.Frame):
|
||||
self.autoconnect_var = tk.StringVar()
|
||||
self.autoconnect_var.set(self.auto_con)
|
||||
|
||||
self.autoconnect = ttk.Label(
|
||||
self.lb_frame3,
|
||||
textvariable=self.autoconnect_var,
|
||||
foreground="#0071ff",
|
||||
width=15,
|
||||
)
|
||||
self.autoconnect = ttk.Label(self.lb_frame3, textvariable=self.autoconnect_var, foreground="#0071ff", width=15)
|
||||
self.autoconnect.config(font=("Ubuntu", 11))
|
||||
self.autoconnect.grid(column=1, row=0, sticky="e", pady=19)
|
||||
|
||||
@ -958,9 +786,7 @@ class FrameWidgets(ttk.Frame):
|
||||
"""
|
||||
|
||||
# Address Label
|
||||
self.address = ttk.Label(
|
||||
self.lb_frame, textvariable=self.add, foreground="#0071ff"
|
||||
)
|
||||
self.address = ttk.Label(self.lb_frame, textvariable=self.add, foreground="#0071ff")
|
||||
self.address.grid(column=0, row=5, sticky="w", padx=10, pady=6)
|
||||
self.address.config(font=("Ubuntu", 9))
|
||||
|
||||
@ -970,9 +796,7 @@ class FrameWidgets(ttk.Frame):
|
||||
self.dns.config(font=("Ubuntu", 9))
|
||||
|
||||
# Endpoint Label
|
||||
self.endpoint = ttk.Label(
|
||||
self.lb_frame2, textvariable=self.enp, foreground="#0071ff"
|
||||
)
|
||||
self.endpoint = ttk.Label(self.lb_frame2, textvariable=self.enp, foreground="#0071ff")
|
||||
self.endpoint.grid(column=0, row=8, sticky="w", padx=10, pady=20)
|
||||
self.endpoint.config(font=("Ubuntu", 9))
|
||||
|
||||
@ -980,12 +804,7 @@ class FrameWidgets(ttk.Frame):
|
||||
"""
|
||||
Stop Button
|
||||
"""
|
||||
self.btn_stst = ttk.Button(
|
||||
self.lb_frame_btn_lbox,
|
||||
image=self.wg_vpn_stop,
|
||||
command=self.wg_switch,
|
||||
padding=0,
|
||||
)
|
||||
self.btn_stst = ttk.Button(self.lb_frame_btn_lbox, image=self.wg_vpn_stop, command=self.wg_switch, padding=0)
|
||||
self.btn_stst.grid(column=0, row=0, padx=5, pady=8)
|
||||
|
||||
Tooltip(self.btn_stst, _("Click to stop selected Wireguard Tunnel"), tips)
|
||||
@ -994,12 +813,7 @@ class FrameWidgets(ttk.Frame):
|
||||
"""
|
||||
Start Button
|
||||
"""
|
||||
self.btn_stst = ttk.Button(
|
||||
self.lb_frame_btn_lbox,
|
||||
image=self.wg_vpn_start,
|
||||
command=self.wg_switch,
|
||||
padding=0,
|
||||
)
|
||||
self.btn_stst = ttk.Button(self.lb_frame_btn_lbox, image=self.wg_vpn_start, command=self.wg_switch, padding=0)
|
||||
self.btn_stst.grid(column=0, row=0, padx=5, pady=8)
|
||||
|
||||
tl = Tunnel.list()
|
||||
@ -1016,14 +830,10 @@ class FrameWidgets(ttk.Frame):
|
||||
with open(set_file, "r", encoding="utf-8") as read_file:
|
||||
lines = read_file.readlines()
|
||||
if "light\n" in lines:
|
||||
self.lb_tunnel = ttk.Label(
|
||||
self, textvariable=self.str_var, foreground="green"
|
||||
)
|
||||
self.lb_tunnel = ttk.Label(self, textvariable=self.str_var, foreground="green")
|
||||
|
||||
else:
|
||||
self.lb_tunnel = ttk.Label(
|
||||
self, textvariable=self.str_var, foreground="yellow"
|
||||
)
|
||||
self.lb_tunnel = ttk.Label(self, textvariable=self.str_var, foreground="yellow")
|
||||
|
||||
self.lb_tunnel.config(font=("Ubuntu", 11, "bold"))
|
||||
self.lb_tunnel.grid(column=2, padx=10, row=1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user