Initial commit
This commit is contained in:
47
lslsh.py
Normal file
47
lslsh.py
Normal 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
36
lslshd.lsl
Normal 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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user