diff --git a/library/config.c b/library/config.c index c66ad019..f1dca5e7 100644 --- a/library/config.c +++ b/library/config.c @@ -50,12 +50,25 @@ int ziti_load_config(ziti_config *cfg, const char* cfgstr) { if (!cfgstr) { return ZITI_INVALID_CONFIG; } + bool seems_like_json = false; + const char* c = cfgstr; + while (*cfgstr && isspace((unsigned char)*cfgstr)) { + c++; + } + if (strncmp(c,"{",1) == 0) { + seems_like_json = true; + } memset(cfg, 0, sizeof(*cfg)); - int rc = parse_ziti_config(cfg, cfgstr, strlen(cfgstr)); + int rc; + if(seems_like_json) { + rc = parse_ziti_config(cfg, cfgstr, strlen(cfgstr)); - if (rc < 0) { - ZITI_LOG(DEBUG, "trying to load config from file[%s]", cfgstr); + if (rc < 0) { + ZITI_LOG(DEBUG, "trying to load config from file[%s]", cfgstr); + rc = load_config_file(cfgstr, cfg); + } + } else { rc = load_config_file(cfgstr, cfg); }