Esempio n. 1
0
static void auto_retry(redsocks_client * client, int updcache)
{
	autoproxy_client * aclient = (void*)(client + 1) + client->instance->relay_ss->payload_len;

	if (aclient->state == AUTOPROXY_CONNECTED)
		bufferevent_disable(client->client, EV_READ| EV_WRITE); 
	/* drop relay and update state, then retry with specified relay */
	if (updcache)
	{
		/* only add IP to cache when the IP is not in cache */
		if (get_addr_time_in_cache(&client->destaddr) == NULL)
		{
			add_addr_to_cache(&client->destaddr);
			redsocks_log_error(client, LOG_DEBUG, "ADD IP to cache: %s", 
							inet_ntoa(client->destaddr.sin_addr));
		}
	}
	auto_drop_relay(client);

	// restore callbacks for ordinary client.
	bufferevent_setcb(client->client, NULL, NULL, client->client->errorcb, client);
	// enable reading to handle EOF from client
	bufferevent_enable(client->client, EV_READ); 
	/* connect to relay */
	if (client->instance->relay_ss->connect_relay)
		client->instance->relay_ss->connect_relay(client);
	else
		redsocks_connect_relay(client);
	// 
	if (EVBUFFER_LENGTH(client->client->input) && client->client->readcb)
		client->client->readcb(client->client, client);
}
Esempio n. 2
0
static void auto_retry(redsocks_client * client, int updcache)
{
	if (client->state == socks5_direct)
		bufferevent_disable(client->client, EV_READ| EV_WRITE); 
	/* drop relay and update state, then retry with socks5 relay */
	if (updcache)
	{
		add_addr_to_cache(&client->destaddr);
		redsocks_log_error(client, LOG_DEBUG, "ADD IP to cache: %x", client->destaddr.sin_addr.s_addr);
	}
	auto_drop_relay(client);
	client->state = socks5_new;
	auto_connect_relay(client); /* Retry SOCKS5 proxy relay */
}