MathNodes / meile-gui

Meile dVPN GUI for Linux, OS X, and Windows - Powered by the Sentinel Network
https://meile.app
GNU General Public License v3.0
34 stars 6 forks source link

[0.125 XMR BOUNTY] Clean-up get_ip_address() in MainScren to backend and check for IP changes #46

Closed MathNodes closed 1 year ago

MathNodes commented 1 year ago

Currently in MainScreen in screens.py there is the following routine:

def get_ip_address(self, dt):
        if self.dialog:
            self.dialog.dismiss()

        self.old_ip = self.ip
        try: 
            resolver = DNSRequests.MakeDNSRequest(domain=ICANHAZDNS, timeout=1.5, lifetime=2.5)
            icanhazip = resolver.DNSRequest()
            if icanhazip:
                print("%s:%s" % (ICANHAZDNS, icanhazip))
                Request = HTTPRequests.MakeRequest()
                http = Request.hadapter()
                req = http.get(ICANHAZURL)
                self.ip = req.text

                self.manager.get_screen(WindowNames.MAIN_WINDOW).ids.new_ip.text = self.ip
                return True
                #self.manager.get_screen(WindowNames.MAIN_WINDOW).ids.old_ip.text = "Old IP: " + self.old_ip
            else:
                print("Error resolving ICANHAZIP... defaulting...")
                return False
        except Exception as e:
            print(str(e))
            return False

I'd like this function to make a single call on a backend wrapper routine, (maybe in src/adapters/HTTPRequests.py ) that fetches the IP address and updates the Kivy Label. get_ip_address returns False if it cannot make the DNSLookup in DNSRequests - I'd like to keep this functionality because a class in widgets.py uses it to switch DNS if need be. Maybe have the backend wrapper return a dict with a key set to True or False and another key (ip) that contains the current IP address.

Tkd-Alex commented 1 year ago

Can you please explain better?😶 I don't understand the difference between the actual get_ip_address and your request

MathNodes commented 1 year ago

Actually this bounty is pointless. get_ip_address() is fine by me, it just always bugged me for some reason. I have a better bounty to work on, one sec