Compare commits

..

No commits in common. "03-05-2025-optimize-performance" and "main" have entirely different histories.

23 changed files with 2448 additions and 1927 deletions

5
.gitignore vendored
View File

@ -1,5 +0,0 @@
debug.log
.venv
.idea
.vscode
__pycache__

View File

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

7
.idea/misc.xml generated Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Black">
<option name="sdkName" value="Python 3.12 (wire-py)" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.12 (wire-py)" project-jdk-type="Python SDK" />
</project>

8
.idea/modules.xml generated Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/wire-py.iml" filepath="$PROJECT_DIR$/.idea/wire-py.iml" />
</modules>
</component>
</project>

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,4 @@
<changelist name="Uncommitted_changes_before_Checkout_at_19_08_24,_06_49_[Changes]" date="1724042999949" recycled="false" toDelete="true">
<option name="PATH" value="$PROJECT_DIR$/.idea/shelf/Uncommitted_changes_before_Checkout_at_19_08_24,_06_49_[Changes]/shelved.patch" />
<option name="DESCRIPTION" value="Uncommitted changes before Checkout at 19.08.24, 06:49 [Changes]" />
</changelist>

6
.idea/vcs.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

10
.idea/wire-py.iml generated Normal file
View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.venv" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

606
.idea/workspace.xml generated Normal file
View File

