From 5c07107b73c234ef1f80a92abe795bf3f5c7050f Mon Sep 17 00:00:00 2001 From: guowenxue <guowenxue@gmail.com> Date: Wed, 01 Jan 2020 21:32:29 +0800 Subject: [PATCH] update ddns client, server and configure file --- app_ddns/ddns_client.c | 11 +++++++++-- app_ddns/ddns.conf | 11 ++++++----- app_ddns/ddns_server.c | 4 ++-- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/app_ddns/ddns.conf b/app_ddns/ddns.conf index 7c79ec0..0045da4 100644 --- a/app_ddns/ddns.conf +++ b/app_ddns/ddns.conf @@ -1,6 +1,7 @@ [common] -domain="studio.iot-yun.club" +id="MasterServer" +domain="master.iot-yun.club" #[host0] #comment="localhost" @@ -12,10 +13,10 @@ ip=122.51.234.174 port=10001 -[host2] -comment="aliyun" -ip=47.74.239.156 -port=10001 +#[host2] +#comment="aliyun" +#ip=47.74.239.156 +#port=10001 diff --git a/app_ddns/ddns_client.c b/app_ddns/ddns_client.c index ede812a..ff5650d 100644 --- a/app_ddns/ddns_client.c +++ b/app_ddns/ddns_client.c @@ -52,10 +52,12 @@ char *str; int val; char *domain; + char *id; char *serverip; int port; int i; char key[64]; + char msg[512]; struct option long_options[] = { {"conf", required_argument, NULL, 'c'}, @@ -95,12 +97,17 @@ return -1; } + id=iniparser_getstring(ini, "common:id", NULL); domain=iniparser_getstring(ini, "common:domain", NULL); + if( !domain ) { - printf("ERROR: cannot parse domain in '%s'\n", conf_file); + printf("ERROR: cannot parse domain/id in '%s'\n", conf_file); return -1; } + + memset(msg, 0, sizeof(msg)); + snprintf(msg, sizeof(msg), "[%s]: '%s'", id, domain); for(i=0; i<MAX_HOSTS; i++) { @@ -118,7 +125,7 @@ } printf("==> Start send domain '%s' to [%s:%d]\n", domain, serverip, port); - socket_send_domain(serverip, port, domain); + socket_send_domain(serverip, port, msg); printf("\n"); } diff --git a/app_ddns/ddns_server.c b/app_ddns/ddns_server.c index ce261fd..ffd3d67 100644 --- a/app_ddns/ddns_server.c +++ b/app_ddns/ddns_server.c @@ -185,7 +185,7 @@ memset(buf, 0, sizeof(buf)); if( (rv=read(clifd, buf, sizeof(buf))) <= 0) { - log_err("socket[%d] already get disconncet and will be removed.\n", clifd); + log_dbg("socket[%d] already get disconncet and will be removed.\n", clifd); epoll_ctl(epollfd, EPOLL_CTL_DEL, clifd, NULL); close(clifd); continue; @@ -209,7 +209,7 @@ } - log_nrml("Domain: %s=>%s\n", buf, ipaddr); + log_nrml("<<<<< %s => '%s' >>>>>\n", buf, ipaddr); } } } /* for(i=0; i<rv; i++) */ -- Gitblit v1.9.1