Initial commit

This commit is contained in:
Bridget
2020-04-12 15:51:44 +02:00
commit 1b2998638a
3 changed files with 89 additions and 0 deletions

47
lslsh.py Normal file
View File

@@ -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

36
lslshd.lsl Normal file
View File

@@ -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");
}
}
}
}

6
todo.md Normal file
View File

@@ -0,0 +1,6 @@
# TODO
- [ ] Add user/password login
- [ ] Add key exchange
- [ ] Only allow one session
- [ ] Add keep-alive
- [ ] Add command history