示例#1
0
static int hash_presence_callback(const char *hexhash, unsigned int index, int code, void *context)
{
    hash_presence_ctx_t *ctx = (hash_presence_ctx_t*)context;
    sx_hashfs_t *h = ctx->h;
    sx_nodelist_t *nodes;
    sx_hash_t hash;
    if (code != 200) {
	if (code < 0)
	    WARN("Failed to query hash %.*s: %s", 40, hexhash, sx_hashfs_geterrmsg(h));
	if (hex2bin(hexhash, SXI_SHA1_TEXT_LEN, hash.b, sizeof(hash.b))) {
	    WARN("hex2bin failed on %.*s", 40, hexhash);
	    return -1;
	}
	nodes = sx_hashfs_putfile_hashnodes(h, &hash);
	if (!nodes) {
	    WARN("hashnodes failed");
	    return -1;
	}
	if(ctx->comma)
	    CGI_PUTC(',');
	else
	    ctx->comma |= 1;
        DEBUG("Requesting from user: #%.*s#", 40, hexhash);
	send_qstring_hash(&hash);
	CGI_PUTC(':');
	/* Although there is no danger in doing so, nodes SHOULD NOT be randomized:
	 * hdist already does a pretty good job here */
	send_nodes(nodes);
	sx_nodelist_delete(nodes);
    }
    send_keepalive();
    return 0;
}
示例#2
0
static void verify_challenge(CcnetProcessor *processor, 
                             char *code, char *code_msg,
                             char *content, int clen)
{
    CcnetKeepaliveProcPriv *priv = GET_PRIV (processor);
    ccnet_debug ("[Conn] Verify Peer Challenge\n");

    if (clen != 40 || memcmp(content, priv->random_buf, 40) != 0) {
        ccnet_debug ("[Conn] Peer Challenge failed\n");
        close_processor(processor);
        return;
    }

    CcnetUser *user = ccnet_peer_get_user(processor->peer);
    if (!user) {
        ccnet_debug ("[Conn] No user for this peer, go to auth done\n");
        processor->peer->auth_done = 1;
        g_signal_emit_by_name (processor->peer, "auth-done");
        
        send_keepalive (processor);
        reset_timeout (processor);
        return;
    }

    if (user->pubkey)
        send_challenge_user(processor, user);
    else
        get_pubkey_user(processor);
}
示例#3
0
int svrapp::on_timer(int event, int interval, void * ptr){
	switch(event){
	case ev_keepalive_timer:
		send_keepalive();
		break;
	case ev_report_server_infor_timer:
		report_to_web();
		break;
	}
	add_timer(event, interval, ptr);
	return 0;
}
示例#4
0
int upgradeapp::on_timer(int event, int interval, void * ptr){
	switch(event){
		case ev_keepalive_timer:
			send_keepalive();
			break;

		case ev_plan_poll_timer:
			plan_poll();
			break;
	}
	add_timer(event, interval, ptr);
	return 0;
}
示例#5
0
static int timeout_cb(CcnetProcessor *processor)
{
    /* Since we set MAX_NUM_RETRY to 1, actually, there will be no retry. */
    if (processor->state == INIT) {
        if (++processor->num_retry < MAX_NUM_RETRY)
        {
            send_request(processor);
            return TRUE;
        } else {
            close_processor_in_timeout(processor);
            return FALSE;
        }
    }

    if (processor->state == WAIT_PUBKEY || processor->state == WAIT_CHALLENGE)
    {
        close_processor_in_timeout(processor);
        return FALSE;        
    }

    if (processor->state == WAIT_KEEPALIVE) {
        if (++processor->num_retry < MAX_NUM_RETRY) {
            send_keepalive (processor);
            return TRUE;
        } else {
            close_processor_in_timeout(processor);
            return FALSE;
        }
    }

    if (processor->state == FULL) {
        processor->num_retry = 0;
        send_keepalive(processor);
        return TRUE;
    }

    return FALSE;
}
示例#6
0
int svrapp::on_timer(int event, int interval, void * ptr){
	switch(event){
	case ev_keepalive_timer:
		send_keepalive();
		break;
		
	case ev_motiondetect_timer:
		poll_alarm();
		break;
	}

	add_timer(event, interval, ptr);
	return 0;
}
示例#7
0
bool cli_send_keepalive(struct cli_state *cli)
{
        if (cli->fd == -1) {
                DEBUG(3, ("cli_send_keepalive: fd == -1\n"));
                return false;
        }
        if (!send_keepalive(cli->fd)) {
                close(cli->fd);
                cli->fd = -1;
                DEBUG(0,("Error sending keepalive packet to client.\n"));
                return false;
        }
        return true;
}
示例#8
0
static void send_server_keepalive(void **private_data_pointer) 
{
	/* also send a keepalive to the password server if its still
	   connected */
	if (private_data_pointer) {
		struct cli_state *cli = (struct cli_state *)(*private_data_pointer);
		if (cli && cli->initialised) {
			if (!send_keepalive(cli->fd)) {
				DEBUG( 2, ( "send_server_keepalive: password server keepalive failed.\n"));
				cli_shutdown(cli);
				*private_data_pointer = NULL;
			}
		}
	}
}
示例#9
0
文件: clientgen.c 项目: jophxy/samba
BOOL cli_send_keepalive(struct cli_state *cli)
{
        if (cli->fd == -1) {
                DEBUG(3, ("cli_send_keepalive: fd == -1\n"));
                return False;
        }
        if (!send_keepalive(cli->fd)) {
                close(cli->fd);
                cli->fd = -1;
                DEBUG(0,("Error sending keepalive packet to client. (%s)\n",
					strerror(errno) ));
                return False;
        }
        return True;
}
示例#10
0
static void verify_challenge_user(CcnetProcessor *processor, 
                                  char *code, char *code_msg,
                                  char *content, int clen)
{
    CcnetKeepaliveProcPriv *priv = GET_PRIV (processor);
    ccnet_debug ("[Conn] Verify User Challenge\n");

    if (clen != 40 || memcmp(content, priv->random_buf, 40) != 0) {
        ccnet_debug ("[Keepalive] Challenge failed\n");
        close_processor(processor);
        return;
    }

    processor->peer->auth_done = 1;
    g_signal_emit_by_name (processor->peer, "auth-done");

    send_keepalive (processor);
    reset_timeout (processor);
}
示例#11
0
int socks_activate_peer(SocksQueue_t *sq)
{
   OcatPeer_t *peer;

   insert_peer(sq->fd, sq, time(NULL) - sq->connect_time);

   // Send first keepalive immediately
   lock_peers();
   if ((peer = search_peer(&sq->addr)))
      lock_peer(peer);
   else
      log_msg(LOG_EMERG, "newly inserted peer not found, fd = %d", sq->fd);
   unlock_peers();
   if (peer)
   {
      send_keepalive(peer);
      unlock_peer(peer);
   }

   return 0;
}