little fixes a " " to ' '
This commit is contained in:
parent
e5d86f1f90
commit
b82bd6d9e7
15
.idea/workspace.xml
generated
15
.idea/workspace.xml
generated
@ -4,7 +4,7 @@
|
||||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="940e1630-c825-4d4c-be80-bc11f543c122" name="Changes" comment="import datetime for datetime in zip_name a export Tunnel">
|
||||
<list default="true" id="940e1630-c825-4d4c-be80-bc11f543c122" name="Changes" comment="columnconfigure on all widgets set">
|
||||
<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" />
|
||||
@ -243,7 +243,15 @@
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1724610514658</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="20" />
|
||||
<task id="LOCAL-00020" summary="columnconfigure on all widgets set">
|
||||
<option name="closed" value="true" />
|
||||
<created>1724778892233</created>
|
||||
<option name="number" value="00020" />
|
||||
<option name="presentableId" value="LOCAL-00020" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1724778892233</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="21" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
@ -289,6 +297,7 @@
|
||||
<MESSAGE value="remove a ',' in DNS Name" />
|
||||
<MESSAGE value="fix when Filname > 17 first copy file after rename" />
|
||||
<MESSAGE value="add export Tunnel as zip" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="add export Tunnel as zip" />
|
||||
<MESSAGE value="columnconfigure on all widgets set" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="columnconfigure on all widgets set" />
|
||||
</component>
|
||||
</project>
|
26
main.py
26
main.py
@ -6,7 +6,7 @@ from tkinter import ttk
|
||||
from wg_func import (TunnelActiv, ListTunnels, ImportTunnel, ConToDict, GreenLabel, StartStopBTN, ShowAddress,
|
||||
ExportTunnels)
|
||||
|
||||
fontcolor = '#4011a7'
|
||||
font_color = '#4011a7'
|
||||
|
||||
|
||||
class MainWindow(tk.Tk):
|
||||
@ -71,23 +71,23 @@ class FrameWidgets(ttk.Frame):
|
||||
# Show active Label
|
||||
self.select_tunnel = None
|
||||
self.lb = tk.Label(self, text='Active: ')
|
||||
self.lb.config(font=("Ubuntu", 11, "bold"))
|
||||
self.lb.grid(column=2, row=1, padx=15, sticky="w")
|
||||
self.lb.config(font=('Ubuntu', 11, 'bold'))
|
||||
self.lb.grid(column=2, row=1, padx=15, sticky='w')
|
||||
self.columnconfigure(2, weight=1)
|
||||
self.rowconfigure(1, weight=1)
|
||||
# Label to Show active Tunnel
|
||||
self.StrVar = tk.StringVar(value=self.a)
|
||||
GreenLabel.green_show_label(self)
|
||||
# Interface Label
|
||||
self.interface = tk.Label(self.lb_frame, text='Interface', fg=fontcolor)
|
||||
self.interface.grid(column=0, row=4, sticky="we", padx=120)
|
||||
self.interface.config(font=("Ubuntu", 9))
|
||||
self.interface = tk.Label(self.lb_frame, text='Interface', fg=font_color)
|
||||
self.interface.grid(column=0, row=4, sticky='we', padx=120)
|
||||
self.interface.config(font=('Ubuntu', 9))
|
||||
self.columnconfigure(0, weight=1)
|
||||
self.rowconfigure(4, weight=1)
|
||||
# Peer Label
|
||||
self.peer = tk.Label(self.lb_frame2, text='Peer', fg=fontcolor)
|
||||
self.peer.config(font=("Ubuntu", 9))
|
||||
self.peer.grid(column=0, row=7, sticky="we", padx=130)
|
||||
self.peer = tk.Label(self.lb_frame2, text='Peer', fg=font_color)
|
||||
self.peer.config(font=('Ubuntu', 9))
|
||||
self.peer.grid(column=0, row=7, sticky='we', padx=130)
|
||||
self.columnconfigure(0, weight=1)
|
||||
self.rowconfigure(7, weight=1)
|
||||
# Listbox with Scrollbar
|
||||
@ -95,7 +95,7 @@ class FrameWidgets(ttk.Frame):
|
||||
self.l_box = tk.Listbox(self, fg='#606060', selectmode='single')
|
||||
self.l_box.config(highlightthickness=0, relief='flat')
|
||||
self.scrollbar.config(command=self.l_box.yview)
|
||||
self.l_box.config(font=("Ubuntu", 12, "bold"))
|
||||
self.l_box.config(font=('Ubuntu', 12, 'bold'))
|
||||
self.l_box.grid(column=1, rowspan=3, row=1)
|
||||
self.columnconfigure(1, weight=1)
|
||||
self.rowconfigure(1, weight=1)
|
||||
@ -154,9 +154,15 @@ class FrameWidgets(ttk.Frame):
|
||||
self.btn_exp.grid(column=0, row=4, padx=15, pady=15)
|
||||
self.columnconfigure(0, weight=1)
|
||||
self.rowconfigure(4, weight=1)
|
||||
# Button Rename
|
||||
self.btn_rename = ttk.Button(self, text='Rename')
|
||||
self.btn_rename.grid(column=2, row=4, padx=20, pady=15, sticky='e')
|
||||
self.columnconfigure(3, weight=1)
|
||||
self.rowconfigure(4, weight=1)
|
||||
# Check Buttons
|
||||
self.wg_autostart = tk.Checkbutton(self, text='Autoconnect on PC Start')
|
||||
self.wg_autostart.grid(column=1, rowspan=3, row=3)
|
||||
|
||||
self.columnconfigure(1, weight=1)
|
||||
self.rowconfigure(3, weight=1)
|
||||
self.wg_update = tk.Checkbutton(self, text='Search automatically for\nWire-Py updates')
|
||||
|
62
wg_func.py
62
wg_func.py
@ -5,7 +5,7 @@ from datetime import datetime
|
||||
from tkinter import filedialog
|
||||
import tkinter as tk
|
||||
|
||||
fontcolor = '#4011a7'
|
||||
font_color = '#4011a7'
|
||||
|
||||
|
||||
class Message(tk.Tk):
|
||||
@ -25,9 +25,9 @@ class Message(tk.Tk):
|
||||
|
||||
self.label = tk.Label(self, image=self.warning_pic,
|
||||
text='Oh... no valid Wireguard File!\nPlease select a valid Wireguard File')
|
||||
self.label.config(font=("Ubuntu", 11), padx=15, pady=15)
|
||||
self.label.config(font=('Ubuntu', 11), padx=15, pady=15)
|
||||
self.label.grid(column=0, row=0)
|
||||
self.button = tk.Button(self, text="OK", command=self.destroy)
|
||||
self.button = tk.Button(self, text='OK', command=self.destroy)
|
||||
self.button.config(padx=15, pady=5)
|
||||
self.button.grid(column=0, row=1)
|
||||
|
||||
@ -40,7 +40,7 @@ class GreenLabel(tk.Tk):
|
||||
|
||||
def green_show_label(self):
|
||||
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=2, padx=10, row=1)
|
||||
self.columnconfigure(2, weight=1)
|
||||
self.rowconfigure(1, weight=1)
|
||||
@ -72,14 +72,14 @@ class ConToDict:
|
||||
def covert_to_dict(cls, file):
|
||||
dictlist = []
|
||||
for lines in file.readlines():
|
||||
lineplit = lines.split()
|
||||
dictlist = dictlist + lineplit
|
||||
line_plit = lines.split()
|
||||
dictlist = dictlist + line_plit
|
||||
dictlist.remove('[Interface]')
|
||||
dictlist.remove('[Peer]')
|
||||
for items in dictlist:
|
||||
if items == '=':
|
||||
dictlist.remove(items)
|
||||
for i in dictlist: # Here is the beginning (Loop) of convert List to Dictionary
|
||||
for _ in dictlist: # Here is the beginning (Loop) of convert List to Dictionary
|
||||
a = [dictlist[0], dictlist[1]]
|
||||
b = [dictlist[2], dictlist[3]]
|
||||
c = [dictlist[4], dictlist[5]]
|
||||
@ -88,17 +88,17 @@ class ConToDict:
|
||||
f = [dictlist[10], dictlist[11]]
|
||||
g = [dictlist[12], dictlist[13]]
|
||||
h = [dictlist[14], dictlist[15]]
|
||||
newlist = [a, b, c, d, e, f, g, h]
|
||||
finaldict = {}
|
||||
for elements in newlist:
|
||||
finaldict[elements[0]] = elements[1]
|
||||
new_list = [a, b, c, d, e, f, g, h]
|
||||
final_dict = {}
|
||||
for elements in new_list:
|
||||
final_dict[elements[0]] = elements[1]
|
||||
|
||||
# end... result a Dictionary
|
||||
address = finaldict['Address']
|
||||
dns = finaldict['DNS']
|
||||
address = final_dict['Address']
|
||||
dns = final_dict['DNS']
|
||||
if ',' in dns:
|
||||
dns = dns[:-1]
|
||||
endpoint = finaldict['Endpoint']
|
||||
endpoint = final_dict['Endpoint']
|
||||
return address, dns, endpoint
|
||||
|
||||
|
||||
@ -143,16 +143,16 @@ class ShowAddress(tk.Tk):
|
||||
def show_data(self):
|
||||
# Address Label
|
||||
self.address = tk.Label(self.lb_frame, textvariable=self.add, fg='blue')
|
||||
self.address.grid(column=0, row=5, sticky="w", padx=10)
|
||||
self.address.config(font=("Ubuntu", 9))
|
||||
self.address.grid(column=0, row=5, sticky='w', padx=10)
|
||||
self.address.config(font=('Ubuntu', 9))
|
||||
# DNS Label
|
||||
self.dns = tk.Label(self.lb_frame, textvariable=self.DNS, fg='blue')
|
||||
self.dns.grid(column=0, row=6, sticky="w", padx=10, pady=3)
|
||||
self.dns.config(font=("Ubuntu", 9))
|
||||
self.dns.grid(column=0, row=6, sticky='w', padx=10, pady=3)
|
||||
self.dns.config(font=('Ubuntu', 9))
|
||||
# Endpoint Label
|
||||
self.endpoint = tk.Label(self.lb_frame2, textvariable=self.enp, fg='blue')
|
||||
self.endpoint.grid(column=0, row=8, sticky="w", padx=10, pady=5)
|
||||
self.endpoint.config(font=("Ubuntu", 9))
|
||||
self.endpoint.grid(column=0, row=8, sticky='w', padx=10, pady=5)
|
||||
self.endpoint.config(font=('Ubuntu', 9))
|
||||
|
||||
|
||||
class ListTunnels:
|
||||
@ -178,22 +178,22 @@ class ImportTunnel:
|
||||
|
||||
def wg_import_select(self):
|
||||
try:
|
||||
filepath = filedialog.askopenfilename(initialdir=os.environ['HOME'], title="Select Wireguard config File",
|
||||
filetypes=[("WG config files", "*.conf")])
|
||||
filepath = filedialog.askopenfilename(initialdir=os.environ['HOME'], title='Select Wireguard config File',
|
||||
filetypes=[('WG config files', '*.conf')])
|
||||
file = open(filepath, 'r')
|
||||
read = file.read()
|
||||
file.close()
|
||||
pathsplit = filepath.split("/")
|
||||
pathsplit1 = pathsplit[-1]
|
||||
if "PrivateKey = " in read and "PublicKey = " in read:
|
||||
if len(pathsplit1) > 17:
|
||||
path_split = filepath.split('/')
|
||||
path_split1 = path_split[-1]
|
||||
if 'PrivateKey = ' in read and 'PublicKey = ' in read:
|
||||
if len(path_split1) > 17:
|
||||
p1 = shutil.copy(filepath, os.environ['HOME'] + '/tester/')
|
||||
pathsplit = pathsplit1[len(pathsplit1) - 17:]
|
||||
os.rename(p1, os.environ['HOME'] + '/tester/' + str(pathsplit))
|
||||
path_split = path_split1[len(path_split1) - 17:]
|
||||
os.rename(p1, os.environ['HOME'] + '/tester/' + str(path_split))
|
||||
if self.a != '':
|
||||
os.system('nmcli connection down ' + str(TunnelActiv.active()))
|
||||
os.system('nmcli connection import type wireguard file ' + os.environ['HOME'] + '/tester/' +
|
||||
str(pathsplit))
|
||||
str(path_split))
|
||||
else:
|
||||
shutil.copy(filepath, os.environ['HOME'] + '/tester/')
|
||||
if self.a != '':
|
||||
@ -216,7 +216,7 @@ class ImportTunnel:
|
||||
ShowAddress.show_data(self)
|
||||
file.close()
|
||||
os.system('nmcli con mod ' + str(self.a) + ' connection.autoconnect no')
|
||||
if "PrivateKey = " not in read:
|
||||
if 'PrivateKey = ' not in read:
|
||||
Message()
|
||||
except EOFError:
|
||||
pass
|
||||
@ -230,7 +230,7 @@ class ExportTunnels:
|
||||
@staticmethod
|
||||
def wg_export():
|
||||
now_time = datetime.now()
|
||||
now_datetime = now_time.strftime('/wg-exp-' + "%m-%d-%Y" + '-' + "%H:%M")
|
||||
now_datetime = now_time.strftime('/wg-exp-' + '%m-%d-%Y' + '-' + '%H:%M')
|
||||
tl = ListTunnels.tl_list()
|
||||
try:
|
||||
if len(tl) != 0:
|
||||
|
Loading…
x
Reference in New Issue
Block a user