Пример #1
0
void iguana_iAkill(struct iguana_info *coin,struct iguana_peer *addr,int32_t markflag)
{
    struct iguana_iAddr iA; int32_t ind,rank,status = 0; char ipaddr[64];
    if ( addr->ipbits == 0 )
    {
        printf("cant iAkill null ipbits\n");
        return;
    }
    rank = addr->rank;
    strcpy(ipaddr,addr->ipaddr);
    if ( addr->usock >= 0 )
        close(addr->usock);
    if ( addr == coin->peers.localaddr )
        coin->peers.localaddr = 0;
    if ( markflag != 0 )
    {
        //printf("iAkill.(%s)\n",addr->ipaddr);
        if ( (ind= iguana_ipbits2ind(coin,&iA,addr->ipbits,1)) > 0 )
        {
            if ( addr->height > iA.height )
                iA.height = addr->height;
            iA.numkilled++;
            iA.lastkilled = (uint32_t)time(NULL);
            if ( iguana_rwiAddrind(coin,1,&iA,ind) == 0 )
                printf("killconnection (%s) save error\n",addr->ipaddr);
        } else printf("killconnection cant get ind for ipaddr.%s\n",addr->ipaddr);
    }
    else if ( iguana_rwipbits_status(coin,1,addr->ipbits,&status) == 0 )
        printf("error clearing status for %s\n",addr->ipaddr);
    memset(addr,0,sizeof(*addr));
    addr->usock = -1;
    if ( rank > 0 )
        iguana_possible_peer(coin,ipaddr);
}
Пример #2
0
TWO_STRINGS(iguana,oneshot,activecoin,ipaddr)
{
    if ( coin != 0 && ipaddr != 0 )
    {
        iguana_possible_peer(coin,ipaddr);
        return(clonestr("{\"result\":\"addnode submitted\"}"));
    } else return(clonestr("{\"error\":\"addnode needs coin and ipaddr\"}"));
}
Пример #3
0
void iguana_gotaddr(struct iguana_info *coin,struct iguana_peer *addr,struct iguana_msgaddress *A)
{
    char ipaddr[64]; uint32_t ipbits;
    iguana_rwnum(0,&A->ip[12],sizeof(uint32_t),&ipbits);
    expand_ipbits(ipaddr,ipbits);
    iguana_possible_peer(coin,ipaddr);
    //printf("gotaddr.(%s)\n",ipaddr);
}
Пример #4
0
void iguana_gotaddr(struct iguana_info *coin,struct iguana_peer *addr,struct iguana_msgaddress *A)
{
    char ipaddr[64],ipport[64]; uint32_t ipbits; uint16_t port;
    iguana_rwnum(0,&A->ip[12],sizeof(uint32_t),&ipbits);
    iguana_rwnum(0,(void *)&A->port,sizeof(uint16_t),&port);
    expand_ipbits(ipaddr,ipbits);
    if ( port != 0 )
        sprintf(ipport,"%s:%d",ipaddr,port);
    iguana_possible_peer(coin,ipport);
    //printf("gotaddr.(%s:%d)\n",ipaddr,port);
}