diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 640ba56..32d3f20 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,8 +4,7 @@
-
-
+
@@ -147,7 +146,15 @@
1724102937260
-
+
+
+ 1724233806458
+
+
+
+ 1724233806458
+
+
@@ -181,6 +188,18 @@
-
+
+
+
+
+
+
+
+ file://$PROJECT_DIR$/wg_func.py
+ 116
+
+
+
+
\ No newline at end of file
diff --git a/dict_to_address b/dict_to_address
index 2a74fd9..13bb995 100644
--- a/dict_to_address
+++ b/dict_to_address
@@ -1,3 +1,3 @@
-192.168.178.158/24
-192.168.178.1,
-rj2cexasg9b9oydd.myfritz.net:54775
+10.64.1.5/32
+10.64.1.1
+wg.iunix.dedyn.io:51820
diff --git a/main.py b/main.py
index 827a2aa..acc4863 100644
--- a/main.py
+++ b/main.py
@@ -4,7 +4,7 @@ import tkinter as tk
from tkinter import ttk
from wg_func import (TunnelActiv, ListTunnels, ImportTunnel,
- ConToDict, GreenLabel, ExportTunnels)
+ ConToDict, GreenLabel, StartStopBTN, ExportTunnels)
class MainWindow(tk.Tk):
@@ -37,8 +37,6 @@ class FrameWidgets(ttk.Frame):
self.wg_read = None
self.wg_vpn_start = tk.PhotoImage(file=r'icons/wg-vpn-start-48.png')
self.wg_vpn_stop = tk.PhotoImage(file=r'icons/wg-vpn-stop-48.png')
- self.wgi_on = tk.PhotoImage(file=r'icons/wire-switch-on-48.png')
- self.wgi_off = tk.PhotoImage(file=r'icons/wire-switch-off-48.png')
self.imp_pic = tk.PhotoImage(file=r'icons/wg-import.png')
self.tr_pic = tk.PhotoImage(file=r'icons/wg-trash-48.png')
self.exp_pic = tk.PhotoImage(file=r'icons/wg-export-48.png')
@@ -97,15 +95,13 @@ class FrameWidgets(ttk.Frame):
# Button Vpn
if self.a != '':
- 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")
+ StartStopBTN.button_stop(self)
wg_read = os.environ['HOME'] + '/tester/' + str(self.a) + '.conf'
file = open(wg_read, 'r')
ConToDict.covert_to_dict(file)
file.close()
else:
- 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")
+ StartStopBTN.button_start(self)
# Button Import
self.btn_i = tk.Button(self, image=self.imp_pic, bd=0, command=lambda: ImportTunnel.wg_import_select(self))
self.btn_i.grid(column=0, row=2, padx=15, pady=15)
@@ -118,8 +114,7 @@ class FrameWidgets(ttk.Frame):
os.remove(os.environ['HOME'] + '/tester/' + str(select_tl) + '.conf')
if self.a != '':
self.StrVar.set(value='')
- 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")
+ StartStopBTN.button_start(self)
self.l_box.update()
# Button Trash
@@ -138,7 +133,7 @@ class FrameWidgets(ttk.Frame):
def wg_switch(self):
self.a = TunnelActiv.active()
if self.a == '':
-
+ StartStopBTN.button_start(self)
self.select_tunnel = self.l_box.curselection()
select_tl = self.l_box.get(self.select_tunnel[0])
os.system('nmcli connection up ' + str(select_tl))
@@ -147,20 +142,17 @@ class FrameWidgets(ttk.Frame):
ConToDict.covert_to_dict(file)
file.close()
# Button Start/Stop
- 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")
+ StartStopBTN.button_stop(self)
self.a = TunnelActiv.active()
self.StrVar = tk.StringVar()
self.StrVar.set(self.a)
GreenLabel.green_show_label(self)
elif self.a != '':
# Button Start/Stop
- 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")
+ StartStopBTN.button_stop(self)
os.system('nmcli connection down ' + str(self.a))
# Button Start/Stop
- 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")
+ StartStopBTN.button_start(self)
self.a = TunnelActiv.active()
self.StrVar = tk.StringVar()
self.StrVar.set(value=' ')
diff --git a/wg_func.py b/wg_func.py
index e23164c..a52e906 100644
--- a/wg_func.py
+++ b/wg_func.py
@@ -41,6 +41,23 @@ class GreenLabel(tk.Tk):
self.lb_tunnel.grid(column=3, row=1, sticky="w")
+class StartStopBTN(tk.Tk):
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.wg_switch = None
+ self.btn_stst = None
+ self.wg_vpn_start = tk.PhotoImage(file=r'icons/wg-vpn-start-48.png')
+ self.wg_vpn_stop = tk.PhotoImage(file=r'icons/wg-vpn-stop-48.png')
+
+ def button_stop(self):
+ 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")
+
+ def button_start(self):
+ 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")
+
+
class ConToDict:
@classmethod
def covert_to_dict(cls, file):
@@ -138,8 +155,7 @@ class ImportTunnel:
self.lb_tunnel = tk.Label(self, textvariable=self.StrVar, fg='green')
self.lb_tunnel.config(font=("Ubuntu", 11, "bold"))
self.lb_tunnel.grid(column=3, row=1, sticky="w")
- 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")
+ StartStopBTN.button_stop(self)
wg_read = os.environ['HOME'] + '/tester/' + str(self.a) + '.conf'
file = open(wg_read, 'r')
ConToDict.covert_to_dict(file)