1 Commits

11 changed files with 62 additions and 291 deletions

4
.idea/workspace.xml generated
View File

@ -350,7 +350,7 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1727379755537</updated> <updated>1727379755537</updated>
</task> </task>
<task id="LOCAL-00055" summary="fix installer add .keys file"> <task id="LOCAL-00055" summary="fix installer add keys file">
<option name="closed" value="true" /> <option name="closed" value="true" />
<created>1727380793216</created> <created>1727380793216</created>
<option name="number" value="00055" /> <option name="number" value="00055" />
@ -579,7 +579,7 @@
<MESSAGE value="info icon shadow fix end msg Export fix to" /> <MESSAGE value="info icon shadow fix end msg Export fix to" />
<MESSAGE value="little fixes" /> <MESSAGE value="little fixes" />
<MESSAGE value="fix msg_boxes when tunnel list = 0 a Start, Delete and Export" /> <MESSAGE value="fix msg_boxes when tunnel list = 0 a Start, Delete and Export" />
<MESSAGE value="fix installer add .keys file" /> <MESSAGE value="fix installer add keys file" />
<MESSAGE value="Changelog create When exporting, the folder is now copied to /tmp and the non .conf files are deleted before the zip file is created. In main.py os import removed. Since os have been replaced by pathlib and shutil.&#10;Start with version number 1.4.7&#10;Message window size corrected so text is displayed better" /> <MESSAGE value="Changelog create When exporting, the folder is now copied to /tmp and the non .conf files are deleted before the zip file is created. In main.py os import removed. Since os have been replaced by pathlib and shutil.&#10;Start with version number 1.4.7&#10;Message window size corrected so text is displayed better" />
<MESSAGE value="Fix msg_window and remove x , y argument&#10;Install further adapted and with colored&#10;text if user is not in group sudo or wheel.&#10;Added to install Opensuse for installation" /> <MESSAGE value="Fix msg_window and remove x , y argument&#10;Install further adapted and with colored&#10;text if user is not in group sudo or wheel.&#10;Added to install Opensuse for installation" />
<MESSAGE value=" - Menu add &#10; - New Modern Dark and Light(default) Theme" /> <MESSAGE value=" - Menu add &#10; - New Modern Dark and Light(default) Theme" />

View File

@ -8,12 +8,6 @@ My standard System: Linux Mint 22 Cinnamon
- for loops with lists replaced by List Comprehensions - for loops with lists replaced by List Comprehensions
- Crypt and Decrypt Config Files in ~/.config/wire_py - Crypt and Decrypt Config Files in ~/.config/wire_py
### Added
03-03-2025
- Fixes a new user files create
### Added ### Added
02-03-2025 02-03-2025

0
Wire-Py.desktop Normal file → Executable file
View File

Binary file not shown.

View File

