Compare commits
No commits in common. "9c5004e92ab2fd88d3b585ea2de5aa6edc4edbcf" and "ae32cc9e7487a7760229ce856359e79e9bfa63a7" have entirely different histories.
9c5004e92a
...
ae32cc9e74
33
.idea/workspace.xml
generated
33
.idea/workspace.xml
generated
@ -4,11 +4,7 @@
|
|||||||
<option name="autoReloadType" value="SELECTIVE" />
|
<option name="autoReloadType" value="SELECTIVE" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="940e1630-c825-4d4c-be80-bc11f543c122" name="Changes" comment="add class Frame and class Massage, delete funktion go 100%, add resize window, add warning pic">
|
<list default="true" id="940e1630-c825-4d4c-be80-bc11f543c122" name="Changes" comment="add class Frame and class Massage, delete funktion go 100%, add resize window" />
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/wg_func.py" beforeDir="false" afterPath="$PROJECT_DIR$/wg_func.py" afterDir="false" />
|
|
||||||
</list>
|
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||||
@ -121,15 +117,7 @@
|
|||||||
<option name="project" value="LOCAL" />
|
<option name="project" value="LOCAL" />
|
||||||
<updated>1724013210356</updated>
|
<updated>1724013210356</updated>
|
||||||
</task>
|
</task>
|
||||||
<task id="LOCAL-00005" summary="add class Frame and class Massage, delete funktion go 100%, add resize window, add warning pic">
|
<option name="localTasksCounter" value="5" />
|
||||||
<option name="closed" value="true" />
|
|
||||||
<created>1724013251954</created>
|
|
||||||
<option name="number" value="00005" />
|
|
||||||
<option name="presentableId" value="LOCAL-00005" />
|
|
||||||
<option name="project" value="LOCAL" />
|
|
||||||
<updated>1724013251954</updated>
|
|
||||||
</task>
|
|
||||||
<option name="localTasksCounter" value="6" />
|
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="Vcs.Log.Tabs.Properties">
|
<component name="Vcs.Log.Tabs.Properties">
|
||||||
@ -137,19 +125,7 @@
|
|||||||
<map>
|
<map>
|
||||||
<entry key="MAIN">
|
<entry key="MAIN">
|
||||||
<value>
|
<value>
|
||||||
<State>
|
<State />
|
||||||
<option name="FILTERS">
|
|
||||||
<map>
|
|
||||||
<entry key="branch">
|
|
||||||
<value>
|
|
||||||
<list>
|
|
||||||
<option value="origin/wire-py-reformat-14-08-2024" />
|
|
||||||
</list>
|
|
||||||
</value>
|
|
||||||
</entry>
|
|
||||||
</map>
|
|
||||||
</option>
|
|
||||||
</State>
|
|
||||||
</value>
|
</value>
|
||||||
</entry>
|
</entry>
|
||||||
</map>
|
</map>
|
||||||
@ -160,7 +136,6 @@
|
|||||||
<MESSAGE value="Tunnel Start and Stop Work" />
|
<MESSAGE value="Tunnel Start and Stop Work" />
|
||||||
<MESSAGE value="wg_import_select in wg_func.py extended" />
|
<MESSAGE value="wg_import_select in wg_func.py extended" />
|
||||||
<MESSAGE value="add class Frame and class Massage, delete funktion go 100%, add resize window" />
|
<MESSAGE value="add class Frame and class Massage, delete funktion go 100%, add resize window" />
|
||||||
<MESSAGE value="add class Frame and class Massage, delete funktion go 100%, add resize window, add warning pic" />
|
<option name="LAST_COMMIT_MESSAGE" value="add class Frame and class Massage, delete funktion go 100%, add resize window" />
|
||||||
<option name="LAST_COMMIT_MESSAGE" value="add class Frame and class Massage, delete funktion go 100%, add resize window, add warning pic" />
|
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
33
main.py
33
main.py
@ -2,10 +2,10 @@
|
|||||||
import os
|
import os
|
||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
from tkinter import ttk
|
from tkinter import ttk
|
||||||
|
from wg_func import active, tl_list, wg_export, wg_import_select
|
||||||
from wg_func import tl_list, wg_export, wg_import_select, TunnelActiv
|
|
||||||
|
|
||||||
wg_exp = wg_export()
|
wg_exp = wg_export()
|
||||||
|
a = active()
|
||||||
|
|
||||||
|
|
||||||
class MainWindow(tk.Tk):
|
class MainWindow(tk.Tk):
|
||||||
@ -44,17 +44,13 @@ class FrameWidgets(ttk.Frame):
|
|||||||
self.exp_pic = tk.PhotoImage(file=r'icons/wg-export-48.png')
|
self.exp_pic = tk.PhotoImage(file=r'icons/wg-export-48.png')
|
||||||
self.warning_pic = tk.PhotoImage(file=r'icons/warning_64.png')
|
self.warning_pic = tk.PhotoImage(file=r'icons/warning_64.png')
|
||||||
|
|
||||||
# Show active Tunnel
|
|
||||||
self.a = TunnelActiv.active()
|
|
||||||
|
|
||||||
# Show active Label
|
# Show active Label
|
||||||
self.select_tunnel = None
|
self.select_tunnel = None
|
||||||
self.lb = tk.Label(self, text='Active:')
|
self.lb = tk.Label(self, text='Active:')
|
||||||
self.lb.config(font=("Ubuntu", 11, "bold"))
|
self.lb.config(font=("Ubuntu", 11, "bold"))
|
||||||
self.lb.grid(column=2, row=1, padx=10, pady=5, sticky="e")
|
self.lb.grid(column=2, row=1, padx=10, pady=5, sticky="e")
|
||||||
|
|
||||||
# Label to Show active Tunnel
|
# Label to Show active Tunnel
|
||||||
self.StrVar = tk.StringVar(value=self.a)
|
self.StrVar = tk.StringVar(value=a)
|
||||||
self.lb_tunnel = tk.Label(self, textvariable=self.StrVar, fg='green')
|
self.lb_tunnel = tk.Label(self, textvariable=self.StrVar, fg='green')
|
||||||
|
|
||||||
self.lb_tunnel.config(font=("Ubuntu", 11, "bold"))
|
self.lb_tunnel.config(font=("Ubuntu", 11, "bold"))
|
||||||
@ -73,7 +69,7 @@ class FrameWidgets(ttk.Frame):
|
|||||||
self.l_box.update()
|
self.l_box.update()
|
||||||
self.l_box.select_set(0) # Later add, for first Item Auto select
|
self.l_box.select_set(0) # Later add, for first Item Auto select
|
||||||
# Button Vpn
|
# Button Vpn
|
||||||
if self.a != '':
|
if a != '':
|
||||||
self.btn_stst = tk.Button(self, image=self.wg_vpn_stop, bd=0, command=self.wg_switch)
|
self.btn_stst = tk.Button(self, image=self.wg_vpn_stop, bd=0, command=self.wg_switch)
|
||||||
self.btn_stst.grid(column=0, row=1, padx=15, pady=15, sticky="s")
|
self.btn_stst.grid(column=0, row=1, padx=15, pady=15, sticky="s")
|
||||||
else:
|
else:
|
||||||
@ -88,7 +84,7 @@ class FrameWidgets(ttk.Frame):
|
|||||||
select_tl = self.l_box.get(self.select_tunnel[0])
|
select_tl = self.l_box.get(self.select_tunnel[0])
|
||||||
os.system('nmcli connection delete ' + str(select_tl))
|
os.system('nmcli connection delete ' + str(select_tl))
|
||||||
self.l_box.delete(self.select_tunnel[0])
|
self.l_box.delete(self.select_tunnel[0])
|
||||||
if self.a != '':
|
if a != '':
|
||||||
self.StrVar.set(value='')
|
self.StrVar.set(value='')
|
||||||
self.btn_stst = tk.Button(self, image=self.wg_vpn_start, bd=0, command=self.wg_switch)
|
self.btn_stst = tk.Button(self, image=self.wg_vpn_start, bd=0, command=self.wg_switch)
|
||||||
self.btn_stst.grid(column=0, row=1, padx=15, pady=15, sticky="s")
|
self.btn_stst.grid(column=0, row=1, padx=15, pady=15, sticky="s")
|
||||||
@ -100,37 +96,34 @@ class FrameWidgets(ttk.Frame):
|
|||||||
self.btn_exp = tk.Button(self, image=self.exp_pic, bd=0)
|
self.btn_exp = tk.Button(self, image=self.exp_pic, bd=0)
|
||||||
self.btn_exp.grid(column=0, row=4, padx=15, pady=15)
|
self.btn_exp.grid(column=0, row=4, padx=15, pady=15)
|
||||||
|
|
||||||
# Check Buttons
|
|
||||||
self.wg_autostart = tk.Checkbutton(self, text='Autoconnect on PC Start')
|
self.wg_autostart = tk.Checkbutton(self, text='Autoconnect on PC Start')
|
||||||
self.wg_autostart.grid(column=1, rowspan=3, row=3)
|
self.wg_autostart.grid(column=1, rowspan=3, row=3)
|
||||||
self.wg_update = tk.Checkbutton(self, text='Search automatically for\nWire-Py updates')
|
self.wg_update = tk.Checkbutton(self, text='Search automatically for\nWire-Py updates')
|
||||||
self.wg_update.grid(column=1, rowspan=3, row=4)
|
self.wg_update.grid(column=1, rowspan=3, row=4)
|
||||||
|
|
||||||
def wg_switch(self):
|
def wg_switch(self):
|
||||||
self.a = TunnelActiv.active()
|
global a
|
||||||
if self.a == '':
|
if a == '':
|
||||||
|
# Button Start/Stop
|
||||||
self.select_tunnel = self.l_box.curselection()
|
self.select_tunnel = self.l_box.curselection()
|
||||||
select_tl = self.l_box.get(self.select_tunnel[0])
|
select_tl = self.l_box.get(self.select_tunnel[0])
|
||||||
os.system('nmcli connection up ' + str(select_tl))
|
os.system('nmcli connection up ' + str(select_tl))
|
||||||
# Button Start/Stop
|
|
||||||
self.btn_stst = tk.Button(self, image=self.wg_vpn_stop, bd=0, command=self.wg_switch)
|
self.btn_stst = tk.Button(self, image=self.wg_vpn_stop, bd=0, command=self.wg_switch)
|
||||||
self.btn_stst.grid(column=0, row=1, padx=15, pady=15, sticky="s")
|
self.btn_stst.grid(column=0, row=1, padx=15, pady=15, sticky="s")
|
||||||
self.a = TunnelActiv.active()
|
a = active()
|
||||||
self.StrVar = tk.StringVar()
|
self.StrVar = tk.StringVar()
|
||||||
self.StrVar.set(self.a)
|
self.StrVar.set(a)
|
||||||
self.lb_tunnel = tk.Label(self, textvariable=self.StrVar, fg='green')
|
self.lb_tunnel = tk.Label(self, textvariable=self.StrVar, fg='green')
|
||||||
self.lb_tunnel.config(font=("Ubuntu", 11, "bold"))
|
self.lb_tunnel.config(font=("Ubuntu", 11, "bold"))
|
||||||
self.lb_tunnel.grid(column=3, row=1, sticky="w")
|
self.lb_tunnel.grid(column=3, row=1, sticky="w")
|
||||||
elif self.a != '':
|
elif a != '':
|
||||||
# Button Start/Stop
|
# Button Start/Stop
|
||||||
self.btn_stst = tk.Button(self, image=self.wg_vpn_stop, bd=0, command=self.wg_switch)
|
self.btn_stst = tk.Button(self, image=self.wg_vpn_stop, bd=0, command=self.wg_switch)
|
||||||
self.btn_stst.grid(column=0, row=1, padx=15, pady=15, sticky="s")
|
self.btn_stst.grid(column=0, row=1, padx=15, pady=15, sticky="s")
|
||||||
os.system('nmcli connection down ' + str(self.a))
|
os.system('nmcli connection down ' + str(a))
|
||||||
# Button Start/Stop
|
|
||||||
self.btn_stst = tk.Button(self, image=self.wg_vpn_start, bd=0, command=self.wg_switch)
|
self.btn_stst = tk.Button(self, image=self.wg_vpn_start, bd=0, command=self.wg_switch)
|
||||||
self.btn_stst.grid(column=0, row=1, padx=15, pady=15, sticky="s")
|
self.btn_stst.grid(column=0, row=1, padx=15, pady=15, sticky="s")
|
||||||
self.a = TunnelActiv.active()
|
a = active()
|
||||||
self.StrVar = tk.StringVar()
|
self.StrVar = tk.StringVar()
|
||||||
self.StrVar.set(value=' ')
|
self.StrVar.set(value=' ')
|
||||||
self.lb_tunnel = tk.Label(self, textvariable=self.StrVar, fg='green')
|
self.lb_tunnel = tk.Label(self, textvariable=self.StrVar, fg='green')
|
||||||
|
19
wg_func.py
19
wg_func.py
@ -29,16 +29,17 @@ class Message(tk.Tk):
|
|||||||
self.button.grid(column=0, row=1)
|
self.button.grid(column=0, row=1)
|
||||||
|
|
||||||
|
|
||||||
class TunnelActiv:
|
|
||||||
@staticmethod
|
|
||||||
def active(): # Shows the active tunnel
|
def active(): # Shows the active tunnel
|
||||||
active = os.popen('nmcli con show --active | grep -iPo "(.*)(wireguard)"').read().split()
|
a = os.popen('nmcli con show --active | grep -iPo "(.*)(wireguard)"').read().split()
|
||||||
if not active:
|
if not a:
|
||||||
active = ''
|
a = ''
|
||||||
|
return a
|
||||||
else:
|
else:
|
||||||
active = active[0]
|
a = a[0]
|
||||||
|
return a
|
||||||
|
|
||||||
return active
|
|
||||||
|
a = active()
|
||||||
|
|
||||||
|
|
||||||
def tl_list():
|
def tl_list():
|
||||||
@ -60,13 +61,13 @@ def wg_import_select():
|
|||||||
if len(pathsplit1) > 17:
|
if len(pathsplit1) > 17:
|
||||||
pathsplit = pathsplit1[len(pathsplit1) - 17:]
|
pathsplit = pathsplit1[len(pathsplit1) - 17:]
|
||||||
os.rename(filepath, os.environ['HOME'] + '/tester/' + str(pathsplit))
|
os.rename(filepath, os.environ['HOME'] + '/tester/' + str(pathsplit))
|
||||||
os.system('nmcli connection down ' + str(TunnelActiv.active()))
|
os.system('nmcli connection down ' + str(a))
|
||||||
os.system('nmcli connection import type wireguard file ' + os.environ['HOME'] + '/tester/' +
|
os.system('nmcli connection import type wireguard file ' + os.environ['HOME'] + '/tester/' +
|
||||||
str(pathsplit))
|
str(pathsplit))
|
||||||
os.system('nmcli con mod ' + str(pathsplit[:-5]) + ' connection.autoconnect no')
|
os.system('nmcli con mod ' + str(pathsplit[:-5]) + ' connection.autoconnect no')
|
||||||
else:
|
else:
|
||||||
subprocess.call('cp ' + str(filepath) + ' ' + os.environ['HOME'] + '/tester/', shell=True)
|
subprocess.call('cp ' + str(filepath) + ' ' + os.environ['HOME'] + '/tester/', shell=True)
|
||||||
os.system('nmcli connection down ' + str(TunnelActiv.active()))
|
os.system('nmcli connection down ' + str(a))
|
||||||
os.system('nmcli connection import type wireguard file ' + str(filepath))
|
os.system('nmcli connection import type wireguard file ' + str(filepath))
|
||||||
os.system('nmcli con mod ' + str(pathsplit1[:-5]) + ' connection.autoconnect no')
|
os.system('nmcli con mod ' + str(pathsplit1[:-5]) + ' connection.autoconnect no')
|
||||||
if "PrivateKey = " not in read:
|
if "PrivateKey = " not in read:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user