diff options
-rw-r--r-- | cfg/ogserver.json | 2 | ||||
-rw-r--r-- | src/cfg.c | 4 | ||||
-rw-r--r-- | src/cfg.h | 1 | ||||
-rw-r--r-- | src/dbi.c | 1 | ||||
-rw-r--r-- | src/dbi.h | 1 | ||||
-rw-r--r-- | src/ogAdmServer.c | 5 | ||||
-rw-r--r-- | src/ogAdmServer.h | 1 |
7 files changed, 15 insertions, 0 deletions
diff --git a/cfg/ogserver.json b/cfg/ogserver.json index 009d436..20ae5ac 100644 --- a/cfg/ogserver.json +++ b/cfg/ogserver.json @@ -5,6 +5,8 @@ "api_token": "5a5ca1172136299640a9f47469237e0a" }, "database" : { + "ip": "127.0.0.1", + "port": 3306, "name" : "opengnsys", "user" : "mysql", "pass" : "mysql" @@ -57,6 +57,9 @@ static int parse_json_db(struct og_server_cfg *cfg, json_t *element) } else if (!strcmp(key, "name")) { if (og_json_parse_string(value, &cfg->db.name) < 0) return -1; + } else if (!strcmp(key, "port")) { + if (og_json_parse_uint(value, &cfg->db.port) < 0) + return -1; } else { syslog(LOG_ERR, "unknown key `%s' in db\n", key); return -1; @@ -162,4 +165,5 @@ void from_json_to_legacy(struct og_server_cfg *cfg) snprintf(catalog, sizeof(catalog), cfg->db.name); snprintf(interface, sizeof(interface), cfg->wol.interface); snprintf(auth_token, sizeof(auth_token), cfg->rest.api_token); + snprintf(db_port, sizeof(db_port), "%u", cfg->db.port); } @@ -6,6 +6,7 @@ struct og_server_cfg { const char *user; const char *pass; const char *ip; + unsigned int port; const char *name; } db; struct { @@ -24,6 +24,7 @@ struct og_dbi *og_dbi_open(struct og_dbi_config *config) } dbi_conn_set_option(dbi->conn, "host", config->host); + dbi_conn_set_option(dbi->conn, "port", config->port); dbi_conn_set_option(dbi->conn, "username", config->user); dbi_conn_set_option(dbi->conn, "password", config->passwd); dbi_conn_set_option(dbi->conn, "dbname", config->database); @@ -7,6 +7,7 @@ struct og_dbi_config { const char *user; const char *passwd; const char *host; + const char *port; const char *database; }; diff --git a/src/ogAdmServer.c b/src/ogAdmServer.c index f8a50ae..3ba5b30 100644 --- a/src/ogAdmServer.c +++ b/src/ogAdmServer.c @@ -31,6 +31,7 @@ char interface[4096]; // Interface name char auth_token[4096]; // API token char servidoradm[4096]; // Dirección IP del servidor de administración char puerto[4096]; // Puerto de comunicación +char db_port[4096]; SOCKETCL tbsockets[MAXIMOS_CLIENTES]; @@ -38,6 +39,7 @@ struct og_dbi_config dbi_config = { .user = usuario, .passwd = pasguor, .host = datasource, + .port = db_port, .database = catalog, }; @@ -101,6 +103,9 @@ bool tomaConfiguracion(const char *filecfg) line = fgets(buf, sizeof(buf), fcfg); } + /* Default value to preserve legacy config file support */ + snprintf(db_port, sizeof(db_port), "3306"); + fclose(fcfg); if (!servidoradm[0]) { diff --git a/src/ogAdmServer.h b/src/ogAdmServer.h index 7e5fcd3..f51b7be 100644 --- a/src/ogAdmServer.h +++ b/src/ogAdmServer.h @@ -29,6 +29,7 @@ extern char interface[4096]; extern char api_token[4096]; extern char servidoradm[4096]; extern char puerto[4096]; +extern char db_port[4096]; struct og_client; |