Compare commits

..

No commits in common. "b9083d4698cd36d907bac23ea4937653afecf6a9" and "6bd8775490b7e55f3580a537c02c4525958fb9c5" have entirely different histories.

4 changed files with 33 additions and 99 deletions

View File

@ -4,8 +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 Label Interface and Peer to new FrameWidget one and two. when import Tunnel then add to list works and remove of list when Tunnel delete.(with Label active on and off) &#10;add to class and methods open a avtive Tunnel when Wire-Py open, when import and start a Tunnel"> <list default="true" id="940e1630-c825-4d4c-be80-bc11f543c122" name="Changes" comment="add class ListTunnels and class ImportTunnel, and add class ExportTunnels (ExportTunnels no finish)">
<change afterPath="$PROJECT_DIR$/dict_to_address" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <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$/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" /> <change beforePath="$PROJECT_DIR$/wg_func.py" beforeDir="false" afterPath="$PROJECT_DIR$/wg_func.py" afterDir="false" />
@ -41,16 +40,16 @@
<option name="hideEmptyMiddlePackages" value="true" /> <option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" /> <option name="showLibraryContents" value="true" />
</component> </component>
<component name="PropertiesComponent">{ <component name="PropertiesComponent"><![CDATA[{
&quot;keyToString&quot;: { "keyToString": {
&quot;ASKED_ADD_EXTERNAL_FILES&quot;: &quot;true&quot;, "ASKED_ADD_EXTERNAL_FILES": "true",
&quot;Python.main.executor&quot;: &quot;Run&quot;, "Python.main.executor": "Run",
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;, "RunOnceActivity.ShowReadmeOnStart": "true",
&quot;git-widget-placeholder&quot;: &quot;main&quot;, "git-widget-placeholder": "main",
&quot;last_opened_file_path&quot;: &quot;/home/punix/Pyapps/wire-py&quot;, "last_opened_file_path": "/home/punix/Downloads/tkinter-bitcoin_price_converter_objectoriented(1).py",
&quot;settings.editor.selected.configurable&quot;: &quot;preferences.lookFeel&quot; "settings.editor.selected.configurable": "preferences.lookFeel"
} }
}</component> }]]></component>
<component name="RunManager"> <component name="RunManager">
<configuration name="main" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true"> <configuration name="main" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true">
<module name="wire-py" /> <module name="wire-py" />
@ -139,15 +138,7 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1724048994613</updated> <updated>1724048994613</updated>
</task> </task>
<task id="LOCAL-00007" summary="add Label Interface and Peer to new FrameWidget one and two. when import Tunnel then add to list works and remove of list when Tunnel delete.(with Label active on and off) &#10;add to class and methods open a avtive Tunnel when Wire-Py open, when import and start a Tunnel"> <option name="localTasksCounter" value="7" />
<option name="closed" value="true" />
<created>1724102937260</created>
<option name="number" value="00007" />
<option name="presentableId" value="LOCAL-00007" />
<option name="project" value="LOCAL" />
<updated>1724102937260</updated>
</task>
<option name="localTasksCounter" value="8" />
<servers /> <servers />
</component> </component>
<component name="Vcs.Log.Tabs.Properties"> <component name="Vcs.Log.Tabs.Properties">
@ -180,7 +171,6 @@
<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" /> <MESSAGE value="add class Frame and class Massage, delete funktion go 100%, add resize window, add warning pic" />
<MESSAGE value="add class ListTunnels and class ImportTunnel, and add class ExportTunnels (ExportTunnels no finish)" /> <MESSAGE value="add class ListTunnels and class ImportTunnel, and add class ExportTunnels (ExportTunnels no finish)" />
<MESSAGE value="add Label Interface and Peer to new FrameWidget one and two. when import Tunnel then add to list works and remove of list when Tunnel delete.(with Label active on and off) &#10;add to class and methods open a avtive Tunnel when Wire-Py open, when import and start a Tunnel" /> <option name="LAST_COMMIT_MESSAGE" value="add class ListTunnels and class ImportTunnel, and add class ExportTunnels (ExportTunnels no finish)" />
<option name="LAST_COMMIT_MESSAGE" value="add Label Interface and Peer to new FrameWidget one and two. when import Tunnel then add to list works and remove of list when Tunnel delete.(with Label active on and off) &#10;add to class and methods open a avtive Tunnel when Wire-Py open, when import and start a Tunnel" />
</component> </component>
</project> </project>

