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
36 stars 6 forks source link

Add Node Health Check Data #69

Closed MathNodes closed 9 months ago

MathNodes commented 9 months ago

Sentinel has set up an API for the Node Health Report of Nodes. Using this data, we can indicate via status icon on the node card a ✅︎ if the node passed the integrity checks or an ❌ if the node failed any of the checks.

API: https://api.health.sentinel.co/v1/records

This request should be made by a GetHealthCheckData() in sentinel.py about line 158

Line https://github.com/MathNodes/meile-gui/blob/c2fecdd76d7755ceef07003c8a65e3ff3b1d8d38/src/cli/sentinel.py#L117 should contain a call to the routine self.GetHealthCheckData()

Line https://github.com/MathNodes/meile-gui/blob/c2fecdd76d7755ceef07003c8a65e3ff3b1d8d38/src/cli/sentinel.py#L30 should contain an empty dictionary NodeHealth which will be populated in GetHealthCheckData(). The keys of NodeHealth will be the sentnode addresses and the value of each key will be boolean.

def GetHealthCheckData(self):
        Request = HTTPRequests.MakeRequest(TIMEOUT=2)
        http = Request.hadapter()
        try:
            r = http.get("https://api.health.sentinel.co/v1/records") #specify a constant in konstants.py
            data = r.json()

            for nodehealthdata in data['result']:
                k=0

                # integrity check
                if nodehealthdata['status'] != 1:
                    NodeHealth[nodehealthdata['addr']] = False
               elif "info_fetch_error " in nodehealthdata:
                    NodeHealth[nodehealthdata['addr']] = False
               elif "config_exchange_error" in nodehealthdata:
                    NodeHealth[nodehealthdata['addr']] = False
               elif "location_fetch_error" in nodehealthdata:
                    NodeHealth[nodehealthdata['addr']] = False
               else:
                    NodeHealth[nodehealthdata['addr']] = True

        except Exception as e:
            print(str(e))

This NodeHalth dictionary can be parsed in screens.py and a check for the boolean value can be made in add_rv_data() 1288 and a status Icon set to the appropriate indicator.

The Icon will be need to be added to meile.kv in RecyclerViewRow https://github.com/MathNodes/meile-gui/blob/c2fecdd76d7755ceef07003c8a65e3ff3b1d8d38/src/kv/meile.kv#L567 similar to the existing one. It can be made a Button with icon specified in add_rv_data()

MathNodes commented 9 months ago

The Button can be made a ToolTipButton with status indicator Passed Health Check or Failed Health Check