@ -0,0 +1,606 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="940e1630-c825-4d4c-be80-bc11f543c122" name="Changes" comment=" - Update Translate Files">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/cls_mth_fc.py" beforeDir="false" afterPath="$PROJECT_DIR$/cls_mth_fc.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Python Script" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_BRANCH_BY_REPOSITORY">
<map>
<entry key="$PROJECT_DIR$" value="1.11.0824" />
</map>
</option>
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
<option name="UPDATE_TYPE" value="REBASE" />
</component>
<component name="HighlightingSettingsPerFile">
<setting file="file://$PROJECT_DIR$/wg_func.py" root0="SKIP_INSPECTION" />
<setting file="file://$PROJECT_DIR$/wg_main.py" root0="FORCE_HIGHLIGHTING" />
</component>
<component name="ProjectColorInfo">{
&quot;associatedIndex&quot;: 3
}</component>
<component name="ProjectId" id="2kSbZdjOvr0wsVJSNcaMwSfVaxR" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true">
<ConfirmationsSetting value="2" id="Add" />
</component>
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;ASKED_ADD_EXTERNAL_FILES&quot;: &quot;true&quot;,
&quot;Python.INSTALL.executor&quot;: &quot;Run&quot;,
&quot;Python.install.executor&quot;: &quot;Run&quot;,
&quot;Python.main.executor&quot;: &quot;Run&quot;,
&quot;Python.messagebox.executor&quot;: &quot;Run&quot;,
&quot;Python.start_wg.executor&quot;: &quot;Run&quot;,
&quot;Python.testtheme.executor&quot;: &quot;Run&quot;,
&quot;Python.wg_func.executor&quot;: &quot;Run&quot;,
&quot;Python.wg_main.executor&quot;: &quot;Run&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;Shell Script.install.executor&quot;: &quot;Run&quot;,
&quot;Shell Script.run_as.executor&quot;: &quot;Run&quot;,
&quot;git-widget-placeholder&quot;: &quot;1.11.1024&quot;,
&quot;last_opened_file_path&quot;: &quot;/home/punix/Pyapps/wire-py&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;reference.settingsdialog.IDE.editor.colors&quot;
}
}</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/lx-icons" />
<recent name="$PROJECT_DIR$" />
</key>
<key name="MoveFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/TK-Themes/theme" />
<recent name="$PROJECT_DIR$/TK-Themes" />
<recent name="$PROJECT_DIR$" />
<recent name="$PROJECT_DIR$/wire-py" />
</key>
</component>
<component name="RunManager" selected="Python.wg_main">
<configuration name="start_wg" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="wire-py" />
<option name="ENV_FILES" value="" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/start_wg.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="wg_main" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true">
<module name="wire-py" />
<option name="ENV_FILES" value="" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/wg_main.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<recent_temporary>
<list>
<item itemvalue="Python.start_wg" />
</list>
</recent_temporary>
</component>
<component name="SharedIndexes">
<attachedChunks>
<set>
<option value="bundled-python-sdk-8336bb23522e-31b6be0877a2-com.jetbrains.pycharm.community.sharedIndexes.bundled-PC-241.19072.16" />
</set>
</attachedChunks>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="940e1630-c825-4d4c-be80-bc11f543c122" name="Changes" comment="" />
<created>1723279982210</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1723279982210</updated>
</task>
<task id="LOCAL-00029" summary="little fixes a labels when stop and start, installer first functions works">
<option name="closed" value="true" />
<created>1725991610908</created>
<option name="number" value="00029" />
<option name="presentableId" value="LOCAL-00029" />
<option name="project" value="LOCAL" />
<updated>1725991610908</updated>
</task>
<task id="LOCAL-00030" summary="little fixes, add msg_window() &#10;function for Messagebox to show a tk.Toplevel()&#10;replace var = open() with: &#10;with open() as var:&#10;and remove by classes (tk.tk) and super()">
<option name="closed" value="true" />
<created>1726349168248</created>
<option name="number" value="00030" />
<option name="presentableId" value="LOCAL-00030" />
<option name="project" value="LOCAL" />
<updated>1726349168248</updated>
</task>
<task id="LOCAL-00031" summary="in delete replace open with Path&#10;install fixes">
<option name="closed" value="true" />
<created>1726359012150</created>
<option name="number" value="00031" />
<option name="presentableId" value="LOCAL-00031" />
<option name="project" value="LOCAL" />
<updated>1726359012150</updated>
</task>
<task id="LOCAL-00032" summary="new format little fixes icons sort add policy add .desktop File install Part 2">
<option name="closed" value="true" />
<created>1726599446537</created>
<option name="number" value="00032" />
<option name="presentableId" value="LOCAL-00032" />
<option name="project" value="LOCAL" />
<updated>1726599446538</updated>
</task>
<task id="LOCAL-00033" summary="install fix for set dir right">
<option name="closed" value="true" />
<created>1726599588155</created>
<option name="number" value="00033" />
<option name="presentableId" value="LOCAL-00033" />
<option name="project" value="LOCAL" />
<updated>1726599588155</updated>
</task>
<task id="LOCAL-00034" summary="fix checkbox disable and policy rename main.py to wg_main.py">
<option name="closed" value="true" />
<created>1726650691719</created>
<option name="number" value="00034" />
<option name="presentableId" value="LOCAL-00034" />
<option name="project" value="LOCAL" />
<updated>1726650691719</updated>
</task>
<task id="LOCAL-00035" summary="fix rename in Messagebox warning to error">
<option name="closed" value="true" />
<created>1726652747322</created>
<option name="number" value="00035" />
<option name="presentableId" value="LOCAL-00035" />
<option name="project" value="LOCAL" />
<updated>1726652747322</updated>
</task>
<task id="LOCAL-00036" summary="set rights in install and a .conf a import Tunnel Filedialog Part 1 /home when open">
<option name="closed" value="true" />
<created>1726691611936</created>
<option name="number" value="00036" />
<option name="presentableId" value="LOCAL-00036" />
<option name="project" value="LOCAL" />
<updated>1726691611936</updated>
</task>
<task id="LOCAL-00037" summary="fix set rights in install and a .conf a import Tunnel Filedialog Part 1 /home when open">
<option name="closed" value="true" />
<created>1726734843529</created>
<option name="number" value="00037" />
<option name="presentableId" value="LOCAL-00037" />
<option name="project" value="LOCAL" />
<updated>1726734843529</updated>
</task>
<task id="LOCAL-00038" summary="fix a filedialog for hidden Files work&#10;install rollback to bash for start wirepy and wirepy rollback to bash">
<option name="closed" value="true" />
<created>1726764877546</created>
<option name="number" value="00038" />
<option name="presentableId" value="LOCAL-00038" />
<option name="project" value="LOCAL" />
<updated>1726764877546</updated>
</task>
<task id="LOCAL-00039" summary="install rollback bash to py wirepy and wirepy rollback to py">
<option name="closed" value="true" />
<created>1726770649542</created>
<option name="number" value="00039" />
<option name="presentableId" value="LOCAL-00039" />
<option name="project" value="LOCAL" />
<updated>1726770649542</updated>
</task>
<task id="LOCAL-00040" summary="fix install and .desktop File Tar works now for user home and filebrowser.askfilebrowser start now in user home">
<option name="closed" value="true" />
<created>1726777434040</created>
<option name="number" value="00040" />
<option name="presentableId" value="LOCAL-00040" />
<option name="project" value="LOCAL" />
<updated>1726777434040</updated>
</task>
<task id="LOCAL-00041" summary="replace tar with zip and Check if Zip file is empty">
<option name="closed" value="true" />
<created>1726836930251</created>
<option name="number" value="00041" />
<option name="presentableId" value="LOCAL-00041" />
<option name="project" value="LOCAL" />
<updated>1726836930251</updated>
</task>
<task id="LOCAL-00042" summary="Create your own message boxes for export">
<option name="closed" value="true" />
<created>1726841190285</created>
<option name="number" value="00042" />
<option name="presentableId" value="LOCAL-00042" />
<option name="project" value="LOCAL" />
<updated>1726841190285</updated>
</task>
<task id="LOCAL-00043" summary="chown Export File to 1000:1000">
<option name="closed" value="true" />
<created>1726860371820</created>
<option name="number" value="00043" />
<option name="presentableId" value="LOCAL-00043" />
<option name="project" value="LOCAL" />
<updated>1726860371820</updated>
</task>
<task id="LOCAL-00044" summary="add rename Label rename works">
<option name="closed" value="true" />
<created>1726915238475</created>
<option name="number" value="00044" />
<option name="presentableId" value="LOCAL-00044" />
<option name="project" value="LOCAL" />
<updated>1726915238475</updated>
</task>
<task id="LOCAL-00045" summary="add con_to_dict in import for write PreSharedKey in .key File to warning if tunnel has already been imported and delete that the key is deleted again">
<option name="closed" value="true" />
<created>1726959423800</created>
<option name="number" value="00045" />
<option name="presentableId" value="LOCAL-00045" />
<option name="project" value="LOCAL" />
<updated>1726959423800</updated>
</task>
<task id="LOCAL-00046" summary="add con_to_dict in import for write PreSharedKey in .key File to warning if tunnel has already been imported and delete that the key is deleted again&#10;now works">
<option name="closed" value="true" />
<created>1727015078922</created>
<option name="number" value="00046" />
<option name="presentableId" value="LOCAL-00046" />
<option name="project" value="LOCAL" />
<updated>1727015078922</updated>
</task>
<task id="LOCAL-00047" summary="Descriptions added in wg_func-py">
<option name="closed" value="true" />
<created>1727018233930</created>
<option name="number" value="00047" />
<option name="presentableId" value="LOCAL-00047" />
<option name="project" value="LOCAL" />
<updated>1727018233930</updated>
</task>
<task id="LOCAL-00048" summary="If tunnel is renamed and this is in the car start,&#10;is now renamed the label">
<option name="closed" value="true" />
<created>1727028762875</created>
<option name="number" value="00048" />
<option name="presentableId" value="LOCAL-00048" />
<option name="project" value="LOCAL" />
<updated>1727028762875</updated>
</task>
<task id="LOCAL-00049" summary="fix scrollbar view with set self.y_height = 330 to self.y_height = 340">
<option name="closed" value="true" />
<created>1727028915701</created>
<option name="number" value="00049" />
<option name="presentableId" value="LOCAL-00049" />
<option name="project" value="LOCAL" />
<updated>1727028915701</updated>
</task>
<task id="LOCAL-00050" summary="in msg_window two further parameters to be added to the pass, so height and wide can also be specified.&#10;In rename, messages come now if new names do not fit&#10;Fix Index Error on msg_window()">
<option name="closed" value="true" />
<created>1727118598759</created>
<option name="number" value="00050" />
<option name="presentableId" value="LOCAL-00050" />
<option name="project" value="LOCAL" />
<updated>1727118598760</updated>
</task>
<task id="LOCAL-00051" summary="ad max 12-character message, no character message and special_characters message for entry label">
<option name="closed" value="true" />
<created>1727288788988</created>
<option name="number" value="00051" />
<option name="presentableId" value="LOCAL-00051" />
<option name="project" value="LOCAL" />
<updated>1727288788988</updated>
</task>
<task id="LOCAL-00052" summary="info icon shadow fix end msg Export fix to">
<option name="closed" value="true" />
<created>1727347126769</created>
<option name="number" value="00052" />
<option name="presentableId" value="LOCAL-00052" />
<option name="project" value="LOCAL" />
<updated>1727347126769</updated>
</task>
<task id="LOCAL-00053" summary="little fixes">
<option name="closed" value="true" />
<created>1727378355274</created>
<option name="number" value="00053" />
<option name="presentableId" value="LOCAL-00053" />
<option name="project" value="LOCAL" />
<updated>1727378355275</updated>
</task>
<task id="LOCAL-00054" summary="fix msg_boxes when tunnel list = 0 a Start, Delete and Export">
<option name="closed" value="true" />
<created>1727379755537</created>
<option name="number" value="00054" />
<option name="presentableId" value="LOCAL-00054" />
<option name="project" value="LOCAL" />
<updated>1727379755537</updated>
</task>
<task id="LOCAL-00055" summary="fix installer add .keys file">
<option name="closed" value="true" />
<created>1727380793216</created>
<option name="number" value="00055" />
<option name="presentableId" value="LOCAL-00055" />
<option name="project" value="LOCAL" />
<updated>1727380793216</updated>
</task>
<task id="LOCAL-00056" summary="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">
<option name="closed" value="true" />
<created>1727525609727</created>
<option name="number" value="00056" />
<option name="presentableId" value="LOCAL-00056" />
<option name="project" value="LOCAL" />
<updated>1727525609728</updated>
</task>
<task id="LOCAL-00057" summary="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">
<option name="closed" value="true" />
<created>1728059870005</created>
<option name="number" value="00057" />
<option name="presentableId" value="LOCAL-00057" />
<option name="project" value="LOCAL" />
<updated>1728059870005</updated>
</task>
<task id="LOCAL-00058" summary=" - Menu add &#10; - New Modern Dark and Light(default) Theme">
<option name="closed" value="true" />
<created>1729103964804</created>
<option name="number" value="00058" />
<option name="presentableId" value="LOCAL-00058" />
<option name="project" value="LOCAL" />
<updated>1729103964804</updated>
</task>
<task id="LOCAL-00059" summary=" - Theme modify to water-theme&#10; - add ttk.Menubutton vor modern Menu and automatic theme and textvariable for color on font in menu">
<option name="closed" value="true" />
<created>1729283656386</created>
<option name="number" value="00059" />
<option name="presentableId" value="LOCAL-00059" />
<option name="project" value="LOCAL" />
<updated>1729283656387</updated>
</task>
<task id="LOCAL-00060" summary=" - Theme modify to water-theme&#10; - add ttk.Menubutton vor modern Menu and automatic theme and textvariable for color on font in menu">
<option name="closed" value="true" />
<created>1729283719951</created>
<option name="number" value="00060" />
<option name="presentableId" value="LOCAL-00060" />
<option name="project" value="LOCAL" />
<updated>1729283719951</updated>
</task>
<task id="LOCAL-00061" summary=" - Add Options, Help, Update Label and Update Menubutton &#10; - Theme now separate Light and Dark">
<option name="closed" value="true" />
<created>1729353898829</created>
<option name="number" value="00061" />
<option name="presentableId" value="LOCAL-00061" />
<option name="project" value="LOCAL" />
<updated>1729353898830</updated>
</task>
<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>
<task id="LOCAL-00066" summary="- methods from class MainWindow move to class FrameWidgets for active color_label when theme change&#10;- optimize columnconfigure, rowconfigure in class MainWindow and FrameWidgets&#10;- add new Frame for Widgets on Bottom&#10;- optimize from tkinter * to from tkinter import filedialog, ttk, TclError">
<option name="closed" value="true" />
<created>1731097309468</created>
<option name="number" value="00066" />
<option name="presentableId" value="LOCAL-00066" />
<option name="project" value="LOCAL" />
<updated>1731097309468</updated>
</task>
<task id="LOCAL-00067" summary="- methods from class MainWindow move to class FrameWidgets for active color_label when theme change&#10;- optimize columnconfigure, rowconfigure in class MainWindow and FrameWidgets&#10;- add new Frame for Widgets on Bottom&#10;- optimize from tkinter * to from tkinter import filedialog, ttk, TclError">
<option name="closed" value="true" />
<created>1731097969343</created>
<option name="number" value="00067" />
<option name="presentableId" value="LOCAL-00067" />
<option name="project" value="LOCAL" />
<updated>1731097969344</updated>
</task>
<task id="LOCAL-00068" summary="- methods from class MainWindow move to class FrameWidgets for active color_label when theme change&#10;- optimize columnconfigure, rowconfigure in class MainWindow and FrameWidgets&#10;- add new Frame for Widgets on Bottom&#10;- optimize from tkinter * to from tkinter import filedialog, ttk, TclError">
<option name="closed" value="true" />
<created>1731098372497</created>
<option name="number" value="00068" />
<option name="presentableId" value="LOCAL-00068" />
<option name="project" value="LOCAL" />
<updated>1731098372497</updated>
</task>
<task id="LOCAL-00069" summary=" - - Fix Checkbutton Autostart when first install Wire-Py">
<option name="closed" value="true" />
<created>1731690583059</created>
<option name="number" value="00069" />
<option name="presentableId" value="LOCAL-00069" />
<option name="project" value="LOCAL" />
<updated>1731690583060</updated>
</task>
<task id="LOCAL-00070" summary=" - - Fix Checkbutton Autostart when first install Wire-Py">
<option name="closed" value="true" />
<created>1731836942211</created>
<option name="number" value="00070" />
<option name="presentableId" value="LOCAL-00070" />
<option name="project" value="LOCAL" />
<updated>1731836942212</updated>
</task>
<task id="LOCAL-00071" summary=" - Update Translate Files">
<option name="closed" value="true" />
<created>1731840048762</created>
<option name="number" value="00071" />
<option name="presentableId" value="LOCAL-00071" />
<option name="project" value="LOCAL" />
<updated>1731840048763</updated>
</task>
<task id="LOCAL-00072" summary=" - Update Translate Files">
<option name="closed" value="true" />
<created>1731840089956</created>
<option name="number" value="00072" />
<option name="presentableId" value="LOCAL-00072" />
<option name="project" value="LOCAL" />
<updated>1731840089956</updated>
</task>
<task id="LOCAL-00073" summary=" - Update Translate Files">
<option name="closed" value="true" />
<created>1731840188277</created>
<option name="number" value="00073" />
<option name="presentableId" value="LOCAL-00073" />
<option name="project" value="LOCAL" />
<updated>1731840188278</updated>
</task>
<task id="LOCAL-00074" summary=" - Update Translate Files">
<option name="closed" value="true" />
<created>1731840383592</created>
<option name="number" value="00074" />
<option name="presentableId" value="LOCAL-00074" />
<option name="project" value="LOCAL" />
<updated>1731840383592</updated>
</task>
<task id="LOCAL-00075" summary=" - Update Translate Files">
<option name="closed" value="true" />
<created>1731841930614</created>
<option name="number" value="00075" />
<option name="presentableId" value="LOCAL-00075" />
<option name="project" value="LOCAL" />
<updated>1731841930615</updated>
</task>
<task id="LOCAL-00076" summary=" - Update Translate Files">
<option name="closed" value="true" />
<created>1731844213239</created>
<option name="number" value="00076" />
<option name="presentableId" value="LOCAL-00076" />
<option name="project" value="LOCAL" />
<updated>1731844213239</updated>
</task>
<task id="LOCAL-00077" summary=" - Update Translate Files">
<option name="closed" value="true" />
<created>1731844339039</created>
<option name="number" value="00077" />
<option name="presentableId" value="LOCAL-00077" />
<option name="project" value="LOCAL" />
<updated>1731844339039</updated>
</task>
<option name="localTasksCounter" value="78" />
<servers />
</component>
<component name="UnknownFeatures">
<option featureType="com.intellij.fileTypeFactory" implementationName="*.policy" />
</component>
<component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES">
<map>
<entry key="MAIN">
<value>
<State>
<option name="FILTERS">
<map>
<entry key="branch">
<value>
<list>
<option value="1.11.0824" />
</list>
</value>
</entry>
</map>
</option>
</State>
</value>
</entry>
</map>
</option>
</component>
<component name="VcsManagerConfiguration">
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
<MESSAGE value="replace tar with zip and Check if Zip file is empty" />
<MESSAGE value="Create your own message boxes for export" />
<MESSAGE value="chown Export File to 1000:1000" />
<MESSAGE value="add rename Label rename works" />
<MESSAGE value="add con_to_dict in import for write PreSharedKey in .key File to warning if tunnel has already been imported and delete that the key is deleted again" />
<MESSAGE value="add con_to_dict in import for write PreSharedKey in .key File to warning if tunnel has already been imported and delete that the key is deleted again&#10;now works" />
<MESSAGE value="Descriptions added in wg_func-py" />
<MESSAGE value="If tunnel is renamed and this is in the car start,&#10;is now renamed the label" />
<MESSAGE value="fix scrollbar view with set self.y_height = 330 to self.y_height = 340" />
<MESSAGE value="in msg_window two further parameters to be added to the pass, so height and wide can also be specified.&#10;In rename, messages come now if new names do not fit&#10;Fix Index Error on msg_window()" />
<MESSAGE value="ad max 12-character message, no character message and special_characters message for entry label" />
<MESSAGE value="info icon shadow fix end msg Export fix to" />
<MESSAGE value="little fixes" />
<MESSAGE value="fix msg_boxes when tunnel list = 0 a Start, Delete and Export" />
<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="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=" - Theme modify to water-theme&#10; - 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 &#10; - 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" />
<MESSAGE value="- methods from class MainWindow move to class FrameWidgets for active color_label when theme change&#10;- optimize columnconfigure, rowconfigure in class MainWindow and FrameWidgets&#10;- add new Frame for Widgets on Bottom&#10;- optimize from tkinter * to from tkinter import filedialog, ttk, TclError" />
<MESSAGE value=" - - Fix Checkbutton Autostart when first install Wire-Py" />
<MESSAGE value=" - Update Translate Files" />
<option name="LAST_COMMIT_MESSAGE" value=" - Update Translate Files" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/wg_main.py</url>
<line>1128</line>
<option name="timeStamp" value="3" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
</component>
</project>

