lmproxy reference

Complete command-line subcommands and flags, Proxy, Url, and Message host methods, standard lmcode_std_v3 REST and CLI interfaces, and exit codes for lmproxy v0.1.1.

Host and CLI subcommands

Command or flagArgumentsDescription
--versionnonePrint lmproxy 0.1.1 and exit 0.
--lmcode-schema[--json]Print human-readable signatures summary, or exact embedded host schema JSON bytes when --json is passed.
--lmcode-signaturesnonePrint all canonical context, function, and method signatures (host + 226 standard library signatures).
--lmcode<file.dslb>...Load and execute compiled LMScript bytecode files against the embedded lmproxy schema.
parse-url<URL>...Parse one or more URLs with Squid 7 and print one JSON object per line ({valid,scheme,host,host_is_ip,userinfo,port,path,error}).
parse-request<FILE | ->Parse a raw HTTP/1.x request from FILE or stdin (-) and print JSON ({kind,complete,version,method,target,headers,error}).
parse-response<FILE | ->Parse a raw HTTP/1.x response from FILE or stdin (-) and print JSON ({kind,complete,version,status,reason,headers,error}).
forward[--port P] [--bind ADDR] [proxy-flags]Start the embedded Squid 7 forward proxy daemon (default port 3128, default bind 127.0.0.1).
intercept[--port P] [--bind ADDR] [proxy-flags]Start the embedded Squid 7 transparent interception proxy daemon (default port 3129, default bind 127.0.0.1).
run--config <file.conf> [--debug N]Run the embedded Squid 7 engine directly using a custom Squid configuration file.
certgen[security_file_certgen-args]Internal subcommand invoking the embedded Squid dynamic SSL certificate generator helper.
--port / -p<port>Listening TCP port for forward (default 3128) or intercept (default 3129).
--bind / -b<address>Bind IP address for forward or intercept (default 127.0.0.1).
--ssl-bumpnoneEnable dynamic SSL-bump TLS decryption and on-the-fly host certificate generation.
--ca-cert / --ca-key<path>Custom PEM Root CA certificate and private key for --ssl-bump (auto-generated if omitted).
--tapnonePrint real-time intercepted HTTP/HTTPS request and response summaries to stderr.
--record<file.jsonl>Append structured JSONL traffic records ({timestamp,client,method,url,status,bytes,duration_ms}) to FILE.
--route<PATTERN=HOST:PORT>Transparently route requests matching domain or regex PATTERN to an alternate backend origin HOST:PORT.
--redirect<PATTERN=URL>Intercept requests matching PATTERN and respond with an HTTP 307 Temporary Redirect to URL.
--debug / -d<level>Set Squid debug logging verbosity level.

Host context proxy: Proxy, Url, and Message methods

Type / contextMethod or function signatureDescription
context proxy: Proxyproxy.parse_url(string) -> Url | parse_url(string) -> UrlParse a URL string using Squid 7 and return a Url handle (up to 65536 handles per run).
Proxy / functionproxy.parse_request(string) -> Message | parse_request(string) -> MessageParse a raw HTTP/1.x request string using Squid 7 and return a Message handle.
Proxy / functionproxy.parse_response(string) -> Message | parse_response(string) -> MessageParse a raw HTTP/1.x response string using Squid 7 and return a Message handle.
Proxy / functionproxy.percent_decode(string) -> string | percent_decode(string) -> stringPercent-decode an URL path or query component string.
Proxy / functionproxy.percent_encode(string) -> string | percent_encode(string) -> stringPercent-encode special characters in a string according to Squid URL rules.
function printlnprintln(string) -> voidWrite a line of text to host output.
Urlu.raw() -> string | u.valid() -> bool | u.error() -> stringReturn the original unparsed input string, whether parsing succeeded, or the parser error message.
Urlu.scheme() | u.host() | u.userinfo() | u.path() -> stringReturn the decomposed URL scheme, hostname or IP literal, userinfo prefix, or path+query string.
Urlu.host_is_ip() -> bool | u.port() -> int | u.has_port() -> boolCheck whether host is an IPv4/IPv6 literal, read the effective port number (0 if none), or check if an explicit port was specified.
Messagem.kind() -> string | m.complete() -> bool | m.error() -> stringReturn "request" or "response", whether the HTTP header block parsed completely, or any parse error text.
Messagem.version() -> string | m.method() -> string | m.target() -> stringReturn the HTTP version string (such as "HTTP/1.1"), request method, or request target URI.
Messagem.status() -> int | m.reason() -> stringReturn the HTTP response status code (0 for requests) and reason phrase.
Messagem.header(string) -> string | m.header_count() -> int | m.header_names() -> StrListLook up a header value case-insensitively ("" if missing), return distinct header count, or return an independent StrList of header names.

Standard lmcode_std_v3 REST and CLI interfaces

Interface or functionSignature / annotationDescription
RestGet .. RestOptions@"/path/:param" fn h(x: RestExchange) -> void implements RestGetBind an HTTP GET, POST, PUT, DELETE, PATCH, HEAD, or OPTIONS route handler.
RestHandler@"/path" fn h(x: RestExchange) -> void implements RestHandlerBind a method-agnostic HTTP route handler.
CliCommand@"cmd" fn h(x: RestExchange) -> void implements CliCommandBind a named CLI subcommand dispatched by rest_cli.
CliOption@"--flag" fn h(x: RestExchange) -> void implements CliOptionBind a CLI option flag (--flag=val or --flag val) evaluated before the command handler.
rest_configrest_config(key: string, value: string) -> voidConfigure server or CLI settings such as host, port, and session (ephemeral or global).
rest_routerest_route(method: string, path: string, handler: string) -> voidDynamically register an HTTP method and route pattern to a handler function name.
rest_serve / rest_stoprest_serve() -> void | rest_stop() -> voidStart or stop the embedded standard HTTP server loop.
rest_clirest_cli(args: StrList) -> stringDispatch CLI options, commands, or path requests in-process without opening a socket.
RestExchangex.method() | x.path() | x.body() | x.param(string) | x.query(string) | x.header(string) -> stringRead request method, path, body, :param segment, query parameter, or header.
RestExchangex.has_query(string) | x.has_header(string) -> boolCheck whether a query parameter or request header is present.
RestExchangex.status(int) | x.set_header(string, string) | x.send(string) | x.json(string) -> voidSet response status code and headers, and emit plain text or application/json bodies.
RestExchangex.get(string) -> string | x.set(string, string) -> void | x.increment(string) -> intRead, write, or atomically increment session state keys across global or ephemeral exchanges.

Exit codes

Exit codeCategoryMeaning
0SuccessCLI parser, proxy daemon execution, or _lmcode_ program completed and all assertions passed.
2Usage errorInvalid command-line flag, malformed --route or --redirect argument, or invocation metadata error.
3Host / load errorUnreadable input file in parse-request/parse-response, bytecode load failure, arena limit exceeded, or unhandled VM error.
4Contract / output failureAn assertion (assert, assert_eq) or result schema contract failed, or stdout write failed.