Browse Source

Test

etomic
jl777 8 years ago
parent
commit
3f7f0a5a36
  1. 2
      iguana/exchanges/LP_commands.c
  2. 20
      iguana/exchanges/LP_forwarding.c
  3. 4
      iguana/exchanges/LP_rpc.c

2
iguana/exchanges/LP_commands.c

@ -264,7 +264,7 @@ forwardhex(pubkey,hex)\n\
if ( strcmp(method,"register") == 0 ) if ( strcmp(method,"register") == 0 )
{ {
retstr = LP_register(jbits256(argjson,"client"),jstr(argjson,"pushaddr"),juint(argjson,"pushport")); retstr = LP_register(jbits256(argjson,"client"),jstr(argjson,"pushaddr"),juint(argjson,"pushport"));
printf("got (%s) from register\n",retstr!=0?retstr:""); //printf("got (%s) from register\n",retstr!=0?retstr:"");
return(retstr); return(retstr);
} }
else if ( strcmp(method,"lookup") == 0 ) else if ( strcmp(method,"lookup") == 0 )

20
iguana/exchanges/LP_forwarding.c

@ -151,7 +151,7 @@ char *LP_register(bits256 pubkey,char *ipaddr,uint16_t port)
int32_t LP_forwarding_register(bits256 pubkey,char *publicaddr,uint16_t publicport,int32_t max) int32_t LP_forwarding_register(bits256 pubkey,char *publicaddr,uint16_t publicport,int32_t max)
{ {
char *retstr,ipaddr[64]; cJSON *retjson; struct LP_peerinfo *peer,*tmp; int32_t j,n=0,retval = -1; char *argstr,ipaddr[64]; cJSON *argjson; struct LP_peerinfo *peer,*tmp; int32_t j,n=0,arglen;
if ( publicaddr == 0 || publicaddr[0] == 0 || bits256_nonz(pubkey) == 0 ) if ( publicaddr == 0 || publicaddr[0] == 0 || bits256_nonz(pubkey) == 0 )
{ {
char str[65]; printf("LP_forwarding_register illegal publicaddr.(%s):%u or null pubkey (%s)\n",publicaddr,publicport,bits256_str(str,pubkey)); char str[65]; printf("LP_forwarding_register illegal publicaddr.(%s):%u or null pubkey (%s)\n",publicaddr,publicport,bits256_str(str,pubkey));
@ -161,10 +161,23 @@ int32_t LP_forwarding_register(bits256 pubkey,char *publicaddr,uint16_t publicpo
if ( publicaddr[j] >= '0' && publicaddr[j] <= '9' ) if ( publicaddr[j] >= '0' && publicaddr[j] <= '9' )
break; break;
parse_ipaddr(ipaddr,publicaddr+j); parse_ipaddr(ipaddr,publicaddr+j);
argjson = cJSON_CreateObject();
jaddstr(argjson,"agent","stats");
jaddstr(argjson,"method","register");
jaddbits256(argjson,"client",pubkey);
jaddstr(argjson,"pushaddr",ipaddr);
jaddnum(argjson,"pushport",publicport);
argstr = jprint(argjson,1);
arglen = (int32_t)strlen(argstr) + 1;
HASH_ITER(hh,LP_peerinfos,peer,tmp) HASH_ITER(hh,LP_peerinfos,peer,tmp)
{ {
if ( peer->pushsock >= 0 )
{
LP_send(peer->pushsock,argstr,arglen,0);
n++;
}
//printf("register.(%s) %s %u with (%s)\n",publicaddr,ipaddr,publicport,peer->ipaddr); //printf("register.(%s) %s %u with (%s)\n",publicaddr,ipaddr,publicport,peer->ipaddr);
if ( (retstr= issue_LP_register(peer->ipaddr,peer->port,pubkey,ipaddr,publicport)) != 0 ) /*if ( (retstr= issue_LP_register(peer->ipaddr,peer->port,pubkey,ipaddr,publicport)) != 0 )
{ {
//printf("[%s] LP_register.(%s) returned.(%s)\n",publicaddr,peer->ipaddr,retstr); //printf("[%s] LP_register.(%s) returned.(%s)\n",publicaddr,peer->ipaddr,retstr);
if ( (retjson= cJSON_Parse(retstr)) != 0 ) if ( (retjson= cJSON_Parse(retstr)) != 0 )
@ -176,8 +189,9 @@ int32_t LP_forwarding_register(bits256 pubkey,char *publicaddr,uint16_t publicpo
free(retstr); free(retstr);
} else printf("timeout registering with %s errs.%d good.%d\n",peer->ipaddr,peer->errors,peer->good); } else printf("timeout registering with %s errs.%d good.%d\n",peer->ipaddr,peer->errors,peer->good);
if ( retval == 0 ) if ( retval == 0 )
break; break;*/
} }
free(argstr);
return(n); return(n);
} }

4
iguana/exchanges/LP_rpc.c

@ -115,7 +115,7 @@ char *issue_LP_notifyutxo(char *destip,uint16_t destport,struct LP_utxoinfo *utx
} }
} }
char *issue_LP_register(char *destip,uint16_t destport,bits256 pubkey,char *ipaddr,uint16_t pushport) /*char *issue_LP_register(char *destip,uint16_t destport,bits256 pubkey,char *ipaddr,uint16_t pushport)
{ {
char url[512],str[65],*retstr; char url[512],str[65],*retstr;
sprintf(url,"http://%s:%u/api/stats/register?client=%s&pushaddr=%s&pushport=%u",destip,destport,bits256_str(str,pubkey),ipaddr,pushport); sprintf(url,"http://%s:%u/api/stats/register?client=%s&pushaddr=%s&pushport=%u",destip,destport,bits256_str(str,pubkey),ipaddr,pushport);
@ -123,7 +123,7 @@ char *issue_LP_register(char *destip,uint16_t destport,bits256 pubkey,char *ipad
retstr = issue_curlt(url,LP_HTTP_TIMEOUT); retstr = issue_curlt(url,LP_HTTP_TIMEOUT);
//printf("register.(%s) -> (%s)\n",url,retstr!=0?retstr:""); //printf("register.(%s) -> (%s)\n",url,retstr!=0?retstr:"");
return(retstr); return(retstr);
} }*/
char *issue_LP_psock(char *destip,uint16_t destport,int32_t ispaired) char *issue_LP_psock(char *destip,uint16_t destport,int32_t ispaired)
{ {

Loading…
Cancel
Save