Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
7b946eae5a
  1. 7
      iguana/SuperNET.c
  2. 5
      iguana/SuperNET_hexmsg.c
  3. 4
      iguana/iguana_rpc.c

7
iguana/SuperNET.c

@ -537,7 +537,7 @@ int32_t SuperNET_destination(struct supernet_info *myinfo,uint32_t *destipbitsp,
destflag |= SUPERNET_FORWARD;
}
}
else if ( remoteaddr == 0 || remoteaddr[0] == 0 )
if ( remoteaddr == 0 || remoteaddr[0] == 0 || strcmp(remoteaddr,"127.0.0.1") == 0 )
destflag |= SUPERNET_ISMINE;
return(destflag);
}
@ -562,6 +562,7 @@ char *SuperNET_JSON(struct supernet_info *myinfo,cJSON *json,char *remoteaddr)
}
if ( hexmsg != 0 )
{
printf("check.(%s)\n",hexmsg);
if ( SuperNET_hexmsguniq(myinfo,destpub,hexmsg,0) >= 0 )
{
SuperNET_hexmsgadd(myinfo,destpub,hexmsg);
@ -985,8 +986,8 @@ TWOSTRINGS_AND_HASH_AND_TWOINTS(SuperNET,DHT,hexmsg,destip,destpub,maxdelay,broa
{
if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"cant remote DHT\"}"));
else if ( is_hexstr(hexmsg,(int32_t)strlen(hexmsg)) <= 0 )
return(clonestr("{\"error\":\"message must be in hex\"}"));
else if ( hexmsg == 0 || is_hexstr(hexmsg,(int32_t)strlen(hexmsg)) <= 0 )
return(clonestr("{\"error\":\"hexmsg missing or not in hex\"}"));
return(SuperNET_DHTencode(myinfo,destip,destpub,hexmsg,maxdelay,broadcast,juint(json,"plaintext")!=0));
}

5
iguana/SuperNET_hexmsg.c

@ -21,7 +21,10 @@ int32_t SuperNET_hexmsguniq(struct supernet_info *myinfo,bits256 dest,char *hexm
bits256 packethash; int32_t i,datalen;
datalen = (int32_t)strlen(hexmsg) + 1;
vcalc_sha256(0,packethash.bytes,(void *)hexmsg,datalen);
if ( bits256_nonz(dest) == 0 )
dest = GENESIS_PUBKEY;
packethash = curve25519(dest,packethash);
//printf("addflag.%d packethash.%llx dest.%llx\n",addflag,(long long)packethash.txid,(long long)dest.txid);
for (i=0; i<sizeof(Packetcache)/sizeof(*Packetcache); i++)
{
if ( Packetcache[i] == 0 )
@ -29,7 +32,7 @@ int32_t SuperNET_hexmsguniq(struct supernet_info *myinfo,bits256 dest,char *hexm
if ( addflag != 0 )
{
Packetcache[i] = packethash.txid;
printf("add.%llx packetcache(%s) -> slot[%d]\n",(long long)packethash.txid,hexmsg,i);
//printf("add.%llx packetcache(%s) -> slot[%d]\n",(long long)packethash.txid,hexmsg,i);
}
break;
}

4
iguana/iguana_rpc.c

@ -853,7 +853,9 @@ void iguana_rpcloop(void *args)
char remoteaddr[64],jsonbuf[8192],*buf,*retstr,*space;//,*retbuf; ,n,i,m
struct sockaddr_in cli_addr; uint32_t ipbits,i,size = IGUANA_WIDTH*IGUANA_HEIGHT*16 + 512; uint16_t port;
port = IGUANA_RPCPORT;
bindsock = iguana_socket(1,"127.0.0.1",port);
while ( (bindsock= iguana_socket(1,"127.0.0.1",port)) < 0 )
sleep(3);
printf("iguana_rpcloop 127.0.0.1:%d bind sock.%d\n",port,bindsock);
space = calloc(1,size);
while ( bindsock >= 0 )

Loading…
Cancel
Save