forked from Telodendria/Telodendria
[MOD] Make tls optional
This commit is contained in:
parent
a089224630
commit
1d93b1c22c
3 changed files with 10 additions and 9 deletions
|
@ -6,8 +6,8 @@
|
||||||
"types": {
|
"types": {
|
||||||
"ConfigTls": {
|
"ConfigTls": {
|
||||||
"fields": {
|
"fields": {
|
||||||
"cert": { "type": "string" },
|
"cert": { "type": "string", "required": true },
|
||||||
"key": { "type": "string" }
|
"key": { "type": "string", "required": true }
|
||||||
},
|
},
|
||||||
"type": "struct"
|
"type": "struct"
|
||||||
},
|
},
|
||||||
|
|
|
@ -19,8 +19,7 @@ key-value form:
|
||||||
"serverName": "telodendria.io",
|
"serverName": "telodendria.io",
|
||||||
"listen": [
|
"listen": [
|
||||||
{
|
{
|
||||||
"port": 8008,
|
"port": 8008
|
||||||
"tls": false
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -51,7 +50,7 @@ Here are the top-level directives:
|
||||||
this is a concern, a reverse-proxy such as `relayd` can be placed
|
this is a concern, a reverse-proxy such as `relayd` can be placed
|
||||||
in front of Telodendria to block access to undesired APIs.
|
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
|
Telodendria can be compiled with TLS support. If it is, then a
|
||||||
particular listener can be set to use TLS for connections. If
|
particular listener can be set to use TLS for connections. If
|
||||||
|
|
10
src/Config.c
10
src/Config.c
|
@ -120,6 +120,7 @@ ConfigCreateDefault(Db * db)
|
||||||
ConfigListener *listener;
|
ConfigListener *listener;
|
||||||
|
|
||||||
HashMap *json;
|
HashMap *json;
|
||||||
|
JsonValue *val;
|
||||||
|
|
||||||
DbRef *ref;
|
DbRef *ref;
|
||||||
|
|
||||||
|
@ -147,16 +148,17 @@ ConfigCreateDefault(Db * db)
|
||||||
/* Add simple listener without TLS. */
|
/* Add simple listener without TLS. */
|
||||||
config.listen = ArrayCreate();
|
config.listen = ArrayCreate();
|
||||||
listener = Malloc(sizeof(ConfigListener));
|
listener = Malloc(sizeof(ConfigListener));
|
||||||
listener->maxConnections = Int64Create(0, 0);
|
listener->maxConnections = Int64Create(0, 32);
|
||||||
listener->port = Int64Create(0, 8008);
|
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);
|
ArrayAdd(config.listen, listener);
|
||||||
|
|
||||||
/* Write it all out to the configuration file. */
|
/* Write it all out to the configuration file. */
|
||||||
json = ConfigToJson(&config);
|
json = ConfigToJson(&config);
|
||||||
|
val = JsonGet(json, 1, "listen");
|
||||||
|
val = ArrayGet(JsonValueAsArray(val), 0);
|
||||||
|
JsonValueFree(HashMapDelete(JsonValueAsObject(val), "tls"));
|
||||||
|
|
||||||
ref = DbCreate(db, 1, "config");
|
ref = DbCreate(db, 1, "config");
|
||||||
if (!ref)
|
if (!ref)
|
||||||
|
|
Loading…
Reference in a new issue