__type__ *findtmp, *tmp = (__type__ *) config->tmp; \
int got_errno = 0
+/* allocate the tmp field for fetching data */
+#define SILC_SERVER_CONFIG_ALLOCTMP(__type__) \
+ if (!tmp) { \
+ config->tmp = silc_calloc(1, sizeof(*findtmp)); \
+ tmp = (__type__ *) config->tmp; \
+ }
+
/* append the tmp field to the specified list */
#define SILC_SERVER_CONFIG_LIST_APPENDTMP(__list__) \
if (!__list__) { \
(params->p ? params->p : (defaults && defaults->p ? defaults->p : d))
SET_PARAM_DEFAULT(connections_max, SILC_SERVER_MAX_CONNECTIONS);
- SET_PARAM_DEFAULT(connections_max_per_host,
+ SET_PARAM_DEFAULT(connections_max_per_host,
SILC_SERVER_MAX_CONNECTIONS_SINGLE);
SET_PARAM_DEFAULT(keepalive_secs, SILC_SERVER_KEEPALIVE);
SET_PARAM_DEFAULT(reconnect_count, SILC_SERVER_RETRY_COUNT);
/* Find connection parameters by the parameter block name. */
static SilcServerConfigConnParams *
-my_find_param(SilcServerConfig config, const char *name, SilcUInt32 line)
+my_find_param(SilcServerConfig config, const char *name)
{
SilcServerConfigConnParams *param;
return param;
}
- SILC_SERVER_LOG_ERROR(("\nError while parsing config file at line %lu: "
- "Cannot find Param \"%s\".\n", line, name));
+ SILC_SERVER_LOG_ERROR(("Error while parsing config file: "
+ "Cannot find Params \"%s\".\n", name));
return NULL;
}
/* parse an authdata according to its auth method */
-static bool my_parse_authdata(SilcAuthMethod auth_meth, char *p,
- SilcUInt32 line, void **auth_data,
+static bool my_parse_authdata(SilcAuthMethod auth_meth, char *p,
+ SilcUInt32 line, void **auth_data,
SilcUInt32 *auth_data_len)
{
if (auth_meth == SILC_AUTH_PASSWORD) {
/* p is a plain text password */
- if (auth_data)
- *auth_data = (void *) strdup(p);
- if (auth_data_len)
- *auth_data_len = (SilcUInt32) strlen(p);
+ if (auth_data && auth_data_len) {
+ if (!silc_utf8_valid(p, strlen(p))) {
+ *auth_data_len = silc_utf8_encoded_len(p, strlen(p), 0);
+ *auth_data = silc_calloc(*auth_data_len, sizeof(unsigned char));
+ silc_utf8_encode(p, strlen(p), SILC_STRING_ASCII, *auth_data,
+ *auth_data_len);
+ } else {
+ *auth_data = (void *) strdup(p);
+ *auth_data_len = (SilcUInt32) strlen(p);
+ }
+ }
} else if (auth_meth == SILC_AUTH_PUBLIC_KEY) {
/* p is a public key file name */
SilcPublicKey public_key;
if (!silc_pkcs_load_public_key(p, &public_key, SILC_PKCS_FILE_PEM))
if (!silc_pkcs_load_public_key(p, &public_key, SILC_PKCS_FILE_BIN)) {
- SILC_SERVER_LOG_ERROR(("\nError while parsing config file at line %lu: "
- "Could not load public key file!\n", line));
+ SILC_SERVER_LOG_ERROR(("\nError while parsing config file at line "
+ "%lu: Could not load public key file!\n",
+ line));
return FALSE;
}
}
else if (!strcmp(name, "version_protocol")) {
CONFIG_IS_DOUBLE(config->param.version_protocol);
- config->param.version_protocol =
+ config->param.version_protocol =
(*(char *)val ? strdup((char *) val) : NULL);
}
else if (!strcmp(name, "version_software")) {
CONFIG_IS_DOUBLE(config->param.version_software);
- config->param.version_software =
+ config->param.version_software =
(*(char *)val ? strdup((char *) val) : NULL);
}
else if (!strcmp(name, "version_software_vendor")) {
CONFIG_IS_DOUBLE(config->param.version_software_vendor);;
- config->param.version_software_vendor =
+ config->param.version_software_vendor =
(*(char *)val ? strdup((char *) val) : NULL);
}
+ else if (!strcmp(name, "detach_disabled")) {
+ config->detach_disabled = *(bool *)val;
+ }
+ else if (!strcmp(name, "detach_timeout")) {
+ config->detach_timeout = (SilcUInt32) *(int *)val;
+ }
else
return SILC_CONFIG_EINTERNAL;
type, name, context));
if (type == SILC_CONFIG_ARG_BLOCK) {
/* check the temporary struct's fields */
- if (!tmp) /* empty sub-block? */
+ if (!tmp) /* discard empty sub-blocks */
return SILC_CONFIG_OK;
if (!tmp->name) {
got_errno = SILC_CONFIG_EMISSFIELDS;
goto got_err;
}
- /* the temporary struct is ok, append it to the list */
+
SILC_SERVER_CONFIG_LIST_APPENDTMP(config->cipher);
config->tmp = NULL;
return SILC_CONFIG_OK;
}
- /* if there isn't a temporary struct alloc one */
- if (!tmp) {
- config->tmp = silc_calloc(1, sizeof(*findtmp));
- tmp = (SilcServerConfigCipher *) config->tmp;
- }
+ SILC_SERVER_CONFIG_ALLOCTMP(SilcServerConfigCipher);
/* Identify and save this value */
if (!strcmp(name, "name")) {
type, name, context));
if (type == SILC_CONFIG_ARG_BLOCK) {
/* check the temporary struct's fields */
- if (!tmp) /* empty sub-block? */
+ if (!tmp) /* discard empty sub-blocks */
return SILC_CONFIG_OK;
if (!tmp->name || (tmp->block_length == 0) || (tmp->digest_length == 0)) {
got_errno = SILC_CONFIG_EMISSFIELDS;
goto got_err;
}
- /* the temporary struct in tmp is ok */
+
SILC_SERVER_CONFIG_LIST_APPENDTMP(config->hash);
config->tmp = NULL;
return SILC_CONFIG_OK;
}
-
- /* if there isn't a temporary struct alloc one */
- if (!tmp) {
- config->tmp = silc_calloc(1, sizeof(*findtmp));
- tmp = (SilcServerConfigHash *) config->tmp;
- }
+ SILC_SERVER_CONFIG_ALLOCTMP(SilcServerConfigHash);
/* Identify and save this value */
if (!strcmp(name, "name")) {
type, name, context));
if (type == SILC_CONFIG_ARG_BLOCK) {
/* check the temporary struct's fields */
- if (!tmp) /* empty sub-block? */
+ if (!tmp) /* discard empty sub-blocks */
return SILC_CONFIG_OK;
if (!tmp->name || !tmp->hash || (tmp->mac_length == 0)) {
got_errno = SILC_CONFIG_EMISSFIELDS;
goto got_err;
}
- /* the temporary struct is ok, append it to the list */
+
SILC_SERVER_CONFIG_LIST_APPENDTMP(config->hmac);
config->tmp = NULL;
return SILC_CONFIG_OK;
}
- /* if there isn't a temporary struct alloc one */
- if (!tmp) {
- config->tmp = silc_calloc(1, sizeof(*findtmp));
- tmp = (SilcServerConfigHmac *) config->tmp;
- }
+ SILC_SERVER_CONFIG_ALLOCTMP(SilcServerConfigHmac);
/* Identify and save this value */
if (!strcmp(name, "name")) {
type, name, context));
if (type == SILC_CONFIG_ARG_BLOCK) {
/* check the temporary struct's fields */
- if (!tmp) /* empty sub-block? */
+ if (!tmp) /* discard empty sub-blocks */
return SILC_CONFIG_OK;
if (!tmp->name) {
got_errno = SILC_CONFIG_EMISSFIELDS;
goto got_err;
}
- /* the temporary struct is ok, append it to the list */
+
SILC_SERVER_CONFIG_LIST_APPENDTMP(config->pkcs);
config->tmp = NULL;
return SILC_CONFIG_OK;
}
- /* if there isn't a temporary struct alloc one */
- if (!tmp) {
- config->tmp = silc_calloc(1, sizeof(*findtmp));
- tmp = (SilcServerConfigPkcs *) config->tmp;
- }
+ SILC_SERVER_CONFIG_ALLOCTMP(SilcServerConfigPkcs);
/* Identify and save this value */
if (!strcmp(name, "name")) {
SILC_CONFIG_CALLBACK(fetch_serverinfo)
{
- SilcServerConfig config = (SilcServerConfig) context;
+ SILC_SERVER_CONFIG_SECTION_INIT(SilcServerConfigServerInfoInterface);
SilcServerConfigServerInfo *server_info = config->server_info;
- int got_errno = 0;
/* if there isn't the struct alloc it */
if (!server_info)
silc_calloc(1, sizeof(*server_info));
if (type == SILC_CONFIG_ARG_BLOCK) {
- /* check for mandatory inputs */
- if (!server_info->public_key || !server_info->private_key) {
+ if (!strcmp(name, "primary")) {
+ CONFIG_IS_DOUBLE(server_info->primary);
+ if (!tmp)
+ return SILC_CONFIG_OK;
+ server_info->primary = tmp;
+ config->tmp = NULL;
+ return SILC_CONFIG_OK;
+ } else if (!strcmp(name, "secondary")) {
+ if (!tmp)
+ return SILC_CONFIG_OK;
+ SILC_SERVER_CONFIG_LIST_APPENDTMP(server_info->secondary);
+ config->tmp = NULL;
+ return SILC_CONFIG_OK;
+ } else if (!server_info->public_key || !server_info->private_key) {
got_errno = SILC_CONFIG_EMISSFIELDS;
goto got_err;
}
server_info->server_name = strdup((char *) val);
}
else if (!strcmp(name, "ip")) {
- CONFIG_IS_DOUBLE(server_info->server_ip);
- server_info->server_ip = strdup((char *) val);
+ SILC_SERVER_CONFIG_ALLOCTMP(SilcServerConfigServerInfoInterface);
+ CONFIG_IS_DOUBLE(tmp->server_ip);
+ tmp->server_ip = strdup((char *) val);
}
else if (!strcmp(name, "port")) {
int port = *(int *)val;
+ SILC_SERVER_CONFIG_ALLOCTMP(SilcServerConfigServerInfoInterface);
if ((port <= 0) || (port > 65535)) {
- SILC_SERVER_LOG_ERROR(("Error: line %lu: Invalid port number!\n", line));
- return SILC_CONFIG_ESILENT;
+ SILC_SERVER_LOG_ERROR(("Error while parsing config file: "
+ "Invalid port number!\n"));
+ got_errno = SILC_CONFIG_EPRINTLINE;
+ goto got_err;
}
- server_info->port = (SilcUInt16) port;
+ tmp->port = (SilcUInt16) port;
}
else if (!strcmp(name, "servertype")) {
CONFIG_IS_DOUBLE(server_info->server_type);
if (!silc_pkcs_load_public_key(file_tmp, &server_info->public_key,
SILC_PKCS_FILE_BIN)) {
SILC_SERVER_LOG_ERROR(("Error: Could not load public key file.\n"));
- SILC_SERVER_LOG_ERROR((" line %lu: file \"%s\"\n", line, file_tmp));
+ SILC_SERVER_LOG_ERROR((" line %lu, file \"%s\"\n", line, file_tmp));
return SILC_CONFIG_ESILENT;
}
}
if (!silc_pkcs_load_private_key(file_tmp, &server_info->private_key,
SILC_PKCS_FILE_PEM)) {
SILC_SERVER_LOG_ERROR(("Error: Could not load private key file.\n"));
- SILC_SERVER_LOG_ERROR((" line %lu: file \"%s\"\n", line, file_tmp));
+ SILC_SERVER_LOG_ERROR((" line %lu, file \"%s\"\n", line, file_tmp));
return SILC_CONFIG_ESILENT;
}
}
return SILC_CONFIG_OK;
got_err:
+ silc_free(tmp);
+ silc_free(config->tmp);
+ config->tmp = NULL;
return got_errno;
}
SILC_CONFIG_CALLBACK(fetch_logging)
{
- SilcServerConfig config = (SilcServerConfig) context;
- SilcServerConfigLogging *tmp =
- (SilcServerConfigLogging *) config->tmp;
- int got_errno;
+ SILC_SERVER_CONFIG_SECTION_INIT(SilcServerConfigLogging);
if (!strcmp(name, "quicklogs")) {
config->logging_quick = *(bool *)val;
else if (!strcmp(name, "flushdelay")) {
int flushdelay = *(int *)val;
if (flushdelay < 2) { /* this value was taken from silclog.h (min delay) */
- SILC_SERVER_LOG_ERROR(("Error: line %lu: Invalid flushdelay value, use "
- "quicklogs if you want real-time logging.\n", line));
- return SILC_CONFIG_ESILENT;
+ SILC_SERVER_LOG_ERROR(("Error while parsing config file: "
+ "Invalid flushdelay value, use quicklogs if you "
+ "want real-time logging.\n"));
+ return SILC_CONFIG_EPRINTLINE;
}
config->logging_flushdelay = (long) flushdelay;
}
+
+ /* The following istances happens only in Logging's sub-blocks, a match
+ for the sub-block name means that you should store the filename/maxsize
+ temporary struct to the proper logging channel.
+ If we get a match for "file" or "maxsize" this means that we are inside
+ a sub-sub-block and it is safe to alloc a new tmp. */
#define FETCH_LOGGING_CHAN(__chan__, __member__) \
else if (!strcmp(name, __chan__)) { \
if (!tmp) return SILC_CONFIG_OK; \
FETCH_LOGGING_CHAN("fatals", logging_fatals)
#undef FETCH_LOGGING_CHAN
else if (!strcmp(name, "file")) {
- if (!tmp) { /* FIXME: what the fuck is this? */
- config->tmp = silc_calloc(1, sizeof(*tmp));
- tmp = (SilcServerConfigLogging *) config->tmp;
- }
- if (tmp->file) {
- got_errno = SILC_CONFIG_EMISSFIELDS; goto got_err;
- }
+ SILC_SERVER_CONFIG_ALLOCTMP(SilcServerConfigLogging);
+ CONFIG_IS_DOUBLE(tmp->file);
tmp->file = strdup((char *) val);
}
else if (!strcmp(name, "size")) {
{
SILC_SERVER_CONFIG_SECTION_INIT(SilcServerConfigConnParams);
- SERVER_CONFIG_DEBUG(("Received CONNPARAM type=%d name=\"%s\" (val=%x)",
+ SERVER_CONFIG_DEBUG(("Received CONNPARAM type=%d name=\"%s\" (val=%x)",
type, name, context));
-
if (type == SILC_CONFIG_ARG_BLOCK) {
- if (!tmp)
+ /* check the temporary struct's fields */
+ if (!tmp) /* discard empty sub-blocks */
return SILC_CONFIG_OK;
-
if (!tmp->name) {
got_errno = SILC_CONFIG_EMISSFIELDS;
goto got_err;
}
-
/* Set defaults */
my_set_param_defaults(tmp, &config->param);
config->tmp = NULL;
return SILC_CONFIG_OK;
}
-
- /* if there isn't a temporary struct alloc one */
- if (!tmp) {
- config->tmp = silc_calloc(1, sizeof(*findtmp));
- tmp = (SilcServerConfigConnParams *) config->tmp;
- }
+ SILC_SERVER_CONFIG_ALLOCTMP(SilcServerConfigConnParams);
if (!strcmp(name, "name")) {
CONFIG_IS_DOUBLE(tmp->name);
}
else if (!strcmp(name, "version_software_vendor")) {
CONFIG_IS_DOUBLE(tmp->version_software_vendor);;
- tmp->version_software_vendor =
+ tmp->version_software_vendor =
(*(char *)val ? strdup((char *) val) : NULL);
}
else
SERVER_CONFIG_DEBUG(("Received CLIENT type=%d name=\"%s\" (val=%x)",
type, name, context));
- /* alloc tmp before block checking (empty sub-blocks are welcome here) */
- if (!tmp) {
- config->tmp = silc_calloc(1, sizeof(*findtmp));
- tmp = (SilcServerConfigClient *) config->tmp;
- }
+ /* Alloc before block checking, because empty sub-blocks are welcome here */
+ SILC_SERVER_CONFIG_ALLOCTMP(SilcServerConfigClient);
if (type == SILC_CONFIG_ARG_BLOCK) {
- /* closing the block */
+ /* empty sub-blocks are welcome */
SILC_SERVER_CONFIG_LIST_APPENDTMP(config->clients);
config->tmp = NULL;
return SILC_CONFIG_OK;
}
else if (!strcmp(name, "params")) {
CONFIG_IS_DOUBLE(tmp->param);
- tmp->param = my_find_param(config, (char *) val, line);
- if (!tmp->param) { /* error already output */
- got_errno = SILC_CONFIG_ESILENT;
+ tmp->param = my_find_param(config, (char *) val);
+ if (!tmp->param) { /* error message already output */
+ got_errno = SILC_CONFIG_EPRINTLINE;
goto got_err;
}
}
SERVER_CONFIG_DEBUG(("Received CLIENT type=%d name=\"%s\" (val=%x)",
type, name, context));
-
if (type == SILC_CONFIG_ARG_BLOCK) {
/* check the temporary struct's fields */
- if (!tmp) /* empty sub-block? */
+ if (!tmp) /* discard empty sub-blocks */
return SILC_CONFIG_OK;
SILC_SERVER_CONFIG_LIST_APPENDTMP(config->admins);
config->tmp = NULL;
return SILC_CONFIG_OK;
}
-
- /* if there isn't a temporary struct alloc one */
- if (!tmp) {
- config->tmp = silc_calloc(1, sizeof(*findtmp));
- tmp = (SilcServerConfigAdmin *) config->tmp;
- }
+ SILC_SERVER_CONFIG_ALLOCTMP(SilcServerConfigAdmin);
/* Identify and save this value */
if (!strcmp(name, "host")) {
type, name, context));
if (type == SILC_CONFIG_ARG_BLOCK) {
/* check the temporary struct's fields */
- if (!tmp) /* empty sub-block? */
+ if (!tmp) /* discard empty sub-blocks */
return SILC_CONFIG_OK;
if (!tmp->reason) {
got_errno = SILC_CONFIG_EMISSFIELDS;
goto got_err;
}
+
SILC_SERVER_CONFIG_LIST_APPENDTMP(config->denied);
config->tmp = NULL;
return SILC_CONFIG_OK;
}
- /* if there isn't a temporary struct alloc one */
- if (!tmp) {
- config->tmp = silc_calloc(1, sizeof(*findtmp));
- tmp = (SilcServerConfigDeny *) config->tmp;
- }
+ SILC_SERVER_CONFIG_ALLOCTMP(SilcServerConfigDeny);
/* Identify and save this value */
if (!strcmp(name, "host")) {
SERVER_CONFIG_DEBUG(("Received SERVER type=%d name=\"%s\" (val=%x)",
type, name, context));
-
if (type == SILC_CONFIG_ARG_BLOCK) {
/* check the temporary struct's fields */
- if (!tmp) /* empty sub-block? */
+ if (!tmp) /* discard empty sub-blocks */
return SILC_CONFIG_OK;
/* the temporary struct is ok, append it to the list */
config->tmp = NULL;
return SILC_CONFIG_OK;
}
-
- /* if there isn't a temporary struct alloc one */
- if (!tmp) {
- config->tmp = silc_calloc(1, sizeof(*findtmp));
- tmp = (SilcServerConfigServer *) config->tmp;
- }
+ SILC_SERVER_CONFIG_ALLOCTMP(SilcServerConfigServer);
/* Identify and save this value */
if (!strcmp(name, "host")) {
}
else if (!strcmp(name, "params")) {
CONFIG_IS_DOUBLE(tmp->param);
- tmp->param = my_find_param(config, (char *) val, line);
- if (!tmp->param) { /* error already output */
- got_errno = SILC_CONFIG_ESILENT;
+ tmp->param = my_find_param(config, (char *) val);
+ if (!tmp->param) { /* error message already output */
+ got_errno = SILC_CONFIG_EPRINTLINE;
goto got_err;
}
}
SERVER_CONFIG_DEBUG(("Received ROUTER type=%d name=\"%s\" (val=%x)",
type, name, context));
-
if (type == SILC_CONFIG_ARG_BLOCK) {
- if (!tmp) /* empty sub-block? */
+ if (!tmp) /* discard empty sub-blocks */
return SILC_CONFIG_OK;
- /* the temporary struct is ok, append it to the list */
SILC_SERVER_CONFIG_LIST_APPENDTMP(config->routers);
config->tmp = NULL;
return SILC_CONFIG_OK;
}
-
- /* if there isn't a temporary struct alloc one */
- if (!tmp) {
- config->tmp = silc_calloc(1, sizeof(*findtmp));
- tmp = (SilcServerConfigRouter *) config->tmp;
- }
+ SILC_SERVER_CONFIG_ALLOCTMP(SilcServerConfigRouter);
/* Identify and save this value */
if (!strcmp(name, "host")) {
else if (!strcmp(name, "port")) {
int port = *(int *)val;
if ((port <= 0) || (port > 65535)) {
- SILC_SERVER_LOG_ERROR(("Error: line %lu: Invalid port number!\n", line));
- return SILC_CONFIG_ESILENT;
+ SILC_SERVER_LOG_ERROR(("Error while parsing config file: "
+ "Invalid port number!\n"));
+ got_errno = SILC_CONFIG_EPRINTLINE;
+ goto got_err;
}
tmp->port = (SilcUInt16) port;
}
}
else if (!strcmp(name, "params")) {
CONFIG_IS_DOUBLE(tmp->param);
- tmp->param = my_find_param(config, (char *) val, line);
- if (!tmp->param) { /* error already output */
- got_errno = SILC_CONFIG_ESILENT;
+ tmp->param = my_find_param(config, (char *) val);
+ if (!tmp->param) { /* error message already output */
+ got_errno = SILC_CONFIG_EPRINTLINE;
goto got_err;
}
}
CONFIG_IS_DOUBLE(tmp->backup_replace_ip);
tmp->backup_replace_ip = (*(char *)val ? strdup((char *) val) :
strdup("*"));
+ tmp->backup_router = TRUE;
}
else if (!strcmp(name, "backupport")) {
int port = *(int *)val;
if ((port <= 0) || (port > 65535)) {
- SILC_SERVER_LOG_ERROR(("Error: line %lu: Invalid port number!\n", line));
- return SILC_CONFIG_ESILENT;
+ SILC_SERVER_LOG_ERROR(("Error while parsing config file: "
+ "Invalid port number!\n"));
+ got_errno = SILC_CONFIG_EPRINTLINE;
+ goto got_err;
}
tmp->backup_replace_port = (SilcUInt16) port;
}
{ "channel_rekey_secs", SILC_CONFIG_ARG_INT, fetch_generic, NULL },
{ "key_exchange_timeout", SILC_CONFIG_ARG_INT, fetch_generic, NULL },
{ "conn_auth_timeout", SILC_CONFIG_ARG_INT, fetch_generic, NULL },
- { "version_protocol", SILC_CONFIG_ARG_STR, fetch_generic, NULL },
- { "version_software", SILC_CONFIG_ARG_STR, fetch_generic, NULL },
- { "version_software_vendor", SILC_CONFIG_ARG_STR, fetch_generic, NULL },
+ { "version_protocol", SILC_CONFIG_ARG_STR, fetch_generic, NULL },
+ { "version_software", SILC_CONFIG_ARG_STR, fetch_generic, NULL },
+ { "version_software_vendor", SILC_CONFIG_ARG_STR, fetch_generic, NULL },
+ { "detach_disabled", SILC_CONFIG_ARG_TOGGLE, fetch_generic, NULL },
+ { "detach_timeout", SILC_CONFIG_ARG_INT, fetch_generic, NULL },
{ 0, 0, 0, 0 }
};
{ 0, 0, 0, 0 }
};
-static const SilcConfigTable table_serverinfo[] = {
- { "hostname", SILC_CONFIG_ARG_STR, fetch_serverinfo, NULL},
+static const SilcConfigTable table_serverinfo_c[] = {
{ "ip", SILC_CONFIG_ARG_STR, fetch_serverinfo, NULL},
{ "port", SILC_CONFIG_ARG_INT, fetch_serverinfo, NULL},
+ { 0, 0, 0, 0 }
+};
+
+static const SilcConfigTable table_serverinfo[] = {
+ { "hostname", SILC_CONFIG_ARG_STR, fetch_serverinfo, NULL},
+ { "primary", SILC_CONFIG_ARG_BLOCK, fetch_serverinfo, table_serverinfo_c},
+ { "secondary", SILC_CONFIG_ARG_BLOCK, fetch_serverinfo, table_serverinfo_c},
{ "servertype", SILC_CONFIG_ARG_STR, fetch_serverinfo, NULL},
{ "location", SILC_CONFIG_ARG_STR, fetch_serverinfo, NULL},
{ "admin", SILC_CONFIG_ARG_STR, fetch_serverinfo, NULL},
{ "key_exchange_pfs", SILC_CONFIG_ARG_TOGGLE, fetch_connparam, NULL },
{ "version_protocol", SILC_CONFIG_ARG_STR, fetch_connparam, NULL },
{ "version_software", SILC_CONFIG_ARG_STR, fetch_connparam, NULL },
- { "version_software_vendor", SILC_CONFIG_ARG_STR, fetch_connparam, NULL },
+ { "version_software_vendor", SILC_CONFIG_ARG_STR, fetch_connparam, NULL },
{ 0, 0, 0, 0 }
};
/* alloc a config object */
config_new = silc_calloc(1, sizeof(*config_new));
+ config_new->refcount = 1;
if (!config_new)
return NULL;
if (ret != SILC_CONFIG_ESILENT) {
char *linebuf, *filename = silc_config_get_filename(file);
SilcUInt32 line = silc_config_get_line(file);
- SILC_SERVER_LOG_ERROR(("Error while parsing config file: %s.\n",
- silc_config_strerror(ret)));
+ if (ret != SILC_CONFIG_EPRINTLINE)
+ SILC_SERVER_LOG_ERROR(("Error while parsing config file: %s.\n",
+ silc_config_strerror(ret)));
linebuf = silc_config_read_line(file, line);
- SILC_SERVER_LOG_ERROR((" file %s line %lu: %s\n", filename,
+ SILC_SERVER_LOG_ERROR((" file %s line %lu: %s\n\n", filename,
line, linebuf));
silc_free(linebuf);
}
/* Set default to configuration parameters */
silc_server_config_set_defaults(config_new);
- config_new->refcount = 1;
return config_new;
}
config->refcount++;
ref->config = config;
ref->ref_ptr = ref_ptr;
- SILC_LOG_DEBUG(("Referencing config [%p] refcnt %hu->%hu", config,
+ SILC_LOG_DEBUG(("Referencing config [%p] refcnt %d->%d", config,
config->refcount - 1, config->refcount));
}
}
void *tmp;
config->refcount--;
- SILC_LOG_DEBUG(("Unreferencing config [%p] refcnt %hu->%hu", config,
+ SILC_LOG_DEBUG(("Unreferencing config [%p] refcnt %d->%d", config,
config->refcount + 1, config->refcount));
if (config->refcount > 0)
return;
if (config->server_info) {
register SilcServerConfigServerInfo *si = config->server_info;
silc_free(si->server_name);
- silc_free(si->server_ip);
+ if (si->primary) {
+ silc_free(si->primary->server_ip);
+ silc_free(si->primary);
+ }
+ SILC_SERVER_CONFIG_LIST_DESTROY(SilcServerConfigServerInfoInterface,
+ si->secondary)
+ silc_free(di->server_ip);
+ silc_free(di);
+ }
silc_free(si->server_type);
silc_free(si->location);
silc_free(si->admin);
SILC_CIPHER_SIM_SET_KEY));
SILC_LOG_DEBUG(("set_key=%p", cipher_obj.set_key));
cipher_obj.set_key_with_string =
- silc_sim_getsym(sim,
+ silc_sim_getsym(sim,
silc_sim_symname(alg_name,
SILC_CIPHER_SIM_SET_KEY_WITH_STRING));
SILC_LOG_DEBUG(("set_key_with_string=%p",
SILC_LOG_DEBUG(("Setting configured log file names and options"));
silc_log_quick = config->logging_quick;
- silc_log_flushdelay = (config->logging_flushdelay ?
+ silc_log_flushdelay = (config->logging_flushdelay ?
config->logging_flushdelay :
SILC_SERVER_LOG_FLUSH_DELAY);
nickname. */
SilcServerConfigAdmin *
-silc_server_config_find_admin(SilcServer server, char *host, char *user,
+silc_server_config_find_admin(SilcServer server, char *host, char *user,
char *nick)
{
SilcServerConfig config = server->config;