fix problems in last few commits

This commit is contained in:
wangyu- 2018-06-05 12:57:25 -05:00
parent 5c7d48e711
commit c0b70c95ca
2 changed files with 17 additions and 10 deletions

@ -1761,26 +1761,33 @@ int main(int argc, char *argv[])
local_ip_uint32=inet_addr(local_ip); local_ip_uint32=inet_addr(local_ip);
source_ip_uint32=inet_addr(source_ip); source_ip_uint32=inet_addr(source_ip);
// if(enable_dns_resolve)
// {
#if ENABLE_DNS_RESOLVE #if ENABLE_DNS_RESOLVE
//if(enable_dns_resolve)
//{
struct hostent *he; struct hostent *he;
if ( (he = gethostbyname(remote_address) ) == NULL ) { if ( (he = gethostbyname(remote_address) ) == NULL ) {
mylog(log_error,"Unable to resolve hostname: %s\n",remote_address); mylog(log_error,"Unable to resolve hostname: %s, error:%s \n",remote_address,hstrerror(h_errno) );
exit(1); /* error */ myexit(1); /* error */
} }
struct in_addr **addr_list = (struct in_addr **)he->h_addr_list; struct in_addr **addr_list = (struct in_addr **)he->h_addr_list;
assert( he->h_addrtype ==AF_INET);
assert(addr_list!=NULL);
remote_ip_uint32=(*addr_list[0]).s_addr; remote_ip_uint32=(*addr_list[0]).s_addr;
mylog(log_info,"%s ip = %s\n", program_mode==client_mode?"server":"remote", my_ntoa(remote_ip_uint32)); mylog(log_info,"remote_address[%s] has been resolved to [%s]\n",remote_address, my_ntoa(remote_ip_uint32));
strcpy(remote_ip,my_ntoa(remote_ip_uint32)); strcpy(remote_ip,my_ntoa(remote_ip_uint32));
#else
// } //}
// else //else
#else
{ {
//strncpy(remote_ip,remote_address,sizeof(remote_ip)-1); //strncpy(remote_ip,remote_address,sizeof(remote_ip)-1);
mylog(log_info,"remote_ip=[%s], make sure this is a vaild IP address",remote_ip);
strcpy(remote_ip,remote_address); strcpy(remote_ip,remote_address);
remote_ip_uint32=inet_addr(remote_ip); remote_ip_uint32=inet_addr(remote_ip);
} }

@ -656,13 +656,13 @@ void process_arg(int argc, char *argv[]) //process all options
{ {
sscanf(optarg,"%d",&ttl_value); sscanf(optarg,"%d",&ttl_value);
assert(ttl_value>=0&&ttl_value<=255); assert(ttl_value>=0&&ttl_value<=255);
mylog(log_info,"ttl_value=%d",ttl_value); mylog(log_info,"ttl_value=%d\n",ttl_value);
} }
else if(strcmp(long_options[option_index].name,"dns-resolve")==0) else if(strcmp(long_options[option_index].name,"dns-resolve")==0)
{ {
enable_dns_resolve=1; enable_dns_resolve=1;
mylog(log_info,"dns-resolve enabled \n",max_rst_allowed); mylog(log_info,"dns-resolve enabled\n");
} }
else else
{ {