| 
														
															@@ -19,6 +19,26 @@ class LocalNetwork: 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     #     if interface is None:
 
														 | 
														
														 | 
														
															     #     if interface is None:
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     #         interface = self.
 
														 | 
														
														 | 
														
															     #         interface = self.
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
 
														 | 
														
														 | 
														
															 
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    def get_mac(self, interface: typing.Optional[str] = None) -> str:
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        if interface is None:
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            interface = self.get_default_interface()
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        global OUR_MAC
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        if OUR_MAC:
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            return OUR_MAC
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        OUR_MAC = getmac.get_mac_address(interface)
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        return typing.cast(str, OUR_MAC)
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    def get_ip(self) -> str:
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        global OUR_IP
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        if OUR_IP:
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            return OUR_IP
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s:
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            s.connect(("1.1.1.1", 80))
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            ip = typing.cast(str, s.getsockname()[0])
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            OUR_IP = ip
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            return OUR_IP
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
 
														 | 
														
														 | 
														
															 
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     def get_default_interface(self) -> str:
 
														 | 
														
														 | 
														
															     def get_default_interface(self) -> str:
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         global OUR_INTERFACE
 
														 | 
														
														 | 
														
															         global OUR_INTERFACE
 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -26,8 +46,6 @@ class LocalNetwork: 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             return OUR_INTERFACE
 
														 | 
														
														 | 
														
															             return OUR_INTERFACE
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         output = subprocess.check_output(['ip', 'route', 'list']).decode().split()
 
														 | 
														
														 | 
														
															         output = subprocess.check_output(['ip', 'route', 'list']).decode().split()
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
 
														 | 
														
														 | 
														
															 
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        return 'qwerty'
 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-
 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         for ind, word in enumerate(output):
 
														 | 
														
														 | 
														
															         for ind, word in enumerate(output):
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             if word == 'dev':
 
														 | 
														
														 | 
														
															             if word == 'dev':
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 OUR_INTERFACE = output[ind + 1]
 
														 | 
														
														 | 
														
															                 OUR_INTERFACE = output[ind + 1]
 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -38,5 +56,6 @@ class LocalNetwork: 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 if __name__ == '__main__':
 
														 | 
														
														 | 
														
															 if __name__ == '__main__':
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     foo = LocalNetwork()
 
														 | 
														
														 | 
														
															     foo = LocalNetwork()
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     print(foo.get_default_interface())
 
														 | 
														
														 | 
														
															     print(foo.get_default_interface())
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-
 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    print(foo.get_mac())
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    print(foo.get_ip())
 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 # print(getmac.get_mac_address('Ethernet 3')) 
														 | 
														
														 | 
														
															 # print(getmac.get_mac_address('Ethernet 3')) 
														 |