libwebsockets
Lightweight C library for HTML5 websockets
Loading...
Searching...
No Matches
WHOIS Client

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)

Detailed Description

WHOIS Client APIs


Data Structure Documentation

◆ lws_whois_results

struct lws_whois_results

Definition at line 41 of file lws-whois.h.

Collaboration diagram for lws_whois_results:
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

◆ lws_whois_args

struct lws_whois_args

Definition at line 56 of file lws-whois.h.

Collaboration diagram for lws_whois_args:
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.

Macro Definition Documentation

◆ LWS_WHOIS_CANON_MAX

#define LWS_WHOIS_CANON_MAX   4096

#include <lws-whois.h>

Definition at line 34 of file lws-whois.h.

◆ LWS_WHOIS_TIMEOUT_DEFAULT_MS

#define LWS_WHOIS_TIMEOUT_DEFAULT_MS   (20 * 1000)

#include <lws-whois.h>

Definition at line 37 of file lws-whois.h.

◆ LWS_WHOIS_ANSWER_MAX

#define LWS_WHOIS_ANSWER_MAX   (64 * 1024)

#include <lws-whois.h>

Definition at line 39 of file lws-whois.h.

◆ lws_whois_query

#define lws_whois_query ( _a)

#include <lws-whois.h>

Value:
(1)

lws_whois_query() - Trigger a WHOIS query for a domain

Parameters
argsstruct 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.

◆ lws_whois_json_purify

#define lws_whois_json_purify ( _o,
_ol,
_i,
_il,
_p )

#include <lws-whois.h>

Value:
((void)(_o), -1)

lws_whois_json_purify() - canonicalize untrusted whois JSON

Parameters
outbuffer to receive the canonical JSON; must be at least 4097 bytes
out_lensize of out in bytes
inthe untrusted JSON to purify
in_lenlength of in in bytes
problemsif 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.

◆ lws_whois_results_to_json

#define lws_whois_results_to_json ( _o,
_ol,
_r,
_p )

#include <lws-whois.h>

Value:
((void)(_o), -1)

lws_whois_results_to_json() - express whois results as canonical JSON

Parameters
outbuffer to receive the canonical JSON; must be at least 4097 bytes
out_lensize of out in bytes
resthe results, as delivered to an lws_whois_cb_t
problemsif 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 Documentation

◆ lws_whois_cb_t

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.