commit 1b2998638a9dc5ecdb919404efcbe645aef4c1a9 Author: Bridget Date: Sun Apr 12 15:51:44 2020 +0200 Initial commit diff --git a/lslsh.py b/lslsh.py new file mode 100644 index 0000000..72f0446 --- /dev/null +++ b/lslsh.py @@ -0,0 +1,47 @@ +import requests +import warnings +from urllib3.connectionpool import InsecureRequestWarning +from json.decoder import JSONDecodeError + +warnings.filterwarnings("ignore", category=InsecureRequestWarning) + +def init() -> str: + initialized: bool = False + while not initialized: + try: + url = input("url > ") + response = requests.post(url, data="init", verify=False) + uuid = response.json().get("uuid") + except (requests.ConnectionError, requests.exceptions.MissingSchema, + requests.exceptions.InvalidURL): + print("Error: Invalid URL") + except (KeyError, JSONDecodeError): + print(f"Error: Invalid response") + else: + initialized = True + + print(f"Connected to {uuid}") + print("-------------------------------------------------------------------------------") + print("") + return url + +def disconnect(url: str): + response = requests.post(url, data="disconnect", verify=False) + print("") + if response.content.decode("utf-8") == "disconnected": + print("Disconnected from remote.") + else: + print("Disconnected from remote (without acknowledgement).") + +def run(url: str): + while True: + data = {"input": input("sl > ")} + response = requests.post(url, data=data, verify=False) + print(response.content.decode("utf-8")) + +try: + url = init() + run(url) +except EOFError: + disconnect(url) + pass diff --git a/lslshd.lsl b/lslshd.lsl new file mode 100644 index 0000000..df7635a --- /dev/null +++ b/lslshd.lsl @@ -0,0 +1,36 @@ +integer connected = 0; + +default +{ + state_entry() + { + llRequestSecureURL(); + } + + http_request(key id, string method, string body) + { + if(method == URL_REQUEST_GRANTED) + { + string url = body; + llOwnerSay(url); + } + else if(method == "POST") + { + if(body == "init") + { + llHTTPResponse(id, 200, "{\"uuid\": \"" + string(llGetKey()) + "\"}"); + connected = 1; + } + else if(body == "disconnect") + { + llHTTPResponse(id, 200, "disconnected"); + connected = 0; + } + else + { + llOwnerSay("POST: " + body); + llHTTPResponse(id, 200, "success"); + } + } + } +} diff --git a/todo.md b/todo.md new file mode 100644 index 0000000..0233539 --- /dev/null +++ b/todo.md @@ -0,0 +1,6 @@ +# TODO +- [ ] Add user/password login +- [ ] Add key exchange +- [ ] Only allow one session +- [ ] Add keep-alive +- [ ] Add command history