diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 2e7a420..fab43ca 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,10 +4,13 @@
-
+
+
+
+
@@ -45,13 +48,15 @@
"keyToString": {
"ASKED_ADD_EXTERNAL_FILES": "true",
"Python.main.executor": "Run",
+ "Python.start_wg.executor": "Run",
+ "Python.wg_func.executor": "Run",
"RunOnceActivity.ShowReadmeOnStart": "true",
"git-widget-placeholder": "main",
"last_opened_file_path": "/home/punix/Pyapps/wire-py",
"settings.editor.selected.configurable": "preferences.lookFeel"
}
}
-
+
@@ -74,6 +79,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -291,7 +323,15 @@
1725567453540
-
+
+
+ 1725639633873
+
+
+
+ 1725639633873
+
+
@@ -343,6 +383,7 @@
-
+
+
\ No newline at end of file
diff --git a/main.py b/main.py
index 4f9e64f..6479b92 100755
--- a/main.py
+++ b/main.py
@@ -7,7 +7,6 @@ from wg_func import (TunnelActiv, ListTunnels, ImportTunnel, ConToDict, GreenLab
FileHandle, ExportTunnels, OnOff)
font_color = '#4011a7'
-replacement = ''
class MainWindow(tk.Tk):
@@ -35,8 +34,7 @@ class MainWindow(tk.Tk):
# App Menu
self.app_menu = tk.Menu(self, borderwidth=0)
- for item in self.app_menu.keys():
- print(item, ': ', self.app_menu[item])
+
self.configure(menu=self.app_menu)
self.app_menu.add_cascade(label='?')
@@ -106,7 +104,6 @@ class FrameWidgets(ttk.Frame):
# Listbox with Scrollbar
def enable_check_box(event):
tl = ListTunnels.tl_list()
- print(len(tl))
if len(tl) != 0:
self.wg_autostart.configure(state='normal')
@@ -158,23 +155,6 @@ class FrameWidgets(ttk.Frame):
self.l_box.delete(self.select_tunnel[0])
os.remove(os.environ['HOME'] + '/tester/' + str(select_tl) + '.conf')
- del_tl_read = open('wg_py.xml', 'r')
- if 'false ' in del_tl_read:
- first_word = 'false '
- else:
- first_word = 'true '
-
- word_replace = ''
- # using the for loop
- for line in del_tl_read:
- line = line.strip()
- changes = line.replace(first_word + select_tl, '')
- word_replace = word_replace + changes + "\n"
-
- del_tl_read.close()
- del_tl = open('wg_py.xml', 'w')
- del_tl.write(word_replace)
- del_tl.close()
# for disable checkbox when Listbox empty
tl = ListTunnels.tl_list()
if len(tl) == 0:
diff --git a/start_wg.py b/start_wg.py
new file mode 100755
index 0000000..af53a1c
--- /dev/null
+++ b/start_wg.py
@@ -0,0 +1,12 @@
+#!/usr/bin/python3
+from subprocess import check_call
+from pathlib import Path
+
+home = Path.home()
+path_to_file = home / 'Pyapps/wire-py/wg_py'
+
+with open(path_to_file, 'r') as file:
+ for line in file.readlines():
+ a_con = line[5:]
+check_call(['nmcli', 'connection', 'up', a_con])
+
diff --git a/wg_func.py b/wg_func.py
index 2473572..c714be5 100755
--- a/wg_func.py
+++ b/wg_func.py
@@ -213,9 +213,6 @@ class ImportTunnel:
ShowAddress.show_data(self)
file.close()
os.system('nmcli con mod ' + str(self.a) + ' connection.autoconnect no')
- new_tl = open('wg_py.xml', 'a')
- new_tl.write('false ' + str(self.a) + '\n')
- new_tl.close()
if 'PrivateKey = ' not in read:
Message()
except EOFError:
@@ -240,31 +237,16 @@ class FileHandle:
self.select_tunnel = None
def box_set(self):
- word_replace = ''
try:
self.select_tunnel = self.l_box.curselection()
select_tl = self.l_box.get(self.select_tunnel[0])
if self.selected_option.get() == 0:
- set_on = open('wg_py.xml', 'r')
- # using the for loop
- for line in set_on:
- line = line.strip()
- changes = line.replace('true ' + select_tl, 'false ' + select_tl)
- os.system('nmcli con mod ' + str(self.auto_con) + ' connection.autoconnect no')
- word_replace = word_replace + changes + "\n"
- set_on.close()
+ off = open('wg_py', 'w')
+ off.close()
if self.selected_option.get() >= 1:
- set_on = open('wg_py.xml', 'r')
- # using the for loop
- for line in set_on:
- line = line.strip()
- changes = line.replace('false ' + select_tl, 'true ' + select_tl)
- os.system('nmcli con mod ' + str(select_tl) + ' connection.autoconnect yes')
- word_replace = word_replace + changes + "\n"
+ set_on = open('wg_py', 'w')
+ set_on.write(select_tl)
set_on.close()
- set_off = open('wg_py.xml', 'w')
- set_off.write(word_replace)
- set_off.close()
except IndexError:
self.selected_option.set(1)
@@ -279,7 +261,7 @@ class OnOff(tk.Tk, FileHandle):
def on_off(self):
a_connect = {}
- on_or_off = open('wg_py.xml', 'r')
+ on_or_off = open('wg_py', 'r')
for line in on_or_off.readlines():
line_splitted = line.split()
a_connect[line_splitted[0]] = line_splitted[1]
diff --git a/wg_py b/wg_py
new file mode 100644
index 0000000..e69de29
diff --git a/wg_py.xml b/wg_py.xml
deleted file mode 100644
index 2d98c87..0000000
--- a/wg_py.xml
+++ /dev/null
@@ -1,2 +0,0 @@
-false peer_iasus
-false rverEppingen