3. Johd – Jabber Over HTTP Daemon

The following table summarizes the available command line options in alphabetic order. For each option, it provides a reference to the place in the tutorial where the option is discussed.

-c class

Sets socket class. Allowed values for class are ‘CGI’ and ‘HTTP’. This option affects all subsequent ‘-l’ options appearing to the right of it, until another ‘-c’ option or end of command line is encountered, whichever occurs first.

See socket class.

-D

After startup, switch to the background and run as daemon. See daemon.

-d number

Sets debugging level. See section Logging and Debugging.

-E file

Read the 404 error page from file. This error page is returned as a response to HTTP GET requests. The file must contain a valid HTML document without external references in the ‘head’ section. See section HTTP GET Requests.

This option affects all HTTP sockets created by subsequent ‘-l’ options which appear to the right of it, until another ‘-E’ option or end of command line is encountered, whichever occurs first.

-F facility

Sets syslog facility. Allowed values for facility are: ‘user’, ‘daemon’, ‘auth’, ‘authpriv’, ‘mail’, ‘cron’, ‘local0’ through ‘local7’. All names are case-insensitive.

See section Logging and Debugging.

-h

Shows a terse help summary.

-i

Show source line information with debug messages. See section Logging and Debugging.

-L string

Sets log tag. See section Logging and Debugging.

-l url

Listen on the given url. Several ‘-l’ options can appear in the command line.

See listen option.

-P

Prefix diagnostic messages with their severity level. See section Logging and Debugging.

-p file

Write PID to file. See daemon.

-R url

Redirect HTTP GET requests to url. The argument must begin with ‘http://’. See section HTTP GET Requests.

This option affects all HTTP sockets created by subsequent ‘-l’ options which appear to the right of it, until another ‘-R’ option or end of command line is encountered, whichever occurs first.

-S name

Sets service name for TCP wrappers. This option affects all subsequent ‘-l’ options appearing to the right of it, until another ‘-S’ option or end of command line is encountered, whichever occurs first.

See TCP wrappers.

-s url

Sets URL of the default jabber server. It is used if the request does not specify the server explicitly.

-t type:timeout

Sets session idle timeout. Type is the type of the socket: ‘C’ for client sockets (either ‘CGI’ or ‘HTTP’) and ‘J’ for Jabber socket. Timeout is the timeout value, either in seconds or in ‘XhYmZs’ form.

Defaults are: ‘-t C:5m -t J:1m’.

-u user

Run as user, after completing privileged operations, such as creating sockets that listen on ports below 1024. See daemon.

-V

Prints the program version.

3.1 URLs

JOH components are able to handle three socket families: UNIX sockets, IPv4 and IPv6. URLs provide a uniform way of specifying socket addresses in any of these families.

A URL consists of the following parts:

 
  scheme://adress:port

Up to two parts can be omitted, if that does not create ambiguity.

Valid URL schemes are:

unix

Specifies a UNIX socket. The address part is the socket pathname, and the ‘:port’ part is not used. The pathname must be absolute, e.g. ‘unix:///var/run/joh.socket’.

To facilitate typing, the two slashes after the colon can be omitted, as in:

 
unix:/var/run/joh.socket
inet

Specifies an IPv4 socket. The address part must be an IPv4 address in dotted quad form, or a host name. If the latter resolves to multiple addresses, those belonging to the IPv4 family are selected. The port part is either the network port number in decimal, or a corresponding service name from ‘/etc/services’. For example:

 
inet://127.0.0.1:1100
inet6

Specifies an IPv6 socket. The address part must be either an IPv6 address in numeric notation enclosed in square brackets or a host name. If the latter resolves to multiple addresses, those belonging to the IPv6 family are selected. The port part is either the network port number in decimal, or a corresponding service name from ‘/etc/services’. E.g.:

 
inet6://[::1]:1100

For URLs given as argument to the ‘-l’ option, either address or port can be omitted. If address is omitted, the program will listen on all available network interfaces with addresses from the specified family, e.g.:

 
inet6://:1100

instructs johd to listen on port 1100 on all IPv6 interfaces.

If port is omitted, the default is selected depending upon the class of the socket: 1100 is used for ‘CGI’ sockets, and 80 is used for ‘HTTP’ sockets.

The port component can also be omitted in URLs which are arguments to the ‘-s’ option (see default jabber server). In this case, port defaults to 5222, e.g.:

 
inet6://[::1]
inet://127.0.0.1

For compatibility with earlier versions, johd accepts IPv6 addresses without square brackets, although such use is not recommended, e.g.:

 
inet6://::1:1100

If the scheme part is omitted, johd tries to do its best to guess what address family is assumed. Thus:

/var/run/socket’ is treated as ‘unix:///var/run/socket’;

127.0.0.1’ is treated as ‘inet://127.0.0.1’;

[::1]:3398’ is treated as ‘inet6://[::1]:3398’;

::1:3398’ is treated as ‘inet6://[::1]:3398’;

The URL ‘3456’ causes johd to listen on port 3456 on all available network interfaces, no matter what their address family is.

3.2 Exit Codes

Depending on the reason for termination, johd exits with the following codes:

0

Normal termination. This includes, e.g., termination on ‘SIGTERM’ signal.

64

Usage error, e.g. unknown option or erroneous argument was given in the command line.

69

A service is unavailable. This happens, for instance, if the program could not fork or disconnect from the controlling terminal.

70

An internal software error has been detected. If it ever happens, please report this as bug. See section How to Report a Bug.

75

Temporary error condition. Currently this happens if the ‘-p file’ option is specified, file exists, but cannot be accessed.

78

A configuration error occurred. This is different from usage error (64) in that the data supplied to the program where syntactically correct, but cannot be used. For example, a host name supplied with ‘-l’ cannot be resolved.

3.3 Signals

The following signals cause immediate program termination with exit code 0: ‘SIGPIPE’, ‘SIGINT’, ‘SIGQUIT’, ‘SIGTERM’, ‘SIGHUP’.