void windows_refresh (string kind) { if (kind == "auto" && texmacs_time () < refresh_time) return; iterator<int> it= iterate (window_table); while (it->busy ()) { int id= it->next (); send_refresh (window_table[id], kind); #ifdef X11TEXMACS if (kind == "auto") refresh_size (window_table[id], false); #endif } if (kind == "auto") windows_delayed_refresh (1000000000); }
/** * @brief authenticated - called for all request from authenticated clients. * @param connection * @param ip_addr * @param mac * @param url * @param client * @return * * It's unsual to received request from clients which are already authed. * Happens when the user: * - clicked in multiple windows on "accept" -> redirect to origin - no checking * - when the user reloaded a splashpage -> redirect to origin * - when a user calls deny url -> deauth it */ static int authenticated(struct MHD_Connection *connection, const char *ip_addr, const char *mac, const char *url, t_client *client) { s_config *config = config_get_config(); const char *redirect_url; const char *host = NULL; char redirect_to_us[128]; MHD_get_connection_values(connection, MHD_HEADER_KIND, get_host_value_callback, &host); if (is_splashpage(host, url) || check_authdir_match(url, config->authdir)) { redirect_url = get_redirect_url(connection); /* TODO: what should we do when we get such request? */ if (redirect_url == NULL || strlen(redirect_url) == 0) return show_splashpage(connection, client); else return authenticate_client(connection, ip_addr, mac, redirect_url, client); } else if (check_authdir_match(url, config->denydir)) { auth_client_action(ip_addr, mac, AUTH_MAKE_DEAUTHENTICATED); snprintf(redirect_to_us, 128, "http://%s:%u/", config->gw_address, config->gw_port); return send_redirect_temp(connection, redirect_to_us); } /* check if this is an late request meaning the user tries to get the internet, but ended up here, * because the iptables rule came to late */ if (is_foreign_hosts(connection, host)) { /* might happen if the firewall rule isn't yet installed */ return send_refresh(connection); } /* user doesn't wants the splashpage or tried to auth itself */ return serve_file(connection, client, url); }
/* * Notify application and shutdown the TCP session. */ static void sess_shutdown(pj_tcp_session *sess, pj_status_t status) { pj_bool_t can_destroy = PJ_TRUE; PJ_LOG(4,(sess->obj_name, "Request to shutdown in state %s, cause:%d", state_names[sess->state], status)); if (sess->last_status == PJ_SUCCESS && status != PJ_SUCCESS) sess->last_status = status; switch (sess->state) { case PJ_TCP_STATE_NULL: break; case PJ_TCP_STATE_RESOLVING: if (sess->dns_async != NULL) { pj_dns_srv_cancel_query(sess->dns_async, PJ_FALSE); sess->dns_async = NULL; } break; case PJ_TCP_STATE_RESOLVED: break; case PJ_TCP_STATE_CONNECTING: /* We need to wait until connection complete */ sess->pending_destroy = PJ_TRUE; can_destroy = PJ_FALSE; break; case PJ_TCP_STATE_READY: /* Send REFRESH with LIFETIME=0 */ #if 0 can_destroy = PJ_FALSE; send_refresh(sess, 0); #endif break; case PJ_TCP_STATE_DISCONNECTING: can_destroy = PJ_FALSE; /* This may recursively call this function again with * state==PJ_TCP_STATE_DISCONNECTING. */ #if 0 send_refresh(sess, 0); #endif break; case PJ_TCP_STATE_DISCONNECTED: case PJ_TCP_STATE_DESTROYING: break; } if (can_destroy) { /* Schedule destroy */ pj_time_val delay = {0, 0}; pj_tcp_session_set_state(sess, PJ_TCP_STATE_DESTROYING); if (sess->timer.id != TIMER_NONE) { pj_timer_heap_cancel(sess->timer_heap, &sess->timer); sess->timer.id = TIMER_NONE; } sess->timer.id = TIMER_DESTROY; pj_timer_heap_schedule(sess->timer_heap, &sess->timer, &delay); } }