91 lines
2.6 KiB
Python
91 lines
2.6 KiB
Python
import json
|
|
import account
|
|
import requests
|
|
import os
|
|
|
|
# Plugin Data
|
|
info = {
|
|
"name": "Public Node Dashboard",
|
|
"description": "Dashboard modules for public nodes",
|
|
"version": "1.0",
|
|
"author": "Nathan.Woodburn/"
|
|
}
|
|
|
|
# Functions
|
|
functions = {
|
|
"main":{
|
|
"name": "Info Dashboard widget",
|
|
"type": "dashboard",
|
|
"description": "This creates the widget that shows on the dashboard",
|
|
"params": {},
|
|
"returns": {
|
|
"status":
|
|
{
|
|
"name": "Status of Node",
|
|
"type": "text"
|
|
}
|
|
}
|
|
},
|
|
"enable": {
|
|
"name": "Enable Dashboard widget",
|
|
"type": "default",
|
|
"description": "Enable the dashboard widget",
|
|
"params": {},
|
|
"returns": {
|
|
"result":
|
|
{
|
|
"name": "Result",
|
|
"type": "text"
|
|
}
|
|
}
|
|
},
|
|
"disable": {
|
|
"name": "Disable Dashboard widget",
|
|
"type": "default",
|
|
"description": "Disable the dashboard widget",
|
|
"params": {},
|
|
"returns": {
|
|
"result":
|
|
{
|
|
"name": "Result",
|
|
"type": "text"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if not os.path.exists("user_data/public_info.json"):
|
|
with open("user_data/public_info.json", "w") as f:
|
|
json.dump({"enabled": False}, f)
|
|
|
|
def main(params, authentication):
|
|
with open("user_data/public_info.json", "r") as f:
|
|
multiwallet = json.load(f)
|
|
if not multiwallet['enabled']:
|
|
return {"status": None}
|
|
|
|
info = account.hsd.getInfo()
|
|
status = f"Version: {info['version']}<br>Inbound Connections: {info['pool']['inbound']}<br>Outbound Connections: {info['pool']['outbound']}<br>"
|
|
if info['pool']['public']['listen']:
|
|
status += f"Public Node: Yes<br>Host: {info['pool']['public']['host']}<br>Port: {info['pool']['public']['port']}<br>"
|
|
else:
|
|
status += f"Public Node: No<br>"
|
|
status += f"Agent: {info['pool']['agent']}<br>Services: {info['pool']['services']}<br>"
|
|
|
|
return {"status": status}
|
|
|
|
def enable(params, authentication):
|
|
with open("user_data/public_info.json", "r") as f:
|
|
multiwallet = json.load(f)
|
|
multiwallet['enabled'] = True
|
|
with open("user_data/public_info.json", "w") as f:
|
|
json.dump(multiwallet, f)
|
|
return {"result": "Success"}
|
|
|
|
def disable(params, authentication):
|
|
with open("user_data/public_info.json", "r") as f:
|
|
multiwallet = json.load(f)
|
|
multiwallet['enabled'] = False
|
|
with open("user_data/public_info.json", "w") as f:
|
|
json.dump(multiwallet, f)
|
|
return {"result": "Success"} |