04-06-2025_large_update #35
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										70
									
								
								wirepy.py
									
									
									
									
									
								
							
							
						
						
									
										70
									
								
								wirepy.py
									
									
									
									
									
								
							@@ -333,16 +333,11 @@ class FrameWidgets(ttk.Frame):
 | 
				
			|||||||
            self.l_box.insert("end", tunnels[:-5])
 | 
					            self.l_box.insert("end", tunnels[:-5])
 | 
				
			||||||
            self.l_box.update()
 | 
					            self.l_box.update()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Button Vpn
 | 
					        # Button Vpn
 | 
				
			||||||
        if self.a != "":
 | 
					        if self.a != "":
 | 
				
			||||||
            self.stop()
 | 
					            self.stop()
 | 
				
			||||||
            wg_read = f"/tmp/tlecdcwg/{self.a}.conf"
 | 
					            data = self.handle_tunnel_data(self.a)
 | 
				
			||||||
            with open(wg_read, "r", encoding="utf-8") as file:
 | 
					 | 
				
			||||||
                data = Tunnel.con_to_dict(file)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            # Address Label
 | 
					 | 
				
			||||||
            self.init_and_report(data)
 | 
					 | 
				
			||||||
            self.show_data()
 | 
					 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            self.start()
 | 
					            self.start()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -350,7 +345,7 @@ class FrameWidgets(ttk.Frame):
 | 
				
			|||||||
            self.add = tk.StringVar()
 | 
					            self.add = tk.StringVar()
 | 
				
			||||||
            self.DNS = tk.StringVar()
 | 
					            self.DNS = tk.StringVar()
 | 
				
			||||||
            self.enp = tk.StringVar()
 | 
					            self.enp = tk.StringVar()
 | 
				
			||||||
            self.label_empty()
 | 
					            self.reset_fields()
 | 
				
			||||||
            self.show_data()
 | 
					            self.show_data()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Button Import
 | 
					        # Button Import
 | 
				
			||||||
@@ -413,10 +408,7 @@ class FrameWidgets(ttk.Frame):
 | 
				
			|||||||
                    self.start()
 | 
					                    self.start()
 | 
				
			||||||
                    self.l_box.update()
 | 
					                    self.l_box.update()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    # Address Label
 | 
					                    self.reset_fields()
 | 
				
			||||||
                    self.add.set("")
 | 
					 | 
				
			||||||
                    self.DNS.set("")
 | 
					 | 
				
			||||||
                    self.enp.set("")
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            except IndexError:
 | 
					            except IndexError:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -591,7 +583,7 @@ class FrameWidgets(ttk.Frame):
 | 
				
			|||||||
                                        new_conf = f"/tmp/tlecdcwg/{path_split}"
 | 
					                                        new_conf = f"/tmp/tlecdcwg/{path_split}"
 | 
				
			||||||
                                        if self.a != "":
 | 
					                                        if self.a != "":
 | 
				
			||||||
                                            check_call(["nmcli", "connection", "down", Tunnel.active()])
 | 
					                                            check_call(["nmcli", "connection", "down", Tunnel.active()])
 | 
				
			||||||
                                            self.label_empty()
 | 
					                                            self.reset_fields()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                                        subprocess.check_output(["nmcli", "connection", "import", "type",
 | 
					                                        subprocess.check_output(["nmcli", "connection", "import", "type",
 | 
				
			||||||
                                                                 "wireguard", "file", new_conf], text=True)
 | 
					                                                                 "wireguard", "file", new_conf], text=True)
 | 
				
			||||||
@@ -602,7 +594,7 @@ class FrameWidgets(ttk.Frame):
 | 
				
			|||||||
                                        shutil.copy(filepath, "/tmp/tlecdcwg/")
 | 
					                                        shutil.copy(filepath, "/tmp/tlecdcwg/")
 | 
				
			||||||
                                        if self.a != "":
 | 
					                                        if self.a != "":
 | 
				
			||||||
                                            check_call(["nmcli", "connection", "down", Tunnel.active()])
 | 
					                                            check_call(["nmcli", "connection", "down", Tunnel.active()])
 | 
				
			||||||
                                            self.label_empty()
 | 
					                                            self.reset_fields()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                                        subprocess.check_output(["nmcli", "connection", "import", "type",
 | 
					                                        subprocess.check_output(["nmcli", "connection", "import", "type",
 | 
				
			||||||
                                                                 "wireguard", "file", filepath], text=True)
 | 
					                                                                 "wireguard", "file", filepath], text=True)
 | 
				
			||||||
