replace-old-files-with-new-files-and-remove-no longer needed
This commit is contained in:
parent
1bba45a6c1
commit
97bf9df041
16
Changelog
16
Changelog
@ -6,13 +6,17 @@ My standard System: Linux Mint 22 Cinnamon
|
|||||||
- os import in cls_mth_fc.py replaced by other methods
|
- os import in cls_mth_fc.py replaced by other methods
|
||||||
- If Wire-Py already runs, prevent further start
|
- If Wire-Py already runs, prevent further start
|
||||||
- for loops with lists replaced by List Comprehensions
|
- for loops with lists replaced by List Comprehensions
|
||||||
- Update search after start of Wire-Py
|
- Crypt and Decrypt Config Files in ~/.config/wire_py
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
07-11-2024
|
02-03-2025
|
||||||
|
|
||||||
- remove classes and add methods to class FrameWidgets (removed self errors)
|
|
||||||
|
|
||||||
|
- Fix ipv6 in Config File on import
|
||||||
|
- Wirepy run now as user
|
||||||
|
- settings, keys and Config Files now in ~/.config/wire_py
|
||||||
|
- For new users, the required files are created and autostart service is started.
|
||||||
|
- Tunnels are now read from the directory to view them in the list.
|
||||||
|
To display only own tunnels, and read errors are minimized.
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
10-11-2024
|
10-11-2024
|
||||||
@ -62,7 +66,7 @@ My standard System: Linux Mint 22 Cinnamon
|
|||||||
### Added
|
### Added
|
||||||
27-10-2024
|
27-10-2024
|
||||||
|
|
||||||
- Add Autoconnect settings to settings.conf
|
- Add Autoconnect settings to settings
|
||||||
|
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
@ -70,7 +74,7 @@ My standard System: Linux Mint 22 Cinnamon
|
|||||||
|
|
||||||
- Add run_as Bash script and open_gitea.py python script
|
- Add run_as Bash script and open_gitea.py python script
|
||||||
- Add Tooltip disable/enable
|
- Add Tooltip disable/enable
|
||||||
- Rename settings to settings.conf for theme, updates and tooltip enable in one file
|
- Rename settings to settings for theme, updates and tooltip enable in one file
|
||||||
|
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
[Desktop Entry]
|
[Desktop Entry]
|
||||||
Type=Application
|
Type=Application
|
||||||
Name=Wire-Py
|
Name=Wire-Py
|
||||||
Exec=/usr/bin/wirepy.py
|
Exec=/usr/local/bin/wg_main.py
|
||||||
Terminal=false
|
Terminal=false
|
||||||
Categories=Network;
|
Categories=Network;
|
||||||
Icon=/usr/share/icons/wp-icons/128/wg_vpn.png
|
Icon=/usr/share/icons/wp-icons/128/wg_vpn.png
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
#!/usr/bin/python3
|
|
||||||
|
|
||||||
import webbrowser
|
|
||||||
|
|
||||||
webbrowser.open('https://git.ilunix.de/punix/Wire-Py')
|
|
@ -1,16 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE policyconfig PUBLIC "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN" "http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
|
|
||||||
<policyconfig>
|
|
||||||
<vendor>Project Wire-Py</vendor>
|
|
||||||
<vendor_url>https://git.ilunix.de/punix/Wire-Py</vendor_url>
|
|
||||||
<icon_name>wg-vpn</icon_name>
|
|
||||||
<action id="org.wirepy">
|
|
||||||
<defaults>
|
|
||||||
<allow_any>auth_admin_keep</allow_any>
|
|
||||||
<allow_inactive>auth_admin_keep</allow_inactive>
|
|
||||||
<allow_active>yes</allow_active>
|
|
||||||
</defaults>
|
|
||||||
<annotate key="org.freedesktop.policykit.exec.path">/usr/bin/wg_main.py</annotate>
|
|
||||||
<annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
|
|
||||||
</action>
|
|
||||||
</policyconfig>
|
|
@ -2,7 +2,7 @@
|
|||||||
from subprocess import check_call
|
from subprocess import check_call
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
path_to_file = Path('/etc/wire_py/settings.conf')
|
path_to_file = Path(Path.home() / '.config/wire_py/settings')
|
||||||
|
|
||||||
with open(path_to_file, 'r') as a_con:
|
with open(path_to_file, 'r') as a_con:
|
||||||
lines = a_con.readlines()
|
lines = a_con.readlines()
|
||||||
|
49
wg_main.py
49
wg_main.py
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import gettext
|
import gettext
|
||||||
import locale
|
import locale
|
||||||
|
import webbrowser
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
@ -9,7 +10,7 @@ import tkinter as tk
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from subprocess import check_call
|
from subprocess import check_call
|
||||||
from tkinter import filedialog, ttk, TclError
|
from tkinter import filedialog, ttk, TclError
|
||||||
from cls_mth_fc import (Tunnel, msg_window, GiteaUpdate, _u, wg_tips, wg_set)
|
from cls_mth_fc import (Tunnel, msg_window, GiteaUpdate, wg_tips, dirs_and_files, wg_set, files_for_autostart)
|
||||||
|
|
||||||
tcl_path = Path('/usr/share/TK-Themes')
|
tcl_path = Path('/usr/share/TK-Themes')
|
||||||
|
|
||||||
@ -26,7 +27,6 @@ gettext.bindtextdomain(APP, LOCALE_DIR)
|
|||||||
gettext.textdomain(APP)
|
gettext.textdomain(APP)
|
||||||
_ = gettext.gettext
|
_ = gettext.gettext
|
||||||
|
|
||||||
|
|
||||||
class MainWindow(tk.Tk):
|
class MainWindow(tk.Tk):
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
@ -141,9 +141,7 @@ class FrameWidgets(ttk.Frame):
|
|||||||
|
|
||||||
def info():
|
def info():
|
||||||
def link_btn():
|
def link_btn():
|
||||||
_u1 = str(_u[6:])
|
webbrowser.open('https://git.ilunix.de/punix/Wire-Py')
|
||||||
path_to_file = Path('/usr/bin/./run_as')
|
|
||||||
check_call(['su', _u1, path_to_file])
|
|
||||||
|
|
||||||
"""img_w, img_i, w_title, w_txt , txt2, com hand over"""
|
"""img_w, img_i, w_title, w_txt , txt2, com hand over"""
|
||||||
iw = r'/usr/share/icons/wp-icons/48/wg_vpn.png'
|
iw = r'/usr/share/icons/wp-icons/48/wg_vpn.png'
|
||||||
@ -332,7 +330,7 @@ class FrameWidgets(ttk.Frame):
|
|||||||
''' Listbox with Scrollbar '''
|
''' Listbox with Scrollbar '''
|
||||||
|
|
||||||
def enable_check_box(_):
|
def enable_check_box(_):
|
||||||
|
files_for_autostart()
|
||||||
if self.l_box.size() != 0:
|
if self.l_box.size() != 0:
|
||||||
self.wg_autostart.configure(state='normal')
|
self.wg_autostart.configure(state='normal')
|
||||||
self.lb_rename.config(state='normal')
|
self.lb_rename.config(state='normal')
|
||||||
@ -351,7 +349,7 @@ class FrameWidgets(ttk.Frame):
|
|||||||
''' Tunnel List '''
|
''' Tunnel List '''
|
||||||
self.tl = Tunnel.list()
|
self.tl = Tunnel.list()
|
||||||
for tunnels in self.tl:
|
for tunnels in self.tl:
|
||||||
self.l_box.insert("end", tunnels)
|
self.l_box.insert("end", tunnels[:-5])
|
||||||
self.l_box.update()
|
self.l_box.update()
|
||||||
|
|
||||||
def list_empty_enter(event):
|
def list_empty_enter(event):
|
||||||
@ -382,7 +380,7 @@ class FrameWidgets(ttk.Frame):
|
|||||||
''' Button Vpn '''
|
''' Button Vpn '''
|
||||||
if self.a != '':
|
if self.a != '':
|
||||||
self.stop()
|
self.stop()
|
||||||
wg_read = Path('/etc/wire_py') / str(self.a + '.conf')
|
wg_read = str(Path.home()) + '/.config/wire_py/' + str(self.a + '.conf')
|
||||||
with open(wg_read, 'r') as file:
|
with open(wg_read, 'r') as file:
|
||||||
data = Tunnel.con_to_dict(file)
|
data = Tunnel.con_to_dict(file)
|
||||||
|
|
||||||
@ -420,7 +418,7 @@ class FrameWidgets(ttk.Frame):
|
|||||||
try:
|
try:
|
||||||
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])
|
||||||
with open('/etc/wire_py/' + select_tl + '.conf', 'r+') as file2:
|
with open(str(Path.home()) + '/.config/wire_py/' + select_tl + '.conf', 'r+') as file2:
|
||||||
key = Tunnel.con_to_dict(file2)
|
key = Tunnel.con_to_dict(file2)
|
||||||
pre_key = key[3]
|
pre_key = key[3]
|
||||||
check_call(['nmcli', 'connection', 'delete', select_tl])
|
check_call(['nmcli', 'connection', 'delete', select_tl])
|
||||||
@ -434,14 +432,14 @@ class FrameWidgets(ttk.Frame):
|
|||||||
self.selected_option.set(0)
|
self.selected_option.set(0)
|
||||||
self.autoconnect_var.set(_('no Autoconnect'))
|
self.autoconnect_var.set(_('no Autoconnect'))
|
||||||
|
|
||||||
Path.unlink(Path('/etc/wire_py') / str(select_tl + '.conf'))
|
Path.unlink(str(Path.home()) + '/.config/wire_py/' + str(select_tl + '.conf'))
|
||||||
with open('/etc/wire_py/.keys', 'r') as readfile:
|
with open(str(Path.home()) + '/.config/wire_py/keys', 'r') as readfile:
|
||||||
with open('/etc/wire_py/.keys2', 'w') as writefile:
|
with open(str(Path.home()) + '/.config/wire_py/keys2', 'w') as writefile:
|
||||||
for line in readfile:
|
for line in readfile:
|
||||||
if pre_key not in line.strip("\n"):
|
if pre_key not in line.strip("\n"):
|
||||||
writefile.write(line)
|
writefile.write(line)
|
||||||
file_one = Path('/etc/wire_py/.keys2')
|
file_one = Path(str(Path.home()) + '/.config/wire_py/keys2')
|
||||||
file_two = file_one.with_name('.keys')
|
file_two = file_one.with_name('keys')
|
||||||
file_one.replace(file_two)
|
file_one.replace(file_two)
|
||||||
self.wg_autostart.configure(state='disabled')
|
self.wg_autostart.configure(state='disabled')
|
||||||
|
|
||||||
@ -636,7 +634,7 @@ class FrameWidgets(ttk.Frame):
|
|||||||
|
|
||||||
''' nmcli connection modify old connection.id iphone '''
|
''' nmcli connection modify old connection.id iphone '''
|
||||||
check_call(['nmcli', 'connection', 'modify', select_tl, 'connection.id', self.lb_rename.get()])
|
check_call(['nmcli', 'connection', 'modify', select_tl, 'connection.id', self.lb_rename.get()])
|
||||||
source = Path('/etc/wire_py') / str(select_tl + '.conf')
|
source = Path.home() / '.config/wire_py' / str(select_tl + '.conf')
|
||||||
destination = source.with_name(str(self.lb_rename.get() + '.conf'))
|
destination = source.with_name(str(self.lb_rename.get() + '.conf'))
|
||||||
source.replace(destination)
|
source.replace(destination)
|
||||||
self.l_box.delete(self.select_tunnel[0])
|
self.l_box.delete(self.select_tunnel[0])
|
||||||
@ -738,8 +736,11 @@ class FrameWidgets(ttk.Frame):
|
|||||||
If True then the name is automatically shortened to 12 characters and then imported.
|
If True then the name is automatically shortened to 12 characters and then imported.
|
||||||
If in each case false comes out, a corresponding window comes to inform the user that something is wrong.
|
If in each case false comes out, a corresponding window comes to inform the user that something is wrong.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
dirs_and_files()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
filepath = filedialog.askopenfilename(initialdir=str(_u), title=_('Select Wireguard config File'),
|
filepath = filedialog.askopenfilename(initialdir=str(Path.home()), title=_('Select Wireguard config File'),
|
||||||
filetypes=[(_('WG config files'), '*.conf')], )
|
filetypes=[(_('WG config files'), '*.conf')], )
|
||||||
|
|
||||||
with open(filepath, 'r') as file:
|
with open(filepath, 'r') as file:
|
||||||
@ -753,7 +754,7 @@ class FrameWidgets(ttk.Frame):
|
|||||||
key = Tunnel.con_to_dict(file)
|
key = Tunnel.con_to_dict(file)
|
||||||
pre_key = key[3]
|
pre_key = key[3]
|
||||||
if len(pre_key) != 0:
|
if len(pre_key) != 0:
|
||||||
with open('/etc/wire_py/.keys', 'r') as readfile:
|
with open(str(Path.home()) + '/.config/wire_py/keys', 'r') as readfile:
|
||||||
p_key = readfile.readlines()
|
p_key = readfile.readlines()
|
||||||
if pre_key in p_key or pre_key + '\n' in p_key:
|
if pre_key in p_key or pre_key + '\n' in p_key:
|
||||||
"""img_w, img_i, w_title, w_txt hand over"""
|
"""img_w, img_i, w_title, w_txt hand over"""
|
||||||
@ -765,13 +766,13 @@ class FrameWidgets(ttk.Frame):
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
with open('/etc/wire_py/.keys', 'a') as keyfile:
|
with open(str(Path.home()) + '/.config/wire_py/keys', 'a') as keyfile:
|
||||||
keyfile.write(pre_key + '\r')
|
keyfile.write(pre_key + '\r')
|
||||||
if len(path_split1) > 17:
|
if len(path_split1) > 17:
|
||||||
p1 = shutil.copy(filepath, Path('/etc/wire_py/'))
|
p1 = shutil.copy(filepath, str(Path.home()) + '/.config/wire_py/')
|
||||||
path_split = path_split1[len(path_split1) - 17:]
|
path_split = path_split1[len(path_split1) - 17:]
|
||||||
os.rename(p1, Path('/etc/wire_py') / str(path_split))
|
os.rename(p1, str(Path.home()) + '/.config/wire_py/' + str(path_split))
|
||||||
new_conf = '/etc/wire_py/' + path_split
|
new_conf = str(Path.home()) + '/.config/wire_py/' + path_split
|
||||||
if self.a != '':
|
if self.a != '':
|
||||||
check_call(['nmcli', 'connection', 'down', Tunnel.active()])
|
check_call(['nmcli', 'connection', 'down', Tunnel.active()])
|
||||||
self.label_empty()
|
self.label_empty()
|
||||||
@ -780,7 +781,7 @@ class FrameWidgets(ttk.Frame):
|
|||||||
'wireguard', 'file', new_conf], text=True)
|
'wireguard', 'file', new_conf], text=True)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
shutil.copy(filepath, Path('/etc/wire_py/'))
|
shutil.copy(filepath, str(Path.home()) + '/.config/wire_py/')
|
||||||
if self.a != '':
|
if self.a != '':
|
||||||
check_call(['nmcli', 'connection', 'down', Tunnel.active()])
|
check_call(['nmcli', 'connection', 'down', Tunnel.active()])
|
||||||
self.label_empty()
|
self.label_empty()
|
||||||
@ -865,7 +866,7 @@ class FrameWidgets(ttk.Frame):
|
|||||||
self.StrVar.set(self.a)
|
self.StrVar.set(self.a)
|
||||||
self.color_label()
|
self.color_label()
|
||||||
self.stop()
|
self.stop()
|
||||||
wg_read = Path('/etc/wire_py') / str(self.a + '.conf')
|
wg_read = str(Path.home()) + '/.config/wire_py/' + str(self.a + '.conf')
|
||||||
with open(wg_read, 'r') as file_for_key:
|
with open(wg_read, 'r') as file_for_key:
|
||||||
data = Tunnel.con_to_dict(file_for_key)
|
data = Tunnel.con_to_dict(file_for_key)
|
||||||
|
|
||||||
@ -1061,7 +1062,7 @@ class FrameWidgets(ttk.Frame):
|
|||||||
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])
|
||||||
check_call(['nmcli', 'connection', 'up', select_tl])
|
check_call(['nmcli', 'connection', 'up', select_tl])
|
||||||
wg_read = Path('/etc/wire_py') / str(select_tl + '.conf')
|
wg_read = str(Path.home()) + '/.config/wire_py/' + str(select_tl + '.conf')
|
||||||
with open(wg_read, 'r') as file:
|
with open(wg_read, 'r') as file:
|
||||||
data = Tunnel.con_to_dict(file)
|
data = Tunnel.con_to_dict(file)
|
||||||
|
|
||||||
|
@ -5,6 +5,6 @@ After=network-online.target
|
|||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
ExecStartPre=/bin/sleep 5
|
ExecStartPre=/bin/sleep 5
|
||||||
ExecStart=/usr/bin/start_wg.py
|
ExecStart=/usr/local/bin/start_wg.py
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=default.target
|
||||||
|
Loading…
x
Reference in New Issue
Block a user