[MOD] Make tls optional

This commit is contained in:
lda 2024-01-05 13:00:50 +01:00
parent a089224630
commit 1d93b1c22c
Signed by: lda
GPG key ID: 6898757653ABE3E6
3 changed files with 10 additions and 9 deletions

View file

@ -6,8 +6,8 @@
"types": {
"ConfigTls": {
"fields": {
"cert": { "type": "string" },
"key": { "type": "string" }
"cert": { "type": "string", "required": true },
"key": { "type": "string", "required": true }
},
"type": "struct"
},

View file

@ -19,8 +19,7 @@ key-value form:
"serverName": "telodendria.io",
"listen": [
{
"port": 8008,
"tls": false
"port": 8008
}
]
@ -51,7 +50,7 @@ Here are the top-level directives:
this is a concern, a reverse-proxy such as `relayd` can be placed
in front of Telodendria to block access to undesired APIs.
- **tls:** `Object|null|false`
- **tls:** `Object`
Telodendria can be compiled with TLS support. If it is, then a
particular listener can be set to use TLS for connections. If

View file

@ -120,6 +120,7 @@ ConfigCreateDefault(Db * db)
ConfigListener *listener;
HashMap *json;
JsonValue *val;
DbRef *ref;
@ -147,16 +148,17 @@ ConfigCreateDefault(Db * db)
/* Add simple listener without TLS. */
config.listen = ArrayCreate();
listener = Malloc(sizeof(ConfigListener));
listener->maxConnections = Int64Create(0, 0);
listener->maxConnections = Int64Create(0, 32);
listener->port = Int64Create(0, 8008);
listener->threads = Int64Create(0, 0);
listener->threads = Int64Create(0, 4);
listener->tls.key = NULL;
listener->tls.cert = NULL;
ArrayAdd(config.listen, listener);
/* Write it all out to the configuration file. */
json = ConfigToJson(&config);
val = JsonGet(json, 1, "listen");
val = ArrayGet(JsonValueAsArray(val), 0);
JsonValueFree(HashMapDelete(JsonValueAsObject(val), "tls"));
ref = DbCreate(db, 1, "config");
if (!ref)