@@ -635,15 +627,8 @@ class FrameWidgets(ttk.Frame):
 | 
				
			|||||||
                                    self.str_var.set(self.a)
 | 
					                                    self.str_var.set(self.a)
 | 
				
			||||||
                                    self.color_label()
 | 
					                                    self.color_label()
 | 
				
			||||||
                                    self.stop()
 | 
					                                    self.stop()
 | 
				
			||||||
                                    wg_read = f"/tmp/tlecdcwg/{self.a}.conf"
 | 
					                                    data = self.handle_tunnel_data(self.a)
 | 
				
			||||||
                                    with open(wg_read, "r", encoding="utf-8") as file_for_key:
 | 
					 | 
				
			||||||
                                        data = Tunnel.con_to_dict(file_for_key)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                                    # Address Label
 | 
					 | 
				
			||||||
                                    self.init_and_report(data)
 | 
					 | 
				
			||||||
                                    self.show_data()
 | 
					 | 
				
			||||||
                                    check_call(["nmcli", "con", "mod", self.a, "connection.autoconnect", "no"])
 | 
					                                    check_call(["nmcli", "con", "mod", self.a, "connection.autoconnect", "no"])
 | 
				
			||||||
                                    Path.chmod(wg_read, 0o600)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if ("PrivateKey = " in read) and ("Endpoint = " in read):
 | 
					            if ("PrivateKey = " in read) and ("Endpoint = " in read):
 | 
				
			||||||
                pass
 | 
					                pass
 | 
				
			||||||
@@ -661,6 +646,23 @@ class FrameWidgets(ttk.Frame):
 | 
				
			|||||||
        except subprocess.CalledProcessError:
 | 
					        except subprocess.CalledProcessError:
 | 
				
			||||||
            print("Tunnel exist!")
 | 
					            print("Tunnel exist!")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def handle_tunnel_data(self, tunnel_name: str) -> dict[str, str]:
 | 
				
			||||||
 | 
					        """_summary_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Args:
 | 
				
			||||||
 | 
					            tunnel_name (str): name of tunnel
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Returns:
 | 
				
			||||||
 | 
					            Dict[str, str]: dictionary with tunneldata
 | 
				
			||||||
 | 
					        """
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        wg_read = f"/tmp/tlecdcwg/{tunnel_name}.conf"
 | 
				
			||||||
 | 
					        with open(wg_read, "r", encoding="utf-8") as file:
 | 
				
			||||||
 | 
					            data = Tunnel.con_to_dict(file)
 | 
				
			||||||
 | 
					            self.init_and_report(data)
 | 
				
			||||||
 | 
					            self.show_data()
 | 
				
			||||||
 | 
					            return data
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def box_set(self):
 | 
					    def box_set(self):
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        This Method will display the autostart label which
 | 
					        This Method will display the autostart label which
 | 
				
			||||||
@@ -736,13 +738,14 @@ class FrameWidgets(ttk.Frame):
 | 
				
			|||||||
        self.enp = tk.StringVar()
 | 
					        self.enp = tk.StringVar()
 | 
				
			||||||
        self.enp.set(f"{_("Endpoint:    ")}{data[2]}")
 | 
					        self.enp.set(f"{_("Endpoint:    ")}{data[2]}")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def label_empty(self):
 | 
					    def reset_fields(self) -> None:
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        empty labels
 | 
					        reset data from labels
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        self.add.set("")
 | 
					        fields = [self.add, self.DNS, self.enp]
 | 
				
			||||||
        self.DNS.set("")
 | 
					        for field in fields:
 | 
				
			||||||
        self.enp.set("")
 | 
					            field.set("")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def show_data(self):
 | 
					    def show_data(self):
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
@@ -814,13 +817,7 @@ class FrameWidgets(ttk.Frame):
 | 
				
			|||||||
                self.select_tunnel = self.l_box.curselection()
 | 
					                self.select_tunnel = self.l_box.curselection()
 | 
				
			||||||
                select_tl = self.l_box.get(self.select_tunnel[0])
 | 
					                select_tl = self.l_box.get(self.select_tunnel[0])
 | 
				
			||||||
                check_call(["nmcli", "connection", "up", select_tl])
 | 
					                check_call(["nmcli", "connection", "up", select_tl])
 | 
				
			||||||
                wg_read = f"/tmp/tlecdcwg/{select_tl}.conf"
 | 
					                data = self.handle_tunnel_data(self.a)
 | 
				
			||||||
                with open(wg_read, "r", encoding="utf-8") as file:
 | 
					 | 
				
			||||||
                    data = Tunnel.con_to_dict(file)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                # Address Label
 | 
					 | 
				
			||||||
                self.init_and_report(data)
 | 
					 | 
				
			||||||
                self.show_data()
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                # Button Start/Stop
 | 
					                # Button Start/Stop
 | 
				
			||||||
                self.stop()
 | 
					                self.stop()
 | 
				
			||||||
@@ -841,10 +838,7 @@ class FrameWidgets(ttk.Frame):
 | 
				
			|||||||
                self.str_var.set("")
 | 
					                self.str_var.set("")
 | 
				
			||||||
                self.color_label()
 | 
					                self.color_label()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                # Address Label
 | 
					                self.reset_fields()
 | 
				
			||||||
                self.add.set("")
 | 
					 | 
				
			||||||
                self.DNS.set("")
 | 
					 | 
				
			||||||
                self.enp.set("")
 | 
					 | 
				
			||||||
                self.show_data()
 | 
					                self.show_data()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        except IndexError:
 | 
					        except IndexError:
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user