diff options
Diffstat (limited to 'howlers/src/howler.jac')
| -rw-r--r-- | howlers/src/howler.jac | 68 |
1 files changed, 59 insertions, 9 deletions
diff --git a/howlers/src/howler.jac b/howlers/src/howler.jac index 5789e20..6771549 100644 --- a/howlers/src/howler.jac +++ b/howlers/src/howler.jac @@ -1,7 +1,10 @@ import sys; +import socket; +import signal; import mmap; import struct; -import from typing { List, Dict } +import from types { FrameType } +import from typing { List, Dict, Optional } import from os { path } glob MAX_EVENTS: int = 256; @@ -17,12 +20,12 @@ enum EVENT { } glob EventName: Dict[EVENT, str] = { - CHLD_PROC_START: "child_start", - CHLD_PROC_DONE: "child_done", - CHLD_PROC_FAILED: "child_failed", - CHLD_PROC_HURT: "child_hurt", - CHLD_PROC_HEALING: "child_healing", - CHLD_PROC_HEALED: "child_healed" + EVENT.CHLD_PROC_START: "child_start", + EVENT.CHLD_PROC_DONE: "child_done", + EVENT.CHLD_PROC_FAILED: "child_failed", + EVENT.CHLD_PROC_HURT: "child_hurt", + EVENT.CHLD_PROC_HEALING: "child_healing", + EVENT.CHLD_PROC_HEALED: "child_healed" }; obj SysLurchEvent_t { @@ -68,6 +71,53 @@ walker Crawler { def fix_scrape_script(script: str) -> str by llm(); -with entry { - print("Hello, World!"); +def signal_handler(sig: int, frame: Optional[FrameType]) -> None { + print("\n\n[!] Interupt CTRL+C. Exiting..."); + sys.exit(0); +} + +with entry:__main__ { + SOCKET_PATH: str = "/tmp/lurchers.sock"; + + signal.signal(signal.SIGINT, signal_handler); + + while True { + try { + user_input: str = input("\nsend_bytes> "); + + if user_input.strip().lower() in ["exit()", "quit()"] { + print("exiting..."); + break; + } + + if not user_input { + continue; + } + + # Ex: '{"method": "query","function": "get User","params": {"id": 1, "user": "wcole"}}' + payload: bytes = (user_input + "\n").encode('utf-8'); + + with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as client { + client.connect(SOCKET_PATH); + client.sendall(payload); + + resp = client.recv(4096); + if resp { + print("\n--- Server Response ---"); + print(resp.decode('utf-8').strip()); + } else { + print("\nData sent to server success (no data returned)"); + } + } + + } except FileNotFoundError { + print(f"Error: the socket file '{SOCKET_PATH}' does not exist"); + } except PermissionError { + print(f"Error: missing permissions to write to '{SOCKET_PATH}"); + } except ConnectionRefusedError { + print(f"Error: conn refused"); + } except Exception as e { + print(f"Error: unexpected error occurred: {e}"); + } + } } |
