コード例 #1
0
ファイル: http.c プロジェクト: awaysoft/apfree_wifidog
static int
_special_process(request *r, const char *mac, const char *redir_url)
{
	t_offline_client *o_client = NULL;

	
	if(_is_apple_captive(r->request.host)) {
		int interval = 0;
		LOCK_OFFLINE_CLIENT_LIST();
    	o_client = offline_client_list_find_by_mac(mac);
    	if(o_client == NULL) {
    		o_client = offline_client_list_add(r->clientAddr, mac);
    	} else {
			o_client->last_login = time(NULL);
			interval = o_client->last_login - o_client->first_login;
		}

		debug(LOG_INFO, "Into captive.apple.com hit_counts %d interval %d http version %d\n", 
				o_client->hit_counts, interval, r->request.version);
    	
		o_client->hit_counts++;

		if(o_client->client_type == 1 ) {
    		UNLOCK_OFFLINE_CLIENT_LIST();
			if(interval > 20 && r->request.version == HTTP_1_0) {
				fw_set_mac_temporary(mac, 0);	
				http_send_apple_redirect(r, redir_url);
			} else if(o_client->hit_counts > 2 && r->request.version == HTTP_1_0)
				http_send_apple_redirect(r, redir_url);
			else {
				http_send_redirect_to_auth(r, redir_url, "Redirect to login page");
			}
		} else {	
			o_client->client_type = 1;
			UNLOCK_OFFLINE_CLIENT_LIST();
			http_relay_wisper(r);
		}
		return 1;
	} 

	return 0;
}
コード例 #2
0
ファイル: http.c プロジェクト: feiying1460/apfree_wifidog
static int
_special_process(request *r, const char *mac, const char *redir_url)
{
	t_offline_client *o_client = NULL;

	LOCK_OFFLINE_CLIENT_LIST();
    o_client = offline_client_list_find_by_mac(mac);
    if(o_client == NULL) {
    	o_client = offline_client_list_add(r->clientAddr, mac);
    } else {
		o_client->last_login = time(NULL);
	}
    UNLOCK_OFFLINE_CLIENT_LIST();

	if(_is_apple_captive(r->request.host)) {
		unsigned int interval = time(NULL) - o_client->first_login;
		debug(LOG_INFO, "Into captive.apple.com hit_counts %d interval %d\n", o_client->hit_counts, interval);
		LOCK_OFFLINE_CLIENT_LIST();
    	o_client->hit_counts++;
		UNLOCK_OFFLINE_CLIENT_LIST();
		if(o_client->client_type == 1 ) {
			if(o_client->hit_counts < 5 && interval < 30 )
				http_send_js_redirect_ex(r, redir_url);
			else {
				http_send_apple_redirect(r, redir_url);
			}
		} else {	
			LOCK_OFFLINE_CLIENT_LIST();
			o_client->client_type = 1;
			UNLOCK_OFFLINE_CLIENT_LIST();
			http_send_js_redirect_ex(r, redir_url);
		}
		return 1;
	} 

	return 0;
}