import json import account import requests # Plugin Data info = { "name": "HNS Links", "description": "This is a plugin to quickly setup a HNS Links site", "version": "1.0", "author": "Nathan.Woodburn/" } # Functions functions = { "login":{ "name": "Login to Varo Instance", "type": "default", "description": "You need to connect to a varo instance to setup the dns for domains", "params": { "instance": { "name":"Varo Instance", "type":"text" }, "key": { "name":"API Key", "type":"text" } }, "returns": { "status": { "name": "Status", "type": "text" } } }, "dns":{ "name": "Set Onchain DNS for Domains", "type": "default", "description": "Set onchain DNS for domains before HNS Links can work", "params": { "domain": { "name":"Domain", "type":"text" } }, "returns": { "hash": { "name": "Hash of the transaction", "type": "tx" } } } } def login(params, authentication): instance = params["instance"] key = params["key"] # Test Connection if instance == "": return {"status":"Please enter a valid instance"} instance = instance.replace("https://","") instance = instance.replace("http://","") if instance[-1] == "/": instance = instance[:-1] try: # Authorization: Bearer response = requests.post("https://" + instance + "/api", json={"action":"getInfo"}, headers={"Authorization": "Bearer " + key}) if response.status_code != 200: return {"status":"Error connecting to instance"} except: return {"status":"Error connecting to instance"} with open("user_data/hnslinks.json", "w") as f: json.dump({"instance":instance,"key":key},f) return {"status":"Connected to " + instance} def dns(params,authentication): dns = params["dns"] return {"hash":"f921ffe1bb01884bf515a8079073ee9381cb93a56b486694eda2cce0719f27c0"}