Merge pull request '1.11.0724' (#22) from 1.11.0724 into main
Reviewed-on: https://git.ilunix.de/punix/Wire-Py/pulls/22
This commit is contained in:
commit
5f6aaa6cf1
@ -4,11 +4,14 @@
|
|||||||
<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=" - Fix a ConToDict Class when Endpoint not in Wireguard config file">
|
<list default="true" id="940e1630-c825-4d4c-be80-bc11f543c122" name="Changes" comment="- Optimize Class and Tooltip">
|
||||||
|
<change afterPath="$PROJECT_DIR$/run_as" 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$/Changelog" beforeDir="false" afterPath="$PROJECT_DIR$/Changelog" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Changelog" beforeDir="false" afterPath="$PROJECT_DIR$/Changelog" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/install" beforeDir="false" afterPath="$PROJECT_DIR$/install" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/testtheme.py" beforeDir="false" />
|
<change beforePath="$PROJECT_DIR$/settings" beforeDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/start_wg.py" beforeDir="false" afterPath="$PROJECT_DIR$/start_wg.py" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/theme" beforeDir="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" />
|
||||||
<change beforePath="$PROJECT_DIR$/wg_main.py" beforeDir="false" afterPath="$PROJECT_DIR$/wg_main.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/wg_main.py" beforeDir="false" afterPath="$PROJECT_DIR$/wg_main.py" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
@ -61,9 +64,10 @@
|
|||||||
"Python.wg_main.executor": "Run",
|
"Python.wg_main.executor": "Run",
|
||||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
"Shell Script.install.executor": "Run",
|
"Shell Script.install.executor": "Run",
|
||||||
|
"Shell Script.run_as.executor": "Run",
|
||||||
"git-widget-placeholder": "main",
|
"git-widget-placeholder": "main",
|
||||||
"last_opened_file_path": "/home/punix/Pyapps/wire-py",
|
"last_opened_file_path": "/home/punix/Pyapps/wire-py",
|
||||||
"settings.editor.selected.configurable": "configurable.group.editor"
|
"settings.editor.selected.configurable": "reference.settingsdialog.IDE.editor.colors"
|
||||||
}
|
}
|
||||||
}</component>
|
}</component>
|
||||||
<component name="RecentsManager">
|
<component name="RecentsManager">
|
||||||
@ -144,38 +148,6 @@
|
|||||||
<option name="presentableId" value="Default" />
|
<option name="presentableId" value="Default" />
|
||||||
<updated>1723279982210</updated>
|
<updated>1723279982210</updated>
|
||||||
</task>
|
</task>
|
||||||
<task id="LOCAL-00013" summary="In FrameWidged Class else Block StrVar, this resorts reference and variable assignment together">
|
|
||||||
<option name="closed" value="true" />
|
|
||||||
<created>1724401340512</created>
|
|
||||||
<option name="number" value="00013" />
|
|
||||||
<option name="presentableId" value="LOCAL-00013" />
|
|
||||||
<option name="project" value="LOCAL" />
|
|
||||||
<updated>1724401340512</updated>
|
|
||||||
</task>
|
|
||||||
<task id="LOCAL-00014" summary="add method init_and_report and label_empty to Class ShowAddress">
|
|
||||||
<option name="closed" value="true" />
|
|
||||||
<created>1724410630021</created>
|
|
||||||
<option name="number" value="00014" />
|
|
||||||
<option name="presentableId" value="LOCAL-00014" />
|
|
||||||
<option name="project" value="LOCAL" />
|
|
||||||
<updated>1724410630021</updated>
|
|
||||||
</task>
|
|
||||||
<task id="LOCAL-00015" summary="little fixes in Class Import">
|
|
||||||
<option name="closed" value="true" />
|
|
||||||
<created>1724416642213</created>
|
|
||||||
<option name="number" value="00015" />
|
|
||||||
<option name="presentableId" value="LOCAL-00015" />
|
|
||||||
<option name="project" value="LOCAL" />
|
|
||||||
<updated>1724416642213</updated>
|
|
||||||
</task>
|
|
||||||
<task id="LOCAL-00016" summary="fix label when laat Tunnel delete and fix Tuple error in delete and Start/Stop when listbox empty">
|
|
||||||
<option name="closed" value="true" />
|
|
||||||
<created>1724495688099</created>
|
|
||||||
<option name="number" value="00016" />
|
|
||||||
<option name="presentableId" value="LOCAL-00016" />
|
|
||||||
<option name="project" value="LOCAL" />
|
|
||||||
<updated>1724495688099</updated>
|
|
||||||
</task>
|
|
||||||
<task id="LOCAL-00017" summary="remove a ',' in DNS Name">
|
<task id="LOCAL-00017" summary="remove a ',' in DNS Name">
|
||||||
<option name="closed" value="true" />
|
<option name="closed" value="true" />
|
||||||
<created>1724576599289</created>
|
<created>1724576599289</created>
|
||||||
@ -536,7 +508,39 @@
|
|||||||
<option name="project" value="LOCAL" />
|
<option name="project" value="LOCAL" />
|
||||||
<updated>1729353898830</updated>
|
<updated>1729353898830</updated>
|
||||||
</task>
|
</task>
|
||||||
<option name="localTasksCounter" value="62" />
|
<task id="LOCAL-00062" summary="- Optimize Class. Move to wg_main Import Start/StopBTN and Tooltip">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1729541504291</created>
|
||||||
|
<option name="number" value="00062" />
|
||||||
|
<option name="presentableId" value="LOCAL-00062" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1729541504292</updated>
|
||||||
|
</task>
|
||||||
|
<task id="LOCAL-00063" summary="- Optimize Class. Move to wg_main Import Start/StopBTN and Tooltip">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1729541561434</created>
|
||||||
|
<option name="number" value="00063" />
|
||||||
|
<option name="presentableId" value="LOCAL-00063" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1729541561434</updated>
|
||||||
|
</task>
|
||||||
|
<task id="LOCAL-00064" summary="- Optimize Class. Move to wg_main Import Start/StopBTN and Tooltip">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1729593628907</created>
|
||||||
|
<option name="number" value="00064" />
|
||||||
|
<option name="presentableId" value="LOCAL-00064" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1729593628908</updated>
|
||||||
|
</task>
|
||||||
|
<task id="LOCAL-00065" summary="- Optimize Class and Tooltip">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1729938941026</created>
|
||||||
|
<option name="number" value="00065" />
|
||||||
|
<option name="presentableId" value="LOCAL-00065" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1729938941027</updated>
|
||||||
|
</task>
|
||||||
|
<option name="localTasksCounter" value="66" />
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="UnknownFeatures">
|
<component name="UnknownFeatures">
|
||||||
@ -577,8 +581,6 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="VcsManagerConfiguration">
|
<component name="VcsManagerConfiguration">
|
||||||
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
|
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
|
||||||
<MESSAGE value="set rights in install and a .conf a import Tunnel Filedialog Part 1 /home when open" />
|
|
||||||
<MESSAGE value="fix set rights in install and a .conf a import Tunnel Filedialog Part 1 /home when open" />
|
|
||||||
<MESSAGE value="fix a filedialog for hidden Files work install rollback to bash for start wirepy and wirepy rollback to bash" />
|
<MESSAGE value="fix a filedialog for hidden Files work install rollback to bash for start wirepy and wirepy rollback to bash" />
|
||||||
<MESSAGE value="install rollback bash to py wirepy and wirepy rollback to py" />
|
<MESSAGE value="install rollback bash to py wirepy and wirepy rollback to py" />
|
||||||
<MESSAGE value="fix install and .desktop File Tar works now for user home and filebrowser.askfilebrowser start now in user home" />
|
<MESSAGE value="fix install and .desktop File Tar works now for user home and filebrowser.askfilebrowser start now in user home" />
|
||||||
@ -602,20 +604,17 @@
|
|||||||
<MESSAGE value=" - Menu add - New Modern Dark and Light(default) Theme" />
|
<MESSAGE value=" - Menu add - New Modern Dark and Light(default) Theme" />
|
||||||
<MESSAGE value=" - Theme modify to water-theme - add ttk.Menubutton vor modern Menu and automatic theme and textvariable for color on font in menu" />
|
<MESSAGE value=" - Theme modify to water-theme - add ttk.Menubutton vor modern Menu and automatic theme and textvariable for color on font in menu" />
|
||||||
<MESSAGE value=" - Add Options, Help, Update Label and Update Menubutton - Theme now separate Light and Dark" />
|
<MESSAGE value=" - Add Options, Help, Update Label and Update Menubutton - Theme now separate Light and Dark" />
|
||||||
<option name="LAST_COMMIT_MESSAGE" value=" - Add Options, Help, Update Label and Update Menubutton - Theme now separate Light and Dark" />
|
<MESSAGE value="- Optimize Class. Move to wg_main Import Start/StopBTN and Tooltip" />
|
||||||
|
<MESSAGE value="- Optimize Class and Tooltip" />
|
||||||
|
<option name="LAST_COMMIT_MESSAGE" value="- Optimize Class and Tooltip" />
|
||||||
</component>
|
</component>
|
||||||
<component name="XDebuggerManager">
|
<component name="XDebuggerManager">
|
||||||
<breakpoint-manager>
|
<breakpoint-manager>
|
||||||
<breakpoints>
|
<breakpoints>
|
||||||
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
|
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
|
||||||
<url>file://$PROJECT_DIR$/wg_func.py</url>
|
<url>file://$PROJECT_DIR$/start_wg.py</url>
|
||||||
<line>341</line>
|
<line>1</line>
|
||||||
<option name="timeStamp" value="8" />
|
<option name="timeStamp" value="2" />
|
||||||
</line-breakpoint>
|
|
||||||
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
|
|
||||||
<url>file://$PROJECT_DIR$/wg_main.py</url>
|
|
||||||
<line>273</line>
|
|
||||||
<option name="timeStamp" value="11" />
|
|
||||||
</line-breakpoint>
|
</line-breakpoint>
|
||||||
</breakpoints>
|
</breakpoints>
|
||||||
</breakpoint-manager>
|
</breakpoint-manager>
|
||||||
|
25
Changelog
25
Changelog
@ -4,12 +4,29 @@ My standard System: Linux Mint 22 Cinnamon
|
|||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
- os import in wg_func replaced by other methods
|
- os import in wg_func replaced by other methods
|
||||||
- Guide to menu '?' with pictures
|
|
||||||
- In Gitea Readme enter text, images
|
|
||||||
- Own filedialog for import
|
|
||||||
- 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
|
||||||
- Keeping Classes Together
|
- Update search after start of Wire-Py
|
||||||
|
|
||||||
|
|
||||||
|
### Added
|
||||||
|
27-10-2024
|
||||||
|
|
||||||
|
- Add Autoconnect settings to settings.conf
|
||||||
|
|
||||||
|
|
||||||
|
### Added
|
||||||
|
26-10-2024
|
||||||
|
|
||||||
|
- Add run_as Bash script and open_gitea.py python script
|
||||||
|
- Add Tooltip disable/enable
|
||||||
|
- Rename settings to settings.conf for theme, updates and tooltip enable in one file
|
||||||
|
|
||||||
|
|
||||||
|
### Added
|
||||||
|
25-10-2024
|
||||||
|
|
||||||
|
- Optimize Class and Tooltip
|
||||||
|
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
16
install
16
install
@ -7,8 +7,8 @@ BLUE='\033[30;1;34m'
|
|||||||
install_file_with(){
|
install_file_with(){
|
||||||
clear
|
clear
|
||||||
sudo apt install python3-tk && \
|
sudo apt install python3-tk && \
|
||||||
sudo cp -u wg_main.py start_wg.py wg_func.py wirepy.py /usr/bin/ && \
|
sudo cp -u wg_main.py start_wg.py wg_func.py wirepy.py run_as open_gitea.py /usr/bin/ && \
|
||||||
sudo mkdir -p /etc/wire_py && sudo touch /etc/wire_py/.keys && sudo cp -u settings theme /etc/wire_py/ && \
|
sudo mkdir -p /etc/wire_py && sudo touch /etc/wire_py/.keys && sudo cp -u settings.conf /etc/wire_py/ && \
|
||||||
sudo cp -uR wp-icons /usr/share/icons/ && sudo cp -uR TK-Themes /usr/share/ && \
|
sudo cp -uR wp-icons /usr/share/icons/ && sudo cp -uR TK-Themes /usr/share/ && \
|
||||||
sudo chown -R root:root /etc/wire_py && sudo chmod 755 /etc/wire_py && \
|
sudo chown -R root:root /etc/wire_py && sudo chmod 755 /etc/wire_py && \
|
||||||
sudo ln -sf /usr/bin/wirepy.py /usr/local/bin/wirepy && \
|
sudo ln -sf /usr/bin/wirepy.py /usr/local/bin/wirepy && \
|
||||||
@ -21,8 +21,8 @@ install_file_with(){
|
|||||||
install_arch_d(){
|
install_arch_d(){
|
||||||
clear
|
clear
|
||||||
sudo pacman -S --noconfirm tk python3 python-requests && \
|
sudo pacman -S --noconfirm tk python3 python-requests && \
|
||||||
sudo cp -u wg_main.py start_wg.py wg_func.py wirepy.py /usr/bin/ && \
|
sudo cp -u wg_main.py start_wg.py wg_func.py wirepy.py run_as open_gitea.py /usr/bin/ && \
|
||||||
sudo mkdir -p /etc/wire_py && sudo touch /etc/wire_py/.keys && sudo cp -u settings theme /etc/wire_py/ && \
|
sudo mkdir -p /etc/wire_py && sudo touch /etc/wire_py/.keys && sudo cp -u settings.conf /etc/wire_py/ && \
|
||||||
sudo cp -uR wp-icons /usr/share/icons/ && sudo cp -uR TK-Themes /usr/share/ && \
|
sudo cp -uR wp-icons /usr/share/icons/ && sudo cp -uR TK-Themes /usr/share/ && \
|
||||||
sudo chown -R root:root /etc/wire_py && sudo chmod 755 /etc/wire_py && \
|
sudo chown -R root:root /etc/wire_py && sudo chmod 755 /etc/wire_py && \
|
||||||
sudo ln -sf /usr/bin/wirepy.py /usr/local/bin/wirepy && \
|
sudo ln -sf /usr/bin/wirepy.py /usr/local/bin/wirepy && \
|
||||||
@ -89,9 +89,9 @@ elif grep -i 'fedora' /etc/os-release > /dev/null 2>&1
|
|||||||
if ! which python3-tkinter &> /dev/null
|
if ! which python3-tkinter &> /dev/null
|
||||||
then sudo dnf install python3-tkinter -y
|
then sudo dnf install python3-tkinter -y
|
||||||
|
|
||||||
sudo cp -u wg_main.py start_wg.py wg_func.py wirepy.py /usr/bin/ && \
|
sudo cp -u wg_main.py start_wg.py wg_func.py wirepy.py run_as open_gitea.py /usr/bin/ && \
|
||||||
sudo mkdir -p /etc/wire_py && sudo touch /etc/wire_py/.keys && \
|
sudo mkdir -p /etc/wire_py && sudo touch /etc/wire_py/.keys && \
|
||||||
sudo cp -u settings theme /etc/wire_py/ && \
|
sudo cp -u settings.conf /etc/wire_py/ && \
|
||||||
sudo cp -uR wp-icons /usr/share/icons/ && sudo cp -uR TK-Themes /usr/share/ && \
|
sudo cp -uR wp-icons /usr/share/icons/ && sudo cp -uR TK-Themes /usr/share/ && \
|
||||||
sudo chown -R root:root /etc/wire_py && sudo chmod 755 /etc/wire_py && \
|
sudo chown -R root:root /etc/wire_py && sudo chmod 755 /etc/wire_py && \
|
||||||
sudo ln -sf /usr/bin/wirepy.py /usr/local/bin/wirepy && \
|
sudo ln -sf /usr/bin/wirepy.py /usr/local/bin/wirepy && \
|
||||||
@ -105,9 +105,9 @@ elif grep -i 'suse' /etc/os-release > /dev/null 2>&1
|
|||||||
then
|
then
|
||||||
if ! which python311-tk &> /dev/null
|
if ! which python311-tk &> /dev/null
|
||||||
then sudo zypper install python311-tk
|
then sudo zypper install python311-tk
|
||||||
sudo cp -u wg_main.py start_wg.py wg_func.py wirepy.py /usr/bin/ && \
|
sudo cp -u wg_main.py start_wg.py wg_func.py wirepy.py run_as open_gitea.py /usr/bin/ && \
|
||||||
sudo mkdir -p /etc/wire_py && sudo touch /etc/wire_py/.keys && \
|
sudo mkdir -p /etc/wire_py && sudo touch /etc/wire_py/.keys && \
|
||||||
sudo cp -u settings theme /etc/wire_py/ && \
|
sudo cp -u settings.conf /etc/wire_py/ && \
|
||||||
sudo cp -uR wp-icons /usr/share/icons/ && sudo cp -uR TK-Themes /usr/share/ && \
|
sudo cp -uR wp-icons /usr/share/icons/ && sudo cp -uR TK-Themes /usr/share/ && \
|
||||||
sudo chown -R root:root /etc/wire_py && sudo chmod 755 /etc/wire_py && \
|
sudo chown -R root:root /etc/wire_py && sudo chmod 755 /etc/wire_py && \
|
||||||
sudo ln -sf /usr/bin/wirepy.py /usr/local/bin/wirepy && \
|
sudo ln -sf /usr/bin/wirepy.py /usr/local/bin/wirepy && \
|
||||||
|
5
open_gitea.py
Executable file
5
open_gitea.py
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import webbrowser
|
||||||
|
|
||||||
|
webbrowser.open('https://git.ilunix.de/punix/Wire-Py')
|
8
settings.conf
Normal file
8
settings.conf
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
[UPDATES]
|
||||||
|
on
|
||||||
|
[THEME]
|
||||||
|
light
|
||||||
|
[TOOLTIP]
|
||||||
|
True
|
||||||
|
[AUTOSTART ON]
|
||||||
|
off
|
10
start_wg.py
10
start_wg.py
@ -2,11 +2,13 @@
|
|||||||
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/wg_py')
|
path_to_file = Path('/etc/wire_py/settings.conf')
|
||||||
|
|
||||||
if Path.exists(path_to_file):
|
with open(path_to_file, 'r') as a_con:
|
||||||
a_con = Path.read_text(path_to_file)
|
lines = a_con.readlines()
|
||||||
|
a_con = lines[7].strip()
|
||||||
|
if a_con != 'off':
|
||||||
check_call(['nmcli', 'connection', 'up', a_con])
|
check_call(['nmcli', 'connection', 'up', a_con])
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
208
wg_func.py
208
wg_func.py
@ -3,6 +3,7 @@
|
|||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import time
|
||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
import zipfile
|
import zipfile
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
@ -15,9 +16,7 @@ import requests
|
|||||||
''' 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. 1.10.2124'
|
version = 'v. 1.10.2124'
|
||||||
|
|
||||||
path_to_file = Path('/etc/wire_py/wg_py')
|
path_to_file2 = Path('/etc/wire_py/settings.conf')
|
||||||
path_to_file2 = Path('/etc/wire_py/settings')
|
|
||||||
path_to_file3 = Path('/etc/wire_py/theme')
|
|
||||||
_u = Path.read_text(Path('/tmp/_u'))
|
_u = Path.read_text(Path('/tmp/_u'))
|
||||||
|
|
||||||
UPDATE_API_URL = 'https://git.ilunix.de/api/v1/repos/punix/Wire-Py/releases'
|
UPDATE_API_URL = 'https://git.ilunix.de/api/v1/repos/punix/Wire-Py/releases'
|
||||||
@ -32,7 +31,7 @@ class WirePyUpdate:
|
|||||||
response_dict = response_dict[0]
|
response_dict = response_dict[0]
|
||||||
with open(path_to_file2, 'r') as set_file:
|
with open(path_to_file2, 'r') as set_file:
|
||||||
set_file = set_file.read()
|
set_file = set_file.read()
|
||||||
if 'Update on' in set_file:
|
if 'on\n' in set_file:
|
||||||
if version[3:] != response_dict['tag_name']:
|
if version[3:] != response_dict['tag_name']:
|
||||||
return response_dict['tag_name']
|
return response_dict['tag_name']
|
||||||
else:
|
else:
|
||||||
@ -76,7 +75,8 @@ class WirePyUpdate:
|
|||||||
res = WirePyUpdate.api_down()
|
res = WirePyUpdate.api_down()
|
||||||
|
|
||||||
|
|
||||||
def msg_window(img_w, img_i, w_title, w_txt):
|
|
||||||
|
def msg_window(img_w, img_i, w_title, w_txt, txt2=None, com=None):
|
||||||
"""
|
"""
|
||||||
Function for different message windows for the user. with 4 arguments to be passed.
|
Function for different message windows for the user. with 4 arguments to be passed.
|
||||||
To create messages with your own images, icons, and titles. As an alternative to Python Messagebox.
|
To create messages with your own images, icons, and titles. As an alternative to Python Messagebox.
|
||||||
@ -93,13 +93,25 @@ def msg_window(img_w, img_i, w_title, w_txt):
|
|||||||
msg.configure(pady=15, padx=15)
|
msg.configure(pady=15, padx=15)
|
||||||
msg.img = tk.PhotoImage(file=img_w)
|
msg.img = tk.PhotoImage(file=img_w)
|
||||||
msg.i_window = tk.Label(msg, image=msg.img)
|
msg.i_window = tk.Label(msg, image=msg.img)
|
||||||
msg.i_window.grid(column=0, row=0)
|
|
||||||
label = tk.Label(msg, text=w_txt)
|
label = tk.Label(msg, text=w_txt)
|
||||||
label.config(font=('Ubuntu', 11), padx=15)
|
|
||||||
label.grid(column=1, row=0)
|
label.grid(column=1, row=0)
|
||||||
|
|
||||||
|
if txt2 != None and com != None:
|
||||||
|
label.config(font=('Ubuntu', 11), padx=15, justify='left')
|
||||||
|
msg.i_window.grid(column=0, row=0, sticky='nw')
|
||||||
|
button2 = ttk.Button(msg, text=f'{txt2}', command=com, padding=4)
|
||||||
|
button2.grid(column=0, row=1, sticky='e', columnspan=2)
|
||||||
|
button = ttk.Button(msg, text='OK', command=msg.destroy, padding=4)
|
||||||
|
button.grid(column=0, row=1, sticky='w', columnspan=2)
|
||||||
|
|
||||||
|
else:
|
||||||
|
label.config(font=('Ubuntu', 11), padx=15)
|
||||||
|
msg.i_window.grid(column=0, row=0)
|
||||||
button = ttk.Button(msg, text='OK', command=msg.destroy, padding=4)
|
button = ttk.Button(msg, text='OK', command=msg.destroy, padding=4)
|
||||||
button.config()
|
|
||||||
button.grid(column=0, columnspan=2, row=1)
|
button.grid(column=0, columnspan=2, row=1)
|
||||||
|
|
||||||
img_i = tk.PhotoImage(file=img_i)
|
img_i = tk.PhotoImage(file=img_i)
|
||||||
msg.iconphoto(True, img_i)
|
msg.iconphoto(True, img_i)
|
||||||
msg.columnconfigure(0, weight=1)
|
msg.columnconfigure(0, weight=1)
|
||||||
@ -107,43 +119,19 @@ def msg_window(img_w, img_i, w_title, w_txt):
|
|||||||
msg.winfo_toplevel()
|
msg.winfo_toplevel()
|
||||||
|
|
||||||
|
|
||||||
class GreenLabel:
|
class Tunnel:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Show the active tunnel in green in the label
|
Class of Methods for Wire-Py
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
self.StrVar = None
|
|
||||||
self.lb_tunnel = None
|
|
||||||
|
|
||||||
def green_show_label(self):
|
|
||||||
with open(path_to_file3, 'r') as read_file:
|
|
||||||
if 'light' in read_file:
|
|
||||||
self.lb_tunnel = ttk.Label(self, textvariable=self.StrVar, foreground='green')
|
|
||||||
|
|
||||||
else:
|
|
||||||
self.lb_tunnel = ttk.Label(self, textvariable=self.StrVar, foreground='yellow')
|
|
||||||
|
|
||||||
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(0, weight=1)
|
|
||||||
|
|
||||||
def columnconfigure(self, param, weight):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def rowconfigure(self, param, weight):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class ConToDict:
|
|
||||||
"""
|
"""
|
||||||
The config file is packed into a dictionary,
|
The config file is packed into a dictionary,
|
||||||
to display the values Address , DNS and Peer in the labels
|
to display the values Address , DNS and Peer in the labels
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def covert_to_dict(cls, file):
|
def con_to_dict(cls, file):
|
||||||
|
|
||||||
dictlist = []
|
dictlist = []
|
||||||
for lines in file.readlines():
|
for lines in file.readlines():
|
||||||
@ -184,7 +172,6 @@ class ConToDict:
|
|||||||
return address, dns, endpoint, pre_key
|
return address, dns, endpoint, pre_key
|
||||||
|
|
||||||
|
|
||||||
class TunnelActiv:
|
|
||||||
"""
|
"""
|
||||||
Shows the Active Tunnel
|
Shows the Active Tunnel
|
||||||
"""
|
"""
|
||||||
@ -200,61 +187,12 @@ class TunnelActiv:
|
|||||||
|
|
||||||
return active
|
return active
|
||||||
|
|
||||||
|
|
||||||
class ShowAddress:
|
|
||||||
"""
|
|
||||||
Displays the value address, DNS and peer in the labels
|
|
||||||
or empty it again
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
self.lb_frame2 = None
|
|
||||||
self.lb_frame = None
|
|
||||||
self.endpoint = None
|
|
||||||
self.dns = None
|
|
||||||
self.address = None
|
|
||||||
self.enp = None
|
|
||||||
self.DNS = None
|
|
||||||
self.add = None
|
|
||||||
|
|
||||||
def init_and_report(self, data=None):
|
|
||||||
""" Address Label """
|
|
||||||
self.add = tk.StringVar()
|
|
||||||
self.add.set('Address: ' + data[0])
|
|
||||||
self.DNS = tk.StringVar()
|
|
||||||
self.DNS.set(' DNS: ' + data[1])
|
|
||||||
self.enp = tk.StringVar()
|
|
||||||
self.enp.set('Endpoint: ' + data[2])
|
|
||||||
|
|
||||||
def label_empty(self):
|
|
||||||
self.add.set('')
|
|
||||||
self.DNS.set('')
|
|
||||||
self.enp.set('')
|
|
||||||
|
|
||||||
def show_data(self):
|
|
||||||
""" Address Label """
|
|
||||||
self.address = ttk.Label(self.lb_frame, textvariable=self.add, foreground='#0071ff')
|
|
||||||
self.address.grid(column=0, row=5, sticky='w', padx=10, pady=6)
|
|
||||||
self.address.config(font=('Ubuntu', 9))
|
|
||||||
|
|
||||||
''' DNS Label '''
|
|
||||||
self.dns = ttk.Label(self.lb_frame, textvariable=self.DNS, foreground='#0071ff')
|
|
||||||
self.dns.grid(column=0, row=7, sticky='w', padx=10, pady=6)
|
|
||||||
self.dns.config(font=('Ubuntu', 9))
|
|
||||||
|
|
||||||
''' Endpoint Label '''
|
|
||||||
self.endpoint = ttk.Label(self.lb_frame2, textvariable=self.enp, foreground='#0071ff')
|
|
||||||
self.endpoint.grid(column=0, row=8, sticky='w', padx=10, pady=20)
|
|
||||||
self.endpoint.config(font=('Ubuntu', 9))
|
|
||||||
|
|
||||||
|
|
||||||
class ListTunnels:
|
|
||||||
"""
|
"""
|
||||||
Shows all existing Wireguard tunnels
|
Shows all existing Wireguard tunnels
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def tl_list():
|
def list():
|
||||||
wg_s = os.popen('nmcli con show | grep -iPo "(.*)(wireguard)"').read().split()
|
wg_s = os.popen('nmcli con show | grep -iPo "(.*)(wireguard)"').read().split()
|
||||||
|
|
||||||
''' tl = Tunnel list # Show of 4.Element in list '''
|
''' tl = Tunnel list # Show of 4.Element in list '''
|
||||||
@ -262,84 +200,6 @@ class ListTunnels:
|
|||||||
return tl
|
return tl
|
||||||
|
|
||||||
|
|
||||||
class FileHandle:
|
|
||||||
"""
|
|
||||||
This class will display the autostart label which
|
|
||||||
Tunnel is automatically started regardless of the active tunnel.
|
|
||||||
The selected tunnel is written into a file to read it after the start of the system.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
|
|
||||||
self.wg_autostart = None
|
|
||||||
self.autoconnect = None
|
|
||||||
self.auto_con = None
|
|
||||||
self.autoconnect_var = None
|
|
||||||
self.tl = None
|
|
||||||
self.selected_option = None
|
|
||||||
self.l_box = None
|
|
||||||
|
|
||||||
def box_set(self):
|
|
||||||
|
|
||||||
try:
|
|
||||||
select_tunnel = self.l_box.curselection()
|
|
||||||
select_tl = self.l_box.get(select_tunnel[0])
|
|
||||||
|
|
||||||
if self.selected_option.get() == 0:
|
|
||||||
Path.unlink(path_to_file)
|
|
||||||
tl = ListTunnels.tl_list()
|
|
||||||
|
|
||||||
if len(tl) == 0:
|
|
||||||
self.wg_autostart.configure(state='disabled')
|
|
||||||
|
|
||||||
if self.selected_option.get() >= 1:
|
|
||||||
Path.write_text(path_to_file, select_tl)
|
|
||||||
|
|
||||||
except IndexError:
|
|
||||||
self.selected_option.set(1)
|
|
||||||
|
|
||||||
OnOff.on_off(self)
|
|
||||||
|
|
||||||
|
|
||||||
class OnOff:
|
|
||||||
"""
|
|
||||||
Here it is checked whether the path to the file is there if not it is created.
|
|
||||||
Set (on), the selected tunnel is displayed in the label.
|
|
||||||
At (off) the label is first emptied then filled with No Autoconnect
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
|
|
||||||
self.wg_autostart = None
|
|
||||||
self.selected_option = None
|
|
||||||
self.auto_con = None
|
|
||||||
self.autoconnect = None
|
|
||||||
self.autoconnect_var = None
|
|
||||||
self.lb_frame_buttons = None
|
|
||||||
|
|
||||||
def on_off(self):
|
|
||||||
|
|
||||||
if Path.exists(path_to_file):
|
|
||||||
self.selected_option.set(1)
|
|
||||||
self.autoconnect_var.set('')
|
|
||||||
if not Path.is_dir(Path('/etc/wire_py')):
|
|
||||||
Path.mkdir(Path('/etc/wire_py'))
|
|
||||||
self.auto_con = Path.read_text(path_to_file)
|
|
||||||
|
|
||||||
else:
|
|
||||||
|
|
||||||
self.wg_autostart.configure(state='disabled')
|
|
||||||
self.auto_con = 'no Autoconnect'
|
|
||||||
self.autoconnect_var.set('')
|
|
||||||
self.autoconnect_var = tk.StringVar()
|
|
||||||
self.autoconnect_var.set(self.auto_con)
|
|
||||||
|
|
||||||
self.autoconnect = ttk.Label(self, textvariable=self.autoconnect_var, foreground='#0071ff')
|
|
||||||
self.autoconnect.config(font=('Ubuntu', 11))
|
|
||||||
self.autoconnect.grid(column=0, row=4, sticky='ne', pady=19)
|
|
||||||
|
|
||||||
|
|
||||||
class ExportTunnels:
|
|
||||||
"""
|
"""
|
||||||
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
|
||||||
@ -347,11 +207,11 @@ class ExportTunnels:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def wg_export():
|
def export():
|
||||||
_u1 = str(_u[6:])
|
_u1 = str(_u[6:])
|
||||||
now_time = datetime.now()
|
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()
|
tl = Tunnel.list()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if len(tl) != 0:
|
if len(tl) != 0:
|
||||||
@ -360,8 +220,7 @@ class ExportTunnels:
|
|||||||
source = Path('/tmp/wire_py')
|
source = Path('/tmp/wire_py')
|
||||||
Path.unlink(Path(source) / 'wg_py', missing_ok=True)
|
Path.unlink(Path(source) / 'wg_py', missing_ok=True)
|
||||||
Path.unlink(Path(source) / '.keys', missing_ok=True)
|
Path.unlink(Path(source) / '.keys', missing_ok=True)
|
||||||
Path.unlink(Path(source) / 'settings', missing_ok=True)
|
Path.unlink(Path(source) / 'settings.conf', missing_ok=True)
|
||||||
Path.unlink(Path(source) / 'theme', 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)
|
||||||
@ -396,5 +255,16 @@ class ExportTunnels:
|
|||||||
except TypeError:
|
except TypeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def if_tip():
|
||||||
|
with open(path_to_file2, 'r') as set_file2:
|
||||||
|
lines2 = set_file2.readlines()
|
||||||
|
if 'False\n' in lines2:
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return True
|
||||||
|
|
||||||
|
tips = Tunnel.if_tip()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
973
wg_main.py
973
wg_main.py
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user