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

Common arguments for REST API usage. More...

#include <tsRestArgs.h>

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

Public Types

using SuperClass = TLSArgs
 Explicit definition of the superclass.
 

Public Member Functions

 RestArgs (const UString &description=u"server", const UString &prefix=UString())
 Constructor.
 
virtual void defineClientArgs (Args &args) override
 Add some command line options for a client in an Args.
 
virtual void defineServerArgs (Args &args) override
 Add command line options for a server in an Args.
 
bool isAllowed (const IPAddress &client) const
 On the server side, check if a client address is allowed, based on sets of allowed and denied clients.
 
bool loadAllowedClients (Args &args, const UChar *option)
 Load the set of allowed clients from a command line (server side).
 
virtual bool loadClientArgs (Args &args, const UChar *server_option=nullptr) override
 Load arguments for a client from a command line.
 
bool loadDeniedClients (Args &args, const UChar *option)
 Load the set of denied clients from a command line (server side).
 
virtual bool loadServerArgs (Args &args, const UChar *server_option=nullptr) override
 Load arguments for a server from a command line.
 

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.
 
bool insecure = false
 Do not verify TLS server's certificate.
 
UString key_path {}
 TLS server private key path.
 
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.
 

Protected Attributes

UString _description
 Short description of the TLS service.
 
UString _opt_certificate_path
 Option name for –[prefix-]certificate-path.
 
UString _opt_certificate_store
 Option name for –[prefix-]store.
 
UString _opt_insecure
 Option name for –[prefix-]insecure.
 
UString _opt_key_path
 Option name for –[prefix-]key-path.
 
UString _opt_tls
 Option name for –[prefix-]tls.
 
UString _opt_token
 Option name for –[prefix-]token.
 
UString _prefix
 Option prefix, ready to use in other option names.
 

Detailed Description

Common arguments for REST API usage.

Can be set by fields or using command line options.

Constructor & Destructor Documentation

◆ RestArgs()

ts::RestArgs::RestArgs ( const UString description = u"server",
const UString prefix = UString() 
)

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.

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.

◆ loadAllowedClients()

bool ts::IPArgs::loadAllowedClients ( Args args,
const UChar option 
)
inlineinherited

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.
Returns
True on success, false on error in argument line.

◆ loadDeniedClients()

bool ts::IPArgs::loadDeniedClients ( Args args,
const UChar option 
)
inlineinherited

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.

Member Data Documentation

◆ certificate_store

UString ts::TLSArgs::certificate_store {}
inherited

TLS server certificate store.

See also
TLSServer::setCertificateStore()

◆ certificate_path

UString ts::TLSArgs::certificate_path {}
inherited

TLS server certificate path.

See also
TLSServer::setCertificatePath()

◆ key_path

UString ts::TLSArgs::key_path {}
inherited

TLS server private key path.

See also
TLSServer::setKeyPath()

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