diff --git a/README.md b/README.md index 7fbb786..b0dd629 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ make test - /acquire-jwt - this parameter (0 or 1) specifies whether there will be a dns lookup. If not, or if any problem occurs with the dns lookup, then webpa-url will be the target. -- /dns-id - this parameter is used along with the hw_mac parameter to create the dns txt record id +- /dns-txt-url - this parameter is used along with the hw_mac parameter to create the dns txt record id - /jwt-algo -Allowed algorithm used for communication @@ -75,17 +75,17 @@ make test ``` # Seshat & FEATURE_DNS_QUERY Enabled -./parodus --hw-model=TGXXX --hw-serial-number=E8GBUEXXXXXXXXX --hw-manufacturer=ARRIS --hw-mac=14cfexxxxxxx --hw-last-reboot-reason=unknown --fw-name=TG1682_DEV_master_20170512115046sdy --boot-time=1494590301 --webpa-ping-timeout=180 --webpa-interface-used=eth0 --webpa-url=fabric.webpa.comcast.net:8080 --webpa-backoff-max=9 --parodus-local-url=tcp://127.0.0.1:6666 --partner-id=comcast --ssl-cert-path=/etc/ssl/certs/ca-certificates.crt --acquire-jwt=1 --dns-id=fabric.xmidt.comcast.net --jwt-public-key-file=webpa-rs256.pem --jwt-algo=RS256 --seshat-url=tcp://127.0.0.1:7777 --token-read-script=/usr/ccsp/parodus/parodus_token1.sh --token-acquisition-script=/usr/ccsp/parodus/parodus_token2.sh --force-ipv4 +./parodus --hw-model=TGXXX --hw-serial-number=E8GBUEXXXXXXXXX --hw-manufacturer=ARRIS --hw-mac=14cfexxxxxxx --hw-last-reboot-reason=unknown --fw-name=TG1682_DEV_master_20170512115046sdy --boot-time=1494590301 --webpa-ping-timeout=180 --webpa-interface-used=eth0 --webpa-url=somebody.net:8080 --webpa-backoff-max=9 --parodus-local-url=tcp://127.0.0.1:6666 --partner-id=comcast --ssl-cert-path=/etc/ssl/certs/ca-certificates.crt --acquire-jwt=1 --dns-txt-url=somebody.net --jwt-public-key-file=webpa-rs256.pem --jwt-algo=RS256 --seshat-url=tcp://127.0.0.1:7777 --token-read-script=/usr/ccsp/parodus/parodus_token1.sh --token-acquisition-script=/usr/ccsp/parodus/parodus_token2.sh --force-ipv4 # Seshat is not enabled -./parodus --hw-model=TGXXX --hw-serial-number=E8GBUEXXXXXXXXX --hw-manufacturer=ARRIS --hw-mac=14cfexxxxxxx --hw-last-reboot-reason=unknown --fw-name=TG1682_DEV_master_20170512115046sdy --boot-time=1494590301 --webpa-ping-timeout=180 --webpa-interface-used=eth0 --webpa-url=fabric.webpa.comcast.net:8080 --webpa-backoff-max=9 --parodus-local-url=tcp://127.0.0.1:6666 --partner-id=comcast --ssl-cert-path=/etc/ssl/certs/ca-certificates.crt --acquire-jwt=1 --dns-id=fabric.xmidt.comcast.net --jwt-public-key-file=webpa-rs256.pem --jwt-algo=RS256 --token-read-script=/usr/ccsp/parodus/parodus_token1.sh --token-acquisition-script=/usr/ccsp/parodus/parodus_token2.sh --force-ipv4 +./parodus --hw-model=TGXXX --hw-serial-number=E8GBUEXXXXXXXXX --hw-manufacturer=ARRIS --hw-mac=14cfexxxxxxx --hw-last-reboot-reason=unknown --fw-name=TG1682_DEV_master_20170512115046sdy --boot-time=1494590301 --webpa-ping-timeout=180 --webpa-interface-used=eth0 --webpa-url=somebody.net:8080 --webpa-backoff-max=9 --parodus-local-url=tcp://127.0.0.1:6666 --partner-id=comcast --ssl-cert-path=/etc/ssl/certs/ca-certificates.crt --acquire-jwt=1 --dns-txt-url=somebody.net --jwt-public-key-file=webpa-rs256.pem --jwt-algo=RS256 --token-read-script=/usr/ccsp/parodus/parodus_token1.sh --token-acquisition-script=/usr/ccsp/parodus/parodus_token2.sh --force-ipv4 # When both Seshat & FEATURE_DNS_QUERY not Enabled -./parodus --hw-model=TGXXX --hw-serial-number=E8GBUEXXXXXXXXX --hw-manufacturer=ARRIS --hw-mac=14cfexxxxxxx --hw-last-reboot-reason=unknown --fw-name=TG1682_DEV_master_20170512115046sdy --boot-time=1494590301 --webpa-ping-timeout=180 --webpa-interface-used=eth0 --webpa-url=fabric.webpa.comcast.net:8080 --webpa-backoff-max=9 --parodus-local-url=tcp://127.0.0.1:6666 --partner-id=comcast --ssl-cert-path=/etc/ssl/certs/ca-certificates.crt --token-read-script=/usr/ccsp/parodus/parodus_token1.sh --token-acquisition-script=/usr/ccsp/parodus/parodus_token2.sh --force-ipv4 +./parodus --hw-model=TGXXX --hw-serial-number=E8GBUEXXXXXXXXX --hw-manufacturer=ARRIS --hw-mac=14cfexxxxxxx --hw-last-reboot-reason=unknown --fw-name=TG1682_DEV_master_20170512115046sdy --boot-time=1494590301 --webpa-ping-timeout=180 --webpa-interface-used=eth0 --webpa-url=somebody.net:8080 --webpa-backoff-max=9 --parodus-local-url=tcp://127.0.0.1:6666 --partner-id=comcast --ssl-cert-path=/etc/ssl/certs/ca-certificates.crt --token-read-script=/usr/ccsp/parodus/parodus_token1.sh --token-acquisition-script=/usr/ccsp/parodus/parodus_token2.sh --force-ipv4 ``` diff --git a/src/config.c b/src/config.c index bf26849..87fb9e9 100644 --- a/src/config.c +++ b/src/config.c @@ -284,7 +284,7 @@ int parseCommandLine(int argc,char **argv,ParodusCfg * cfg) #ifdef ENABLE_SESHAT {"seshat-url", required_argument, 0, 'e'}, #endif - {"dns-id", required_argument, 0, 'D'}, + {"dns-txt-url", required_argument, 0, 'D'}, {"acquire-jwt", required_argument, 0, 'j'}, {"jwt-algo", required_argument, 0, 'a'}, {"jwt-public-key-file", required_argument, 0, 'k'}, @@ -404,8 +404,8 @@ int parseCommandLine(int argc,char **argv,ParodusCfg * cfg) // like 'fabric' or 'test' // this parameter is used, along with the hw_mac parameter // to create the dns txt record id - parStrncpy(cfg->dns_id, optarg,sizeof(cfg->dns_id)); - ParodusInfo("parodus dns_id is %s\n",cfg->dns_id); + parStrncpy(cfg->dns_txt_url, optarg,sizeof(cfg->dns_txt_url)); + ParodusInfo("parodus dns-txt-url is %s\n",cfg->dns_txt_url); break; case 'j': @@ -568,7 +568,7 @@ void setDefaultValuesToCfg(ParodusCfg *cfg) cfg->acquire_jwt = 0; - parStrncpy(cfg->dns_id, DNS_ID,sizeof(cfg->dns_id)); + parStrncpy(cfg->dns_txt_url, DNS_TXT_URL, sizeof(cfg->dns_txt_url)); parStrncpy(cfg->jwt_key, "\0", sizeof(cfg->jwt_key)); @@ -691,14 +691,14 @@ void loadParodusCfg(ParodusCfg * config,ParodusCfg *cfg) #endif cfg->acquire_jwt = config->acquire_jwt; - if( strlen(config->dns_id) !=0) + if( strlen(config->dns_txt_url) !=0) { - parStrncpy(cfg->dns_id, config->dns_id,sizeof(cfg->dns_id)); + parStrncpy(cfg->dns_txt_url, config->dns_txt_url, sizeof(cfg->dns_txt_url)); } else { - ParodusInfo("parodus dns-id is NULL. adding default\n"); - parStrncpy(cfg->dns_id, DNS_ID,sizeof(cfg->dns_id)); + ParodusInfo("parodus dns-txt-url is NULL. adding default\n"); + parStrncpy(cfg->dns_txt_url, DNS_TXT_URL, sizeof(cfg->dns_txt_url)); } if(strlen(config->jwt_key )!=0) diff --git a/src/config.h b/src/config.h index 0e5524b..537a71f 100644 --- a/src/config.h +++ b/src/config.h @@ -54,7 +54,7 @@ extern "C" { #define WEBPA_PATH_URL "/api/v2/device" #define JWT_ALGORITHM "jwt-algo" #define JWT_KEY "jwt-key" -#define DNS_ID "fabric" +#define DNS_TXT_URL "fabric" #define PARODUS_UPSTREAM "tcp://127.0.0.1:6666" #define ALLOW_NON_RSA_ALG false @@ -85,7 +85,7 @@ typedef struct #ifdef ENABLE_SESHAT char seshat_url[128]; #endif - char dns_id[64]; + char dns_txt_url[64]; unsigned int acquire_jwt; unsigned int jwt_algo; // bit mask set for each allowed algorithm char jwt_key[4096]; // may be read in from a pem file diff --git a/src/token.c b/src/token.c index 701b0a4..258f168 100644 --- a/src/token.c +++ b/src/token.c @@ -467,7 +467,7 @@ static void get_dns_txt_record_id (char *buf) ParodusCfg *cfg = get_parodus_cfg(); buf[0] = 0; - sprintf (buf, "%s.%s", cfg->hw_mac, cfg->dns_id); + sprintf (buf, "%s.%s", cfg->hw_mac, cfg->dns_txt_url); ParodusInfo("dns_txt_record_id %s\n", buf); } #endif diff --git a/tests/parodus_cmd.sh b/tests/parodus_cmd.sh index 9afd7f7..5c77094 100755 --- a/tests/parodus_cmd.sh +++ b/tests/parodus_cmd.sh @@ -1,3 +1,3 @@ -sudo ./parodus --hw-model=TG1682 --hw-serial-number=Fer23u948590 --hw-manufacturer=ARRISGroup,Inc. --hw-mac=aabb33ddeeff --hw-last-reboot-reason=unknown --fw-name=TG1682_DEV_master_2016000000sdy --boot-time=123589 --webpa-ping-timeout=180 --webpa-backoff-max=0 --webpa-interface-used=p7p1 --webpa-url=https://fabric-beta.webpa.comcast.net --acquire-jwt=1 --jwt-algo=RS256 --jwt-public-key-file=../../tests/webpa-rs256.pem --dns-id=fabric.xmidt.comcast.net +sudo ./parodus --hw-model=TG1682 --hw-serial-number=Fer23u948590 --hw-manufacturer=ARRISGroup,Inc. --hw-mac=aabb33ddeeff --hw-last-reboot-reason=unknown --fw-name=TG1682_DEV_master_2016000000sdy --boot-time=123589 --webpa-ping-timeout=180 --webpa-backoff-max=0 --webpa-interface-used=p7p1 --webpa-url=https://example.net:8080 --acquire-jwt=1 --jwt-algo=RS256 --jwt-public-key-file=../../tests/webpa-rs256.pem --dns-txt-url=example.net diff --git a/tests/test_config.c b/tests/test_config.c index a7758c5..14bc930 100644 --- a/tests/test_config.c +++ b/tests/test_config.c @@ -79,7 +79,7 @@ void test_setParodusConfig() cfg.webpa_backoff_max = 255; #ifdef FEATURE_DNS_QUERY cfg.acquire_jwt = 1; - parStrncpy(cfg.dns_id, "test",sizeof(cfg.dns_id)); + parStrncpy(cfg.dns_txt_url, "test",sizeof(cfg.dns_txt_url)); cfg.jwt_algo = 1025; parStrncpy(cfg.jwt_key, "key.txt",sizeof(cfg.jwt_key)); #endif @@ -107,7 +107,7 @@ void test_setParodusConfig() assert_int_equal((int) cfg.webpa_backoff_max, (int) temp->webpa_backoff_max); #ifdef FEATURE_DNS_QUERY assert_int_equal( (int) cfg.acquire_jwt, (int) temp->acquire_jwt); - assert_string_equal(cfg.dns_id, temp->dns_id); + assert_string_equal(cfg.dns_txt_url, temp->dns_txt_url); assert_int_equal( (int) cfg.jwt_algo, (int) temp->jwt_algo); assert_string_equal(cfg.jwt_key, temp->jwt_key); #endif @@ -184,7 +184,7 @@ void test_parseCommandLine() "--ssl-cert-path=/etc/ssl/certs/ca-certificates.crt", #ifdef FEATURE_DNS_QUERY "--acquire-jwt=1", - "--dns-id=fabric.comcast.net", + "--dns-txt-url=fabric.comcast.net", "--jwt-public-key-file=../../tests/jwt_key.tst", "--jwt-algo=RS256", #endif @@ -226,7 +226,7 @@ void test_parseCommandLine() assert_string_equal( parodusCfg.cert_path,"/etc/ssl/certs/ca-certificates.crt"); #ifdef FEATURE_DNS_QUERY assert_int_equal( (int) parodusCfg.acquire_jwt, 1); - assert_string_equal(parodusCfg.dns_id, "fabric.comcast.net"); + assert_string_equal(parodusCfg.dns_txt_url, "fabric.comcast.net"); assert_int_equal( (int) parodusCfg.jwt_algo, 1024); assert_string_equal ( get_parodus_cfg()->jwt_key, jwt_key); #endif @@ -272,7 +272,7 @@ void err_parseCommandLine() #ifdef FEATURE_DNS_QUERY command[5] = "--webpa-url=https://127.0.0.1"; command[3] = "--acquire-jwt=1"; - command[4] = "--dns-id=fabric.comcast.net"; + command[4] = "--dns-txt-url=fabric.comcast.net"; // missing algo assert_int_equal (parseCommandLine(argc,command,&parodusCfg), -1); command[4] = "--jwt-algo=none:RS256"; @@ -307,7 +307,7 @@ void test_loadParodusCfg() parStrncpy(Cfg->partner_id , "shaw", sizeof(Cfg->partner_id)); #ifdef FEATURE_DNS_QUERY Cfg->acquire_jwt = 1; - parStrncpy(Cfg->dns_id, "fabric",sizeof(Cfg->dns_id)); + parStrncpy(Cfg->dns_txt_url, "fabric",sizeof(Cfg->dns_txt_url)); Cfg->jwt_algo = 1025; parStrncpy(Cfg->jwt_key, "AGdyuwyhwl2ow2ydsoioiygkshwdthuwd",sizeof(Cfg->jwt_key)); #endif @@ -329,7 +329,7 @@ void test_loadParodusCfg() assert_string_equal( tmpcfg.webpa_protocol, protocol); #ifdef FEATURE_DNS_QUERY assert_int_equal( (int) tmpcfg.acquire_jwt, 1); - assert_string_equal(tmpcfg.dns_id, "fabric"); + assert_string_equal(tmpcfg.dns_txt_url, "fabric"); assert_int_equal( (int) tmpcfg.jwt_algo, 1025); assert_string_equal(tmpcfg.jwt_key, "AGdyuwyhwl2ow2ydsoioiygkshwdthuwd"); #endif @@ -401,7 +401,7 @@ void test_setDefaultValuesToCfg() assert_string_equal( cfg->local_url, PARODUS_UPSTREAM); #ifdef FEATURE_DNS_QUERY assert_int_equal(cfg->acquire_jwt, 0); - assert_string_equal(cfg->dns_id, DNS_ID); + assert_string_equal(cfg->dns_txt_url, DNS_TXT_URL); assert_string_equal(cfg->jwt_key, "\0"); assert_int_equal( (int)cfg->jwt_algo, 0); #endif diff --git a/tests/test_token.c b/tests/test_token.c index fd97a5c..c78e750 100644 --- a/tests/test_token.c +++ b/tests/test_token.c @@ -569,7 +569,7 @@ void test_allow_insecure_conn () ParodusCfg *cfg = get_parodus_cfg(); parStrncpy (cfg->hw_mac, "aabbccddeeff", sizeof(cfg->hw_mac)); - parStrncpy (cfg->dns_id, "test", sizeof(cfg->dns_id)); + parStrncpy (cfg->dns_txt_url, "test", sizeof(cfg->dns_txt_url)); parStrncpy (cfg->jwt_algo, "none:RS256", sizeof(cfg->jwt_algo)); read_key_from_file ("../../tests/webpa-rs256.pem", cfg->jwt_key, 4096); @@ -582,7 +582,7 @@ void test_allow_insecure_conn () assert_int_equal (insecure, 0); parStrncpy (cfg->hw_mac, "aabbccddeeff", sizeof(cfg->hw_mac)); - parStrncpy (cfg->dns_id, "err5", sizeof(cfg->dns_id)); + parStrncpy (cfg->dns_txt_url, "err5", sizeof(cfg->dns_txt_url)); will_return (__res_ninit, 0); expect_function_call (__res_ninit); @@ -592,7 +592,7 @@ void test_allow_insecure_conn () assert_int_equal (insecure, TOKEN_ERR_QUERY_DNS_FAIL); parStrncpy (cfg->hw_mac, "aabbccddeeff", sizeof(cfg->hw_mac)); - parStrncpy (cfg->dns_id, "test", sizeof(cfg->dns_id)); + parStrncpy (cfg->dns_txt_url, "test", sizeof(cfg->dns_txt_url)); parStrncpy (cfg->jwt_algo, "none:RS256", sizeof(cfg->jwt_algo)); parStrncpy (cfg->jwt_key, "xxxxxxxxxx", sizeof(cfg->jwt_key)); @@ -604,7 +604,7 @@ void test_allow_insecure_conn () assert_int_equal (insecure, TOKEN_ERR_JWT_DECODE_FAIL); parStrncpy (cfg->hw_mac, "aabbccddeeff", sizeof(cfg->hw_mac)); - parStrncpy (cfg->dns_id, "test", sizeof(cfg->dns_id)); + parStrncpy (cfg->dns_txt_url, "test", sizeof(cfg->dns_txt_url)); parStrncpy (cfg->jwt_algo, "none:RS512", sizeof(cfg->jwt_algo)); read_key_from_file ("../../tests/webpa-rs256.pem", cfg->jwt_key, 4096);