@ -4,8 +4,8 @@ import gettext
import locale import locale
import os import os
import shutil import shutil
from subprocess import check_call
import subprocess import subprocess
from subprocess import check_call
import tkinter as tk import tkinter as tk
import zipfile import zipfile
from datetime import datetime from datetime import datetime
@ -13,7 +13,6 @@ from pathlib import Path
from tkinter import ttk from tkinter import ttk
import requests import requests
APP = 'wirepy' APP = 'wirepy'
LOCALE_DIR = "/usr/share/locale/" LOCALE_DIR = "/usr/share/locale/"
locale.bindtextdomain(APP, LOCALE_DIR) locale.bindtextdomain(APP, LOCALE_DIR)
@ -21,99 +20,42 @@ gettext.bindtextdomain(APP, LOCALE_DIR)
gettext.textdomain(APP) gettext.textdomain(APP)
_ = gettext.gettext _ = gettext.gettext
def dirs_and_files():
pth = Path.home() / '.config/wire_py'
pth.mkdir(parents=True, exist_ok=True)
sett = Path.home() / '.config/wire_py/settings'
ks = Path.home() / '.config/wire_py/keys'
if sett.exists():
pass
else:
sett.touch()
sett.write_text('[UPDATES]\non\n[THEME]\nlight\n[TOOLTIP]\nTrue\n[AUTOSTART ON]\noff')
if ks.exists():
pass
else:
ks.touch()
def files_for_autostart():
pth2 = Path.home() / '.config/systemd/user'
pth2.mkdir(parents=True, exist_ok=True)
wg_ser = Path.home() / '.config/systemd/user/wg_start.service'
if wg_ser.exists():
pass
else:
wg_ser.touch()
sett.write_text('[Unit]\nDescription=Automatic Tunnel Start\nAfter=network-online.target\n\n[Service]\nType=oneshot\nExecStartPre=/bin/sleep 5\nExecStart=/usr/local/bin/start_wg.py\n[Install]\nWantedBy=default.target')
check_call(['systemctl', '--user', 'enable', wg_start.service])
wg_set = Path(Path.home() / '.config/wire_py/settings') wg_set = Path(Path.home() / '.config/wire_py/settings')
class Create():
"""
This class is for the creation of the folders and files
required by Wire-Py, as well as for decryption
the tunnel from the user's home directory
"""
@staticmethod
def dir_and_files():
pth = Path.home() / '.config/wire_py'
pth.mkdir(parents=True, exist_ok=True)
sett = Path.home() / '.config/wire_py/settings'
ks = Path.home() / '.config/wire_py/keys'
if sett.exists():
pass
else:
sett.touch()
sett.write_text('[UPDATES]\non\n[THEME]\nlight\n[TOOLTIP]\nTrue\n[AUTOSTART ON]\noff\n')
if ks.exists():
pass
else:
ks.touch()
@staticmethod
def files_for_autostart():
pth2 = Path.home() / '.config/systemd/user'
pth2.mkdir(parents=True, exist_ok=True)
wg_ser = Path.home() / '.config/systemd/user/wg_start.service'
if wg_ser.exists():
pass
else:
wg_ser.touch()
wg_ser.write_text('[Unit]\nDescription=Automatic Tunnel Start\nAfter=network-online.target'
'\n\n[Service]\nType=oneshot\nExecStartPre=/bin/sleep 5\nExecStart=/usr/'
'local/bin/start_wg.py\n[Install]\nWantedBy=default.target')
check_call(['systemctl', '--user', 'enable', 'wg_start.service'])
@staticmethod
def make_dir():
''' Dirname "tlecdewg" = Tunnel Encrypt Decrypt Wireguard '''
dirname = Path('/tmp/tlecdcwg/')
if dirname.exists():
pass
else:
dirname.mkdir()
@staticmethod
def decrypt():
process = subprocess.run(['pkexec', '/usr/local/bin/ssl_decrypt.py'], stdout=subprocess.PIPE, text=True)
#print(process.stdout)
if process.returncode == 0:
print('File successfully decrypted...')
else:
print(f'Error with the following code... {process.returncode}')
@staticmethod
def encrypt():
process = subprocess.run(['pkexec', '/usr/local/bin/ssl_encrypt.py'], stdout=subprocess.PIPE, text=True)
print(process.stdout)
if process.returncode == 0:
print('All Files successfully encrypted...')
else:
print(f'Error with the following code... {process.returncode}')
class UOS:
"""
The class is only for unixoidal systems "UOS" = UnixOS
"""
"""
This method displays the user name of the logged-in user,
even if you are rooted in a shell
"""
@staticmethod
def username():
logname = str(Path.home())[6:]
file = Path.home() / '/tmp/.loguser'
with open(file, "w") as f:
f.write(logname)
class GiteaUpdate: class GiteaUpdate:
""" """
@ -287,13 +229,13 @@ class Tunnel:
""" """
@staticmethod @staticmethod
def list(): def list():
dirname = Path.home() / '.config/wire_py/'
dirname = Path('/tmp/tlecdcwg/')
wg_s = os.listdir(dirname) wg_s = os.listdir(dirname)
wg_s.remove('keys')
wg_s.remove('settings')
return wg_s return wg_s
""" """
This will export the tunnels. This will export the tunnels.
A zipfile with current date and time is created A zipfile with current date and time is created
@ -308,8 +250,11 @@ class Tunnel:
try: try:
if len(tl) != 0: if len(tl) != 0:
wg_tar = str(Path.home()) + '/' + now_datetime wg_tar = str(Path.home()) + '/' + now_datetime
shutil.copytree('/tmp/tlecdcwg/', '/tmp/wire_py', dirs_exist_ok=True) shutil.copytree(Path.home() / '.config/wire_py/', '/tmp/wire_py', dirs_exist_ok=True)
source = Path('/tmp/wire_py') source = Path('/tmp/wire_py')
Path.unlink(Path(source) / 'wg_py', missing_ok=True)
Path.unlink(Path(source) / 'keys', missing_ok=True)
Path.unlink(Path(source) / 'settings', missing_ok=True)
shutil.make_archive(wg_tar, 'zip', source) shutil.make_archive(wg_tar, 'zip', source)
#shutil.chown(wg_tar + '.zip', 1000, 1000) #shutil.chown(wg_tar + '.zip', 1000, 1000)
shutil.rmtree(source) shutil.rmtree(source)
@ -359,3 +304,5 @@ class Tipi:
else: else:
return True return True
wg_tips = Tipi.if_tip(wg_set)

