TSDuck v3.46-4930
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches
ts::RestArgs Class Reference

#include <tsRestArgs.h>

Inheritance diagram for ts::RestArgs:
Collaboration diagram for ts::RestArgs:

Public Types

using SuperClass = TLSArgs

Public Member Functions

 RestArgs (const UString &description=u"server", const UString &prefix=UString(), bool tls_default=false)
virtual void defineClientArgs (Args &args) override
virtual void defineServerArgs (Args &args) override
const UString & description () const
bool hasCertificate () const
bool isAllowed (const IPAddress &client) const
bool loadAllowedClients (Args &args, const UChar *option, bool default_local_only)
virtual bool loadClientArgs (Args &args, const UChar *server_option=nullptr) override
bool loadDeniedClients (Args &args, const UChar *option)
virtual bool loadServerArgs (Args &args, const UChar *server_option=nullptr) override
const UString & prefix () const
const UString & withTLS () const

Public Attributes

IPAddressSet allowed_clients {}
 White-list of allowed incoming clients.
UString api_root {}
 Optional root path for api (e.g. "/serve/api").
UString auth_token {}
 Authentication token.
UString certificate_path {}
 TLS server certificate path.
UString certificate_store {}
 TLS server certificate store.
cn::milliseconds connection_timeout {0}
 Connection timeout in milliseconds (zero means none).
IPAddressSet denied_clients {}
 Black-list of denied incoming clients.
size_t ephemeral_rsa_bits = 0
 TLS server ephemeral certificate RSA kiey size in bits, when not zero.
bool insecure = false
 Do not verify TLS server's certificate.
UString key_path {}
 TLS server private key path.
size_t max_header_count = DEFAULT_MAX_HEADER_COUNT
 Maximum number of received headers.
size_t max_line_size = DEFAULT_MAX_LINE_SIZE
 Maximum size of received text lines.
size_t max_post_size = DEFAULT_MAX_POST_SIZE
 Maximum size of received POST data.
cn::milliseconds receive_timeout {0}
 Reception timeout in milliseconds (zero means none).
bool reuse_port = true
 Reuse-port socket option.
IPSocketAddress server_addr {}
 Server address and port. The address is optional on server side.
UString server_name {}
 Server host name (required in addition to server address in some cases).
bool use_tls = false
 Use SSL/TLS.

Static Public Attributes

static constexpr size_t DEFAULT_MAX_HEADER_COUNT = 256
 Default maximum number of received headers.
static constexpr size_t DEFAULT_MAX_LINE_SIZE = 2048
 Default maximum size of received text lines.
static constexpr size_t DEFAULT_MAX_POST_SIZE = 65536
 Default maximum size of received POST data.

Detailed Description

Common arguments for REST API usage. Can be set by fields or using command line options.

Member Typedef Documentation

◆ SuperClass

Explicit definition of the superclass.

Constructor & Destructor Documentation

◆ RestArgs()

ts::RestArgs::RestArgs ( const UString & description = u"server",
const UString & prefix = UString(),
bool tls_default = false )

Constructor.

Parameters
[in]descriptionShort description of the REST service. Example: "control port". Use no initial cap, no final dot.
[in]prefixOptional prefix for all command line options. Example: when prefix is "foo", the option –certificate-path becomes –foo-certificate-path.
[in]tls_defaultIf false (the default) TLS is not the default and the option –tls is defined to activate it. If true, TLS is the default and the option –no-tls is defined to deactivate it and use clear communication.

Member Function Documentation

◆ defineServerArgs()

virtual void ts::RestArgs::defineServerArgs ( Args & args)
overridevirtual

Add command line options for a server in an Args. No options is defined for server [addr:]port because the description is probably too specific. Same for lists of allowed and denied clients.

Parameters
[in,out]argsCommand line arguments to update.

Reimplemented from ts::TLSArgs.

◆ defineClientArgs()

virtual void ts::RestArgs::defineClientArgs ( Args & args)
overridevirtual

Add some command line options for a client in an Args. No options is defined for server addr:port because the description is probably too specific.

Parameters
[in,out]argsCommand line arguments to update.

Reimplemented from ts::TLSArgs.

◆ loadServerArgs()

virtual bool ts::RestArgs::loadServerArgs ( Args & args,
const UChar * server_option = nullptr )
overridevirtual

Load arguments for a server from a command line. Args error indicator is set in case of incorrect arguments.

Parameters
[in,out]argsCommand line arguments.
[in]server_optionOptional name of an option which defines the server port and optional address.
Returns
True on success, false on error in argument line.

Reimplemented from ts::TLSArgs.

◆ loadClientArgs()

virtual bool ts::RestArgs::loadClientArgs ( Args & args,
const UChar * server_option = nullptr )
overridevirtual

Load arguments for a client from a command line. Args error indicator is set in case of incorrect arguments.

Parameters
[in,out]argsCommand line arguments.
[in]server_optionOptional name of an option which defines the server name and address.
Returns
True on success, false on error in argument line.

Reimplemented from ts::TLSArgs.

◆ hasCertificate()

bool ts::TLSArgs::hasCertificate ( ) const
inherited

Check if enough parameters are provided to specify a certificate, depending on the operating system.

Returns
True if enough parameters are provided to specify a certificate.

◆ withTLS()

const UString & ts::TLSArgs::withTLS ( ) const
inlineinherited

Get the help string which defines the condition of using SSL/TLS. The actual string depends if SSL/TLS is enabled by default or not.

Returns
A constant reference to the string "Without --[prefix-]no-tls" or "With --[prefix-]tls".

◆ loadAllowedClients()

bool ts::IPArgs::loadAllowedClients ( Args & args,
const UChar * option,
bool default_local_only )
inherited

Load the set of allowed clients from a command line (server side).

Parameters
[in,out]argsCommand line arguments.
[in]optionOption which defines the client addresses.
[in]default_local_onlyWhen true and no value is specified for the option, the local host is the only allowed client.
Returns
True on success, false on error in argument line.

◆ loadDeniedClients()

bool ts::IPArgs::loadDeniedClients ( Args & args,
const UChar * option )
inherited

Load the set of denied clients from a command line (server side).

Parameters
[in,out]argsCommand line arguments.
[in]optionOption which defines the client addresses.
Returns
True on success, false on error in argument line.

◆ isAllowed()

bool ts::IPArgs::isAllowed ( const IPAddress & client) const
inherited

On the server side, check if a client address is allowed, based on sets of allowed and denied clients.

Parameters
[in]clientIncoming client address.
Returns
True if the client is allowed, false if it is denied.

◆ description()

const UString & ts::IPArgs::description ( ) const
inlineinherited

Get the short description of the service, as specified in the constructor. The result can be used in help text in subclasses for instance.

Returns
A constant reference to the description string.

◆ prefix()

const UString & ts::IPArgs::prefix ( ) const
inlineinherited

Get the option prefix, ready to use in other option names. If the prefix was set to a non-empty string without trailing dash, the returned string contains a trailing dash. Example: when prefix was set to "foo" in the constructor, the returned value is "foo-"

Returns
A constant reference to the prefix string.

Member Data Documentation

◆ certificate_store

UString ts::TLSArgs::certificate_store {}
inherited

TLS server certificate store.

See also
TLSServerBase::setCertificateStore()

◆ certificate_path

UString ts::TLSArgs::certificate_path {}
inherited

TLS server certificate path.

See also
TLSServerBase::setCertificatePath()

◆ key_path

UString ts::TLSArgs::key_path {}
inherited

TLS server private key path.

See also
TLSServerBase::setKeyPath()

The documentation for this class was generated from the following file: