libonion
|
Data Structures | |
struct | onion_listen_point_t |
Stored common data for each listen point: address, port, protocol status data... More... |
int onion_listen_point_accept | ( | onion_listen_point * | op | ) |
Called when a new connection appears on the listenfd.
When the new connection appears, creates the request and adds it to the pollers.
It returns always 1 as any <0 would detach from the poller and close the listen point, and not accepting a request does not mean the connection point is corrupted. If a connection point may become corrupted should be the connection point itself who detaches from the poller.
op | The listen point from where the request must be built |
References onion_request_t::connection, onion_request_t::fd, onion_request_t::listen_point, ONION_ERROR, onion_listen_point_t::onion_listen_point_read_ready(), onion_poller_t::onion_poller_add(), onion_poller_slot_t::onion_poller_slot_new(), onion_poller_slot_t::onion_poller_slot_set_shutdown(), onion_poller_slot_t::onion_poller_slot_set_timeout(), onion_request_t::onion_request_free(), onion_request_t::onion_request_new(), onion_t::poller, onion_listen_point_t::server, and onion_t::timeout.
Referenced by onion_listen().
void onion_listen_point_free | ( | onion_listen_point * | op | ) |
Free and closes the listen point.
Calls the custom listen_stop mathod, and frees all common structures.
op | the listen point |
References onion_listen_point_t::free_user_data, onion_listen_point_t::hostname, onion_listen_point_t::listenfd, ONION_DEBUG, onion_listen_point_t::onion_listen_point_listen_stop(), onion_low_free(), and onion_listen_point_t::port.
Referenced by onion_free(), onion_https_t::onion_https_new(), and onion_set_certificate_va().
int onion_listen_point_listen | ( | onion_listen_point * | op | ) |
Starts the listening phase for this listen point for sockets.
Default listen implementation that listens on sockets. Opens sockets and setup everything properly.
op | The listen point |
References onion_t::flags, onion_listen_point_t::hostname, onion_listen_point_t::listen, onion_listen_point_t::listenfd, O_SYSTEMD, ONION_DEBUG, ONION_ERROR, ONION_WARNING, onion_listen_point_t::port, onion_listen_point_t::server, and SOCK_CLOEXEC.
Referenced by onion_listen().
void onion_listen_point_listen_stop | ( | onion_listen_point * | op | ) |
Stops listening the listen point.
Calls the op->listen_stop if any, and if not just closes the listenfd.
op | The listen point |
References onion_listen_point_t::listen_stop, and onion_listen_point_t::listenfd.
Referenced by onion_listen_point_t::onion_listen_point_free(), and onion_listen_stop().
onion_listen_point * onion_listen_point_new | ( | ) |
Creates an empty listen point.
Called by real listen points to ease the creation.
References onion_low_calloc().
Referenced by onion_http_t::onion_http_new(), and onion_https_t::onion_https_new().
static int onion_listen_point_read_ready | ( | onion_request * | req | ) |
This listen point has data ready to read; calls the listen_point read_ready.
req | The request with data ready |
References onion_request_t::connection, onion_request_t::listen_point, OCS_INTERNAL_ERROR, ONION_ERROR, and onion_listen_point_t::read_ready.
Referenced by onion_listen_point_t::onion_listen_point_accept().
void onion_listen_point_request_close_socket | ( | onion_request * | oc | ) |
Default implementation that just closes the connection.
oc | The request |
References onion_request_t::connection, onion_request_t::fd, and ONION_DEBUG0.
Referenced by onion_http_t::onion_http_new(), onion_https_t::onion_https_close(), onion_https_t::onion_https_request_init(), and onion_listen_point_t::onion_listen_point_request_init_from_socket().
int onion_listen_point_request_init_from_socket | ( | onion_request * | req | ) |
Default implementation that initializes the request from a socket.
Accepts the connection and initializes it.
req | Request to initialize |
Follows default socket implementation. If your protocol is socket based, just use it.
Thanks to Andrew Victor for pointing that without this client may block HTTPS connection. It could lead to DoS if occupies all connections.
References accept4, onion_request_t::cli_addr, onion_request_t::cli_len, onion_request_t::connection, onion_request_t::fd, onion_request_t::listen_point, onion_listen_point_t::listenfd, ONION_DEBUG, ONION_DEBUG0, ONION_ERROR, onion_listen_point_t::onion_listen_point_request_close_socket(), onion_listen_point_t::server, SOCK_CLOEXEC, and onion_t::timeout.
Referenced by onion_https_t::onion_https_request_init(), and onion_request_t::onion_request_new().