Compare commits

..

48 Commits

Author SHA1 Message Date
4c89488950 Merge pull request 'wire-py-reformat-14-09-2024' (#14) from wire-py-reformat-14-09-2024 into main
Reviewed-on: https://git.ilunix.de/punix/Wire-Py/pulls/14
2024-09-14 23:31:00 +02:00
d1a822fff0 little fixes, add msg_window()
function for Messagebox to show a tk.Toplevel()
replace var = open() with:
with open() as var:
and remove by classes (tk.tk) and super()
2024-09-14 23:25:48 +02:00
8fa6e6374f little fixes a labels when stop and start, installer first functions works 2024-09-10 20:06:33 +02:00
35406026f0 little fixes replace os.system with check_call
first steps in install Script add wg_start.service file
2024-09-08 20:31:46 +02:00
607589d44a little fixes 2024-09-07 23:52:16 +02:00
858e9f07fe little fixes 2024-09-06 18:20:29 +02:00
c0ae2d2b75 Merge pull request 'wire-py-reformat-14-08-2024' (#13) from wire-py-reformat-14-08-2024 into main
Reviewed-on: https://git.ilunix.de/punix/Wire-Py/pulls/13
2024-09-05 22:22:00 +02:00
0c8627fe97 add Frame widget 3
for Buttons and Listbox with Scrollbar.
all Widgets new format
delete works now of disable checkbox when Listbox empty (part two) add Menu widget with one Button
2024-09-05 22:20:07 +02:00
c157154b1c add Frame widget 3
for Buttons and Listbox with Scrollbar.
all Widgets new format
delete works now of disable checkbox when Listbox empty (part two)
2024-09-05 22:17:31 +02:00
e4774abf19 Merge pull request 'fixes on empty Listbox now is disable and now works autoconnect label with read and write, delete works now with read and write' (#12) from wire-py-reformat-14-08-2024 into main
Reviewed-on: https://git.ilunix.de/punix/Wire-Py/pulls/12
2024-09-04 20:55:51 +02:00
2aa9f907b5 fixes on empty Listbox now is disable and now works autoconnect label with read and write, delete works now with read and write 2024-09-04 20:52:44 +02:00
7b1e543428 Merge pull request 'add if question and add autoconnect, autoconnect_var to class Filehandle in box_set no finish!' (#11) from wire-py-reformat-14-08-2024 into main
Reviewed-on: https://git.ilunix.de/punix/Wire-Py/pulls/11
2024-09-04 09:20:05 +02:00
aa84a5ad79 add if question and add autoconnect, autoconnect_var to class Filehandle in box_set no finish! 2024-09-04 09:18:47 +02:00
6f83fc7162 Merge pull request 'wire-py-reformat-14-08-2024' (#10) from wire-py-reformat-14-08-2024 into main
Reviewed-on: https://git.ilunix.de/punix/Wire-Py/pulls/10
2024-09-04 06:26:30 +02:00
00a9436dad add class FileHandle,
add Label to show autoconnect Tunnel
disable checkbox when Listbox is empty or no select Tunnel
2024-09-03 21:27:36 +02:00
b82bd6d9e7 little fixes a " " to ' ' 2024-08-31 17:50:42 +02:00
e5d86f1f90 columnconfigure on all widgets set 2024-08-27 19:14:49 +02:00
6173a653f9 import datetime for datetime in zip_name a export Tunnel 2024-08-26 19:50:06 +02:00
b70400b456 Merge pull request 'wire-py-reformat-14-08-2024' (#9) from wire-py-reformat-14-08-2024 into main
Reviewed-on: https://git.ilunix.de/punix/Wire-Py/pulls/9
2024-08-25 20:32:05 +02:00
4060a92a0e add export Tunnel as zip 2024-08-25 20:28:32 +02:00
980c5a9010 fix when Filname > 17 first copy file after rename 2024-08-25 15:39:23 +02:00
8d657f7c09 remove a ',' in DNS Name 2024-08-25 11:03:15 +02:00
4574f1416e fix label when laat Tunnel delete and fix Tuple error in delete and Start/Stop when listbox empty 2024-08-24 12:34:44 +02:00
e25bc154ea Merge pull request 'wire-py-reformat-14-08-2024' (#8) from wire-py-reformat-14-08-2024 into main
Reviewed-on: https://git.ilunix.de/punix/Wire-Py/pulls/8
2024-08-23 18:00:19 +02:00
bc8dd7fe6d disable button start/stop not 100% work 2024-08-23 16:15:56 +02:00
9667bf0690 little fixes in Class Import 2024-08-23 14:37:19 +02:00
c87ba4493d add method init_and_report and label_empty to Class ShowAddress 2024-08-23 12:57:07 +02:00
101a2167b6 In FrameWidged Class else Block StrVar, this resorts reference and variable assignment together 2024-08-23 10:22:18 +02:00
b6555974ea fixed error when active tunnel is deleted,
now also the Address Label is emptied
2024-08-23 10:07:38 +02:00
357cae2d2a Remove open file function, add Show Address Labels with tk.StrVar when remove a not active Tunnel Labels of Active Tunnel removed! 2024-08-23 02:00:24 +02:00
7aa3cd75fe Merge pull request 'Set Style to Clam' (#7) from wire-py-reformat-14-08-2024 into main
Reviewed-on: https://git.ilunix.de/punix/Wire-Py/pulls/7
2024-08-21 22:52:27 +02:00
2601b7b0ce Set Style to Clam
Improved layout of widgets
2024-08-21 22:39:18 +02:00
0b9eec8d1d Merge pull request 'add Class StartStopBTN to wg_func.py' (#6) from wire-py-reformat-14-08-2024 into main
Reviewed-on: https://git.ilunix.de/punix/Wire-Py/pulls/6
2024-08-21 12:52:51 +02:00
7b4226c704 add Class StartStopBTN to wg_func.py 2024-08-21 12:51:48 +02:00
b9083d4698 Merge pull request 'add file dict_to_address for' (#5) from wire-py-reformat-14-08-2024 into main
Reviewed-on: https://git.ilunix.de/punix/Wire-Py/pulls/5
2024-08-21 12:00:18 +02:00
d490f65825 Merge branch 'main' into wire-py-reformat-14-08-2024 2024-08-21 11:55:11 +02:00
70793075e9 add file dict_to_address for
address a active Tunnel. Label green pack in Class.
add Class to convert fileoutput as String to Dictionary
2024-08-21 11:50:01 +02:00
6bd8775490 Merge pull request 'add Label Interface and Peer to new FrameWidget one and two. when import Tunnel then add to list works and remove of list when Tunnel delete.(with Label active on and off)' (#4) from wire-py-reformat-14-08-2024 into main
Reviewed-on: https://git.ilunix.de/punix/Wire-Py/pulls/4
2024-08-19 23:30:45 +02:00
999fe7be84 add Label Interface and Peer to new FrameWidget one and two. when import Tunnel then add to list works and remove of list when Tunnel delete.(with Label active on and off)
add to class and methods open a avtive Tunnel when Wire-Py open, when import and start a Tunnel
2024-08-19 23:28:53 +02:00
51e372d68c Merge pull request 'add class ListTunnels and class ImportTunnel, and add class ExportTunnels (ExportTunnels no finish)' (#3) from wire-py-reformat-14-08-2024 into main
Reviewed-on: https://git.ilunix.de/punix/Wire-Py/pulls/3
2024-08-19 08:31:09 +02:00
6ab9c43c3a add class ListTunnels and class ImportTunnel, and add class ExportTunnels (ExportTunnels no finish) 2024-08-19 08:29:35 +02:00
9c5004e92a Merge pull request 'add class TunnelActive to wg_func works' (#2) from wire-py-reformat-14-08-2024 into main
Reviewed-on: https://git.ilunix.de/punix/Wire-Py/pulls/2
2024-08-19 00:15:43 +02:00
213032252a add class TunnelActive to wg_func works 2024-08-18 23:23:43 +02:00
ae32cc9e74 Merge pull request 'wire-py-reformat-14-08-2024' (#1) from wire-py-reformat-14-08-2024 into main
Reviewed-on: https://git.ilunix.de/punix/Wire-Py/pulls/1
2024-08-18 22:39:18 +02:00
5606ce15b9 add class Frame and class Massage, delete funktion go 100%, add resize window, add warning pic 2024-08-18 22:34:07 +02:00
b84b783fa0 add class Frame and class Massage, delete funktion go 100%, add resize window 2024-08-18 22:33:16 +02:00
0c48966d47 wg_import_select in wg_func.py more extended 17-8-24 2024-08-17 15:42:57 +02:00
42e2608854 wg_import_select in wg_func.py extended 2024-08-17 00:30:42 +02:00
14 changed files with 974 additions and 95 deletions

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>

View File

@ -4,8 +4,16 @@
<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="Tunnel Start and Stop Work"> <list default="true" id="940e1630-c825-4d4c-be80-bc11f543c122" name="Changes" comment="little fixes a labels when stop and start, installer first functions works">
<change afterPath="$PROJECT_DIR$/message.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/test.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/test2.py" 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$/install.py" beforeDir="false" afterPath="$PROJECT_DIR$/install.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/start_wg.py" beforeDir="false" afterPath="$PROJECT_DIR$/start_wg.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_py" beforeDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -26,6 +34,7 @@
</map> </map>
</option> </option>
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" /> <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
<option name="UPDATE_TYPE" value="REBASE" />
</component> </component>
<component name="ProjectColorInfo">{ <component name="ProjectColorInfo">{
&quot;associatedIndex&quot;: 3 &quot;associatedIndex&quot;: 3
@ -38,16 +47,22 @@
<option name="hideEmptyMiddlePackages" value="true" /> <option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" /> <option name="showLibraryContents" value="true" />
</component> </component>
<component name="PropertiesComponent"><![CDATA[{ <component name="PropertiesComponent">{
"keyToString": { &quot;keyToString&quot;: {
"ASKED_ADD_EXTERNAL_FILES": "true", &quot;ASKED_ADD_EXTERNAL_FILES&quot;: &quot;true&quot;,
"Python.main.executor": "Run", &quot;Python.INSTALL.executor&quot;: &quot;Run&quot;,
"RunOnceActivity.ShowReadmeOnStart": "true", &quot;Python.install.executor&quot;: &quot;Run&quot;,
"git-widget-placeholder": "main", &quot;Python.main.executor&quot;: &quot;Run&quot;,
"last_opened_file_path": "/home/punix/Pyapps/wire-py" &quot;Python.messagebox.executor&quot;: &quot;Run&quot;,
&quot;Python.start_wg.executor&quot;: &quot;Run&quot;,
&quot;Python.wg_func.executor&quot;: &quot;Run&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;git-widget-placeholder&quot;: &quot;main&quot;,
&quot;last_opened_file_path&quot;: &quot;/home/punix/Pyapps/wire-py&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;preferences.lookFeel&quot;
} }
}]]></component> }</component>
<component name="RunManager"> <component name="RunManager" selected="Python.main">
<configuration name="main" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true"> <configuration name="main" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true">
<module name="wire-py" /> <module name="wire-py" />
<option name="ENV_FILES" value="" /> <option name="ENV_FILES" value="" />
@ -70,6 +85,33 @@
<option name="INPUT_FILE" value="" /> <option name="INPUT_FILE" value="" />
<method v="2" /> <method v="2" />
</configuration> </configuration>
<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>
<recent_temporary>
<list>
<item itemvalue="Python.start_wg" />
</list>
</recent_temporary>
</component> </component>
<component name="SharedIndexes"> <component name="SharedIndexes">
<attachedChunks> <attachedChunks>
@ -95,13 +137,259 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1723666001005</updated> <updated>1723666001005</updated>
</task> </task>
<option name="localTasksCounter" value="2" /> <task id="LOCAL-00002" summary="Tunnel Start and Stop Work">
<option name="closed" value="true" />
<created>1723666477079</created>
<option name="number" value="00002" />
<option name="presentableId" value="LOCAL-00002" />
<option name="project" value="LOCAL" />
<updated>1723666477079</updated>
</task>
<task id="LOCAL-00003" summary="wg_import_select in wg_func.py extended">
<option name="closed" value="true" />
<created>1723847456806</created>
<option name="number" value="00003" />
<option name="presentableId" value="LOCAL-00003" />
<option name="project" value="LOCAL" />
<updated>1723847456806</updated>
</task>
<task id="LOCAL-00004" summary="add class Frame and class Massage, delete funktion go 100%, add resize window">
<option name="closed" value="true" />
<created>1724013210356</created>
<option name="number" value="00004" />
<option name="presentableId" value="LOCAL-00004" />
<option name="project" value="LOCAL" />
<updated>1724013210356</updated>
</task>
<task id="LOCAL-00005" summary="add class Frame and class Massage, delete funktion go 100%, add resize window, add warning pic">
<option name="closed" value="true" />
<created>1724013251954</created>
<option name="number" value="00005" />
<option name="presentableId" value="LOCAL-00005" />
<option name="project" value="LOCAL" />
<updated>1724013251954</updated>
</task>
<task id="LOCAL-00006" summary="add class ListTunnels and class ImportTunnel, and add class ExportTunnels (ExportTunnels no finish)">
<option name="closed" value="true" />
<created>1724048994613</created>
<option name="number" value="00006" />
<option name="presentableId" value="LOCAL-00006" />
<option name="project" value="LOCAL" />
<updated>1724048994613</updated>
</task>
<task id="LOCAL-00007" summary="add Label Interface and Peer to new FrameWidget one and two. when import Tunnel then add to list works and remove of list when Tunnel delete.(with Label active on and off) &#10;add to class and methods open a avtive Tunnel when Wire-Py open, when import and start a Tunnel">
<option name="closed" value="true" />
<created>1724102937260</created>
<option name="number" value="00007" />
<option name="presentableId" value="LOCAL-00007" />
<option name="project" value="LOCAL" />
<updated>1724102937260</updated>
</task>
<task id="LOCAL-00008" summary="add file dict_to_address for &#10;address a active Tunnel. Label green pack in Class.&#10;add Class to convert fileoutput as String to Dictionary">
<option name="closed" value="true" />
<created>1724233806458</created>
<option name="number" value="00008" />
<option name="presentableId" value="LOCAL-00008" />
<option name="project" value="LOCAL" />
<updated>1724233806458</updated>
</task>
<task id="LOCAL-00009" summary="add Class StartStopBTN to wg_func.py">
<option name="closed" value="true" />
<created>1724237471056</created>
<option name="number" value="00009" />
<option name="presentableId" value="LOCAL-00009" />
<option name="project" value="LOCAL" />
<updated>1724237471056</updated>
</task>
<task id="LOCAL-00010" summary="Set Style to Clam&#10;Improved layout of widgets">
<option name="closed" value="true" />
<created>1724272761629</created>
<option name="number" value="00010" />
<option name="presentableId" value="LOCAL-00010" />
<option name="project" value="LOCAL" />
<updated>1724272761629</updated>
</task>
<task id="LOCAL-00011" summary="Remove open file function, add Show Address Labels with tk.StrVar when remove a not active Tunnel Labels of Active Tunnel removed!">
<option name="closed" value="true" />
<created>1724371229008</created>
<option name="number" value="00011" />
<option name="presentableId" value="LOCAL-00011" />
<option name="project" value="LOCAL" />
<updated>1724371229008</updated>
</task>
<task id="LOCAL-00012" summary="fixed error when active tunnel is deleted,&#10;now also the Address Label is emptied">
<option name="closed" value="true" />
<created>1724400463791</created>
<option name="number" value="00012" />
<option name="presentableId" value="LOCAL-00012" />
<option name="project" value="LOCAL" />
<updated>1724400463791</updated>
</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">
<option name="closed" value="true" />
<created>1724576599289</created>
<option name="number" value="00017" />
<option name="presentableId" value="LOCAL-00017" />
<option name="project" value="LOCAL" />
<updated>1724576599289</updated>
</task>
<task id="LOCAL-00018" summary="fix when Filname &gt; 17 first copy file after rename">
<option name="closed" value="true" />
<created>1724593165879</created>
<option name="number" value="00018" />
<option name="presentableId" value="LOCAL-00018" />
<option name="project" value="LOCAL" />
<updated>1724593165879</updated>
</task>
<task id="LOCAL-00019" summary="add export Tunnel as zip">
<option name="closed" value="true" />
<created>1724610514657</created>
<option name="number" value="00019" />
<option name="presentableId" value="LOCAL-00019" />
<option name="project" value="LOCAL" />
<updated>1724610514658</updated>
</task>
<task id="LOCAL-00020" summary="columnconfigure on all widgets set">
<option name="closed" value="true" />
<created>1724778892233</created>
<option name="number" value="00020" />
<option name="presentableId" value="LOCAL-00020" />
<option name="project" value="LOCAL" />
<updated>1724778892233</updated>
</task>
<task id="LOCAL-00021" summary="little fixes a &quot; &quot; to ' '">
<option name="closed" value="true" />
<created>1725119445803</created>
<option name="number" value="00021" />
<option name="presentableId" value="LOCAL-00021" />
<option name="project" value="LOCAL" />
<updated>1725119445803</updated>
</task>
<task id="LOCAL-00022" summary="add class FileHandle,&#10;add Label to show autoconnect Tunnel&#10;disable checkbox when Listbox is empty or no select Tunnel">
<option name="closed" value="true" />
<created>1725391658456</created>
<option name="number" value="00022" />
<option name="presentableId" value="LOCAL-00022" />
<option name="project" value="LOCAL" />
<updated>1725391658456</updated>
</task>
<task id="LOCAL-00023" summary="add if question and add autoconnect, autoconnect_var to class Filehandle in box_set no finish!">
<option name="closed" value="true" />
<created>1725434328731</created>
<option name="number" value="00023" />
<option name="presentableId" value="LOCAL-00023" />
<option name="project" value="LOCAL" />
<updated>1725434328731</updated>
</task>
<task id="LOCAL-00024" summary="fixes on empty Listbox now is disable and now works autoconnect label with read and write, delete works now with read and write">
<option name="closed" value="true" />
<created>1725475967338</created>
<option name="number" value="00024" />
<option name="presentableId" value="LOCAL-00024" />
<option name="project" value="LOCAL" />
<updated>1725475967338</updated>
</task>
<task id="LOCAL-00025" summary="add Frame widget 3&#10;for Buttons and Listbox with Scrollbar.&#10;all Widgets new format&#10;delete works now of disable checkbox when Listbox empty (part two)">
<option name="closed" value="true" />
<created>1725567453540</created>
<option name="number" value="00025" />
<option name="presentableId" value="LOCAL-00025" />
<option name="project" value="LOCAL" />
<updated>1725567453540</updated>
</task>
<task id="LOCAL-00026" summary="little fixes">
<option name="closed" value="true" />
<created>1725639633873</created>
<option name="number" value="00026" />
<option name="presentableId" value="LOCAL-00026" />
<option name="project" value="LOCAL" />
<updated>1725639633873</updated>
</task>
<task id="LOCAL-00027" summary="little fixes">
<option name="closed" value="true" />
<created>1725746027132</created>
<option name="number" value="00027" />
<option name="presentableId" value="LOCAL-00027" />
<option name="project" value="LOCAL" />
<updated>1725746027132</updated>
</task>
<task id="LOCAL-00028" summary="little fixes replace os.system with check_call&#10;first steps in install Script add wg_start.service file">
<option name="closed" value="true" />
<created>1725820337669</created>
<option name="number" value="00028" />
<option name="presentableId" value="LOCAL-00028" />
<option name="project" value="LOCAL" />
<updated>1725820337669</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>
<option name="localTasksCounter" value="30" />
<servers /> <servers />
</component> </component>
<component name="Vcs.Log.Tabs.Properties"> <component name="Vcs.Log.Tabs.Properties">
<option name="OPEN_GENERIC_TABS">
<map>
<entry key="f9756e7d-0c5c-4b84-84e4-660314c46ea4" value="TOOL_WINDOW" />
</map>
</option>
<option name="TAB_STATES"> <option name="TAB_STATES">
<map> <map>
<entry key="MAIN"> <entry key="MAIN">
<value>
<State>
<option name="FILTERS">
<map>
<entry key="branch">
<value>
<list>
<option value="origin/wire-py-reformat-14-08-2024" />
</list>
</value>
</entry>
</map>
</option>
</State>
</value>
</entry>
<entry key="f9756e7d-0c5c-4b84-84e4-660314c46ea4">
<value> <value>
<State /> <State />
</value> </value>
@ -111,7 +399,31 @@
</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="Tunnel Start and Stop Work" /> <MESSAGE value="add class Frame and class Massage, delete funktion go 100%, add resize window" />
<option name="LAST_COMMIT_MESSAGE" value="Tunnel Start and Stop Work" /> <MESSAGE value="add class Frame and class Massage, delete funktion go 100%, add resize window, add warning pic" />
<MESSAGE value="add class ListTunnels and class ImportTunnel, and add class ExportTunnels (ExportTunnels no finish)" />
<MESSAGE value="add Label Interface and Peer to new FrameWidget one and two. when import Tunnel then add to list works and remove of list when Tunnel delete.(with Label active on and off) &#10;add to class and methods open a avtive Tunnel when Wire-Py open, when import and start a Tunnel" />
<MESSAGE value="add file dict_to_address for &#10;address a active Tunnel. Label green pack in Class.&#10;add Class to convert fileoutput as String to Dictionary" />
<MESSAGE value="add Class StartStopBTN to wg_func.py" />
<MESSAGE value="Set Style to Clam&#10;Improved layout of widgets" />
<MESSAGE value="Remove open file function, add Show Address Labels with tk.StrVar when remove a not active Tunnel Labels of Active Tunnel removed!" />
<MESSAGE value="fixed error when active tunnel is deleted,&#10;now also the Address Label is emptied" />
<MESSAGE value="In FrameWidged Class else Block StrVar, this resorts reference and variable assignment together" />
<MESSAGE value="add method init_and_report and label_empty to Class ShowAddress" />
<MESSAGE value="little fixes in Class Import" />
<MESSAGE value="fix label when laat Tunnel delete and fix Tuple error in delete and Start/Stop when listbox empty" />
<MESSAGE value="remove a ',' in DNS Name" />
<MESSAGE value="fix when Filname &gt; 17 first copy file after rename" />
<MESSAGE value="add export Tunnel as zip" />
<MESSAGE value="columnconfigure on all widgets set" />
<MESSAGE value="little fixes a &quot; &quot; to ' '" />
<MESSAGE value="add class FileHandle,&#10;add Label to show autoconnect Tunnel&#10;disable checkbox when Listbox is empty or no select Tunnel" />
<MESSAGE value="add if question and add autoconnect, autoconnect_var to class Filehandle in box_set no finish!" />
<MESSAGE value="fixes on empty Listbox now is disable and now works autoconnect label with read and write, delete works now with read and write" />
<MESSAGE value="add Frame widget 3&#10;for Buttons and Listbox with Scrollbar.&#10;all Widgets new format&#10;delete works now of disable checkbox when Listbox empty (part two)" />
<MESSAGE value="little fixes" />
<MESSAGE value="little fixes replace os.system with check_call&#10;first steps in install Script add wg_start.service file" />
<MESSAGE value="little fixes a labels when stop and start, installer first functions works" />
<option name="LAST_COMMIT_MESSAGE" value="little fixes a labels when stop and start, installer first functions works" />
</component> </component>
</project> </project>

BIN
icons/warning_128.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

BIN
icons/warning_256.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
icons/warning_32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
icons/warning_64.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

34
install.py Executable file
View File

@ -0,0 +1,34 @@
#!/usr/bin/python3
from pathlib import Path
from getpass import getpass
# for services file in /lib/systemd/system/
config_path = Path.home() / ".config" / "wire_py" / "wg_py"
start_file = f'''\
#!/usr/bin/python3
from subprocess import check_call
path_to_file = {str(config_path)!r}
with open(path_to_file, 'r') as file:
*_, line = file
a_con = line[5:]
check_call(['nmcli', 'connection', 'up', a_con])
'''
Path("start_wg.py").write_text(start_file)
config_path.parent.mkdir(exist_ok=True)
if not Path.exists(config_path):
config_path.write_text("false")
# Prompt the user for the sudo password
#sudo_password = getpass('Enter sudo password: ')
#def cp_files():
# Define the command to run the Python script with sudo
#command = ['sudo', '-S', 'python3', 'script.py']
# Run the command as a subprocess, passing the sudo password
#subprocess.run(command, input=sudo_password.encode(), check=True)

278
main.py Normal file → Executable file
View File

@ -1,112 +1,254 @@
#!/usr/bin/python3 #!/usr/bin/python3
import os import os
import tkinter as tk import tkinter as tk
from subprocess import check_call
from tkinter import ttk from tkinter import ttk
from pathlib import Path
from wg_func import (TunnelActiv, ListTunnels, ImportTunnel, ConToDict, GreenLabel, StartStopBTN, ShowAddress,
FileHandle, ExportTunnels, OnOff)
from wg_func import active font_color = '#4011a7'
from wg_func import tl_list
path = '/~/.config/wg_nmcli/'
color_default = '#d3ebff'
color_dark = '#2e2e2e'
a = active()
class MainWindow(tk.Tk): class MainWindow(tk.Tk):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
self.select_tunnel = None
self.switch_on = None self.switch_on = None
self.switch_off = None self.switch_off = None
self.x_width = 600 self.x_width = 600
self.y_height = 350 self.y_height = 340
self.monitor_center_x = self.winfo_screenwidth() / 2 - (self.x_width / 2) self.monitor_center_x = self.winfo_screenwidth() / 2 - (self.x_width / 2)
self.monitor_center_y = self.winfo_screenheight() / 2 - (self.y_height / 2) self.monitor_center_y = self.winfo_screenheight() / 2 - (self.y_height / 2)
self.lb_tunnel = None self.resizable(width=False, height=False)
self.title('Wire-Py') self.title('Wire-Py')
self.configure() self.configure()
self.geometry('%dx%d+%d+%d' % (self.x_width, self.y_height, self.monitor_center_x, self.monitor_center_y)) self.geometry('%dx%d+%d+%d' % (self.x_width, self.y_height, self.monitor_center_x, self.monitor_center_y))
self.columnconfigure(0, weight=1)
self.rowconfigure(0, weight=1)
self.style = ttk.Style(self)
self.style.theme_use('clam')
# Load the image file from disk. # Load the image file from disk.
wg_icon = tk.PhotoImage(file=r'icons/wg-vpn-48.png') self.wg_icon = tk.PhotoImage(file=r'icons/wg-vpn-48.png')
# Set it as the window icon. # Set it as the window icon.
self.iconphoto(True, wg_icon) self.iconphoto(True, self.wg_icon)
# App Menu
self.app_menu = tk.Menu(self, borderwidth=0)
self.configure(menu=self.app_menu)
self.app_menu.add_cascade(label='?')
FrameWidgets(self).grid()
class FrameWidgets(ttk.Frame):
def __init__(self, container, **kwargs):
super().__init__(container, **kwargs)
self.auto_con = None
self.enp = None
self.DNS = None
self.add = None
self.data = None
self.peer = None
self.lb_tunnel = None
self.wg_read = None
self.wg_vpn_start = tk.PhotoImage(file=r'icons/wg-vpn-start-48.png') self.wg_vpn_start = tk.PhotoImage(file=r'icons/wg-vpn-start-48.png')
self.wg_vpn_stop = tk.PhotoImage(file=r'icons/wg-vpn-stop-48.png') self.wg_vpn_stop = tk.PhotoImage(file=r'icons/wg-vpn-stop-48.png')
self.wgi_on = tk.PhotoImage(file=r'icons/wire-switch-on-48.png')
self.wgi_off = tk.PhotoImage(file=r'icons/wire-switch-off-48.png')
self.imp_pic = tk.PhotoImage(file=r'icons/wg-import.png') self.imp_pic = tk.PhotoImage(file=r'icons/wg-import.png')
self.tr_pic = tk.PhotoImage(file=r'icons/wg-trash-48.png') self.tr_pic = tk.PhotoImage(file=r'icons/wg-trash-48.png')
self.exp_pic = tk.PhotoImage(file=r'icons/wg-export-48.png') self.exp_pic = tk.PhotoImage(file=r'icons/wg-export-48.png')
self.warning_pic = tk.PhotoImage(file=r'icons/warning_64.png')
# Show active Tunnel
self.a = TunnelActiv.active()
# Label Frame 1
self.lb_frame_btn_lbox = ttk.Frame(self)
self.lb_frame_btn_lbox.configure(relief='flat')
self.lb_frame_btn_lbox.grid(column=0, rowspan=4, row=0)
self.columnconfigure(0, weight=1)
self.rowconfigure(0, weight=1)
# Label Frame 2
self.lb_frame = ttk.Frame(self)
self.lb_frame.configure(relief='solid')
self.lb_frame.grid(column=2, row=1, sticky='snew', padx=20, pady=5)
self.columnconfigure(2, weight=1)
self.rowconfigure(1, weight=1)
# Label Frame 3
self.lb_frame2 = ttk.Frame(self)
self.lb_frame2.configure(relief='solid')
self.lb_frame2.grid(column=2, row=2, sticky='snew', padx=20, pady=5)
self.columnconfigure(2, weight=1)
self.rowconfigure(2, weight=1)
# Show active Label # Show active Label
self.lb = tk.Label(self, text='Active:') self.select_tunnel = None
self.lb.config(font=("Ubuntu", 11, "bold")) self.lb = tk.Label(self, text='Active: ')
self.lb.grid(column=2, row=1, padx=10, pady=5, sticky="e") self.lb.config(font=('Ubuntu', 11, 'bold'))
self.lb.grid(column=2, row=0, padx=15, sticky='w')
self.columnconfigure(2, weight=1)
self.rowconfigure(0, weight=1)
# Label to Show active Tunnel # Label to Show active Tunnel
self.StrVar = tk.StringVar() self.StrVar = tk.StringVar(value=self.a)
self.StrVar.set(a) GreenLabel.green_show_label(self)
self.lb_tunnel = tk.Label(self, textvariable=self.StrVar, fg='green') # Interface Label
self.lb_tunnel.config(font=("Ubuntu", 11, "bold")) self.interface = tk.Label(self.lb_frame, text='Interface', fg=font_color)
self.lb_tunnel.grid(column=3, row=1, sticky="w") self.interface.grid(column=0, row=2, sticky='we', padx=120)
self.interface.config(font=('Ubuntu', 9))
self.scrollbar = tk.Scrollbar(self) # Peer Label
self.l_box = tk.Listbox(self, fg='#606060', selectmode='single') self.peer = tk.Label(self.lb_frame2, text='Peer', fg=font_color)
self.l_box.config(highlightthickness=0, relief='flat') self.peer.config(font=('Ubuntu', 9))
self.scrollbar.config(command=self.l_box.yview) self.peer.grid(column=0, row=3, sticky='we', padx=130)
self.l_box.config(font=("Ubuntu", 12, "bold"))
self.l_box.grid(column=1, rowspan=3, row=1, )
self.tl = tl_list() # Listbox with Scrollbar
def enable_check_box(event):
tl = ListTunnels.tl_list()
if len(tl) != 0:
self.wg_autostart.configure(state='normal')
self.l_box = tk.Listbox(self.lb_frame_btn_lbox, fg='#606060', selectmode='single')
self.l_box.config(highlightthickness=0, relief='ridge')
self.l_box.config(font=('Ubuntu', 12, 'bold'))
self.l_box.grid(column=1, rowspan=4, row=0, sticky='ns')
self.l_box.event_add('<<ClickEvent>>', '<Button-1>')
self.l_box.bind('<<ClickEvent>>', enable_check_box)
self.scrollbar = ttk.Scrollbar(self.lb_frame_btn_lbox, orient='vertical', command=self.l_box.yview)
self.scrollbar.grid(column=1, rowspan=4, row=0, sticky='nse')
self.l_box.configure(yscrollcommand=self.scrollbar.set)
self.rowconfigure(0, weight=1)
# Tunnel List
self.tl = ListTunnels.tl_list()
for tunnels in self.tl: for tunnels in self.tl:
self.l_box.insert("end", tunnels) self.l_box.insert("end", tunnels)
self.l_box.update() self.l_box.update()
self.l_box.select_set(0) # Later add, for first Item Auto select
# Button Vpn # Button Vpn
if a != '': if self.a != '':
self.btn_stst = tk.Button(self, image=self.wg_vpn_stop, bd=0, command=self.wg_switch) StartStopBTN.button_stop(self)
self.btn_stst.grid(column=0, row=1, padx=15, pady=15, sticky="s") wg_read = Path.home() / 'tester/' / str(self.a + '.conf')
with open(wg_read, 'r') as file:
data = ConToDict.covert_to_dict(file)
# Address Label
ShowAddress.init_and_report(self, data)
ShowAddress.show_data(self)
else: else:
self.btn_stst = tk.Button(self, image=self.wg_vpn_start, bd=0, command=self.wg_switch) StartStopBTN.button_start(self)
self.btn_stst.grid(column=0, row=1, padx=15, pady=15, sticky="s") # Address Label
self.add = tk.StringVar()
self.DNS = tk.StringVar()
self.enp = tk.StringVar()
ShowAddress.label_empty(self)
ShowAddress.show_data(self)
# Button Import # Button Import
self.btn_i = tk.Button(self, image=self.imp_pic, bd=0) self.btn_i = tk.Button(self.lb_frame_btn_lbox,
self.btn_i.grid(column=0, row=2, padx=15, pady=15) image=self.imp_pic, bd=0,
# Button Trash command=lambda: ImportTunnel.wg_import_select(self))
self.btn_tr = tk.Button(self, image=self.tr_pic, bd=0) self.btn_i.grid(column=0, row=1, padx=15, pady=8)
self.btn_tr.grid(column=0, row=3, padx=15, pady=15)
# Button Export
self.btn_exp = tk.Button(self, image=self.exp_pic, bd=0)
self.btn_exp.grid(column=0, row=4, padx=15, pady=15)
self.wg_autostart = tk.Checkbutton(self, text='Autoconnect on PC Start') def delete():
self.wg_autostart.grid(column=1, rowspan=3, row=3) try:
self.wg_update = tk.Checkbutton(self, text='Search automatically for\nWire-Py updates')
self.wg_update.grid(column=1, rowspan=3, row=4)
def wg_switch(self):
global a
if a == '':
# Button Start/Stop
self.select_tunnel = self.l_box.curselection() self.select_tunnel = self.l_box.curselection()
select_tl = self.l_box.get(self.select_tunnel[0]) select_tl = self.l_box.get(self.select_tunnel[0])
os.system('nmcli connection up ' + str(select_tl)) check_call(['nmcli', 'connection', 'delete', select_tl])
self.btn_stst = tk.Button(self, image=self.wg_vpn_stop, bd=0, command=self.wg_switch) self.l_box.delete(self.select_tunnel[0])
self.btn_stst.grid(column=0, row=1, padx=15, pady=15, sticky="s") os.remove(Path.home() / 'tester/' / str(select_tl + '.conf'))
a = active()
StrVar = tk.StringVar() path_to_file = Path.home() / '.config/wire_py/wg_py'
return StrVar.set(a) with open(path_to_file, 'r') as file2:
elif a != '': for line in file2.readlines():
a_con = line[5:]
if select_tl == a_con:
self.selected_option.set(0)
self.autoconnect_var.set('no Autoconnect')
# for disable checkbox when Listbox empty
tl = ListTunnels.tl_list()
if len(tl) == 0:
self.wg_autostart.configure(state='disabled')
with open(path_to_file, 'w') as file2:
file2.write('false')
if self.a != '' and self.a == select_tl:
self.StrVar.set(value='')
StartStopBTN.button_start(self)
self.l_box.update()
# Address Label
self.add.set('')
self.DNS.set('')
self.enp.set('')
return select_tl
except IndexError:
pass
# Button Trash
self.btn_tr = tk.Button(self.lb_frame_btn_lbox, image=self.tr_pic, bd=0, command=delete)
self.btn_tr.grid(column=0, row=2, padx=15, pady=8)
# Button Export
self.btn_exp = tk.Button(self.lb_frame_btn_lbox, image=self.exp_pic, bd=0, command=ExportTunnels.wg_export)
self.btn_exp.grid(column=0, row=3, padx=15, pady=8)
# Button Rename
self.btn_rename = ttk.Button(self, text='Rename')
self.btn_rename.grid(column=2, row=4, padx=20, pady=15, sticky='e')
# Check Buttons
self.selected_option = tk.IntVar()
self.autoconnect_var = tk.StringVar()
self.autoconnect_var.set(self.auto_con)
self.autoconnect = tk.Label(self, textvariable=self.autoconnect_var, fg='blue', padx=5)
self.autoconnect.config(font=('Ubuntu', 11))
self.autoconnect.grid(column=0, row=4, sticky='ne', pady=20)
self.wg_autostart = tk.Checkbutton(self,
text='Autoconnect on:',
variable=self.selected_option,
command=lambda: FileHandle.box_set(self))
self.wg_autostart.grid(column=0, row=4, pady=19, padx=15, sticky='nw')
OnOff.on_off(self)
#self.wg_update = tk.Checkbutton(self, tex='Search automatically for\nWire-Py updates')
#self.wg_update.grid(column=1, rowspan=3, row=5)
def wg_switch(self):
self.a = TunnelActiv.active()
try:
if self.a == '':
StartStopBTN.button_start(self)
self.select_tunnel = self.l_box.curselection()
select_tl = self.l_box.get(self.select_tunnel[0])
check_call(['nmcli', 'connection', 'up', select_tl])
wg_read = Path.home() / 'tester/' / str(select_tl + '.conf')
with open(wg_read, 'r') as file:
data = ConToDict.covert_to_dict(file)
# Address Label
ShowAddress.init_and_report(self, data)
ShowAddress.show_data(self)
# Button Start/Stop # Button Start/Stop
self.btn_stst = tk.Button(self, image=self.wg_vpn_stop, bd=0, command=self.wg_switch) StartStopBTN.button_stop(self)
self.btn_stst.grid(column=0, row=1, padx=15, pady=15, sticky="s") self.a = TunnelActiv.active()
os.system('nmcli connection down ' + str(a)) self.StrVar = tk.StringVar()
self.btn_stst = tk.Button(self, image=self.wg_vpn_start, bd=0, command=self.wg_switch) self.StrVar.set(self.a)
self.btn_stst.grid(column=0, row=1, padx=15, pady=15, sticky="s") GreenLabel.green_show_label(self)
a = '' elif self.a != '':
# Button Start/Stop
StartStopBTN.button_stop(self)
check_call(['nmcli', 'connection', 'down', self.a])
# Button Start/Stop
StartStopBTN.button_start(self)
self.a = TunnelActiv.active()
self.StrVar.set('')
GreenLabel.green_show_label(self)
# Address Label
self.add.set('')
self.DNS.set('')
self.enp.set('')
ShowAddress.show_data(self)
except IndexError:
pass
if __name__ == '__main__': if __name__ == '__main__':

9
start_wg.py Executable file
View File

@ -0,0 +1,9 @@
#!/usr/bin/python3
from subprocess import check_call
path_to_file = '/home/punix/.config/wire_py/wg_py'
with open(path_to_file, 'r') as file:
*_, line = file
a_con = line[5:]
check_call(['nmcli', 'connection', 'up', a_con])

312
wg_func.py Normal file → Executable file
View File

@ -1,20 +1,312 @@
# Wireguard functions for Wire-Py # Wireguard functions for Wire-Py
import os import os
import shutil
from datetime import datetime
from tkinter import filedialog, ttk
import tkinter as tk
from pathlib import Path
from subprocess import check_call
font_color = '#4011a7'
path_to_file = Path.home() / '.config/wire_py/wg_py'
def active(): # Shows the active tunnel def msg_window():
a = os.popen('nmcli connection show --active | grep -iPo "(.*)(wireguard)"').read().split() msg = tk.Toplevel()
if not a: msg.resizable(width=False, height=False)
a = '' msg.x_width = 340
msg.y_height = 140
msg.title('Import error!')
msg.monitor_center_x = msg.winfo_screenwidth() / 2 - (msg.x_width / 2)
msg.monitor_center_y = msg.winfo_screenheight() / 2 - (msg.y_height / 2)
msg.geometry('%dx%d+%d+%d' % (msg.x_width, msg.y_height, msg.monitor_center_x, msg.monitor_center_y))
msg.columnconfigure(0, weight=1)
msg.configure(pady=20)
msg.warning = tk.PhotoImage(file=r'icons/warning_64.png')
msg.i_warning = tk.Label(msg, image=msg.warning)
msg.i_warning.grid(column=0, row=0)
label = tk.Label(msg, text='Oh... no valid Wireguard File!\nPlease select a valid Wireguard File')
label.config(font=('Ubuntu', 11), padx=15, pady=15)
label.grid(column=1, row=0)
button = tk.Button(msg, text='OK', command=msg.destroy)
button.config(padx=15, pady=5)
button.grid(column=0, columnspan=2, row=1)
wg_icon_2 = tk.PhotoImage(file=r'icons/wg-stop.png')
msg.iconphoto(True, wg_icon_2)
msg.winfo_toplevel()
return a
class GreenLabel:
def __init__(self):
self.StrVar = None
self.lb_tunnel = None
def green_show_label(self):
self.lb_tunnel = tk.Label(self, textvariable=self.StrVar, fg='green')
self.lb_tunnel.config(font=('Ubuntu', 11, 'bold'))
self.lb_tunnel.grid(column=2, padx=10, row=0)
self.columnconfigure(2, weight=1)
self.rowconfigure(0, weight=1)
def columnconfigure(self, param, weight):
pass
def rowconfigure(self, param, weight):
pass
class StartStopBTN:
def __init__(self):
self.lb_frame_btn_lbox = None
self.wg_switch = None
self.btn_stst = None
self.wg_vpn_start = tk.PhotoImage(file=r'icons/wg-vpn-start-48.png')
self.wg_vpn_stop = tk.PhotoImage(file=r'icons/wg-vpn-stop-48.png')
def button_stop(self):
self.btn_stst = tk.Button(self.lb_frame_btn_lbox, image=self.wg_vpn_stop, bd=0, command=self.wg_switch)
self.btn_stst.grid(column=0, row=0, padx=15, pady=8)
def button_start(self):
self.btn_stst = tk.Button(self.lb_frame_btn_lbox, image=self.wg_vpn_start, bd=0, command=self.wg_switch)
self.btn_stst.grid(column=0, row=0, padx=15, pady=8)
class ConToDict:
@classmethod
def covert_to_dict(cls, file):
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)
for _ in dictlist: # Here is the beginning (Loop) of convert List to Dictionary
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']
return address, dns, endpoint
class TunnelActiv:
@staticmethod
def active(): # Shows the active tunnel
active = os.popen('nmcli con show --active | grep -iPo "(.*)(wireguard)"').read().split()
if not active:
active = ''
else: else:
a = a[0] active = active[0]
return a
return active
def tl_list(): class ShowAddress:
wg_s = os.popen('nmcli connection show | grep -iPo "(.*)(wireguard)"').read().split() def __init__(self):
tl = wg_s[::3] # tl = Tunnelliste # Hiermit wird jedes 4. Element der Liste gezeigt 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 = tk.Label(self.lb_frame, textvariable=self.add, fg='blue')
self.address.grid(column=0, row=4, sticky='w', padx=10, pady=6)
self.address.config(font=('Ubuntu', 9))
# DNS Label
self.dns = tk.Label(self.lb_frame, textvariable=self.DNS, fg='blue')
self.dns.grid(column=0, row=6, sticky='w', padx=10, pady=6)
self.dns.config(font=('Ubuntu', 9))
# Endpoint Label
self.endpoint = tk.Label(self.lb_frame2, textvariable=self.enp, fg='blue')
self.endpoint.grid(column=0, row=7, sticky='w', padx=10, pady=10)
self.endpoint.config(font=('Ubuntu', 9))
class ListTunnels:
@staticmethod
def tl_list():
wg_s = os.popen('nmcli con show | grep -iPo "(.*)(wireguard)"').read().split()
tl = wg_s[::3] # tl = Tunnel list # Show of 4.Element in list
return tl return tl
class ImportTunnel:
def __init__(self):
self.select_tunnel = None
self.wg_switch = None
self.btn_stst = None
self.lb_tunnel = None
self.StrVar = None
self.a = None
self.l_box = None
def wg_import_select(self):
try:
filepath = filedialog.askopenfilename(initialdir=Path.home(), title='Select Wireguard config File',
filetypes=[('WG config files', '*.conf')], )
with open(filepath, 'r') as file:
read = file.read()
path_split = filepath.split('/')
path_split1 = path_split[-1]
self.a = TunnelActiv.active()
if 'PrivateKey = ' in read and 'PublicKey = ' in read:
if len(path_split1) > 17:
p1 = shutil.copy(filepath, Path.home() / 'tester/')
path_split = path_split1[len(path_split1) - 17:]
os.rename(p1, Path.home() / 'tester/' / str(path_split))
if self.a != '':
check_call(['nmcli', 'connection', 'down', TunnelActiv.active()])
ShowAddress.label_empty(self)
check_call(['nmcli', 'connection', 'import', 'type', 'wireguard', 'file', Path.home() / 'tester' /
path_split])
else:
shutil.copy(filepath, Path.home() / 'tester/')
if self.a != '':
check_call(['nmcli', 'connection', 'down', TunnelActiv.active()])
ShowAddress.label_empty(self)
check_call(['nmcli', 'connection', 'import', 'type', 'wireguard', 'file', filepath])
self.StrVar.set('')
self.a = TunnelActiv.active()
self.l_box.insert(0, self.a)
self.l_box.update()
self.StrVar = tk.StringVar()
self.StrVar.set(self.a)
GreenLabel.green_show_label(self)
StartStopBTN.button_stop(self)
wg_read = Path.home() / 'tester/' / str(self.a + '.conf')
with open(wg_read, 'r') as file:
data = ConToDict.covert_to_dict(file)
# Address Label
ShowAddress.init_and_report(self, data)
ShowAddress.show_data(self)
check_call(['nmcli', 'con', 'mod', self.a, 'connection.autoconnect', 'no'])
if 'PrivateKey = ' not in read:
msg_window()
except EOFError:
pass
except TypeError:
pass
except FileNotFoundError:
pass
class FileHandle:
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:
with open(path_to_file, 'w') as off:
off.write('false ' + '\n')
tl = ListTunnels.tl_list()
if len(tl) == 0:
self.wg_autostart.configure(state='disabled')
if self.selected_option.get() >= 1:
with open(path_to_file, 'w') as set_on:
set_on.write('true ' + select_tl)
except IndexError:
self.selected_option.set(1)
OnOff.on_off(self)
class OnOff:
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):
with open(path_to_file, 'r') as file:
for line in file.readlines():
a_connect = line
if 'true' in a_connect:
self.selected_option.set(1)
self.autoconnect_var.set('')
self.auto_con = a_connect[5:]
else:
self.wg_autostart.configure(state='disabled')
self.auto_con = 'no Autoconnect'
self.autoconnect_var = tk.StringVar()
self.autoconnect_var.set(self.auto_con)
self.autoconnect = tk.Label(self, textvariable=self.autoconnect_var, fg='blue', padx=5)
self.autoconnect.config(font=('Ubuntu', 11))
self.autoconnect.grid(column=0, row=4, sticky='ne', pady=20)
class ExportTunnels:
@staticmethod
def wg_export():
now_time = datetime.now()
now_datetime = now_time.strftime('wg-exp-' + '%m-%d-%Y' + '-' + '%H:%M')
tl = ListTunnels.tl_list()
try:
if len(tl) != 0:
wg_tar = Path.home() / now_datetime
p_to_conf = Path.home() / 'tester/'
shutil.make_archive(wg_tar, 'zip', p_to_conf)
#if zip_full != 0:
#print('Export erfolgraeich')
#else:
#print('ups etwwas ging schief bitte Export wiederholen')
else:
print('No Tunnel for Export')
except TypeError:
pass

0
wg_py Normal file
View File

10
wg_start.service Normal file
View File

@ -0,0 +1,10 @@
[Unit]
Description=Automatic Tunnel Start
After=network-online.target
[Service]
Type=oneshot
ExecStartPre=/bin/sleep 3
ExecStart=/bin/start_wg.py
[Install]
WantedBy=multi-user.target