masque_handler behaviour (masque v0.7.0)
View SourceServer-side handler behaviour for MASQUE tunnels.
Callbacks:
accept/1- synchronous accept/reject gate for the handshake. Returnacceptor{reject, masque_errors:handshake_error()}. Optional; default isaccept.init/2- session start. Return{ok, State}or{ok, State, [action()]}or{stop, Reason}.handle_packet/2- inbound UDP payload (CONNECT-UDP tunnels).handle_data/2- inbound TCP bytes (CONNECT-TCP tunnels).handle_capsule/3- inbound capsule on the stream body.handle_info/2- any other Erlang message.terminate/2- session shutdown.
All callbacks are optional. Omitting a callback for a given event makes the session silently ignore it.
Summary
Functions
Default accept/1 behaviour - accept every well-formed request.
Types
-type accept_result() :: accept | {reject, masque_errors:handshake_error()} | {reject, masque_errors:handshake_error(), [{binary(), binary()}]}.
-type req() :: #{method := binary(), protocol => udp | tcp | ip, path := binary(), authority := binary(), scheme := binary(), target_host => binary(), target_port => 1..65535, ip_target => masque_uri_ip:ip_target(), ip_ipproto => masque_uri_ip:ip_ipproto(), resolved_addresses => [inet:ip_address()], headers := [{binary(), binary()}], handler_opts => term(), peer => {inet:ip_address(), inet:port_number()}, peer_cert => binary()}.
Callbacks
Functions
-spec default_accept(req()) -> accept_result().
Default accept/1 behaviour - accept every well-formed request.