Browse Source

youip returned

release/v0.1
jl777 9 years ago
parent
commit
8f2eda1a52
  1. 12
      iguana/iguana_msg.c
  2. 27
      iguana/main.c

12
iguana/iguana_msg.c

@ -124,18 +124,6 @@ int32_t iguana_rwblockhash(int32_t rwflag,uint8_t *serialized,uint32_t *nVersion
return(len);
}*/
int32_t iguana_send_supernet(struct iguana_info *coin,struct iguana_peer *addr,char *jsonstr,int32_t delaymillis)
{
int32_t len; uint8_t serialized[8192];
if ( (len= (int32_t)strlen(jsonstr)) < sizeof(serialized)-sizeof(struct iguana_msghdr) )
{
memcpy(&serialized[sizeof(struct iguana_msghdr)],jsonstr,len+1);
printf("SUPERSEND.(%s) -> (%s) delaymillis.%d\n",jsonstr,addr->ipaddr,delaymillis);
return(iguana_queue_send(coin,addr,delaymillis,serialized,"SuperNET",len+1,0,1));
}
else return(-1);
}
void iguana_gotversion(struct iguana_info *coin,struct iguana_peer *addr,struct iguana_msgversion *vers)
{
uint8_t serialized[sizeof(struct iguana_msghdr)];

27
iguana/main.c

@ -134,8 +134,6 @@ char *SuperNET_JSON(struct supernet_info *myinfo,cJSON *json,char *remoteaddr)
{
jdelete(retjson,"tag");
jadd64bits(retjson,"tag",tag);
if ( remoteaddr != 0 && remoteaddr[0] != 0 && strncmp(remoteaddr,"127.0.0.1",strlen("127.0.0.1")) != 0 )
jaddstr(retjson,"yourip",remoteaddr);
retstr = jprint(retjson,1);
//printf("retstr.(%s) retjsonstr.%p retjson.%p\n",retstr,retjsonstr,retjson);
free(retjsonstr);//,strlen(retjsonstr)+1);
@ -198,6 +196,31 @@ char *SuperNET_p2p(struct iguana_info *coin,struct iguana_peer *addr,int32_t *de
return(retstr);
}
int32_t iguana_send_supernet(struct iguana_info *coin,struct iguana_peer *addr,char *jsonstr,int32_t delaymillis)
{
int32_t len,flag=0,qlen = -1; uint8_t serialized[8192],*buf; cJSON *json;
if ( (json= cJSON_Parse(jsonstr)) != 0 )
{
jdelete(json,"yourip");
jaddstr(json,"yourip",addr->ipaddr);
jsonstr = jprint(json,1);
flag = 1;
}
buf = serialized;
if ( (len= (int32_t)strlen(jsonstr)) > sizeof(serialized)-sizeof(struct iguana_msghdr) )
buf = calloc(1,len+sizeof(struct iguana_msghdr));
{
memcpy(&buf[sizeof(struct iguana_msghdr)],jsonstr,len+1);
printf("SUPERSEND.(%s) -> (%s) delaymillis.%d\n",jsonstr,addr->ipaddr,delaymillis);
qlen = iguana_queue_send(coin,addr,delaymillis,serialized,"SuperNET",len+1,0,1);
}
if ( buf != serialized )
free(buf);
if ( flag != 0 )
free(jsonstr);
return(qlen);
}
void iguana_exit()
{
int32_t i,j,k; char *stopstr = "{\"agent\":\"SuperNET\",\"method\":\"stop\"}";

Loading…
Cancel
Save