View File

@ -9,13 +9,12 @@ install_file_with(){
mkdir -p ~/.config/wire_py && touch ~/.config/wire_py/keys && cp -u settings ~/.config/wire_py/ && \ mkdir -p ~/.config/wire_py && touch ~/.config/wire_py/keys && cp -u settings ~/.config/wire_py/ && \
mkdir -p ~/.config/systemd/user && cp -u wg_start.service ~/.config/systemd/user/ && \ mkdir -p ~/.config/systemd/user && cp -u wg_start.service ~/.config/systemd/user/ && \
systemctl --user enable wg_start.service systemctl --user enable wg_start.service
sudo cp -f org.sslcrypt.policy /usr/share/polkit-1/actions/ && \
sudo apt install python3-tk && \ sudo apt install python3-tk && \
sudo cp -fv wg_main.py start_wg.py cls_mth_fc.py ssl_encrypt.py ssl_decrypt.py /usr/local/bin/ && \ sudo cp -u wg_main.py start_wg.py cls_mth_fc.py /usr/local/bin/ && \
sudo cp -uR wp-icons lx-icons /usr/share/icons/ && sudo cp -uR TK-Themes /usr/share/ && \ sudo cp -uR wp-icons lx-icons /usr/share/icons/ && sudo cp -uR TK-Themes /usr/share/ && \
sudo cp -u languages/de/*.mo /usr/share/locale/de/LC_MESSAGES/ && \ sudo cp -u languages/de/*.mo /usr/share/locale/de/LC_MESSAGES/ && \
sudo ln -sf /usr/local/bin/wg_main.py /usr/local/bin/wirepy && \ sudo ln -sf /usr/local/bin/wg_main.py /usr/local/bin/wirepy && \
sudo cp -f Wire-Py.desktop /usr/share/applications/ sudo cp -u Wire-Py.desktop /usr/share/applications/
} }
install_arch_d(){ install_arch_d(){
@ -29,7 +28,6 @@ install_arch_d(){
sudo ln -sf /usr/bin/wirepy.py /usr/local/bin/wirepy && \ sudo ln -sf /usr/bin/wirepy.py /usr/local/bin/wirepy && \
sudo cp -u org.wirepy.policy /usr/share/polkit-1/actions/ && \ sudo cp -u org.wirepy.policy /usr/share/polkit-1/actions/ && \
sudo cp -u Wire-Py.desktop /usr/share/applications/ && \ sudo cp -u Wire-Py.desktop /usr/share/applications/ && \
sudo cp -u org.sslcrypt.policy /usr/share/polkit-1/actions/ && \
sudo cp -u wg_start.service /lib/systemd/system/ && \ sudo cp -u wg_start.service /lib/systemd/system/ && \
sudo systemctl enable wg_start.service sudo systemctl enable wg_start.service
} }
@ -128,7 +126,7 @@ else
clear clear
exit 0 exit 0
fi fi
#clear clear
read -n 1 -s -r -p $"To close the Window press a button" read -n 1 -s -r -p $"To close the Window press a button"
clear clear

View File

@ -1,42 +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">
<!--
Policy definitions for ssl_encrypt and ssl_decrypt
Copyright (C) 2025 Désiré Werner Menrath <polunga40@unity-mail.de>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see
<http://www.gnu.org/licenses/>.
-->
<policyconfig>
<action id="org.ssl_encrypt">
<defaults>
<allow_any>auth_admin_keep</allow_any>
<allow_active>yes</allow_active>
</defaults>
<annotate key="org.freedesktop.policykit.exec.path">/usr/local/bin/ssl_encrypt.py</annotate>
</action>
<action id="org.ssl_decrypt">
<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/local/bin/ssl_decrypt.py</annotate>
</action>
</policyconfig>

View File

@ -1,28 +0,0 @@
#!/usr/bin/python3
''' This Script decrypt Wireguardfiles for Wirepy users '''
import os
from subprocess import check_call
from pathlib import Path
import shutil
uname = Path('/tmp/.loguser')
with open(uname, 'r') as f:
logname = f.readline()
''' Dirname "tlecdewg" = Tunnel Encrypt Decrypt Wireguard '''
dirname = Path('/tmp/tlecdcwg/')
keyfile = '/usr/local/etc/ssl/pwgk.pem'
dirname2 = ('/home/' + logname + '/.config/wire_py/')
detl = os.listdir(dirname2)
os.chdir(dirname2)
detl.remove('keys')
detl.remove('settings')
if os.path.exists(dirname2 + 'pbwgk.pem'):
detl.remove('pbwgk.pem')
for detunnels in detl:
tlname2 = detunnels[:-4] + '.conf'
extpath = str(dirname) + '/' + tlname2
check_call(['openssl', 'pkeyutl', '-decrypt', '-inkey', keyfile, '-in', detunnels, '-out', extpath])
shutil.chown(extpath, 1000, 1000)

View File

@ -1,49 +0,0 @@
#!/usr/bin/python3
''' This Script encrypt Wireguardfiles for Wirepy users for more Security'''
import os
from subprocess import check_call
from pathlib import Path
import shutil
uname = Path('/tmp/.loguser')
with open(uname, 'r') as f:
logname = f.readline()
keyfile = Path(f'/home/{logname}/.config/wire_py/pbwgk.pem')
dirname = Path('/tmp/tlecdcwg/')
pkeyfile = '/usr/local/etc/ssl/pwgk.pem'
if not keyfile.is_file():
check_call(['openssl', 'rsa', '-in', pkeyfile, '-out', keyfile, '-outform', 'PEM', '-pubout'])
shutil.chown(keyfile, 1000, 1000)
if dirname.exists():
tl = os.listdir(str(dirname))
cpth = str(keyfile)
cryptfiles = cpth[:-9]
if keyfile.exists() and len(tl) != 0:
for tunnels in tl:
sourcetl = str(dirname) + '/' + tunnels
tlname = cryptfiles + tunnels[:-5] + '.dat'
check_call(['openssl', 'pkeyutl', '-encrypt', '-inkey', keyfile, '-pubin', '-in', sourcetl, '-out', tlname])
else:
if dirname.exists():
tl = os.listdir(str(dirname))
cpth = str(keyfile)
cryptfiles = cpth[:-9]
if keyfile.exists() and len(tl) != 0:
for tunnels in tl:
sourcetl = str(dirname) + '/' + tunnels
tlname = cryptfiles + tunnels[:-5] + '.dat'
check_call(['openssl', 'pkeyutl', '-encrypt', '-inkey', keyfile, '-pubin', '-in', sourcetl, '-out', tlname])

View File

@ -4,28 +4,18 @@ import gettext
import locale import locale
import webbrowser import webbrowser
import os import os
import sys
import signal
import subprocess
import shutil import shutil
import subprocess
import tkinter as tk 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, Create, msg_window, Tipi, GiteaUpdate, UOS) from cls_mth_fc import (Tunnel, msg_window, GiteaUpdate, wg_tips, dirs_and_files, wg_set, files_for_autostart)
UOS.username()
Create.dir_and_files()
Create.make_dir()
Create.decrypt()
tcl_path = Path('/usr/share/TK-Themes') tcl_path = Path('/usr/share/TK-Themes')
wg_set = Path(Path.home() / '.config/wire_py/settings')
wg_tips = Tipi.if_tip(wg_set)
dirname = Path('/tmp/tlecdcwg/')
''' 1 = 1. Year, 09 = Month of the Year, 2924 = Day and Year of the Year ''' ''' 1 = 1. Year, 09 = Month of the Year, 2924 = Day and Year of the Year '''
version = 'v. 2.03.0325' version = 'v. 2.03.0225'
res = GiteaUpdate.api_down('https://git.ilunix.de/api/v1/repos/punix/Wire-Py/releases', version) res = GiteaUpdate.api_down('https://git.ilunix.de/api/v1/repos/punix/Wire-Py/releases', version)
@ -37,31 +27,6 @@ gettext.bindtextdomain(APP, LOCALE_DIR)
gettext.textdomain(APP) gettext.textdomain(APP)
_ = gettext.gettext _ = gettext.gettext
def signalHandler(signum, frame):
''' Determine clear text names for signal numbers '''
SIGNALS_TO_NAMES_DICT = dict((getattr(signal, n), n) \
for n in dir(signal) if n.startswith('SIG') and '_' not in n )
signame = SIGNALS_TO_NAMES_DICT.get(signum, "Unnamed signal: %d" % signum)
'''
End program for certain signals,
report to others only reception
'''
if signum in (signal.SIGINT, signal.SIGTERM):
exitCode = 1
print("\nSignal '%s' (%d) received. => Aborting with exit code %d." % (signame, signum, exitCode))
shutil.rmtree(dirname)
Path.unlink('/tmp/.loguser')
print('Breakdown by user...')
sys.exit(exitCode)
else:
print("Signal %d received and ignored." % signum)
shutil.rmtree(dirname)
Path.unlink('/tmp/.loguser')
print('Process unexpectedly ended...')
signal.signal(signal.SIGINT, signalHandler)
signal.signal(signal.SIGTERM, signalHandler)
signal.signal(signal.SIGHUP, signalHandler)
class MainWindow(tk.Tk): class MainWindow(tk.Tk):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
@ -365,7 +330,7 @@ class FrameWidgets(ttk.Frame):
''' Listbox with Scrollbar ''' ''' Listbox with Scrollbar '''
def enable_check_box(_): def enable_check_box(_):
Create.files_for_autostart() 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')
@ -382,7 +347,6 @@ class FrameWidgets(ttk.Frame):
self.l_box.configure(yscrollcommand=self.scrollbar.set) self.l_box.configure(yscrollcommand=self.scrollbar.set)
''' 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[:-5]) self.l_box.insert("end", tunnels[:-5])
@ -416,7 +380,7 @@ class FrameWidgets(ttk.Frame):
''' Button Vpn ''' ''' Button Vpn '''
if self.a != '': if self.a != '':
self.stop() self.stop()
wg_read = '/tmp/tlecdcwg/' + 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)
@ -454,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('/tmp/tlecdcwg/' + 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])
@ -467,10 +431,8 @@ class FrameWidgets(ttk.Frame):
set_file7.writelines(lines6) set_file7.writelines(lines6)
self.selected_option.set(0) self.selected_option.set(0)
self.autoconnect_var.set(_('no Autoconnect')) self.autoconnect_var.set(_('no Autoconnect'))
is_encrypt = Path.home() / '.config/wire_py' / str(select_tl + '.dat')
if is_encrypt.is_file(): Path.unlink(str(Path.home()) + '/.config/wire_py/' + str(select_tl + '.conf'))
Path.unlink(str(Path.home()) + '/.config/wire_py/' + str(select_tl + '.dat'))
Path.unlink(Path('/tmp/tlecdcwg') / str(select_tl + '.conf'))
with open(str(Path.home()) + '/.config/wire_py/keys', 'r') as readfile: with open(str(Path.home()) + '/.config/wire_py/keys', 'r') as readfile:
with open(str(Path.home()) + '/.config/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:
@ -672,10 +634,9 @@ 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('/tmp/tlecdcwg') / 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)
Path.unlink(str(Path.home()) + '/.config/wire_py/' + str(select_tl + '.dat'))
self.l_box.delete(self.select_tunnel[0]) self.l_box.delete(self.select_tunnel[0])
self.l_box.insert("end", self.lb_rename.get()) self.l_box.insert("end", self.lb_rename.get())
self.l_box.update() self.l_box.update()
@ -692,8 +653,6 @@ class FrameWidgets(ttk.Frame):
theme_set5.writelines(lines5) theme_set5.writelines(lines5)
self.autoconnect_var.set(value=new_a_connect) self.autoconnect_var.set(value=new_a_connect)
Create.encrypt()
return select_tl return select_tl
except IndexError: except IndexError:
@ -778,7 +737,7 @@ class FrameWidgets(ttk.Frame):
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.
""" """
Create.dir_and_files() dirs_and_files()
try: try:
filepath = filedialog.askopenfilename(initialdir=str(Path.home()), title=_('Select Wireguard config File'), filepath = filedialog.askopenfilename(initialdir=str(Path.home()), title=_('Select Wireguard config File'),
@ -810,10 +769,10 @@ class FrameWidgets(ttk.Frame):
with open(str(Path.home()) + '/.config/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, '/tmp/tlecdcwg/') 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, '/tmp/tlecdcwg/' + str(path_split)) os.rename(p1, str(Path.home()) + '/.config/wire_py/' + str(path_split))
new_conf = '/tmp/tlecdcwg/' + 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()
@ -821,10 +780,8 @@ class FrameWidgets(ttk.Frame):
subprocess.check_output(['nmcli', 'connection', 'import', 'type', subprocess.check_output(['nmcli', 'connection', 'import', 'type',
'wireguard', 'file', new_conf], text=True) 'wireguard', 'file', new_conf], text=True)
Create.encrypt()
else: else:
shutil.copy(filepath, '/tmp/tlecdcwg/') 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()
@ -832,8 +789,6 @@ class FrameWidgets(ttk.Frame):
subprocess.check_output(['nmcli', 'connection', 'import', 'type', subprocess.check_output(['nmcli', 'connection', 'import', 'type',
'wireguard', 'file', filepath], text=True) 'wireguard', 'file', filepath], text=True)
Create.encrypt()
self.StrVar.set('') self.StrVar.set('')
self.a = Tunnel.active() self.a = Tunnel.active()
self.l_box.insert(0, self.a) self.l_box.insert(0, self.a)
@ -911,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 = '/tmp/tlecdcwg/' + 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)
@ -1107,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 = '/tmp/tlecdcwg/' + 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)
@ -1205,7 +1160,3 @@ if __name__ == '__main__':
window.tk.call('set', '::tk::dialog::file::showHiddenBtn', '0') window.tk.call('set', '::tk::dialog::file::showHiddenBtn', '0')
window.tk.call('set', '::tk::dialog::file::showHiddenVar', '0') window.tk.call('set', '::tk::dialog::file::showHiddenVar', '0')
window.mainloop() window.mainloop()
shutil.rmtree(dirname)
Path.unlink('/tmp/.loguser')
sys.exit(0)