View File

@ -3,7 +3,7 @@ My standard System: Linux Mint 22 Cinnamon
## [Unreleased]
- os import in common_tools.py replaced by other methods
- os import in cls_mth_fc.py replaced by other methods
- If Wire-Py already runs, prevent further start
- for loops with lists replaced by List Comprehensions
@ -41,7 +41,7 @@ My standard System: Linux Mint 22 Cinnamon
- Fix ipv6 in Config File on import
- Wirepy run now as user
- settings, AppConfig.KEYS_FILE and Config Files now in ~/.config/wire_py
- 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.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

429
cls_mth_fc.py Executable file
View File

@ -0,0 +1,429 @@
""" Classes Method and Functions for lx Apps """
import gettext
import locale
import os
import shutil
import subprocess
import tkinter as tk
import zipfile
from datetime import datetime
from pathlib import Path
from subprocess import check_call
from tkinter import ttk
import requests
APP = "wirepy"
LOCALE_DIR = "/usr/share/locale/"
locale.bindtextdomain(APP, LOCALE_DIR)
gettext.bindtextdomain(APP, LOCALE_DIR)
gettext.textdomain(APP)
_ = gettext.gettext
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():
"""
check and create folders and files if not present
"""
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():
"""
check and create file for auto start if not present and enable the service
"""
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():
"""
This start ssl_decrypt file
"""
process = subprocess.run(
["pkexec", "/usr/local/bin/ssl_decrypt.py"],
stdout=subprocess.PIPE,
text=True,
check=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():
"""
this start ssl_encrypt file
"""
process = subprocess.run(
["pkexec", "/usr/local/bin/ssl_encrypt.py"],
stdout=subprocess.PIPE,
text=True,
check=True,
)
print(process.stdout)
if process.returncode == 0:
print("All Files successfully encrypted...")
else:
print(f"Error with the following code... {process.returncode}")
def uos():
"""
uos = LOGIN USERNAME
This method displays the user name of the logged-in user,
even if you are rooted in a shell
"""
logname = str(Path.home())[6:]
file = Path.home() / "/tmp/.loguser"
with open(file, "w", encoding="utf-8") as f:
f.write(logname)
class GiteaUpdate:
"""
Calling download requests the download URL of the running script,
the taskbar image for the Download OK window, the taskbar image for the
Download error window and the variable res
"""
@staticmethod
def api_down(update_api_url, version):
"""
Calling api_down requests the URL and the version of the running script.
Example: version = 'v. 1.1.1.1' GiteaUpdate.api_down(http://example.de, version)
"""
try:
response = requests.get(update_api_url, timeout=10)
response_dict = response.json()
response_dict = response_dict[0]
with open(wg_set, "r", encoding="utf-8") as set_file:
set_file = set_file.read()
if "on\n" in set_file:
if version[3:] != response_dict["tag_name"]:
req = response_dict["tag_name"]
else:
req = "No Updates"
else:
req = "False"
return req
except requests.exceptions.RequestException:
req = "No Internet Connection!"
return req
@staticmethod
def download(urld, down_ok_image, down_not_ok_image, res):
"""
this is for download new Version of wirepy
"""
try:
to_down = "wget -qP " + str(Path.home()) + " " + urld
result = subprocess.call(to_down, shell=True)
if result == 0:
shutil.chown(str(Path.home()) + f"/{res}.zip", 1000, 1000)
# img_w, img_i, w_title, w_txt hand over
iw = r"/usr/share/icons/lx-icons/64/info.png"
ii = down_ok_image
wt = _("Download Successful")
msg_t = _("Your zip file is in home directory")
msg_window(iw, ii, wt, msg_t)
else:
# img_w, img_i, w_title, w_txt hand over
iw = r"/usr/share/icons/lx-icons/64/error.png"
ii = down_not_ok_image
wt = _("Download error")
msg_t = _("Download failed! Please try again")
msg_window(iw, ii, wt, msg_t)
except subprocess.CalledProcessError:
# img_w, img_i, w_title, w_txt hand over
iw = r"/usr/share/icons/lx-icons/64/error.png"
ii = down_not_ok_image
wt = _("Download error")
msg_t = _("Download failed! No internet connection!")
msg_window(iw, ii, wt, msg_t)
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.
To create messages with your own images, icons, and titles.
As an alternative to Python Messagebox.
Paths to images must be specified: r'/usr/share/icons/lx-icons/64/info.png'
img_w = Image for Tk Window
img_i = Image for Icon
w_title = Windows Title
w_txt = Text for Tk Window
txt2 = Text for Button two
com = function for Button command
"""
msg = tk.Toplevel()
msg.resizable(width=False, height=False)
msg.title(w_title)
msg.configure(pady=15, padx=15)
msg.img = tk.PhotoImage(file=img_w)
msg.i_window = tk.Label(msg, image=msg.img)
label = tk.Label(msg, text=w_txt)
label.grid(column=1, row=0)
if txt2 is not None and com is not 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.grid(column=0, columnspan=2, row=1)
img_i = tk.PhotoImage(file=img_i)
msg.iconphoto(True, img_i)
msg.columnconfigure(0, weight=1)
msg.rowconfigure(0, weight=1)
msg.winfo_toplevel()
class Tunnel:
"""
Class of Methods for Wire-Py
"""
@classmethod
def con_to_dict(cls, file):
"""
The config file is packed into a dictionary,
to display the values Address , DNS and Peer in the labels
"""
dictlist = []
for lines in file.readlines():
line_plit = lines.split()
dictlist = dictlist + line_plit
dictlist.remove("[Interface]")
dictlist.remove("[Peer]")
for items in dictlist:
if items == "=":
dictlist.remove(items)
if items == "::/0":
dictlist.remove(items)
# Here is the beginning (Loop) of convert List to Dictionary
for _ 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]]
new_list = [a, b, c, d, e, f, g, h]
final_dict = {}
for elements in new_list:
final_dict[elements[0]] = elements[1]
# end... result a Dictionary
address = final_dict["Address"]
dns = final_dict["DNS"]
if "," in dns:
dns = dns[:-1]
endpoint = final_dict["Endpoint"]
pre_key = final_dict.get("PresharedKey")
if pre_key is None:
pre_key = final_dict.get("PreSharedKey")
return address, dns, endpoint, pre_key
@staticmethod
def active():
"""
Shows the Active Tunnel
"""
active = (
os.popen('nmcli con show --active | grep -iPo "(.*)(wireguard)"')
.read()
.split()
)
if not active:
active = ""
else:
active = active[0]
return active
@staticmethod
def list():
"""
Shows all existing Wireguard tunnels a login user
"""
dirname = Path("/tmp/tlecdcwg/")
wg_s = os.listdir(dirname)
return wg_s
@staticmethod
def export():
"""
This will export the tunnels.
A zipfile with current date and time is created
in the user's home directory with correct right
"""
now_time = datetime.now()
now_datetime = now_time.strftime("wg-exp-" + "%m-%d-%Y" + "-" + "%H:%M")
tl = Tunnel.list()
try:
if len(tl) != 0:
wg_tar = str(Path.home()) + "/" + now_datetime
shutil.copytree("/tmp/tlecdcwg/", "/tmp/wire_py", dirs_exist_ok=True)
source = Path("/tmp/wire_py")
shutil.make_archive(wg_tar, "zip", source)
shutil.rmtree(source)
with zipfile.ZipFile((wg_tar + ".zip"), "r") as zf:
if len(zf.namelist()) != 0:
# img_w, img_i, w_title, w_txt hand over
iw = r"/usr/share/icons/lx-icons/64/info.png"
ii = r"/usr/share/icons/lx-icons/48/wg_vpn.png"
wt = _("Export Successful")
msg_t = _("Your zip file is in home directory")
msg_window(iw, ii, wt, msg_t)
else:
# img_w, img_i, w_title, w_txt hand over
iw = r"/usr/share/icons/lx-icons/64/error.png"
ii = r"/usr/share/icons/lx-icons/48/wg_msg.png"
wt = _("Export error")
msg_t = _("Export failed! Please try again")
msg_window(iw, ii, wt, msg_t)
else:
# img_w, img_i, w_title, w_txt hand over
iw = r"/usr/share/icons/lx-icons/64/info.png"
ii = r"/usr/share/icons/lx-icons/48/wg_msg.png"
wt = _("Select tunnel")
msg_t = _("Please first import tunnel")
msg_window(iw, ii, wt, msg_t)
except TypeError:
pass
def if_tip(path):
"""
method that writes in file whether tooltip is displayed or not
"""
with open(path, "r", encoding="utf-8") as set_file2:
lines2 = set_file2.readlines()
if "False\n" in lines2:
tip = False
else:
tip = True
return tip
class Tooltip:
"""
class for Tooltip
imoprt Tooltip
example: Tooltip(label, "Show tooltip on label")
examble: Tooltip(button, "Show tooltip on button")
info: label and button is parrent.
"""
def __init__(self, widget, text):
self.widget = widget
self.text = text
self.tooltip_window = None
self.widget.bind("<Enter>", self.show_tooltip)
self.widget.bind("<Leave>", self.hide_tooltip)
def show_tooltip(self, event=None):
if self.tooltip_window or not self.text:
return
x, y, _, _ = self.widget.bbox("insert")
x += self.widget.winfo_rootx() + 25
y += self.widget.winfo_rooty() + 20
self.tooltip_window = tw = tk.Toplevel(self.widget)
tw.wm_overrideredirect(True)
tw.wm_geometry(f"+{x}+{y}")
label = tk.Label(tw, text=self.text, relief="solid", borderwidth=1, padx=5, pady=5)
label.grid()
def hide_tooltip(self, event=None):
if self.tooltip_window:
self.tooltip_window.destroy()
self.tooltip_window = None

View File

@ -1,858 +0,0 @@
""" Classes Method and Functions for lx Apps """
import os
import shutil
import signal
import subprocess
import sys
import tkinter as tk
from typing import Optional, Dict, Any, NoReturn, TextIO, Tuple, List
import zipfile
from datetime import datetime
from pathlib import Path
from subprocess import check_call, CompletedProcess
from tkinter import ttk, Toplevel
from wp_app_config import AppConfig, Msg
import requests
# Translate
_ = AppConfig.setup_translations()
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() -> None:
"""
check and create folders and files if not present
"""
pth: Path = Path.home() / ".config/wire_py"
pth.mkdir(parents=True, exist_ok=True)
sett: Path = Path.home() / ".config/wire_py/settings"
AppConfig.KEYS_FILE
if sett.exists():
pass
else:
sett.touch()
sett.write_text(
"[UPDATES]\non\n[THEME]\nlight\n[TOOLTIP]\nTrue\n[AUTOSTART ON]\noff\n"
)
if AppConfig.KEYS_FILE.exists():
pass
else:
AppConfig.KEYS_FILE.touch()
@staticmethod
def files_for_autostart() -> None:
"""
check and create a file for auto start if not present and enable the service
"""
pth2: Path = Path.home() / ".config/systemd/user"
pth2.mkdir(parents=True, exist_ok=True)
wg_ser: Path = 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]\n"
"Type=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() -> None:
"""Folder Name "tlecdewg" = Tunnel Encrypt Decrypt Wireguard"""
if AppConfig.TEMP_DIR.exists():
pass
else:
AppConfig.TEMP_DIR.mkdir()
@staticmethod
def decrypt() -> None:
"""
Starts SSL dencrypt
"""
process: CompletedProcess[str] = subprocess.run(
["pkexec", "/usr/local/bin/ssl_decrypt.py"],
stdout=subprocess.PIPE,
text=True,
check=True,
)
path: Path = Path.home() / ".config/wire_py/"
file_in_path: list[Path] = list(path.rglob("*.dat"))
if file_in_path:
if process.returncode == 0:
print("File successfully decrypted...")
else:
print(f"Error with the following code... {process.returncode}")
else:
print(_("Ready for import"))
@staticmethod
def encrypt() -> None:
"""
Starts SSL encryption
"""
process: CompletedProcess[str] = subprocess.run(
["pkexec", "/usr/local/bin/ssl_encrypt.py"],
stdout=subprocess.PIPE,
text=True,
check=True,
)
print(process.stdout)
if process.returncode == 0:
print("All Files successfully encrypted...")
else:
print(f"Error with the following code... {process.returncode}")
class LxTools(tk.Tk):
"""
Class LinuxTools methods that can also be used for other apps
"""
def __init__(self, *args: Any, **kwargs: Any) -> None:
super().__init__(*args, **kwargs)
@staticmethod
def center_window_cross_platform(window, width, height):
"""
Centers a window on the primary monitor in a way that works on both X11 and Wayland
Args:
window: The tkinter window to center
width: Window width
height: Window height
"""
# Calculate the position before showing the window
# First attempt: Try to use GDK if available (works on both X11 and Wayland)
try:
import gi
gi.require_version("Gdk", "3.0")
from gi.repository import Gdk
display = Gdk.Display.get_default()
monitor = display.get_primary_monitor() or display.get_monitor(0)
geometry = monitor.get_geometry()
scale_factor = monitor.get_scale_factor()
# Calculate center position on primary monitor
x = geometry.x + (geometry.width - width // scale_factor) // 2
y = geometry.y + (geometry.height - height // scale_factor) // 2
# Set window geometry
window.geometry(f"{width}x{height}+{x}+{y}")
return
except (ImportError, AttributeError):
pass
# Second attempt: Try xrandr for X11
try:
import subprocess
output = subprocess.check_output(
["xrandr", "--query"], universal_newlines=True
)
# Parse the output to find the primary monitor
primary_info = None
for line in output.splitlines():
if "primary" in line:
parts = line.split()
for part in parts:
if "x" in part and "+" in part:
primary_info = part
break
break
if primary_info:
# Parse the geometry: WIDTHxHEIGHT+X+Y
geometry = primary_info.split("+")
dimensions = geometry[0].split("x")
primary_width = int(dimensions[0])
primary_height = int(dimensions[1])
primary_x = int(geometry[1])
primary_y = int(geometry[2])
# Calculate center position on primary monitor
x = primary_x + (primary_width - width) // 2
y = primary_y + (primary_height - height) // 2
# Set window geometry
window.geometry(f"{width}x{height}+{x}+{y}")
return
except (subprocess.SubprocessError, ImportError, IndexError, ValueError):
pass
# Final fallback: Use standard Tkinter method
screen_width = window.winfo_screenwidth()
screen_height = window.winfo_screenheight()
# Try to make an educated guess for multi-monitor setups
# If screen width is much larger than height, assume multiple monitors side by side
if (
screen_width > screen_height * 1.8
): # Heuristic for detecting multiple monitors
# Assume primary monitor is on the left half
screen_width = screen_width // 2
x = (screen_width - width) // 2
y = (screen_height - height) // 2
window.geometry(f"{width}x{height}+{x}+{y}")
@staticmethod
def get_file_name(path: Path, i: int = 5) -> List[str]:
"""
Recursively searches the specified path for files and returns a list of filenames,
with the last 'i' characters of each filename removed.
This method is useful for obtaining filenames without specific file extensions,
e.g., to remove '.conf' from Wireguard configuration files.
Args:
path (Path): The directory path to search
i (int, optional): Number of characters to remove from the end of each filename.
Default is 5, which typically corresponds to the length of '.conf'.
Returns:
List[str]: A list of filenames without the last 'i' characters
Example:
If path contains files like 'tunnel1.conf', 'tunnel2.conf' and i=5,
the method returns ['tunnel1', 'tunnel2'].
"""
lists_file = list(path.rglob("*"))
lists_file = [conf_file.name[:-i] for conf_file in lists_file]
return lists_file
@staticmethod
def get_username() -> str:
"""
Returns the username of the logged-in user,
even if the script is running with root privileges.
"""
try:
result = subprocess.run(
["logname"],
stdout=subprocess.PIPE,
text=True,
check=True,
)
if result.returncode != 0:
exit(1)
else:
print(result.stdout.strip())
return result.stdout.strip()
except subprocess.CalledProcessError:
pass
@staticmethod
def clean_files(TEMP_DIR: Path = None, file: Path = None) -> None:
"""
method that can be added after need to delete a folder and a file when quitting.
Args:
:param file: default None
:param AppConfig.TEMP_DIR: default None
"""
if AppConfig.TEMP_DIR is not None:
shutil.rmtree(AppConfig.TEMP_DIR)
try:
if file is not None:
Path.unlink(file)
except FileNotFoundError:
pass
@staticmethod
def msg_window(
image_path: Path,
image_path2: Path,
w_title: str,
w_txt: str,
txt2: Optional[str] = None,
com: Optional[str] = None,
) -> None:
"""
Creates message windows
:argument AppConfig.IMAGE_PATHS["icon_info"] = Image for TK window which is displayed to the left of the text
:argument AppConfig.IMAGE_PATHS["icon_vpn"] = Image for Task Icon
:argument w_title = Windows Title
:argument w_txt = Text for Tk Window
:argument txt2 = Text for Button two
:argument com = function for Button command
"""
msg: tk.Toplevel = tk.Toplevel()
msg.resizable(width=False, height=False)
msg.title(w_title)
msg.configure(pady=15, padx=15)
# Lade das erste Bild für das Fenster
try:
msg.img = tk.PhotoImage(file=image_path)
msg.i_window = tk.Label(msg, image=msg.img)
except Exception as e:
print(f"Fehler beim Laden des Fensterbildes: {e}")
msg.i_window = tk.Label(msg, text="Bild nicht gefunden")
label: tk.Label = tk.Label(msg, text=w_txt)
label.grid(column=1, row=0)
if txt2 is not None and com is not None:
label.config(font=("Ubuntu", 11), padx=15, justify="left")
msg.i_window.grid(column=0, row=0, sticky="nw")
button2: ttk.Button = ttk.Button(
msg, text=f"{txt2}", command=com, padding=4
)
button2.grid(column=0, row=1, sticky="e", columnspan=2)
button: ttk.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 = ttk.Button(
msg, text="OK", command=msg.destroy, padding=4
)
button.grid(column=0, columnspan=2, row=1)
# Lade das Icon für das Fenster
try:
icon = tk.PhotoImage(file=image_path2)
msg.iconphoto(True, icon)
except Exception as e:
print(f"Fehler beim Laden des Fenstericons: {e}")
msg.columnconfigure(0, weight=1)
msg.rowconfigure(0, weight=1)
msg.winfo_toplevel()
@staticmethod
def sigi(file_path: Optional[Path] = None, file: Optional[Path] = None) -> None:
"""
Function for cleanup after a program interruption
:param file: Optional - File to be deleted
:param file_path: Optional - Directory to be deleted
"""
def signal_handler(signum: int, frame: Any) -> NoReturn:
"""
Determines clear text names for signal numbers and handles signals
Args:
signum: The signal number
frame: The current stack frame
Returns:
NoReturn since the function either exits the program or continues execution
"""
signals_to_names_dict: Dict[int, str] = dict(
(getattr(signal, n), n)
for n in dir(signal)
if n.startswith("SIG") and "_" not in n
)
signal_name: str = signals_to_names_dict.get(
signum, f"Unnamed signal: {signum}"
)
# End program for certain signals, report to others only reception
if signum in (signal.SIGINT, signal.SIGTERM):
exit_code: int = 1
print(
f"\nSignal {signal_name} {signum} received. => Aborting with exit code {exit_code}."
)
LxTools.clean_files(file_path, file)
print("Breakdown by user...")
sys.exit(exit_code)
else:
print(f"Signal {signum} received and ignored.")
LxTools.clean_files(file_path, file)
print("Process unexpectedly ended...")
# Register signal handlers for various signals
signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler)
signal.signal(signal.SIGHUP, signal_handler)
class Tunnel:
"""
Class of Methods for Wire-Py
"""
@staticmethod
def parse_files_to_dictionary() -> Dict[str, List[str]]:
data = {}
if not AppConfig.TEMP_DIR.exists() or not AppConfig.TEMP_DIR.is_dir():
pass
# Get a list of all files in the directorys
files = [file for file in AppConfig.TEMP_DIR.iterdir() if file.is_file()]
if not files:
pass
# Search for the string in the files
for file in files:
try:
with open(file, "r") as f:
content = f.read()
# Hier parsen wir die relevanten Zeilen aus dem Inhalt
address_line = next(
line
for line in content.splitlines()
if line.startswith("Address")
)
dns_line = next(
line for line in content.splitlines() if line.startswith("DNS")
)
endpoint_line = next(
line
for line in content.splitlines()
if line.startswith("Endpoint")
)
# Extrahiere die Werte
address = address_line.split("=")[1].strip()
dns = dns_line.split("=")[1].strip()
endpoint = endpoint_line.split("=")[1].strip()
# Speichere im Dictionary
data[file.stem] = {
"Address": address,
"DNS": dns,
"Endpoint": endpoint,
}
except Exception:
# Ignore errors and continue to the next file
continue
return data
@classmethod
def con_to_dict(cls, file: TextIO) -> Tuple[str, str, str, Optional[str]]:
"""
Returns tuple of (address, dns, endpoint, pre_key)
"""
dictlist: List[str] = []
for lines in file.readlines():
line_plit: List[str] = lines.split()
dictlist = dictlist + line_plit
dictlist.remove("[Interface]")
dictlist.remove("[Peer]")
for items in dictlist:
if items == "=":
dictlist.remove(items)
if items == "::/0":
dictlist.remove(items)
# Here is the beginning (Loop) of convert List to Dictionary
for _ in dictlist:
a: List[str] = [dictlist[0], dictlist[1]]
b: List[str] = [dictlist[2], dictlist[3]]
c: List[str] = [dictlist[4], dictlist[5]]
d: List[str] = [dictlist[6], dictlist[7]]
e: List[str] = [dictlist[8], dictlist[9]]
f: List[str] = [dictlist[10], dictlist[11]]
g: List[str] = [dictlist[12], dictlist[13]]
h: List[str] = [dictlist[14], dictlist[15]]
new_list: List[List[str]] = [a, b, c, d, e, f, g, h]
final_dict: Dict[str, str] = {}
for elements in new_list:
final_dict[elements[0]] = elements[1]
# end... result a Dictionary
address: str = final_dict["Address"]
dns: str = final_dict["DNS"]
if "," in dns:
dns = dns[:-1]
endpoint: str = final_dict["Endpoint"]
pre_key: Optional[str] = final_dict.get("PresharedKey")
if pre_key is None:
pre_key: Optional[str] = final_dict.get("PreSharedKey")
return address, dns, endpoint, pre_key
@staticmethod
def active() -> str:
"""
Shows the Active Tunnel
"""
active = (
os.popen('nmcli con show --active | grep -iPo "(.*)(wireguard)"')
.read()
.split()
)
if not active:
active = ""
else:
active = active[0]
return active
@staticmethod
def list() -> List[str]:
"""
Returns a list of Wireguard tunnel names
"""
AppConfig.TEMP_DIR: Path = Path("/tmp/tlecdcwg/")
wg_s: List[str] = os.listdir(AppConfig.TEMP_DIR)
return wg_s
@staticmethod
def export(
image_path: Path = None,
image_path2: Path = None,
image_path3: Path = None,
image_path4: Path = None,
title: Dict = None,
window_msg: Dict = None,
) -> None:
"""
This will export the tunnels.
A zipfile with the current date and time is created
in the user's home directory with the correct right
Args:
AppConfig.IMAGE_PATHS["icon_info"]: Image for TK window which is displayed to the left of the text
AppConfig.IMAGE_PATHS["icon_vpn"]: Image for Task Icon
AppConfig.IMAGE_PATHS["icon_error"]: Image for TK window which is displayed to the left of the text
AppConfig.IMAGE_PATHS["icon_msg"]: Image for Task Icon
"""
now_time: datetime = datetime.now()
now_datetime: str = now_time.strftime("wg-exp-%m-%d-%Y-%H:%M")
tl: List[str] = Tunnel.list()
try:
if len(tl) != 0:
wg_tar: str = f"{Path.home()}/{now_datetime}"
shutil.copytree("/tmp/tlecdcwg/", "/tmp/wire_py", dirs_exist_ok=True)
source: Path = Path("/tmp/wire_py")
shutil.make_archive(wg_tar, "zip", source)
shutil.rmtree(source)
with zipfile.ZipFile(f"{wg_tar}.zip", "r") as zf:
if len(zf.namelist()) != 0:
LxTools.msg_window(
AppConfig.IMAGE_PATHS["icon_info"],
AppConfig.IMAGE_PATHS["icon_vpn"],
Msg.STR["exp_succ"],
Msg.STR["exp_in_home"],
)
else:
LxTools.msg_window(
AppConfig.IMAGE_PATHS["icon_error"],
AppConfig.IMAGE_PATHS["icon_msg"],
Msg.STR["exp_err"],
Msg.STR["exp_try"],
)
else:
LxTools.msg_window(
AppConfig.IMAGE_PATHS["icon_info"],
AppConfig.IMAGE_PATHS["icon_msg"],
Msg.STR["sel_tl"],
Msg.STR["tl_first"],
)
except TypeError:
pass
# ConfigManager with caching
class ConfigManager:
"""
Universal class for managing configuration files with caching.
Can be reused in different projects.
"""
_config = None
_config_file = None
@classmethod
def init(cls, config_file):
"""Initial the Configmanager with the given config file"""
cls._config_file = config_file
cls._config = None # Reset the cache
@classmethod
def load(cls):
"""Load the config file and return the config as dict"""
if not cls._config:
try:
lines = Path(cls._config_file).read_text(encoding="utf-8").splitlines()
cls._config = {
"updates": lines[1].strip(),
"theme": lines[3].strip(),
"tooltips": lines[5].strip()
== "True", # is converted here to boolean!!!
"autostart": lines[7].strip() if len(lines) > 7 else "off",
}
except (IndexError, FileNotFoundError):
# DeDefault values in case of error
cls._config = {
"updates": "on",
"theme": "light",
"tooltips": "True", # Default Value as string !
"autostart": "off",
}
return cls._config
@classmethod
def save(cls):
"""Save the config to the config file"""
if cls._config:
lines = [
"# Configuration\n",
f"{cls._config['updates']}\n",
"# Theme\n",
f"{cls._config['theme']}\n",
"# Tooltips\n",
f"{str(cls._config['tooltips'])}\n",
"# Autostart\n",
f"{cls._config['autostart']}\n",
]
Path(cls._config_file).write_text("".join(lines), encoding="utf-8")
@classmethod
def set(cls, key, value):
"""Sets a configuration value and saves the change"""
cls.load()
cls._config[key] = value
cls.save()
@classmethod
def get(cls, key, default=None):
"""Returns a configuration value"""
config = cls.load()
return config.get(key, default)
class ThemeManager:
@staticmethod
def change_theme(root, theme_in_use, theme_name=None):
"""Change application theme centrally"""
root.tk.call("set_theme", theme_in_use)
if theme_in_use == theme_name:
ConfigManager.set("theme", theme_in_use)
class GiteaUpdate:
"""
Calling download requests the download URL of the running script,
the taskbar image for the Download OK window, the taskbar image for the
Download error window and the variable res
"""
@staticmethod
def api_down(update_api_url: str, version: str, update_setting: str = None) -> str:
"""
Checks for updates via API
Args:
update_api_url: Update API URL
version: Current version
update_setting: Update setting from ConfigManager (on/off)
Returns:
New version or status message
"""
# If updates are disabled, return immediately
if update_setting != "on":
return "False"
try:
response: requests.Response = requests.get(update_api_url, timeout=10)
response.raise_for_status() # Raise exception for HTTP errors
response_data = response.json()
if not response_data:
return "No Updates"
latest_version = response_data[0].get("tag_name")
if not latest_version:
return "Invalid API Response"
# Compare versions (strip 'v. ' prefix if present)
current_version = version[3:] if version.startswith("v. ") else version
if current_version != latest_version:
return latest_version
else:
return "No Updates"
except requests.exceptions.RequestException:
return "No Internet Connection!"
except (ValueError, KeyError, IndexError):
return "Invalid API Response"
@staticmethod
def download(
urld: str,
res: str,
image_path: Path = None,
image_path2: Path = None,
image_path3: Path = None,
image_path4: Path = None,
) -> None:
"""
Downloads new version of wirepy
Args:
urld: Download URL
res: Result filename
AppConfig.IMAGE_PATHS["icon_info"]: Image for TK window which is displayed to the left of the text
AppConfig.IMAGE_PATHS["icon_vpn"]: Image for Task Icon
AppConfig.IMAGE_PATHS["icon_error"]: Image for TK window which is displayed to the left of the text
AppConfig.IMAGE_PATHS["icon_msg"]: Image for Task Icon
"""
try:
to_down: str = f"wget -qP {Path.home()} {" "} {urld}"
result: int = subprocess.call(to_down, shell=True)
if result == 0:
shutil.chown(f"{Path.home()}/{res}.zip", 1000, 1000)
wt: str = _("Download Successful")
msg_t: str = _("Your zip file is in home directory")
LxTools.msg_window(
AppConfig.IMAGE_PATHS["icon_info"],
AppConfig.IMAGE_PATHS["icon_vpn"],
wt,
msg_t,
)
else:
wt: str = _("Download error")
msg_t: str = _("Download failed! Please try again")
LxTools.msg_window(
AppConfig.IMAGE_PATHS["icon_error"],
AppConfig.IMAGE_PATHS["icon_msg"],
wt,
msg_t,
)
except subprocess.CalledProcessError:
wt: str = _("Download error")
msg_t: str = _("Download failed! No internet connection!")
LxTools.msg_window(
AppConfig.IMAGE_PATHS["icon_error"],
AppConfig.IMAGE_PATHS["icon_msg"],
wt,
msg_t,
)
class Tooltip:
"""Class for Tooltip
from common_tools.py import Tooltip
example: Tooltip(label, "Show tooltip on label")
example: Tooltip(button, "Show tooltip on button")
example: Tooltip(widget, "Text", state_var=tk.BooleanVar())
example: Tooltip(widget, "Text", state_var=tk.BooleanVar(), x_offset=20, y_offset=10)
info: label and button are parent widgets.
NOTE: When using with state_var, pass the tk.BooleanVar object directly,
NOT its value. For example: use state_var=my_bool_var, NOT state_var=my_bool_var.get()
"""
def __init__(
self,
widget: Any,
text: str,
state_var: Optional[tk.BooleanVar] = None,
x_offset: int = 65,
y_offset: int = 40,
) -> None:
"""Tooltip Class"""
self.widget: Any = widget
self.text: str = text
self.tooltip_window: Optional[Toplevel] = None
self.state_var = state_var
self.x_offset = x_offset
self.y_offset = y_offset
# Initial binding based on current state
self.update_bindings()
# Add trace to the state_var if provided
if self.state_var is not None:
self.state_var.trace_add("write", self.update_bindings)
def update_bindings(self, *args) -> None:
"""Updates the bindings based on the current state"""
# Remove existing bindings first
self.widget.unbind("<Enter>")
self.widget.unbind("<Leave>")
# Add new bindings if tooltips are enabled
if self.state_var is None or self.state_var.get():
self.widget.bind("<Enter>", self.show_tooltip)
self.widget.bind("<Leave>", self.hide_tooltip)
def show_tooltip(self, event: Optional[Any] = None) -> None:
"""Shows the tooltip"""
if self.tooltip_window or not self.text:
return
x: int
y: int
cx: int
cy: int
x, y, cx, cy = self.widget.bbox("insert")
x += self.widget.winfo_rootx() + self.x_offset
y += self.widget.winfo_rooty() + self.y_offset
self.tooltip_window = tw = tk.Toplevel(self.widget)
tw.wm_overrideredirect(True)
tw.wm_geometry(f"+{x}+{y}")
label: tk.Label = tk.Label(
tw,
text=self.text,
background="lightgreen",
foreground="black",
relief="solid",
borderwidth=1,
padx=5,
pady=5,
)
label.grid()
self.tooltip_window.after(2200, lambda: tw.destroy())
def hide_tooltip(self, event: Optional[Any] = None) -> None:
"""Hides the tooltip"""
if self.tooltip_window:
self.tooltip_window.destroy()
self.tooltip_window = None

10
install
View File

@ -17,7 +17,7 @@ install_file_with(){
exit 0
else
sudo apt install python3-tk && \
sudo cp -fv wirepy.py start_wg.py wp_app_config.py common_tools.py ssl_encrypt.py ssl_decrypt.py /usr/local/bin/ && \
sudo cp -fv wirepy.py start_wg.py cls_mth_fc.py ssl_encrypt.py ssl_decrypt.py /usr/local/bin/ && \
sudo cp -uR 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 -fv Wire-Py.desktop /usr/share/applications/ && \
@ -43,7 +43,7 @@ install_arch_d(){
exit 0
else
sudo pacman -S --noconfirm tk python3 python-requests && \
sudo cp -fv wirepy.py start_wg.py wp_app_config.py common_tools.py ssl_encrypt.py ssl_decrypt.py /usr/local/bin/ && \
sudo cp -fv wirepy.py start_wg.py cls_mth_fc.py ssl_encrypt.py ssl_decrypt.py /usr/local/bin/ && \
sudo cp -uR 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 -fv Wire-Py.desktop /usr/share/applications/ && \
@ -120,7 +120,7 @@ install(){
exit 0
else
sudo dnf install python3-tkinter -y
sudo cp -fv wirepy.py start_wg.py wp_app_config.py common_tools.py ssl_encrypt.py ssl_decrypt.py /usr/local/bin/ && \
sudo cp -fv wirepy.py start_wg.py cls_mth_fc.py ssl_encrypt.py ssl_decrypt.py /usr/local/bin/ && \
sudo cp -uR 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 -fv Wire-Py.desktop /usr/share/applications/ && \
@ -145,7 +145,7 @@ install(){
rm -r ~/.config/wire_py && rm -r ~/.config/systemd
exit 0
else
sudo cp -fv wirepy.py start_wg.py wp_app_config.py common_tools.py ssl_encrypt.py ssl_decrypt.py /usr/local/bin/ && \
sudo cp -fv wirepy.py start_wg.py cls_mth_fc.py ssl_encrypt.py ssl_decrypt.py /usr/local/bin/ && \
sudo cp -uR 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 -fv Wire-Py.desktop /usr/share/applications/ && \
@ -181,7 +181,7 @@ install(){
remove(){
sudo rm -f /usr/local/bin/wirepy /usr/local/bin/wirepy.py /usr/local/bin/start_wg.py \
/usr/local/bin/wp_app_config.py common_tools.py /usr/local/bin/ssl_encrypt.py /usr/local/bin/ssl_decrypt.py
/usr/local/bin/cls_mth_fc.py /usr/local/bin/ssl_encrypt.py /usr/local/bin/ssl_decrypt.py
if [ $? -ne 0 ]
then
exit 0

View File

@ -1,22 +1,20 @@
#!/usr/bin/python3
""" This Script decrypt Wireguard files for Wirepy users """
""" This Script decrypt Wireguardfiles for Wirepy users """
import os
import shutil
from pathlib import Path
from subprocess import check_call
from wp_app_config import AppConfig
import getpass
log_name: str = getpass.getuser()
if log_name == "root":
uname = Path("/tmp/.loguser")
from common_tools import LxTools
with open(uname, "r", encoding="utf-8") as f:
logname = f.readline()
log_name: str = LxTools.get_username()
print("replacement method applied")
keyfile: Path = Path(f"/home/{log_name}/.config/wire_py/pbwgk.pem")
# Dirname "tlecdewg" = Tunnel Encrypt Decrypt Wireguard
dirname = Path("/tmp/tlecdcwg/")
keyfile = Path(f"/home/{logname}/.config/wire_py/pbwgk.pem")
PKEYFILE = "/usr/local/etc/ssl/pwgk.pem"
if not keyfile.is_file():
@ -25,7 +23,7 @@ if not keyfile.is_file():
"openssl",
"rsa",
"-in",
AppConfig.SYSTEM_PATHS["pkey_path"],
PKEYFILE,
"-out",
keyfile,
"-outform",
@ -35,23 +33,23 @@ if not keyfile.is_file():
)
shutil.chown(keyfile, 1000, 1000)
AppConfig.TEMP_DIR2 = f"/home/{log_name}/.config/wire_py/"
detl: list[str] = os.listdir(AppConfig.TEMP_DIR2)
os.chdir(AppConfig.TEMP_DIR2)
dirname2 = "/home/" + logname + "/.config/wire_py/"
detl = os.listdir(dirname2)
os.chdir(dirname2)
detl.remove("keys")
detl.remove("settings")
if os.path.exists(f"{AppConfig.TEMP_DIR2}pbwgk.pem"):
if os.path.exists(dirname2 + "pbwgk.pem"):
detl.remove("pbwgk.pem")
for detunnels in detl:
tlname2 = f"{detunnels[:-4]}.conf"
extpath = f"{AppConfig.TEMP_DIR}/{tlname2}"
tlname2 = detunnels[:-4] + ".conf"
extpath = str(dirname) + "/" + tlname2
check_call(
[
"openssl",
"pkeyutl",
"-decrypt",
"-inkey",
AppConfig.SYSTEM_PATHS["pkey_path"],
PKEYFILE,
"-in",
detunnels,
"-out",

View File

@ -5,10 +5,15 @@ import os
import shutil
from pathlib import Path
from subprocess import check_call
from wp_app_config import AppConfig
from common_tools import LxTools
keyfile: Path = AppConfig.PUBLICKEY
uname = Path("/tmp/.loguser")
with open(uname, "r", encoding="utf-8") 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():
@ -17,7 +22,7 @@ if not keyfile.is_file():
"openssl",
"rsa",
"-in",
AppConfig.SYSTEM_PATHS["pkey_path"],
PKEYFILE,
"-out",
keyfile,
"-outform",
@ -27,15 +32,15 @@ if not keyfile.is_file():
)
shutil.chown(keyfile, 1000, 1000)
if AppConfig.TEMP_DIR.exists():
tl = LxTools.get_file_name(AppConfig.TEMP_DIR)
CPTH: str = f"{keyfile}"
CRYPTFILES: str = CPTH[:-9]
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 = f"{AppConfig.TEMP_DIR}/{tunnels}"
tlname: str = f"{CRYPTFILES}{tunnels[:-5]}.dat"
sourcetl = str(dirname) + "/" + tunnels
tlname = CRYPTFILES + tunnels[:-5] + ".dat"
check_call(
[
"openssl",
@ -53,15 +58,15 @@ if not keyfile.is_file():
else:
if AppConfig.TEMP_DIR.exists():
tl: list[str] = os.listdir(f"{AppConfig.TEMP_DIR}")
CPTH: str = f"{keyfile}"
CRYPTFILES: str = CPTH[:-9]
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 = f"{AppConfig.TEMP_DIR}/{tunnels}"
tlname: str = f"{CRYPTFILES}{tunnels[:-5]}.dat"
sourcetl = str(dirname) + "/" + tunnels
tlname = CRYPTFILES + tunnels[:-5] + ".dat"
check_call(
[
"openssl",

View File

@ -2,15 +2,17 @@
"""
This script belongs to wirepy and is for the auto start of the tunnel
"""
from pathlib import Path
from subprocess import check_call
path_to_file = Path(Path.home() / ".config/wire_py/settings")
a_con = Path(path_to_file).read_text(encoding="utf-8").splitlines(keepends=True)
a_con = a_con[7].strip()
if a_con != "off":
check_call(["nmcli", "connection", "up", a_con])
else:
pass
with open(path_to_file, "r", encoding="utf-8") as a_con:
# This funtion is for the independent autostart of the previously selected tunnel
lines = a_con.readlines()
a_con = lines[7].strip()
if a_con != "off":
check_call(["nmcli", "connection", "up", a_con])
else:
pass

2066
wirepy.py

File diff suppressed because it is too large Load Diff

View File

@ -1,191 +0,0 @@
#!/usr/bin/python3
"""App configuration for Wire-Py"""
import gettext
import locale
from pathlib import Path
from typing import Dict, Any
class AppConfig:
"""Central configuration class for Wire-Py application"""
# Localization
APP_NAME: str = "wirepy"
LOCALE_DIR: Path = Path("/usr/share/locale/")
# Base paths
BASE_DIR: Path = Path.home()
CONFIG_DIR: Path = BASE_DIR / ".config/wire_py"
TEMP_DIR: Path = Path("/tmp/tlecdcwg")
USER_FILE: Path = Path("/tmp/.log_user")
PUBLICKEY: Path = CONFIG_DIR / "pbwgk.pem"
# Configuration files
SETTINGS_FILE: Path = CONFIG_DIR / "settings"
KEYS_FILE: Path = CONFIG_DIR / "keys"
AUTOSTART_SERVICE: Path = Path.home() / ".config/systemd/user/wg_start.service"
# Updates
# 1 = 1. Year, 09 = Month of the Year, 2924 = Day and Year of the Year
VERSION: str = "v. 2.04.1725"
UPDATE_URL: str = "https://git.ilunix.de/api/v1/repos/punix/Wire-Py/releases"
DOWNLOAD_URL: str = "https://git.ilunix.de/punix/Wire-Py/archive"
# UI configuration
UI_CONFIG: Dict[str, Any] = {
"window_title": "Wire-Py",
"window_size": (600, 383),
"font_family": "Ubuntu",
"font_size": 11,
"resizable_window": (False, False),
}
# System-dependent paths
SYSTEM_PATHS: Dict[str, str] = {
"ssl_decrypt": "/usr/local/bin/ssl_decrypt.py",
"ssl_encrypt": "/usr/local/bin/ssl_encrypt.py",
"tcl_path": "/usr/share/TK-Themes",
"pkey_path": "/usr/local/etc/ssl/pwgk.pem",
}
# Images and icons paths
IMAGE_PATHS: Dict[str, str] = {
"icon_vpn": "/usr/share/icons/lx-icons/48/wg_vpn.png",
"icon_msg": "/usr/share/icons/lx-icons/48/wg_msg.png",
"icon_import": "/usr/share/icons/lx-icons/48/wg_import.png",
"icon_export": "/usr/share/icons/lx-icons/48/wg_export.png",
"icon_trash": "/usr/share/icons/lx-icons/48/wg_trash.png",
"icon_start": "/usr/share/icons/lx-icons/48/wg_vpn-start.png",
"icon_stop": "/usr/share/icons/lx-icons/48/wg_vpn-stop.png",
"icon_info": "/usr/share/icons/lx-icons/64/info.png",
"icon_error": "/usr/share/icons/lx-icons/64/error.png",
}
@staticmethod
def setup_translations() -> gettext.gettext:
"""
Initialize translations and set the translation function
Special method for translating strings in this file
Returns:
The gettext translation function
"""
locale.bindtextdomain(AppConfig.APP_NAME, AppConfig.LOCALE_DIR)
gettext.bindtextdomain(AppConfig.APP_NAME, AppConfig.LOCALE_DIR)
gettext.textdomain(AppConfig.APP_NAME)
return gettext.gettext
@classmethod
def ensure_directories(cls) -> None:
"""Ensures that all required directories exist"""
cls.CONFIG_DIR.mkdir(parents=True, exist_ok=True)
cls.TEMP_DIR.mkdir(parents=True, exist_ok=True)
@classmethod
def create_default_settings(cls) -> None:
"""Creates default settings if they don't exist"""
if not cls.SETTINGS_FILE.exists():
content = "\n".join(
f"[{k.upper()}]\n{v}" for k, v in cls.DEFAULT_SETTINGS.items()
)
cls.SETTINGS_FILE.write_text(content)
@classmethod
def get_image_paths(cls) -> Dict[str, Path]:
"""Returns paths to UI images"""
return {
"main_icon": cls.SYSTEM_PATHS["image_path"] / "48/wg_vpn.png",
"warning": cls.CONFIG_DIR / "images/warning.png",
"success": cls.CONFIG_DIR / "images/success.png",
"error": cls.CONFIG_DIR / "images/error.png",
}
@classmethod
def get_autostart_content(cls) -> str:
"""Returns the content for the autostart service file"""
return """[Unit]Description=Automatic Tunnel Start
After=network-online.target
[Service]
Type=oneshot
ExecStartPre=/bin/sleep 5
ExecStart=/usr/local/bin/start_wg.py
[Install]
WantedBy=default.target"""
# here is inizialize the class for translate strrings
_ = AppConfig.setup_translations()
class Msg:
"""
A utility class that provides centralized access to translated message strings.
This class contains a dictionary of message strings used throughout the Wire-Py application.
All strings are prepared for translation using gettext. The short key names make the code
more concise while maintaining readability.
Attributes:
STR (dict): A dictionary mapping short keys to translated message strings.
Keys are abbreviated for brevity but remain descriptive.
Usage:
Import this class and access messages using the dictionary:
`Msg.STR["sel_tl"]` returns the translated "Select tunnel" message.
Note:
Ensure that gettext translation is properly initialized before
accessing these strings to ensure correct localization.
"""
STR: Dict[str, str] = {
# Strings for messages
"sel_tl": _("Select tunnel"),
"ren_err": _("Renaming not possible"),
"exp_succ": _("Export successful"),
"exp_in_home": _("Your zip file is in home directory"),
"imp_err": _("Import Error"),
"exp_err": _("Export Error"),
"exp_try": _("Export failed! Please try again"),
"tl_first": _("Please first import tunnel"),
"sel_list": _("Please select a tunnel from the list"),
"sign_len": _("The new name may contain only 12 characters"),
"zero_signs": _("At least one character must be entered"),
"false signs": _(
"No valid sign. These must not be used.\nBlank, Slash, Backslash and { }\n"
),
"is_in_use": _("The tunnel is already in use"),
"no_valid_file": _(
"Oh... no valid Wireguard File!\nPlease select a valid Wireguard File"
),
"tl_exist": _("Tunnel already available!\nPlease use another file for import"),
}
TTIP: Dict[str, str] = {
# Strings for Tooltips
"settings": _("Click for Settings"),
"import_tl": _("Click to import a Wireguard Tunnel"),
"start_tl": _("Click to start selected Wireguard Tunnel"),
"empty_list": _("No tunnels to start in the list"),
"stop_tl": _("Click to stop selected Wireguard Tunnel"),
"del_tl": _("Click to delete selected Wireguard Tunnel"),
"rename_tl": _(
"To rename a tunnel, you need to\nselect a tunnel from the list"
),
"export_tl": _(" Click to export all\nWireguard Tunnel to Zipfile"),
"trash_tl": _("Click to delete a Wireguard Tunnel\nSelect from the list!"),
"autostart": _("To use the autostart, enable this Checkbox"),
"autostart_info": _(
"You must have at least one\ntunnel in the list,to use the autostart"
),
"export_tl_info": _("No Tunnels in List for Export"),
"start_tl_info": _("Click to start selected Wireguard Tunnel"),
"rename_tl_info": _("To rename a tunnel, at least one must be in the list"),
"trash_tl_info": _("No tunnels to delete in the list"),
"list_auto_info": _(
"To use the autostart, a tunnel must be selected from the list"
),
"download": _("Click to download new version"),
}