|
libwebsockets
Lightweight C library for HTML5 websockets
|
Data Structures | |
| struct | lws_whois_results |
| struct | lws_whois_args |
Macros | |
| #define | LWS_WHOIS_CANON_MAX 4096 |
| #define | LWS_WHOIS_TIMEOUT_DEFAULT_MS (20 * 1000) |
| #define | LWS_WHOIS_ANSWER_MAX (64 * 1024) |
| #define | lws_whois_query(_a) |
| #define | lws_whois_json_purify(_o, _ol, _i, _il, _p) |
| #define | lws_whois_results_to_json(_o, _ol, _r, _p) |
Typedefs | |
| typedef void(* | lws_whois_cb_t) (void *opaque, const struct lws_whois_results *res) |
| struct lws_whois_results |
Definition at line 41 of file lws-whois.h.
| Data Fields | ||
|---|---|---|
| lws_usec_t | creation_date | |
| lws_usec_t | expiry_date | |
| lws_usec_t | updated_date | |
| char | nameservers[256] |
the nameservers, as "a, b, c" |
| char | dnssec[64] | |
| char | ds_data[512] | |
| uint8_t | nameservers_dropped |
nonzero if there were nameservers that did not fit in nameservers[]: only whole names are listed there |
| struct lws_whois_args |
Definition at line 56 of file lws-whois.h.
| Data Fields | ||
|---|---|---|
| struct lws_context * | context |
The lws context to run the query in |
| const char * | domain |
The domain name to query |
| const char * | server |
Optional: The WHOIS server to query directly. If NULL, recursive lookup starting from whois.iana.org is performed. |
| lws_whois_cb_t | cb |
Callback to receive results. Called exactly once, when the query completes, or with NULL results when it fails: a failed connection, no referral, the deadline passing, an answer larger than LWS_WHOIS_ANSWER_MAX, or the context being destroyed with the query in flight. |
| void * | opaque |
User-supplied pointer passed to the callback |
| uint16_t | port |
Optional: TCP port for every connection of the query, or 0 for the standard whois port 43 |
| uint32_t | timeout_ms |
Optional: deadline for the whole query, including any referral, in ms, or 0 for LWS_WHOIS_TIMEOUT_DEFAULT_MS. Whois servers only answer once and close, so nothing else notices one that accepts the connection and never does either. |
| #define LWS_WHOIS_CANON_MAX 4096 |
#include <lws-whois.h>
Definition at line 34 of file lws-whois.h.
| #define LWS_WHOIS_TIMEOUT_DEFAULT_MS (20 * 1000) |
#include <lws-whois.h>
Definition at line 37 of file lws-whois.h.
| #define LWS_WHOIS_ANSWER_MAX (64 * 1024) |
#include <lws-whois.h>
Definition at line 39 of file lws-whois.h.
| #define lws_whois_query | ( | _a | ) |
#include <lws-whois.h>
lws_whois_query() - Trigger a WHOIS query for a domain
| args | struct containing query parameters |
Returns 0 if the query was successfully initiated, or nonzero if failed. The results are delivered asynchronously via the callback in args, which is only called if this returned 0.
Definition at line 95 of file lws-whois.h.
| #define lws_whois_json_purify | ( | _o, | |
| _ol, | |||
| _i, | |||
| _il, | |||
| _p ) |
#include <lws-whois.h>
lws_whois_json_purify() - canonicalize untrusted whois JSON
| out | buffer to receive the canonical JSON; must be at least 4097 bytes |
| out_len | size of out in bytes |
| in | the untrusted JSON to purify |
| in_len | length of in in bytes |
| problems | if non-NULL, set nonzero if anything in the input was not schema-conformant and had to be dropped (unknown members, wrong-typed or out-of-range values, over-quota nameservers) or the canonical form hit its size cap |
Parses in against a fixed whitelist of whois members (creation_date, expiry_date, updated_date, nameservers, dnssec, ds_data) with type, charset and range validation, and re-emits the validated members as canonical JSON. Members that are absent in the input stay absent in the output; anything else in the input is dropped and flagged via problems.
Returns the length of the NUL-terminated canonical JSON written to out, or -1 if in does not parse as JSON at all (in which case nothing is written to out). The canonical form is never larger than 4096 bytes.
Definition at line 128 of file lws-whois.h.
| #define lws_whois_results_to_json | ( | _o, | |
| _ol, | |||
| _r, | |||
| _p ) |
#include <lws-whois.h>
lws_whois_results_to_json() - express whois results as canonical JSON
| out | buffer to receive the canonical JSON; must be at least 4097 bytes |
| out_len | size of out in bytes |
| res | the results, as delivered to an lws_whois_cb_t |
| problems | if non-NULL, set nonzero if anything in res could not be expressed and was left out, as lws_whois_json_purify() would drop it, or if res says the whois client already had to leave out some nameservers |
Produces the same canonical form as lws_whois_json_purify(), with the same validation: members with zero or empty values are absent, and the comma-separated nameservers become an array. So the output can be handed to something that purifies it again, and pass cleanly.
Returns the length of the NUL-terminated canonical JSON written to out, or -1 if out is too small.
Definition at line 157 of file lws-whois.h.
| typedef void(* lws_whois_cb_t) (void *opaque, const struct lws_whois_results *res) |
#include <lws-whois.h>
Definition at line 54 of file lws-whois.h.