> Source: https://docs.cyberelements.io/bastion/4.7/cs/Usage/Reference/ConfigurationFiles/MediationController/ServerServicesXml/

# services.xml

`/etc/ipdiva/server/services.xml` declares the services of the SSL Router of the Mediation Controller: the local listening addresses whose connections it carries to an Edge Gateway, and the addresses that the other nodes may reach through it. It is the file in which the consoles record the permanent tunnels they create (towards the database of an organisation, for instance).

| Property | Value |
|---|---|
| **Component** | Mediation Controller |
| **Path** | `/etc/ipdiva/server/services.xml` |
| **Owner and permissions** | `root:ipdivasrv`, `664` |
| **Package** | none, written at installation, completed on upgrade |
| **Format** | XML |

> **The SSL Router rewrites the file**
>
> Each time the console adds or removes a permanent tunnel, the SSL Router writes the whole file again from what it holds in memory, without comments, without your layout, and with every default value written out. A change made by hand is applied only when the SSL Router restarts: restart it as soon as the change is made, otherwise a rewrite in the meantime would erase it.

## Structure

A single `<services>` element:

| Section | Holds |
|---|---|
| [`<services>`](#services-root) | The Edge Gateways allowed to reach any address through the Mediation Controller. |
| [`<in>`](#in) | The input services: a local listening address, whose connections are carried to an Edge Gateway. |
| [`<out>`](#out) | The output services: an address that the other nodes may reach through the Mediation Controller. |

The installed file declares a single output service, `ntp`, which gives the Edge Gateways the time of the Mediation Controller. A `<multicast>` section is read without effect: only an Edge Gateway creates multicast services.

## Parameters

The tables list every element and every attribute that the SSL Router reads. Two columns give a value:

- **Default value**: the value written in the file as installed. A dash marks an element absent from the installed file.
- **If the element is absent**: the value that the SSL Router uses when it does not find the element.

An element is written as a path from its section, and `@` marks an attribute:

- `service/name` is the `<name>` element of a `<service>` of the section;
- `service/gateway/@passive` is the `passive` attribute of the `<gateway>` element of a `<service>`;
- `service/@max-rate` is the `max-rate` attribute of the `<service>` itself.

### `<services>`

Root element of the file. It holds the `<in>`, `<out>` and `<multicast>` sections, each made of repeatable `<service>` elements, and the `<dyn-gateways>` element. The file is read at startup only. A missing or unreadable file, or one whose root is not `<services>`, is skipped: the program starts with no declared service.

| Element | Default value | If the element is absent | Effect |
|---|---|---|---|
| `dyn-gateways` | — | none | Names of the Edge Gateways allowed to reach, through the Mediation Controller, any address given as `host:port` (port 80 if omitted), even with no declared outgoing service. Names are separated by a space, a comma or a semicolon, and written without prefix as `edge-gateway@organization`. A name may hold wildcards: `*` stands for zero, one or more characters, `?` for exactly one character. For instance, `*@organization` designates every Edge Gateway of an organisation. The name must match as a whole, case included. |

### `<in>`

Incoming services. Each `<service>` opens a local listener on the Mediation Controller; every connection it receives is carried through an Edge Gateway, which hands it to the named service. The system administration console adds here the permanent tunnels it creates, for instance toward an organisation database reached through an Edge Gateway.

| Element | Default value | If the element is absent | Effect |
|---|---|---|---|
| `service/gateway` | — | — | Name of a destination Edge Gateway, as `edge-gateway@organization`; the element is repeated for each Edge Gateway. Each connection goes to one of the connected active Edge Gateways, picked at random. The prefix `S:` is added when missing. |
| `service/gateway/@passive` | — | `false` | `true`: standby destination, used only when no active destination of the service is connected. Any other value: active destination. |
| `service/@max-rate` | — | no limit | Maximum rate, in bytes per second averaged over about 20 seconds, of the data that this node reads on each connection of the service and sends into the tunnel. `0` or a non-numeric value: no limit. |
| `service/protocol` | — | `tcp` | Transport protocol of the service: `tcp` or `udp`, in lowercase. A value written otherwise than in lowercase counts as `tcp`. |
| `service/name` | — | required | Name of the service requested from the destination Edge Gateway: the name of an outgoing service declared on that Edge Gateway, or directly an address `host:port` that the Edge Gateway reaches. |
| `service/listen` | — | required | Local listening address and port, as `address:port`. Port `0` lets the system choose a free port. The protocol and this address identify the service. |
| `service/must-exist` | — | `false` | `true`: the listener is opened with address reuse and, if it cannot be opened, the program stops; systemd restarts it 10 seconds later. `false`: the failure is written to the log and the service is skipped. |
| `service/crypted` | — | `false` | `true`: the data of each connection are encrypted end to end between the two nodes, with a session key exchanged by means of their certificates. `false`: they are protected by the encryption of the links only. |
| `service/timeout` | — | `0` | Time, in milliseconds, after which a connection is closed when no data has arrived from its local side. `0`: no time limit, except for a `udp` service, closed after 180 seconds. |
| `service/compression` | — | `zlib` | Compression of the data that this node sends into the tunnel: `zlib`, `lzo` or `none`, case-insensitive. Any other value counts as `lzo`. |

### `<out>`

Outgoing services. Each `<service>` allows other nodes to open, through the Mediation Controller, a connection toward an address. The Mediation Controller refuses any request for a service that is not declared here, or that comes from a node not allowed, except as set by `<dyn-gateways>`.

| Element | Default value | If the element is absent | Effect |
|---|---|---|---|
| `service/@max-rate` | — | no limit | Maximum rate, in bytes per second averaged over about 20 seconds, of the data that this node reads from the destination address and sends back into the tunnel. `0` or a non-numeric value: no limit. |
| `service/name` | `ntp` | required | Name of the service, as requested by the incoming services of the other nodes (`<name>` of `<in>`). It identifies the service. |
| `service/connect` | `127.0.0.1:123` | required | Address and port, as `host:port`, toward which this node opens the connection. |
| `service/gateways` | — | all nodes | Names of the nodes allowed to request the service, separated by a space, a comma or a semicolon. A name is written without prefix: `edge-gateway@organization` for an Edge Gateway, `Server` (`ServerMaster` or `ServerSlave` in a cluster) for the Mediation Controller. A name may hold wildcards: `*` stands for zero, one or more characters, `?` for exactly one character. For instance, `*@organization` designates every Edge Gateway of an organisation. The name must match as a whole, case included. Empty: all nodes. |

## Applying a change

The file is read only when the SSL Router starts. Edit the file, then restart the SSL Router to apply the change:

```
1
```

> **Restarting the SSL Router cuts the connections in progress**
>
> The SSL Router carries the connections of the Edge Gateways, of the clients and of the web accesses: those in progress are cut, and during the restart users can neither sign in to the portal nor launch an application. Plan the change outside working hours, and in a cluster restart one node at a time.

## Upgrade

No package delivers the file as a configuration file. At each installation or upgrade of the SSL router, the package:

- creates the file from its template if it is missing;
- replaces it with the current template if it is still identical to a template delivered by a former version;
- otherwise, only removes the former output services `ssh` (`127.0.0.1:22`) and `rsync` (`127.0.0.1:873`) if they are still as delivered, after saving the file as `services.xml.<date>`. Nothing else is touched.
