Expand description
Links redirector server utilities, including:
- Listeners, which listen for incoming network traffic
- Acceptors, which accept incoming connections and direct it to the handlers
- Handlers, which handle requests, doing HTTP redirects or RPC calls
- miscellaneous functions used by the server binary
§Listeners
A listener controls a network socket and calls its associated acceptor when a new connection is received. One listener exists for every socket that the links redirector server listens on. Listeners can be added and removed while the server is active.
§Acceptors
Acceptors are the bridge between listeners and handlers. They hold (references to) all necessary state used by themselves and the handlers. One acceptor exists for every combination of listener + encryption + handler type, e.g. an unencrypted TCP acceptor for HTTP, an encrypted TCP/TLS acceptor for RPC, etc. Acceptors are predefined for the lifetime of the redirector server, and initialized at server startup. Acceptors initially process incoming connections (doing handshakes and de/en-cryption if necessary), and then call their associated handler.
§Handlers
Handlers are responsible for all application logic. A handler is an async function called from an acceptor. There is one predefined handler for each kind of request: currently one external HTTP redirector, one HTTP to HTTPS redirector, and one RPC handler.
Structs§
- Listener
- A links redirector listener.
- Plain
Http Acceptor - An acceptor for plaintext (unencrypted) HTTP requests. Supports HTTP/1.0, HTTP/1.1, and HTTP/2 (in its rare unencrypted variety usually not found in any browsers).
- Plain
RpcAcceptor - An acceptor for plaintext (unencrypted) RPC calls. Supports
gRPC
over unencrypted HTTP/2. - TlsHttp
Acceptor - An acceptor for TLS-encrypted HTTPS requests. Supports HTTP/1.0, HTTP/1.1, and HTTP/2.
- TlsRpc
Acceptor - An acceptor for TLS-encrypted RPC calls. Supports
gRPC
over HTTP/2 with HTTPS.
Enums§
- Protocol
- The protocols that links redirector servers can listen on
Constants§
- LISTENER_
TCP_ 🔒BACKLOG_ SIZE - Number of incoming connections that can be kept in the TCP socket backlog of
a listener (see
listen
’s linux man page or winsock docs for details)
Traits§
- Acceptor
- A trait for defining links server acceptors.
Functions§
- http_
handler - A handler that does external HTTP redirects using information from the
provided store. Extra information for statistics can be passed via
stat_info
. - http_
to_ https_ handler - A handler that redirects incoming requests to their original URL, but with the HTTPS scheme instead.
- rpc_
handler - Handler processing RPC API calls.
- store_
setup - Set up the links store, optionally setting an example redirect
(
example
->9dDbKpJP
->https://example.com/
).