def main(): lmq = pylokimq.LokiMQ() lmq.listen_plain("ipc:///tmp/lmq.sock") lmq.add_anonymous_category("llarp") lmq.add_request_command("llarp", "auth", handle_auth) lmq.start() while True: time.sleep(1)
def lmq_connection(): global lmq, lokid if lmq is None: lmq = pylokimq.LokiMQ(pylokimq.LogLevel.warn) lmq.max_message_size = 200 * 1024 * 1024 lmq.start() if lokid is None: lokid = lmq.connect_remote(config.lokid_rpc) return (lmq, lokid)
def main(): ap = argparse.ArgumentParser() ap.add_argument("--bind", required=True, help="url to bind auth socket to") ap.add_argument("--cmd", required=True, help="script to call for authentication") args = ap.parse_args() cmd = shlex.split(args.cmd) lmq = pylokimq.LokiMQ() lmq.listen_plain(args.bind) lmq.add_anonymous_category("llarp") lmq.add_request_command("llarp", "auth", lambda x: handle_auth(x, cmd)) lmq.start() print("server started") while True: time.sleep(1)
import pylokimq import time def handle_ping(args): print(args) return args lmq = pylokimq.LokiMQ() lmq.listen_plain("ipc:///tmp/lmq.sock") lmq.add_anonymous_category("python") lmq.add_request_command("python", "ping", handle_ping) lmq.start() while True: time.sleep(1)
def main(): lmq = pylokimq.LokiMQ() print("start") lmq.start() print(do_request(lmq)) print("done")