Browse Source

dht

release/v0.1
jl777 9 years ago
parent
commit
2a5b032298
  1. 1
      crypto777/curve25519.c
  2. 8
      iguana/SuperNET.h
  3. 8
      iguana/iguana777.h
  4. 4
      iguana/iguana_accept.c
  5. 5
      iguana/iguana_json.c
  6. 12
      iguana/iguana_msg.c
  7. 28
      iguana/iguana_peers.c
  8. 235
      iguana/main.c

1
crypto777/curve25519.c

@ -184,6 +184,7 @@ bits256 fcontract(const bits320 input)
bits256 curve25519(bits256 mysecret,bits256 basepoint)
{
bits320 bp,x,z;
mysecret.bytes[0] &= 0xf8, mysecret.bytes[31] &= 0x7f, mysecret.bytes[31] |= 0x40;
bp = fexpand(basepoint);
cmult(&x,&z,mysecret,bp);
return(fcontract(fmul(x,crecip(z))));

8
iguana/SuperNET.h

@ -66,11 +66,15 @@ struct supernet_agent
uint32_t ipbits,dead; int32_t num,sock; uint16_t port,pubport,repport;
};
struct supernet_address { bits256 pubkey; };
struct supernet_address
{
bits256 pubkey,iphash;
uint32_t selfipbits,myipbits; int32_t confirmed,totalconfirmed;
};
struct supernet_info
{
char ipaddr[64],transport[8]; int32_t APISLEEP; int32_t iamrelay; uint64_t my64bits; uint64_t ipbits;
char ipaddr[64],transport[8]; int32_t APISLEEP; int32_t iamrelay;
int32_t Debuglevel,readyflag,dead,POLLTIMEOUT; char rpcsymbol[16],LBpoint[64],PUBpoint[64];
//int32_t pullsock,subclient,lbclient,lbserver,servicesock,pubglobal,pubrelays,numservers;
bits256 privkey;

8
iguana/iguana777.h

@ -353,10 +353,11 @@ struct iguana_peer
{
struct queueitem DL;
queue_t sendQ;
bits256 iphash;
struct iguana_msgaddress A;
char ipaddr[64],lastcommand[16],coinstr[16],symbol[16];
uint64_t pingnonce,totalsent,totalrecv,ipbits; double pingtime,sendmillis,pingsum,getdatamillis;
uint32_t lastcontact,sendtime,ready,startsend,startrecv,pending,lastgotaddr,lastblockrecv,pendtime,lastflush,lastpoll;
uint32_t lastcontact,sendtime,ready,startsend,startrecv,pending,lastgotaddr,lastblockrecv,pendtime,lastflush,lastpoll,myipbits;
int32_t supernet,dead,addrind,usock,lastheight,protover,relayflag,numpackets,numpings,ipv6,height,rank,pendhdrs,pendblocks,recvhdrs,lastlefti;
double recvblocks,recvtotal;
int64_t allocated,freed;
@ -659,6 +660,9 @@ int32_t iguana_ramchain_spendtxid(struct iguana_info *coin,bits256 *txidp,struct
struct iguana_info *iguana_coinselect();
void iguana_dedicatedloop(struct iguana_info *coin,struct iguana_peer *addr);
struct iguana_peer *iguana_peerslot(struct iguana_info *coin,uint64_t ipbits);
void iguana_dedicatedglue(void *arg);
void SuperNET_remotepeer(struct supernet_info *myinfo,struct iguana_info *coin,char *symbol,char *ipaddr,int32_t supernetflag);
void SuperNET_yourip(struct supernet_info *myinfo,char *yourip);
char *busdata_sync(uint32_t *noncep,char *jsonstr,char *broadcastmode,char *destNXTaddr);
void peggy();
@ -667,7 +671,7 @@ struct iguana_info *iguana_coinfind(const char *symbol);
struct iguana_info *iguana_coinadd(const char *symbol);
struct iguana_ramchain *iguana_bundleload(struct iguana_info *coin,struct iguana_bundle *bp);
int32_t iguana_sendblockreq(struct iguana_info *coin,struct iguana_peer *addr,struct iguana_bundle *bp,int32_t bundlei,bits256 hash2,int32_t iamthreadsafe);
int32_t iguana_send_supernet(struct iguana_info *coin,struct iguana_peer *addr,char *jsonstr,int32_t delay);
int32_t iguana_send_supernet(struct iguana_info *coin,struct iguana_peer *addr,void *data,long datalen,int32_t delay);
struct iguana_waccount *iguana_waccountfind(struct iguana_info *coin,char *account);
struct iguana_waccount *iguana_waccountadd(struct iguana_info *coin,char *walletaccount,struct iguana_waddress *waddr);

4
iguana/iguana_accept.c

@ -100,7 +100,9 @@ void iguana_acceptloop(void *args)
{
printf("LAUNCH DEDICATED THREAD for %s\n",ipaddr);
addr->usock = sock;
iguana_dedicatedloop(coin,addr);
strcpy(addr->symbol,coin->symbol);
iguana_launch(coin,"accept",iguana_dedicatedglue,addr,IGUANA_CONNTHREAD);
//iguana_dedicatedloop(coin,addr);
}
}
}

5
iguana/iguana_json.c

@ -352,11 +352,6 @@ int32_t SuperNET_coinpeers(struct iguana_info *coin,cJSON *SNjson,cJSON *rawjson
return(max);
}
void SuperNET_remotepeer(struct supernet_info *myinfo,struct iguana_info *coin,char *symbol,char *ipaddr,int32_t supernetflag)
{
printf("got %s remotepeer.(%s) supernet.%d\n",symbol,ipaddr,supernetflag);
}
void SuperNET_parsepeers(struct supernet_info *myinfo,cJSON *array,int32_t n,int32_t supernetflag)
{
int32_t i,j,m; cJSON *coinarray,*item; char *symbol,*ipaddr; struct iguana_info *ptr;

12
iguana/iguana_msg.c

@ -163,7 +163,7 @@ int32_t iguana_send_version(struct iguana_info *coin,struct iguana_peer *addr,ui
void iguana_gotverack(struct iguana_info *coin,struct iguana_peer *addr)
{
uint8_t serialized[sizeof(struct iguana_msghdr)];
uint8_t serialized[sizeof(struct iguana_msghdr)]; char *msg = "{\"agent\":\"SuperNET\",\"method\":\"getpeers\"}";
if ( addr != 0 )
{
printf("gotverack from %s\n",addr->ipaddr);
@ -172,7 +172,7 @@ void iguana_gotverack(struct iguana_info *coin,struct iguana_peer *addr)
if ( addr->supernet != 0 )
{
printf("send getpeers to %s\n",addr->ipaddr);
iguana_send_supernet(coin,addr,"{\"agent\":\"SuperNET\",\"method\":\"getpeers\"}",0);
iguana_send_supernet(coin,addr,msg,strlen(msg)+1,0);
}
}
}
@ -192,6 +192,7 @@ void iguana_gotaddr(struct iguana_info *coin,struct iguana_peer *addr,struct igu
void iguana_gotping(struct iguana_info *coin,struct iguana_peer *addr,uint64_t nonce,uint8_t *data)
{
int32_t len; uint8_t serialized[sizeof(struct iguana_msghdr) + sizeof(nonce)];
char *msg = "{\"agent\":\"SuperNET\",\"method\":\"getpeers\"}";
len = iguana_rwnum(1,&serialized[sizeof(struct iguana_msghdr)],sizeof(uint64_t),&nonce);
if ( memcmp(data,&serialized[sizeof(struct iguana_msghdr)],sizeof(nonce)) != 0 )
printf("ping ser error %llx != %llx\n",(long long)nonce,*(long long *)data);
@ -199,13 +200,14 @@ void iguana_gotping(struct iguana_info *coin,struct iguana_peer *addr,uint64_t n
if ( addr->supernet != 0 )
{
printf("send getpeers to %s\n",addr->ipaddr);
iguana_send_supernet(coin,addr,"{\"agent\":\"SuperNET\",\"method\":\"getpeers\"}",0);
iguana_send_supernet(coin,addr,msg,strlen(msg)+1,0);
}
}
int32_t iguana_send_ping(struct iguana_info *coin,struct iguana_peer *addr)
{
int32_t len; uint64_t nonce; uint8_t serialized[sizeof(struct iguana_msghdr) + sizeof(nonce)];
char *msg = "{\"agent\":\"SuperNET\",\"method\":\"getpeers\"}";
if ( (nonce= addr->pingnonce) == 0 )
{
OS_randombytes((uint8_t *)&nonce,sizeof(nonce));
@ -215,7 +217,7 @@ int32_t iguana_send_ping(struct iguana_info *coin,struct iguana_peer *addr)
printf("pingnonce.%llx\n",(long long)nonce);
len = iguana_rwnum(1,&serialized[sizeof(struct iguana_msghdr)],sizeof(uint64_t),&nonce);
if ( addr->supernet != 0 )
iguana_send_supernet(coin,addr,"{\"agent\":\"SuperNET\",\"method\":\"getpeers\"}",(rand() % 10000));
iguana_send_supernet(coin,addr,msg,strlen(msg)+1,(rand() % 10000));
return(iguana_queue_send(coin,addr,0,serialized,"ping",len,0,0));
}
@ -438,7 +440,7 @@ int32_t iguana_msgparser(struct iguana_info *coin,struct iguana_peer *addr,struc
len = recvlen;
if ( (retstr= SuperNET_p2p(coin,addr,&delay,addr->ipaddr,data,recvlen)) != 0 )
{
iguana_send_supernet(coin,addr,retstr,delay);
iguana_send_supernet(coin,addr,retstr,strlen(retstr)+1,delay);
free(retstr);
}
printf("GOT.(%s) [%s] len.%d from %s -> (%s)\n",H->command,data,recvlen,addr->ipaddr,retstr==0?"null":retstr);

28
iguana/iguana_peers.c

@ -602,6 +602,9 @@ void iguana_startconnection(void *arg)
struct iguana_peer *iguana_peerslot(struct iguana_info *coin,uint64_t ipbits)
{
int32_t i; struct iguana_peer *addr; char ipaddr[64];
for (i=0; i<IGUANA_MAXPEERS; i++)
if ( ipbits == coin->peers.active[i].ipbits )
return(0);
expand_ipbits(ipaddr,ipbits);
#ifdef IGUANA_DISABLEPEERS
if ( strcmp("127.0.0.1",ipaddr) != 0 )
@ -883,8 +886,8 @@ int64_t iguana_peerallocated(struct iguana_info *coin,struct iguana_peer *addr)
void iguana_dedicatedloop(struct iguana_info *coin,struct iguana_peer *addr)
{
static uint32_t lastping;
struct pollfd fds; uint8_t *buf,serialized[64]; struct iguana_bundlereq *req;
int32_t bufsize,flag,run,timeout = coin->polltimeout == 0 ? 10 : coin->polltimeout;
char *msg; struct pollfd fds; uint8_t *buf,serialized[64]; struct iguana_bundlereq *req;
uint32_t ipbits; int32_t bufsize,flag,run,timeout = coin->polltimeout == 0 ? 10 : coin->polltimeout;
#ifdef IGUANA_PEERALLOC
int32_t i; int64_t remaining; struct OS_memspace *mem[sizeof(addr->SEROUT)/sizeof(*addr->SEROUT)];
for (i=0; i<sizeof(addr->SEROUT)/sizeof(*addr->SEROUT); i++)
@ -900,7 +903,9 @@ void iguana_dedicatedloop(struct iguana_info *coin,struct iguana_peer *addr)
}
#endif
addr->addrind = (int32_t)(((long)addr - (long)&coin->peers.active[0]) / sizeof(*addr));
printf("start dedicatedloop.%s addrind.%d\n",addr->ipaddr,addr->addrind);
ipbits = (uint32_t)addr->ipbits;
vcalc_sha256(0,addr->iphash.bytes,(uint8_t *)&ipbits,sizeof(ipbits));
char str[65]; printf("start dedicatedloop.%s addrind.%d %s\n",addr->ipaddr,addr->addrind,bits256_str(str,addr->iphash));
addr->maxfilehash2 = IGUANA_MAXFILEITEMS;
bufsize = IGUANA_MAXPACKETSIZE;
buf = mycalloc('r',1,bufsize);
@ -981,7 +986,8 @@ void iguana_dedicatedloop(struct iguana_info *coin,struct iguana_peer *addr)
else if ( addr->supernet != 0 && time(NULL) > lastping+60 )
{
printf("send getpeers\n");
iguana_send_supernet(coin,addr,"{\"agent\":\"SuperNET\",\"method\":\"getpeers\"}",0);
msg = "{\"agent\":\"SuperNET\",\"method\":\"getpeers\"}";
iguana_send_supernet(coin,addr,msg,strlen(msg)+1,0);
lastping = (uint32_t)time(NULL);
}
if ( coin->isRT != 0 && addr->rank > coin->MAXPEERS && (rand() % 100) == 0 )
@ -1020,6 +1026,17 @@ void iguana_dedicatedloop(struct iguana_info *coin,struct iguana_peer *addr)
coin->peers.numconnected--;
}
void iguana_dedicatedglue(void *arg)
{
struct iguana_info *coin = 0; struct iguana_peer *addr = arg;
if ( addr == 0 || (coin= iguana_coinfind(addr->symbol)) == 0 )
{
printf("iguana_dedicatedglue nullptrs addr.%p coin.%p\n",addr,coin);
return;
}
iguana_dedicatedloop(coin,addr);
}
void iguana_peersloop(void *ptr)
{
#ifndef IGUANA_DEDICATED_THREADS
@ -1074,8 +1091,9 @@ void iguana_peersloop(void *ptr)
}
if ( flag == 0 )
{
char *msg = "{\"agent\":\"SuperNET\",\"method\":\"getpeers\"}";
if ( time(NULL) > lastping+1 )
iguana_send_supernet(coin,addr,"{\"agent\":\"SuperNET\",\"method\":\"getpeers\"}",0);
iguana_send_supernet(coin,addr,msg,strlen(msg)+1,0);
usleep(1000);
}
}

235
iguana/main.c

@ -33,6 +33,7 @@ uint32_t prices777_NXTBLOCK,MAX_DEPTH = 100;
char NXTAPIURL[256],IGUANA_NXTADDR[256],IGUANA_NXTACCTSECRET[256];
uint64_t IGUANA_MY64BITS;
queue_t helperQ,jsonQ,finishedQ,bundlesQ;
struct supernet_info MYINFO;
static int32_t initflag;
#ifdef __linux__
int32_t IGUANA_NUMHELPERS = 8;
@ -159,13 +160,199 @@ char *iguana_JSON(char *jsonstr)
return(retstr);
}
int32_t SuperNET_confirmip(struct supernet_info *myinfo,uint32_t ipbits)
{
int32_t i,j,total = 0; uint32_t x;
for (i=0; i<IGUANA_MAXCOINS; i++)
{
if ( Coins[i] != 0 )
{
for (j=0; j<IGUANA_MAXPEERS; j++)
{
if ( (x= Coins[i]->peers.active[j].myipbits) != 0 )
{
if ( x == ipbits )
total++;
else total--;
}
}
}
}
return(total);
}
void SuperNET_myipaddr(struct supernet_info *myinfo,struct iguana_peer *addr,char *myipaddr,char *remoteaddr)
{
uint32_t myipbits = (uint32_t)calc_ipbits(myipaddr);
if ( addr->myipbits == 0 )
addr->myipbits = myipbits;
else if ( addr->myipbits != myipbits )
{
printf("%s: myipaddr conflict %x != %x?\n",addr->ipaddr,addr->myipbits,myipbits);
addr->myipbits = 0;
}
if ( addr->myipbits != 0 && myinfo->myaddr.myipbits == 0 )
myinfo->myaddr.myipbits = addr->myipbits;
if ( addr->myipbits == myinfo->myaddr.myipbits )
{
myinfo->myaddr.confirmed++;
if ( myinfo->myaddr.selfipbits == 0 || myinfo->ipaddr[0] == 0 )
{
if ( (myinfo->myaddr.totalconfirmed= SuperNET_confirmip(myinfo,addr->myipbits)) > 3 )
myinfo->myaddr.selfipbits = addr->myipbits;
}
}
else myinfo->myaddr.confirmed--;
if ( myinfo->myaddr.selfipbits == myinfo->myaddr.myipbits )
{
expand_ipbits(myinfo->ipaddr,myinfo->myaddr.selfipbits);
vcalc_sha256(0,myinfo->myaddr.iphash.bytes,(uint8_t *)&myinfo->myaddr.selfipbits,sizeof(myinfo->myaddr.selfipbits));
}
}
void SuperNET_remotepeer(struct supernet_info *myinfo,struct iguana_info *coin,char *symbol,char *ipaddr,int32_t supernetflag)
{
uint64_t ipbits; struct iguana_peer *addr;
printf("got %s remotepeer.(%s) supernet.%d\n",symbol,ipaddr,supernetflag);
if ( supernetflag != 0 )
{
ipbits = calc_ipbits(ipaddr);
if ( (addr= iguana_peerslot(coin,ipbits)) != 0 )
{
printf("launch startconnection to supernet peer.(%s)\n",ipaddr);
iguana_launch(coin,"connection",iguana_startconnection,addr,IGUANA_CONNTHREAD);
return;
}
}
iguana_possible_peer(coin,ipaddr);
}
int32_t iguana_send_supernet(struct iguana_info *coin,struct iguana_peer *addr,void *data,long datalen,int32_t delaymillis)
{
uint64_t r; char *jsonstr = data; int32_t flag=0,qlen = -1; uint8_t serialized[8192],*buf; cJSON *json;
if ( (json= cJSON_Parse((char *)data)) != 0 )
{
if ( j64bits(json,"tag") == 0 )
{
OS_randombytes((uint8_t *)&r,sizeof(r));
jadd64bits(json,"tag",r);
}
jdelete(json,"yourip");
jaddstr(json,"yourip",addr->ipaddr);
jsonstr = jprint(json,1);
datalen = strlen(jsonstr)+1;
flag = 1;
}
buf = serialized;
if ( datalen > sizeof(serialized)-sizeof(struct iguana_msghdr) )
buf = calloc(1,datalen+sizeof(struct iguana_msghdr));
memcpy(&buf[sizeof(struct iguana_msghdr)],jsonstr,datalen);
printf("SUPERSEND.(%s) -> (%s) delaymillis.%d\n",jsonstr,addr->ipaddr,delaymillis);
qlen = iguana_queue_send(coin,addr,delaymillis,serialized,"SuperNET",(int32_t)datalen,0,1);
if ( buf != serialized )
free(buf);
if ( flag != 0 )
free(jsonstr);
return(qlen);
}
uint64_t Packetcache[1024];
int32_t SuperNET_DHTsend(struct supernet_info *myinfo,bits256 routehash,uint8_t *data,int32_t datalen,int32_t maxdelay)
{
static int lastpurge;
bits256 packethash; int32_t i,j,firstz,iter,n = 0; struct iguana_peer *addr;
vcalc_sha256(0,packethash.bytes,data,datalen);
firstz = -1;
for (i=0; i<sizeof(Packetcache)/sizeof(*Packetcache); i++)
{
if ( Packetcache[i] == 0 )
{
Packetcache[i] = packethash.txid;
printf("add.%llx packetcache(%s)\n",(long long)packethash.txid,(char *)data);
break;
}
else if ( Packetcache[i] == packethash.txid )
{
printf("SuperNET_DHTsend reject repeated packet.%llx (%s)\n",(long long)packethash.txid,(char *)data);
return(-1);
}
}
if ( i == sizeof(Packetcache)/sizeof(*Packetcache) )
{
printf("purge slot[%d]\n",lastpurge);
Packetcache[lastpurge++] = packethash.txid;
if ( lastpurge >= sizeof(Packetcache)/sizeof(*Packetcache) )
lastpurge = 0;
}
for (iter=0; iter<2; iter++)
{
for (i=0; i<IGUANA_MAXCOINS; i++)
{
if ( Coins[i] != 0 )
{
for (j=0; j<IGUANA_MAXPEERS; j++)
{
addr = &Coins[i]->peers.active[j];
if ( addr->usock >= 0 )
{
if ( iter == 0 && memcmp(addr->iphash.bytes,routehash.bytes,sizeof(addr->iphash)) == 0 )
{
iguana_send_supernet(Coins[i],addr,data,datalen,maxdelay==0?0:rand()%maxdelay);
return(100);
}
else if ( iter == 1 )
{
if ( bits256_cmp(addr->iphash,myinfo->myaddr.iphash) < 0 )
{
iguana_send_supernet(Coins[i],addr,data,datalen,maxdelay==0?0:rand()%maxdelay);
n++;
}
}
}
}
}
}
}
return(n);
}
int32_t SuperNET_mypacket(struct supernet_info *myinfo,uint32_t destipbits,bits256 destpub)
{
if ( destipbits == myinfo->myaddr.selfipbits )
return(0);
if ( memcmp(destpub.bytes,myinfo->myaddr.pubkey.bytes,sizeof(destpub)) == 0 )
return(0);
// check for encrypted packets
return(-1);
}
char *SuperNET_p2p(struct iguana_info *coin,struct iguana_peer *addr,int32_t *delaymillisp,char *ipaddr,uint8_t *data,int32_t datalen)
{
cJSON *json,*retjson; char *agent,*method,*retstr = 0;
cJSON *json,*retjson; bits256 destpub,routehash; uint32_t n,destipbits = 0;
char *destip,*agent,*myipaddr,*method,retbuf[512],*retstr = 0;
*delaymillisp = 0;
if ( (json= cJSON_Parse((char *)data)) != 0 )
{
printf("GOT >>>>>>>> SUPERNET P2P.(%s) from.%s\n",(char *)data,coin->symbol);
if ( (myipaddr= jstr(json,"yourip")) != 0 )
SuperNET_myipaddr(&MYINFO,addr,myipaddr,ipaddr);
if ( (destip= jstr(json,"destip")) != 0 )
destipbits = (uint32_t)calc_ipbits(destip);
destpub = jbits256(json,"destpub");
if ( SuperNET_mypacket(&MYINFO,destipbits,destpub) < 0 )
{
if ( destipbits != 0 )
vcalc_sha256(0,routehash.bytes,(uint8_t *)&destipbits,sizeof(destipbits));
else routehash = destpub;
n = SuperNET_DHTsend(&MYINFO,routehash,data,datalen,juint(json,"delay"));
free_json(json);
if ( n > 0 )
{
if ( n == 100 )
sprintf(retbuf,"{\"result\":\"packet sent to destination\"}");
else sprintf(retbuf,"{\"result\":\"packet forwarded to superDHT\",\"branches\":%d}",n);
} else return(clonestr("{\"error\":\"no nodes to forward packet to\"}"));
}
if ( (agent= jstr(json,"agent")) != 0 && (method= jstr(json,"method")) != 0 )
{
if ( strcmp(agent,"SuperNET") == 0 && strcmp(method,"stop") == 0 )
@ -196,31 +383,6 @@ 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\"}";
@ -232,7 +394,7 @@ void iguana_exit()
for (j=0; j<IGUANA_MAXPEERS; j++)
{
if ( Coins[i]->peers.active[j].usock >= 0 && Coins[i]->peers.active[j].supernet != 0 )
iguana_send_supernet(Coins[i],&Coins[i]->peers.active[j],stopstr,0);
iguana_send_supernet(Coins[i],&Coins[i]->peers.active[j],stopstr,strlen(stopstr)+1,0);
}
}
}
@ -271,8 +433,22 @@ void sigcontinue_func() { printf("\nSIGCONT\n"); signal(SIGCONT,sigcontinue_func
void iguana_main(void *arg)
{
struct supernet_info MYINFO; char helperstr[64],*helperargs,*coinargs=0,*secret,*jsonstr = arg;
int32_t i,len,flag; cJSON *json; uint8_t secretbuf[512];
char helperstr[64],*helperargs,*ipaddr,*coinargs=0,*secret,*jsonstr = arg;
int32_t i,len,flag,c; cJSON *json; uint8_t secretbuf[512]; int64_t allocsize;
if ( (ipaddr= OS_filestr(&allocsize,"ipaddr")) != 0 )
{
printf("got ipaddr.(%s)\n",ipaddr);
len = (int32_t)strlen(ipaddr) - 1;
while ( len > 8 && ((c= ipaddr[len]) == '\r' || c == '\n' || c == ' ' || c == '\t') )
ipaddr[len] = 0, len--;
printf("got ipaddr.(%s) %x\n",ipaddr,is_ipaddr(ipaddr));
if ( is_ipaddr(ipaddr) != 0 )
{
strcpy(MYINFO.ipaddr,ipaddr);
MYINFO.myaddr.selfipbits = (uint32_t)calc_ipbits(ipaddr);
}
free(ipaddr);
}
signal(SIGINT,sigint_func);
signal(SIGILL,sigillegal_func);
signal(SIGHUP,sighangup_func);
@ -288,6 +464,7 @@ void iguana_main(void *arg)
OS_ensure_directory("DB");
OS_ensure_directory("tmp");
memset(&MYINFO,0,sizeof(MYINFO));
OS_randombytes(MYINFO.privkey.bytes,sizeof(MYINFO.privkey));
if ( jsonstr != 0 && (json= cJSON_Parse(jsonstr)) != 0 )
{
if ( jobj(json,"numhelpers") != 0 )

Loading…
Cancel
Save