View File

@ -1,3 +0,0 @@
192.168.178.158/24
192.168.178.1,
rj2cexasg9b9oydd.myfritz.net:54775

42
main.py
View File

@ -3,8 +3,7 @@ import os
import tkinter as tk import tkinter as tk
from tkinter import ttk from tkinter import ttk
from wg_func import (TunnelActiv, ListTunnels, ImportTunnel, from wg_func import TunnelActiv, ListTunnels, ImportTunnel, ExportTunnels
ConToDict, GreenLabel, ExportTunnels)
class MainWindow(tk.Tk): class MainWindow(tk.Tk):
@ -18,6 +17,7 @@ class MainWindow(tk.Tk):
self.monitor_center_x = self.winfo_screenwidth() / 2 - (self.x_width / 2) self.monitor_center_x = self.winfo_screenwidth() / 2 - (self.x_width / 2)
self.monitor_center_y = self.winfo_screenheight() / 2 - (self.y_height / 2) self.monitor_center_y = self.winfo_screenheight() / 2 - (self.y_height / 2)
self.resizable(width=False, height=False) self.resizable(width=False, height=False)
self.lb_tunnel = None
self.title('Wire-Py') self.title('Wire-Py')
self.configure() self.configure()
self.geometry('%dx%d+%d+%d' % (self.x_width, self.y_height, self.monitor_center_x, self.monitor_center_y)) self.geometry('%dx%d+%d+%d' % (self.x_width, self.y_height, self.monitor_center_x, self.monitor_center_y))
@ -33,7 +33,6 @@ class FrameWidgets(ttk.Frame):
def __init__(self, container, **kwargs): def __init__(self, container, **kwargs):
super().__init__(container, **kwargs) super().__init__(container, **kwargs)
self.lb_tunnel = None
self.wg_read = None self.wg_read = None
self.wg_vpn_start = tk.PhotoImage(file=r'icons/wg-vpn-start-48.png') 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.wg_vpn_stop = tk.PhotoImage(file=r'icons/wg-vpn-stop-48.png')
@ -60,29 +59,17 @@ class FrameWidgets(ttk.Frame):
# Label to Show active Tunnel # Label to Show active Tunnel
self.StrVar = tk.StringVar(value=self.a) self.StrVar = tk.StringVar(value=self.a)
GreenLabel.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.grid(column=3, row=1, sticky="w")
# Interface Label # Label Interface and Peers
self.interface = tk.Label(self.lb_frame, text='Interface') self.interface = tk.Label(self.lb_frame, text='Interface')
self.interface.grid(column=0, row=4, sticky="n", padx=10) self.interface.grid(column=0, row=4, sticky="n", padx=10)
self.interface.config(font=("Ubuntu", 9)) self.interface.config(font=("Ubuntu", 9))
# Address Label
self.address = tk.Label(self.lb_frame, text='address')
self.address.grid(column=0, row=5, sticky="n", padx=10)
self.address.config(font=("Ubuntu", 9))
# DNS Label
self.dns = tk.Label(self.lb_frame, text='dns')
self.dns.grid(column=0, row=6, sticky="n", padx=10)
self.dns.config(font=("Ubuntu", 9))
# Peer Label
self.peer = tk.Label(self.lb_frame2, text='Peer') self.peer = tk.Label(self.lb_frame2, text='Peer')
self.peer.config(font=("Ubuntu", 9)) self.peer.config(font=("Ubuntu", 9))
self.peer.grid(column=0, row=7, sticky="n", padx=10) self.peer.grid(column=0, row=5, sticky="n", padx=10)
# Endpoint Label
self.endpoint = tk.Label(self.lb_frame2, text='Endpoint')
self.endpoint.config(font=("Ubuntu", 9))
self.endpoint.grid(column=0, row=8, sticky="n", padx=10)
self.scrollbar = tk.Scrollbar(self) self.scrollbar = tk.Scrollbar(self)
self.l_box = tk.Listbox(self, fg='#606060', selectmode='single') self.l_box = tk.Listbox(self, fg='#606060', selectmode='single')
self.l_box.config(highlightthickness=0, relief='flat') self.l_box.config(highlightthickness=0, relief='flat')
@ -101,8 +88,9 @@ class FrameWidgets(ttk.Frame):
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")
wg_read = os.environ['HOME'] + '/tester/' + str(self.a) + '.conf' wg_read = os.environ['HOME'] + '/tester/' + str(self.a) + '.conf'
file = open(wg_read, 'r') file = open(wg_read, 'r')
ConToDict.covert_to_dict(file) read = file.read()
file.close() file.close()
print(read)
else: else:
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")
@ -144,15 +132,19 @@ class FrameWidgets(ttk.Frame):
os.system('nmcli connection up ' + str(select_tl)) os.system('nmcli connection up ' + str(select_tl))
wg_read = os.environ['HOME'] + '/tester/' + str(select_tl) + '.conf' wg_read = os.environ['HOME'] + '/tester/' + str(select_tl) + '.conf'
file = open(wg_read, 'r') file = open(wg_read, 'r')
ConToDict.covert_to_dict(file) read = file.read()
file.close() file.close()
print(read)
# 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")
self.a = TunnelActiv.active() self.a = TunnelActiv.active()
self.StrVar = tk.StringVar() self.StrVar = tk.StringVar()
self.StrVar.set(self.a) self.StrVar.set(self.a)
GreenLabel.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.grid(column=3, row=1, sticky="w")
elif self.a != '': elif self.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)
@ -164,7 +156,9 @@ class FrameWidgets(ttk.Frame):
self.a = TunnelActiv.active() self.a = TunnelActiv.active()
self.StrVar = tk.StringVar() self.StrVar = tk.StringVar()
self.StrVar.set(value=' ') self.StrVar.set(value=' ')
GreenLabel.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.grid(column=3, row=1, sticky="w")
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -1,7 +1,7 @@
# Wireguard functions for Wire-Py # Wireguard functions for Wire-Py
import os import os
import subprocess import subprocess
from tkinter import filedialog, ttk from tkinter import filedialog
import tkinter as tk import tkinter as tk
@ -29,54 +29,6 @@ class Message(tk.Tk):
self.button.grid(column=0, row=1) self.button.grid(column=0, row=1)
class GreenLabel(tk.Tk):
def __init__(self, container, **kwargs):
super().__init__(container, **kwargs)
self.StrVar = None
self.lb_tunnel = None
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.grid(column=3, row=1, sticky="w")
class ConToDict:
@classmethod
def covert_to_dict(cls, file):
dictlist = []
for lines in file.readlines():
lineplit = lines.split()
dictlist = dictlist + lineplit
dictlist.remove('[Interface]')
dictlist.remove('[Peer]')
for items in dictlist:
if items == '=':
dictlist.remove(items)
for i in dictlist:
a = [dictlist[0], dictlist[1]]
b = [dictlist[2], dictlist[3]]
c = [dictlist[4], dictlist[5]]
d = [dictlist[6], dictlist[7]]
e = [dictlist[8], dictlist[9]]
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]
address = finaldict['Address']
dns = finaldict['DNS']
endpoint = finaldict['Endpoint']
with open('dict_to_address', 'w+') as data:
data.write(address + '\n')
data.write(dns + '\n')
data.write(endpoint + '\n')
data.close()
class TunnelActiv: class TunnelActiv:
@staticmethod @staticmethod
def active(): # Shows the active tunnel def active(): # Shows the active tunnel
@ -142,8 +94,9 @@ class ImportTunnel:
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")
wg_read = os.environ['HOME'] + '/tester/' + str(self.a) + '.conf' wg_read = os.environ['HOME'] + '/tester/' + str(self.a) + '.conf'
file = open(wg_read, 'r') file = open(wg_read, 'r')
ConToDict.covert_to_dict(file) read = file.read()
file.close() file.close()
print(read)
if "PrivateKey = " not in read: if "PrivateKey = " not in read:
Message() Message()
except EOFError: except EOFError: