4. [`root-except-ta`](#root-except-ta)
7. [`--shuffle-uris`](#--shuffle-uris)
8. [`--maximum-certificate-depth`](#--maximum-certificate-depth)
- 9. [`--server.disabled`](#--serverdisabled)
+ 9. [`--mode`](#--mode)
10. [`--server.address`](#--serveraddress)
11. [`--server.port`](#--serverport)
12. [`--server.backlog`](#--serverbacklog)
[--sync-strategy=off|strict|root|root-except-ta]
[--shuffle-uris]
[--maximum-certificate-depth=<unsigned integer>]
- [--server.disabled]
+ [--mode=server|standalone]
[--server.address=<string>]
[--server.port=<string>]
[--server.backlog=<unsigned integer>]
Fort's tree traversal is actually iterative (not recursive), so there should be no risk of stack overflow, regardless of this value.
-### `--server.disabled`
+### `--mode`
-- **Type:** None
+- **Type:** Enumeration (`server`, `standalone`)
- **Availability:** `argv` and JSON
+- **Default:** `server`
-Disable the RTR server.
-
-If the flag is set, the server is disabled, the rest of the `server.*` arguments are ignored, and Fort performs an in-place standalone RPKI validation.
+Run mode, commands the way Fort executes the validation. The two possible values and its behavior are:
+- `server`: Enables the RTR server using the `server.*` arguments ([`server.address`](#--serveraddress), [`server.port`](#--serverport), [`server.backlog`](#--serverbacklog), [`server.validation-interval`](#--servervalidation-interval)).
+- `standalone`: Disables the RTR server, the `server.*` arguments are ignored, and Fort performs an in-place standalone RPKI validation.
### `--server.address`
"<a href="#--sync-strategy">sync-strategy</a>": "root",
"<a href="#--shuffle-uris">shuffle-uris</a>": true,
"<a href="#--slurm">slurm</a>": "/tmp/test.slurm",
+ "<a href="#--mode">mode</a>": "server",
"server": {
- "<a href="#--serverdisabled">disabled</a>": false,
"<a href="#--serveraddress">address</a>": "192.0.2.1",
"<a href="#--serverport">port</a>": "8323",
"<a href="#--serverbacklog">backlog</a>": 16,
.RE
.P
-.B \-\-server.disabled
+.B \-\-mode=(\fIserver\fR|\fIstandalone\fR)
.RS 4
-Disable the RTR server implemented by FORT. If this flag is set, the rest of
-the configuration options "\fIserver.*\fR" are ignored and FORT performs an
-in-place standalone RPKI validation.
+Commands the way FORT executes the validation, its possible values are:
.P
-By default, the RTR server is enabled.
+.I server
+.RS 4
+Enable the RTR server using the \fIserver.*\fR arguments.
+.RE
+.P
+.I standalone
+.RS 4
+Disable the RTR server, the configuration options \fIserver.*\fR are ignored
+and FORT performs an in-place standalone validation.
+.RE
+.P
+By default, the mode is \fIserver\fR.
.RE
.P
.RE
.P
-.B fort \-t /tmp/tal \-r /tmp/repository \-\-server.disabled \-\-output.roa -
+.B fort \-t /tmp/tal \-r /tmp/repository \-\-mode=standalone \-\-output.roa -
.RS 4
Run FORT as standalone and output ROAs CSV to the console.
.RE
.nf
\fBfort \-t /tmp/tal \-r /tmp/repository \\
- \-\-server.disabled \\
+ \-\-mode=standalone \\
\-\-slurm /tmp/myslurm.slurm\fR
.fi
.RS 4
"sync-strategy": "root",
"shuffle-uris": true,
"maximum-certificate-depth": 32,
+ "mode": "server",
"slurm": "test.slurm",
"server": {
- "disabled": false,
"address": "192.0.2.1",
"port": "8323",
"backlog": 64,
fort_SOURCES += config/boolean.c config/boolean.h
fort_SOURCES += config/filename_format.h config/filename_format.c
+fort_SOURCES += config/mode.c config/mode.h
fort_SOURCES += config/incidences.h config/incidences.c
fort_SOURCES += config/str.c config/str.h
fort_SOURCES += config/string_array.h config/string_array.c
unsigned int maximum_certificate_depth;
/** File or directory where the .slurm file(s) is(are) located */
char *slurm;
+ /* Run as RTR server or standalone validation */
+ enum mode mode;
struct {
- /** Disable the RTR server. */
- bool disabled;
/** The bound listening address of the RTR server. */
char *address;
/** The bound listening port of the RTR server. */
.type = >_string,
.offset = offsetof(struct rpki_config, slurm),
.doc = "Path to the SLURM file or SLURMs directory (files must have the extension .slurm)",
+ }, {
+ .id = 1004,
+ .name = "mode",
+ .type = >_mode,
+ .offset = offsetof(struct rpki_config, mode),
+ .doc = "Run mode: 'server' (run as RTR server), 'standalone' (run validation once and exit)",
},
/* Server fields */
{
.id = 5000,
- .name = "server.disabled",
- .type = >_bool,
- .offset = offsetof(struct rpki_config, server.disabled),
- .doc = "Disable the RTR server.",
- }, {
- .id = 5001,
.name = "server.address",
.type = >_string,
.offset = offsetof(struct rpki_config, server.address),
.doc = "Address to which RTR server will bind itself to. Can be a name, in which case an address will be resolved.",
}, {
- .id = 5002,
+ .id = 5001,
.name = "server.port",
.type = >_string,
.offset = offsetof(struct rpki_config, server.port),
.doc = "Port to which RTR server will bind itself to. Can be a string, in which case a number will be resolved.",
}, {
- .id = 5003,
+ .id = 5002,
.name = "server.backlog",
.type = >_uint,
.offset = offsetof(struct rpki_config, server.backlog),
.min = 1,
.max = SOMAXCONN,
}, {
- .id = 5004,
+ .id = 5003,
.name = "server.validation-interval",
.type = >_uint,
.offset = offsetof(struct rpki_config,
* duplicates.
*/
- rpki_config.server.disabled = false;
rpki_config.server.address = NULL;
rpki_config.server.port = strdup("323");
if (rpki_config.server.port == NULL)
rpki_config.sync_strategy = SYNC_ROOT;
rpki_config.shuffle_tal_uris = false;
rpki_config.maximum_certificate_depth = 32;
+ rpki_config.mode = SERVER;
rpki_config.rsync.program = strdup("rsync");
if (rpki_config.rsync.program == NULL) {
recursive_rsync_args, ARRAY_LEN(recursive_rsync_args));
if (error)
goto revert_rsync_program;
- /* Simply remove --recursive and --delete. */
+
error = string_array_init(&rpki_config.rsync.args.flat,
flat_rsync_args, ARRAY_LEN(flat_rsync_args));
if (error)
return options;
}
-bool
-config_get_server_disabled(void)
+enum mode
+config_get_mode(void)
{
- return rpki_config.server.disabled;
+ return rpki_config.mode;
}
char const *
#include <stdint.h>
#include "config/filename_format.h"
+#include "config/mode.h"
#include "config/sync_strategy.h"
#include "config/string_array.h"
#include "config/types.h"
void free_rpki_config(void);
/* Getters */
-bool config_get_server_disabled(void);
char const *config_get_server_address(void);
char const *config_get_server_port(void);
int config_get_server_queue(void);
enum sync_strategy config_get_sync_strategy(void);
bool config_get_shuffle_tal_uris(void);
unsigned int config_get_max_cert_depth(void);
+enum mode config_get_mode(void);
bool config_get_color_output(void);
enum filename_format config_get_filename_format(void);
char *config_get_rsync_program(void);
--- /dev/null
+#include "config/mode.h"
+
+#include <getopt.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "log.h"
+#include "config/str.h"
+
+#define VALUE_SERVER "server"
+#define VALUE_STANDALONE "standalone"
+
+#define DEREFERENCE(void_value) (*((enum mode *) void_value))
+
+static void
+print_mode(struct option_field const *field, void *value)
+{
+ char const *str = "<unknown>";
+
+ switch (DEREFERENCE(value)) {
+ case SERVER:
+ str = VALUE_SERVER;
+ break;
+ case STANDALONE:
+ str = VALUE_STANDALONE;
+ break;
+ }
+
+ pr_info("%s: %s", field->name, str);
+}
+
+static int
+parse_argv_mode(struct option_field const *field, char const *str,
+ void *result)
+{
+ if (strcmp(str, VALUE_SERVER) == 0)
+ DEREFERENCE(result) = SERVER;
+ else if (strcmp(str, VALUE_STANDALONE) == 0)
+ DEREFERENCE(result) = STANDALONE;
+ else
+ return pr_err("Unknown mode: '%s'", str);
+
+ return 0;
+}
+
+static int
+parse_json_mode(struct option_field const *opt, struct json_t *json,
+ void *result)
+{
+ char const *string;
+ int error;
+
+ error = parse_json_string(json, opt->name, &string);
+ return error ? error : parse_argv_mode(opt, string, result);
+}
+
+const struct global_type gt_mode = {
+ .has_arg = required_argument,
+ .size = sizeof(enum mode),
+ .print = print_mode,
+ .parse.argv = parse_argv_mode,
+ .parse.json = parse_json_mode,
+ .arg_doc = VALUE_SERVER "|" VALUE_STANDALONE,
+};
--- /dev/null
+#ifndef SRC_CONFIG_MODE_H_
+#define SRC_CONFIG_MODE_H_
+
+#include "config/types.h"
+
+/**
+ * FORT Run mode
+ */
+enum mode {
+ /**
+ * Run as an RTR server
+ */
+ SERVER,
+ /*
+ * Run standalone validation (run validation once and exit)
+ */
+ STANDALONE,
+};
+
+extern const struct global_type gt_mode;
+
+#endif /* SRC_CONFIG_MODE_H_ */
/*
* Starts the server, using the current thread to listen for RTR client
- * requests. If configuration parameter 'server.disabled' is true, then the
+ * requests. If configuration parameter 'mode' is STANDALONE, then the
* server runs "one time" (a.k.a. run the validation just once), it doesn't
* waits for clients requests.
*
if (error)
return error;
- if (config_get_server_disabled()) {
+ if (config_get_mode() == STANDALONE) {
error = vrps_update(&changed);
if (error)
pr_err("Error %d while trying to update the ROA database.",
return NULL;
}
-bool
-config_get_server_disabled(void)
+enum mode
+config_get_mode(void)
{
- return true;
+ return STANDALONE;
}
char const *