TSDuck v3.46-4930
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches

#include <tsIPArgs.h>

Inheritance diagram for ts::IPArgs:
Collaboration diagram for ts::IPArgs:

Public Member Functions

 IPArgs (const UString &description=u"server", const UString &prefix=UString())
virtual void defineClientArgs (Args &args)
virtual void defineServerArgs (Args &args)
const UString & description () 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)
bool loadDeniedClients (Args &args, const UChar *option)
virtual bool loadServerArgs (Args &args, const UChar *server_option=nullptr)
const UString & prefix () const

Public Attributes

IPAddressSet allowed_clients {}
 White-list of allowed incoming clients.
cn::milliseconds connection_timeout {0}
 Connection timeout in milliseconds (zero means none).
IPAddressSet denied_clients {}
 Black-list of denied incoming clients.
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).

Detailed Description

Common arguments for IP clients and servers, UDP and TCP. Can be set by fields or using command line options.

Constructor & Destructor Documentation

◆ IPArgs()

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

Constructor.

Parameters
[in]descriptionShort description of the 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::IPArgs::defineServerArgs ( Args & args)
virtual

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 in ts::RestArgs, and ts::TLSArgs.

◆ defineClientArgs()

virtual void ts::IPArgs::defineClientArgs ( Args & args)
virtual

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 in ts::RestArgs, and ts::TLSArgs.

◆ loadServerArgs()

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

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 in ts::RestArgs, and ts::TLSArgs.

◆ loadClientArgs()

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

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 in ts::RestArgs, and ts::TLSArgs.

◆ loadAllowedClients()

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

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 )

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

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
inline

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
inline

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.

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