Changeset 799

Show
Ignore:
Timestamp:
10/10/05 02:06:47 (3 years ago)
Author:
aprilp
Message:

* Ability to run wifidog without an auth server (splash only).
* Does not allow (yet) to specify a custom splash/disclaimer, but will
forward to the portal of your choice if specified in the config (or
a generic one if none is specified).
Of course, using wifidog without an authentication server will not give
you statistics and all the rest of the cool features.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wifidog/ChangeLog

    r798 r799  
    11# $Header$ 
     22005-10-10 Philippe April <philippe@ilesansfil.org> 
     3        * Ability to run wifidog without an auth server (splash only). 
     4        * Does not allow (yet) to specify a custom splash/disclaimer, but will 
     5        forward to the portal of your choice if specified in the config (or 
     6        a generic one if none is specified). 
     7        Of course, using wifidog without an authentication server will not give 
     8        you statistics and all the rest of the cool features. 
     9 
    2102005-10-09 Philippe April <philippe@ilesansfil.org> 
    311        * Changed html pages, added info to wdctl status 
  • trunk/wifidog/src/conf.c

    r765 r799  
    7878        oAuthServPath, 
    7979        oAuthServMaxTries, 
     80    oPortal, 
    8081        oHTTPDMaxConn, 
    8182        oHTTPDName, 
     
    105106        { "authserver",         oAuthServer }, 
    106107        { "authservmaxtries",   oAuthServMaxTries }, 
     108        { "portal",             oPortal }, 
    107109        { "httpdmaxconn",       oHTTPDMaxConn }, 
    108110        { "httpdname",          oHTTPDName }, 
     
    149151        config.authserv_maxtries = DEFAULT_AUTHSERVMAXTRIES; 
    150152        config.httpdname = NULL; 
     153    config.portal = NULL; 
    151154        config.clienttimeout = DEFAULT_CLIENTTIMEOUT; 
    152155        config.checkinterval = DEFAULT_CHECKINTERVAL; 
     
    640643                                                        &linenum); 
    641644                                        break; 
     645                case oPortal: 
     646                    config.portal = safe_strdup(p1); 
     647                    break; 
    642648                                case oFirewallRuleSet: 
    643649                                        parse_firewall_ruleset(p1, fd, filename, &linenum); 
     
    752758{ 
    753759        config_notnull(config.gw_interface, "GatewayInterface"); 
    754         config_notnull(config.auth_servers, "AuthServer"); 
    755760 
    756761        if (missing_parms) { 
  • trunk/wifidog/src/conf.h

    r765 r799  
    116116                                     connection attempts before abandoning */ 
    117117    t_auth_serv *auth_servers;  /**< @brief Auth servers list */ 
     118    char *portal;           /**< @brief portal file or url to show */ 
    118119    char *httpdname;            /**< @brief Name the web server will return when 
    119120                                     replying to a request */ 
  • trunk/wifidog/src/firewall.c

    r765 r799  
    242242        /* Ping the client, if he responds it'll keep activity on the link */ 
    243243        icmp_ping(ip); 
    244         /* Update the counters on the remote server */ 
    245         auth_server_request(&authresponse, REQUEST_TYPE_COUNTERS, ip, mac, token, incoming, outgoing); 
     244        /* Update the counters on the remote server only if we have an auth server */ 
     245        if (config->auth_servers != NULL) { 
     246            auth_server_request(&authresponse, REQUEST_TYPE_COUNTERS, ip, mac, token, incoming, outgoing); 
     247        } 
    246248            LOCK_CLIENT_LIST(); 
    247249         
     
    253255                                <= time(NULL)) { 
    254256                /* Timing out user */ 
    255                 debug(LOG_INFO, "%s - Inactive for %ld seconds, removing client and denying in firewall", p1->ip, config->checkinterval * config->clienttimeout); 
     257                debug(LOG_INFO, "%s - Inactive for %ld seconds, removing client and denying in firewall", 
     258                        p1->ip, config->checkinterval * config->clienttimeout); 
    256259                fw_deny(p1->ip, p1->mac, p1->fw_connection_state); 
    257260                client_list_delete(p1); 
    258261 
    259                 /* Advertise the logout */ 
     262                /* Advertise the logout if we have an auth server */ 
     263                if (config->auth_servers != NULL) { 
    260264                                        UNLOCK_CLIENT_LIST(); 
    261265                                        auth_server_request(&authresponse, REQUEST_TYPE_LOGOUT, ip, mac, token, 0, 0); 
    262266                                        LOCK_CLIENT_LIST(); 
    263            
    264                                else { 
     267               
     268            } else { 
    265269                /* 
    266270                 * This handles any change in 
     
    268272                 * to change the status of a 
    269273                 * user while he's connected 
     274                 * 
     275                 * Only run if we have an auth server 
     276                 * configured! 
    270277                 */ 
    271                 switch (authresponse.authcode) { 
    272                     case AUTH_DENIED: 
    273                         debug(LOG_NOTICE, "%s - Denied. Removing client and firewall rules", p1->ip); 
    274                         fw_deny(p1->ip, p1->mac, p1->fw_connection_state); 
    275                         client_list_delete(p1); 
    276                         break; 
    277  
    278                     case AUTH_VALIDATION_FAILED: 
    279                         debug(LOG_NOTICE, "%s - Validation timeout, now denied. Removing client and firewall rules", p1->ip); 
    280                         fw_deny(p1->ip, p1->mac, p1->fw_connection_state); 
    281                         client_list_delete(p1); 
    282                         break; 
    283  
    284                     case AUTH_ALLOWED: 
    285                         if (p1->fw_connection_state != FW_MARK_KNOWN) { 
    286                             debug(LOG_INFO, "%s - Access has changed to allowed, refreshing firewall and clearing counters", p1->ip); 
     278                if (config->auth_servers != NULL) { 
     279                    switch (authresponse.authcode) { 
     280                        case AUTH_DENIED: 
     281                            debug(LOG_NOTICE, "%s - Denied. Removing client and firewall rules", p1->ip); 
    287282                            fw_deny(p1->ip, p1->mac, p1->fw_connection_state); 
    288                             p1->fw_connection_state = FW_MARK_KNOWN; 
    289                             p1->counters.incoming = p1->counters.outgoing = p1->counters.incoming_history = p1->counters.outgoing_history = 0; 
    290                             fw_allow(p1->ip, p1->mac, p1->fw_connection_state); 
    291                         } 
    292                         break; 
    293  
    294                     case AUTH_VALIDATION: 
    295                         /* 
    296                          * Do nothing, user 
    297                          * is in validation 
    298                          * period 
    299                          */ 
    300                         debug(LOG_INFO, "%s - User in validation period", p1->ip); 
    301                         break; 
    302  
    303                                                   case AUTH_ERROR: 
    304                                                                 debug(LOG_WARNING, "Error communicating with auth server - leaving %s as-is for now", p1->ip); 
    305                                                                 break; 
    306  
    307                     default: 
    308                         debug(LOG_DEBUG, "I do not know about authentication code %d", authresponse.authcode); 
    309                         break; 
     283                            client_list_delete(p1); 
     284                            break; 
     285 
     286                        case AUTH_VALIDATION_FAILED: 
     287                            debug(LOG_NOTICE, "%s - Validation timeout, now denied. Removing client and firewall rules", p1->ip); 
     288                            fw_deny(p1->ip, p1->mac, p1->fw_connection_state); 
     289                            client_list_delete(p1); 
     290                            break; 
     291 
     292                        case AUTH_ALLOWED: 
     293                            if (p1->fw_connection_state != FW_MARK_KNOWN) { 
     294                                debug(LOG_INFO, "%s - Access has changed to allowed, refreshing firewall and clearing counters", p1->ip); 
     295                                fw_deny(p1->ip, p1->mac, p1->fw_connection_state); 
     296                                p1->fw_connection_state = FW_MARK_KNOWN; 
     297                                p1->counters.incoming = p1->counters.outgoing = 0; 
     298                                fw_allow(p1->ip, p1->mac, p1->fw_connection_state); 
     299                            } 
     300                            break; 
     301 
     302                        case AUTH_VALIDATION: 
     303                            /* 
     304                             * Do nothing, user 
     305                             * is in validation 
     306                             * period 
     307                             */ 
     308                            debug(LOG_INFO, "%s - User in validation period", p1->ip); 
     309                            break; 
     310 
     311                              case AUTH_ERROR: 
     312                                    debug(LOG_WARNING, "Error communicating with auth server - leaving %s as-is for now", p1->ip); 
     313                                    break; 
     314 
     315                        default: 
     316                            debug(LOG_DEBUG, "I do not know about authentication code %d", authresponse.authcode); 
     317                            break; 
     318                    } 
    310319                } 
    311320            } 
  • trunk/wifidog/src/gateway.c

    r765 r799  
    7878/* from client_list.c */ 
    7979extern pthread_mutex_t client_list_mutex; 
     80 
     81/* Time when wifidog started  */ 
     82time_t started_time = 0; 
    8083 
    8184/* Appends -x, the current PID, and NULL to restartargv 
     
    264267{ 
    265268        static  pthread_mutex_t sigterm_mutex = PTHREAD_MUTEX_INITIALIZER; 
     269        s_config *config = config_get_config(); 
    266270 
    267271        debug(LOG_INFO, "Handler for termination caught signal %d", s); 
     
    287291                pthread_kill(tid_fw_counter, SIGKILL); 
    288292        } 
    289         if (tid_ping) { 
     293        if (config->auth_servers != NULL && tid_ping) { 
    290294                debug(LOG_INFO, "Explicitly killing the ping thread"); 
    291295                pthread_kill(tid_ping, SIGKILL); 
     
    360364        request *r; 
    361365        void **params; 
     366    FILE *fh; 
     367 
     368    /* Set the time when wifidog started */ 
     369        if (!started_time) { 
     370                debug(LOG_INFO, "Setting started_time"); 
     371                started_time = time(NULL); 
     372        } 
     373        else if (started_time < MINIMUM_STARTED_TIME) { 
     374                debug(LOG_WARNING, "Detected possible clock skew - re-setting started_time"); 
     375                started_time = time(NULL); 
     376        } 
    362377 
    363378        /* If we don't have the Gateway IP address, get it. Can't fail. */ 
     
    394409        httpdAddCContent(webserver, "/wifidog", "status", 0, NULL, http_callback_status); 
    395410        httpdAddCContent(webserver, "/wifidog", "auth", 0, NULL, http_callback_auth); 
     411        httpdAddCContent(webserver, "/wifidog", "splash", 0, NULL, http_callback_splash); 
     412        httpdAddCContent(webserver, "/wifidog", "portal", 0, NULL, http_callback_portal); 
     413 
    396414        httpdAddC404Content(webserver, http_callback_404); 
    397415 
     
    401419        fw_init(); 
    402420 
    403         /* start clean up thread */ 
     421        /* Start clean up thread */ 
    404422        result = pthread_create(&tid_fw_counter, NULL, (void *)thread_client_timeout_check, NULL); 
    405423        if (result != 0) { 
    406                debug(LOG_ERR, "FATAL: Failed to create a new thread (fw_counter) - exiting"); 
    407                termination_handler(0); 
     424            debug(LOG_ERR, "FATAL: Failed to create a new thread (fw_counter) - exiting"); 
     425            termination_handler(0); 
    408426        } 
    409427        pthread_detach(tid_fw_counter); 
    410428 
    411         /* start control thread */ 
     429        /* Start control thread */ 
    412430        result = pthread_create(&tid, NULL, (void *)thread_wdctl, (void *)safe_strdup(config->wdctl_sock)); 
    413431        if (result != 0) { 
     
    417435        pthread_detach(tid); 
    418436         
    419         /* start heartbeat thread */ 
    420         result = pthread_create(&tid_ping, NULL, (void *)thread_ping, NULL); 
    421         if (result != 0) { 
    422                 debug(LOG_ERR, "FATAL: Failed to create a new thread (ping) - exiting"); 
    423                 termination_handler(0); 
    424         } 
    425         pthread_detach(tid_ping); 
     437        /* Start heartbeat thread, only if we have an auth server set */ 
     438        if (config->auth_servers != NULL) { 
     439            result = pthread_create(&tid_ping, NULL, (void *)thread_ping, NULL); 
     440            if (result != 0) { 
     441                    debug(LOG_ERR, "FATAL: Failed to create a new thread (ping) - exiting"); 
     442                    termination_handler(0); 
     443            } 
     444            pthread_detach(tid_ping); 
     445    } 
    426446         
    427447        debug(LOG_NOTICE, "Waiting for connections"); 
  • trunk/wifidog/src/http.c

    r798 r799  
    6161        int             port; 
    6262        s_config        *config = config_get_config(); 
    63         t_auth_serv     *auth_server = get_auth_server(); 
    64  
    65         if (auth_server->authserv_use_ssl) { 
    66                 protocol = "https"; 
    67                 port = auth_server->authserv_ssl_port; 
    68         } else { 
    69                 protocol = "http"; 
    70                 port = auth_server->authserv_http_port; 
    71         } 
    72  
    73         memset(tmp_url, 0, sizeof(tmp_url)); 
    74         snprintf(tmp_url, (sizeof(tmp_url) - 1), "http://%s%s", 
    75                         r->request.host, 
    76                         r->request.path); 
    77         url = httpdUrlEncode(tmp_url); 
    78  
    79         if (!is_online()) { 
    80                 /* The internet connection is down at the moment  - apologize and do not redirect anywhere */ 
    81                 http_wifidog_header(r, "<h2>Uh oh! Internet access unavailable</h2>"); 
    82                 httpdOutput(r, "<p>We apologize, but it seems that the internet connection that powers this hotspot is temporarily unavailable.</p>"); 
    83                 httpdOutput(r, "<p>If at all possible, please notify the owners of this hotspot that the internet connection is out of service.</p>"); 
    84                 httpdOutput(r, "<p>The maintainers of this network are aware of this disruption.  We hope that this situation will be resolved soon.</p>"); 
    85                 httpdPrintf(r, "<p>In a while please <a href='%s'>click here</a> to try your request again.</p>", tmp_url); 
    86                 http_wifidog_footer(r); 
    87                 debug(LOG_INFO, "Sent %s an apology since I am not online - no point sending them to auth server", r->clientAddr); 
    88         } 
    89         else if (!is_auth_online()) { 
    90                 /* The auth server is down at the moment - apologize and do not redirect anywhere */ 
    91                 http_wifidog_header(r, "<h2>Uh oh! Login screen unavailable</h2>"); 
    92                 httpdOutput(r, "<p>We apologize, but it seems that we are currently unable to re-direct you to the login screen.</p>"); 
    93                 httpdOutput(r, "<p>The maintainers of this network are aware of this disruption.  We hope that this situation will be resolved soon.</p>"); 
    94                 httpdPrintf(r, "<p>In a couple of minutes please <a href='%s'>click here</a> to try your request again.</p>", tmp_url); 
    95                 http_wifidog_footer(r); 
    96                 debug(LOG_INFO, "Sent %s an apology since auth server not online - no point sending them to auth server", r->clientAddr); 
    97         } 
    98         else { 
    99                 /* Re-direct them to auth server */ 
    100                 safe_asprintf(&newlocation, "Location: %s://%s:%d%slogin?gw_address=%s&gw_port=%d&gw_id=%s&url=%s", 
    101                         protocol, 
    102                         auth_server->authserv_hostname, 
    103                         port, 
    104                         auth_server->authserv_path, 
    105                         config->gw_address, 
    106                         config->gw_port,  
    107                         config->gw_id, 
    108                         url); 
    109                 httpdSetResponse(r, "307 Please authenticate yourself here\n"); 
    110                 httpdAddHeader(r, newlocation); 
    111                 http_wifidog_header(r, "Redirection"); 
    112                 httpdPrintf(r, "Please <a href='%s://%s:%d%slogin?gw_address=%s&gw_port=%d&gw_id=%s&url=%s'>click here</a> to login", 
    113                                 protocol, 
    114                                 auth_server->authserv_hostname, 
    115                                 port, 
    116                                 auth_server->authserv_path, 
    117                                 config->gw_address,  
    118                                 config->gw_port, 
    119                                 config->gw_id, 
    120                                 url); 
    121                 http_wifidog_footer(r); 
    122                 debug(LOG_INFO, "Captured %s requesting [%s] and re-directed them to login page", r->clientAddr, url); 
    123                 free(newlocation); 
    124         } 
    125  
    126         free(url); 
     63 
     64    memset(tmp_url, 0, sizeof(tmp_url)); 
     65    snprintf(tmp_url, (sizeof(tmp_url) - 1), "http://%s%s", 
     66            r->request.host, 
     67            r->request.path); 
     68    url = httpdUrlEncode(tmp_url); 
     69 
     70    if (config->auth_servers == NULL) { 
     71        /* Redirect to splash page, no authentication servers exist */ 
     72 
     73        safe_asprintf(&newlocation, "Location: http://%s:%d/wifidog/splash", 
     74            config->gw_address, 
     75            config->gw_port); 
     76 
     77        httpdSetResponse(r, "307 Please visit here\n"); 
     78        httpdAddHeader(r, newlocation); 
     79        http_wifidog_header(r, "Redirection"); 
     80        httpdPrintf(r, "Please <a href='http://%s:%d/wifidog/splash'>click here</a> to login", 
     81            config->gw_address, 
     82            config->gw_port); 
     83        http_wifidog_footer(r); 
     84        debug(LOG_INFO, "Captured %s requesting [%s] and re-directed them to splash page", r->clientAddr, url); 
     85        free(newlocation); 
     86 
     87        http_wifidog_footer(r); 
     88        debug(LOG_INFO, "Sent %s the splash page", r->clientAddr); 
     89    } else { 
     90 
     91        t_auth_serv     *auth_server = get_auth_server(); 
     92 
     93        if (auth_server->authserv_use_ssl) { 
     94            protocol = "https"; 
     95            port = auth_server->authserv_ssl_port; 
     96        } else { 
     97            protocol = "http"; 
     98            port = auth_server->authserv_http_port; 
     99        } 
     100 
     101        if (!is_online()) { 
     102            /* The internet connection is down at the moment  - apologize and do not redirect anywhere */ 
     103            http_wifidog_header(r, "<h3>Internet access unavailable</h3>"); 
     104            httpdOutput(r, "<p>We apologize, but it seems that the internet connection that powers this hotspot is temporarily unavailable.</p>"); 
     105            httpdOutput(r, "<p>If at all possible, please notify the owners of this hotspot that the internet connection is out of service.</p>"); 
     106            httpdOutput(r, "<p>The maintainers of this network are aware of this disruption.  We hope that this situation will be resolved soon.</p>"); 
     107            httpdPrintf(r, "<p>In a while please <a href='%s'>click here</a> to try your request again.</p>", tmp_url); 
     108            http_wifidog_footer(r); 
     109            debug(LOG_INFO, "Sent %s an apology since I am not online - no point sending them to auth server", r->clientAddr); 
     110        } 
     111        else if (!is_auth_online()) { 
     112            /* The auth server is down at the moment - apologize and do not redirect anywhere */ 
     113            http_wifidog_header(r, "<h3>Login screen unavailable</h3>"); 
     114            httpdOutput(r, "<p>We apologize, but it seems that we are currently unable to re-direct you to the login screen.</p>"); 
     115            httpdOutput(r, "<p>The maintainers of this network are aware of this disruption.  We hope that this situation will be resolved soon.</p>"); 
     116            httpdPrintf(r, "<p>In a couple of minutes please <a href='%s'>click here</a> to try your request again.</p>", tmp_url); 
     117            http_wifidog_footer(r); 
     118            debug(LOG_INFO, "Sent %s an apology since auth server not online - no point sending them to auth server", r->clientAddr); 
     119        } 
     120        else { 
     121            /* Re-direct them to auth server */ 
     122            safe_asprintf(&newlocation, "Location: %s://%s:%d%slogin?gw_address=%s&gw_port=%d&gw_id=%s&url=%s", 
     123                protocol, 
     124                auth_server->authserv_hostname, 
     125                port, 
     126                auth_server->authserv_path, 
     127                config->gw_address, 
     128                config->gw_port,  
     129                config->gw_id, 
     130                url); 
     131            httpdSetResponse(r, "307 Please authenticate yourself here\n"); 
     132            httpdAddHeader(r, newlocation); 
     133            http_wifidog_header(r, "Redirection"); 
     134            httpdPrintf(r, "Please <a href='%s://%s:%d%slogin?gw_address=%s&gw_port=%d&gw_id=%s&url=%s'>click here</a> to login", 
     135                    protocol, 
     136                    auth_server->authserv_hostname, 
     137                    port, 
     138                    auth_server->authserv_path, 
     139                    config->gw_address,  
     140                    config->gw_port, 
     141                    config->gw_id, 
     142                    url); 
     143            http_wifidog_footer(r); 
     144            debug(LOG_INFO, "Captured %s requesting [%s] and re-directed them to login page", r->clientAddr, url); 
     145            free(newlocation); 
     146        } 
     147 
     148            free(url); 
     149    } 
    127150} 
    128151 
     
    156179} 
    157180 
     181void 
     182http_callback_splash(httpd *webserver, request *r) 
     183{ 
     184        char * status = NULL; 
     185        httpVar * url; 
     186 
     187        status = get_status_text(); 
     188        http_wifidog_header(r, "Disclaimer"); 
     189        httpdOutput(r, "<p>This hotspot offers Free internet access!</p>"); 
     190        httpdOutput(r, "<p>By clicking ACCEPT, you agree that you will respect these WiFi Do's and Don'ts:</p>"); 
     191    httpdOutput(r, "<ul>\n"); 
     192    httpdOutput(r, "<li>Respect the venue's bandwidth. Don't download too many large files.\n"); 
     193    httpdOutput(r, "<li>Make Purchases and Tip.\n"); 
     194    httpdOutput(r, "<li>If it's a busy place, don't take up too much space.\n"); 
     195    httpdOutput(r, "<li>Turn down your sound or use headphones.\n"); 
     196    httpdOutput(r, "<li>Share a table.\n"); 
     197    httpdOutput(r, "<li>Thank the staff or management - let them know you appreciate the WiFi.\n"); 
     198    httpdOutput(r, "<li>If it's busy - don't overstay your welcome.\n"); 
     199    httpdOutput(r, "<li>Help others who are having trouble getting on the network.\n"); 
     200    httpdOutput(r, "<li>Remember that the WiFi is complimentary. If it doesn't work, let the staff know. Be patient.\n"); 
     201    httpdOutput(r, "</ul>\n"); 
     202        if ((url = httpdGetVariableByName(r, "url"))) { 
     203            httpdPrintf(r, "<a href=\"/wifidog/auth?url=%s\">ACCEPT</a>", url->value); 
     204    } else { 
     205            httpdOutput(r, "<a href=\"/wifidog/auth\">ACCEPT</a>"); 
     206    } 
     207 
     208        http_wifidog_footer(r); 
     209        free(status); 
     210} 
     211 
     212void 
     213http_callback_portal(httpd *webserver, request *r) 
     214{ 
     215        char * status = NULL; 
     216 
     217        status = get_status_text(); 
     218        http_wifidog_header(r, "Enjoy!"); 
     219        httpdOutput(r, "<p>Don't forget, socialize and discuss with others! (you're not at home, enjoy the place and people!)</p>"); 
     220        http_wifidog_footer(r); 
     221        free(status); 
     222} 
     223 
    158224void  
    159225http_callback_auth(httpd *webserver, request *r) 
    160226{ 
     227        s_config        *config = config_get_config(); 
    161228        t_client        *client; 
    162229        httpVar * token; 
    163230        char    *mac; 
     231    char    *newlocation; 
    164232 
    165233        if ((token = httpdGetVariableByName(r, "token"))) { 
     
    188256                        free(mac); 
    189257                } 
     258        } else if (config->auth_servers == NULL) { 
     259        /* No authentication server is configured, we do not expect a token 
     260         * auth right away */ 
     261                if (!(mac = arp_get(r->clientAddr))) { 
     262                        /* We could not get their MAC address */ 
     263                        debug(LOG_ERR, "Failed to retrieve MAC address for ip %s", r->clientAddr); 
     264                        http_wifidog_header(r, "WiFiDog Error"); 
     265                        httpdOutput(r, "Failed to retrieve your MAC address"); 
     266                        http_wifidog_footer(r); 
     267                } else { 
     268                        /* We have their MAC address */ 
     269 
     270                        LOCK_CLIENT_LIST(); 
     271                         
     272                        if ((client = client_list_find(r->clientAddr, mac)) == NULL) { 
     273                                debug(LOG_DEBUG, "New client ip=%s mac=%s", r->clientAddr, mac); 
     274                                client_list_append(r->clientAddr, mac, "SpLaShOnLy"); 
     275                        } else { 
     276                                debug(LOG_DEBUG, "Node for %s already exists", client->ip); 
     277                        } 
     278 
     279            /* Find the client in the list once it's created (not very useful) */ 
     280                        client = client_list_find(r->clientAddr, mac); 
     281 
     282            debug(LOG_INFO, "ALLOWING %s [%s], the user clicked the accept button", client->ip, client->mac); 
     283            client->fw_connection_state = FW_MARK_KNOWN; 
     284            fw_allow(client->ip, client->mac, FW_MARK_KNOWN); 
     285 
     286                        UNLOCK_CLIENT_LIST(); 
     287 
     288                        free(mac); 
     289 
     290            httpdSetResponse(r, "307 Redirect to portal\n"); 
     291            /* If we have a portal url specified in the configuration, 
     292               forward to it, otherwise forward to /wifidog/portal */ 
     293            if (config->portal && strncmp(config->portal, "http://", strlen("http://")) == 0) { 
     294                debug(LOG_INFO, "Redirecting to portal at %s", config->portal); 
     295                safe_asprintf(&newlocation, "Location: %s", 
     296                    config->portal 
     297                ); 
     298 
     299                httpdAddHeader(r, newlocation); 
     300                http_wifidog_header(r, "Redirection"); 
     301 
     302                httpdPrintf(r, "Please <a href='%s'>click here</a> for the portal", 
     303                    config->portal); 
     304            } else { 
     305                safe_asprintf(&newlocation, "Location: http://%s:%d/wifidog/portal", 
     306                    config->gw_address, 
     307                    config->gw_port); 
     308                debug(LOG_INFO, "Redirecting to local portal"); 
     309 
     310                httpdAddHeader(r, newlocation); 
     311                http_wifidog_header(r, "Redirection"); 
     312 
     313                httpdPrintf(r, "Please <a href='http://%s:%d/wifidog/portal'>click here</a> for the portal", 
     314                    config->gw_address,  
     315                    config->gw_port); 
     316            } 
     317 
     318            http_wifidog_footer(r); 
     319            free(newlocation); 
     320                } 
    190321        } else { 
    191322                /* They did not supply variable "token" */ 
  • trunk/wifidog/src/http.h

    r479 r799  
    3939void http_callback_status(httpd *webserver, request *r); 
    4040/**@brief Callback for libhttpd */ 
     41void http_callback_splash(httpd *webserver, request *r); 
     42/**@brief Callback for libhttpd */ 
     43void http_callback_portal(httpd *webserver, request *r); 
     44/**@brief Callback for libhttpd */ 
    4145void http_callback_auth(httpd *webserver, request *r); 
    4246 
  • trunk/wifidog/src/ping_thread.c

    r631 r799  
    5252static void ping(void); 
    5353 
    54 time_t started_time = 0
     54extern time_t started_time
    5555 
    5656/** Launches a thread that periodically checks in with the wifidog auth server to perform heartbeat function. 
     
    6565        struct  timespec        timeout; 
    6666         
    67         if (!started_time) { 
    68                 debug(LOG_INFO, "Setting started_time"); 
    69                 started_time = time(NULL); 
    70         } 
    71         else if (started_time < MINIMUM_STARTED_TIME) { 
    72                 debug(LOG_WARNING, "Detected possible clock skew - re-setting started_time"); 
    73                 started_time = time(NULL); 
    74         } 
    75  
    7667        while (1) { 
    7768                /* Make sure we check the servers at the very begining */ 
  • trunk/wifidog/src/util.c

    r798 r799  
    317317        unsigned long int uptime = 0; 
    318318        unsigned int days = 0, hours = 0, minutes = 0, seconds = 0; 
     319     t_trusted_mac *p; 
    319320         
    320321        len = 0; 
     
    394395                first = first->next; 
    395396        } 
    396          
     397 
    397398        UNLOCK_CLIENT_LIST(); 
     399 
     400    config = config_get_config(); 
    398401     
    399         snprintf((buffer + len), (sizeof(buffer) - len), "\nAuthentication servers:\n"); 
    400         len = strlen(buffer); 
    401  
    402         LOCK_CONFIG(); 
    403  
    404         config = config_get_config(); 
    405         for (auth_server = config->auth_servers; auth_server != NULL; auth_server = auth_server->next) { 
    406                 snprintf((buffer + len), (sizeof(buffer) - len), "  Host: %s (%s)\n", auth_server->authserv_hostname, auth_server->last_ip); 
    407                 len = strlen(buffer); 
    408         } 
    409  
    410         UNLOCK_CONFIG(); 
     402    if (config->trustedmaclist != NULL) { 
     403        snprintf((buffer + len), (sizeof(buffer) - len), "\nTrusted MAC addresses:\n"); 
     404        len = strlen(buffer); 
     405 
     406        for (p = config->trustedmaclist; p != NULL; p = p->next) { 
     407            snprintf((buffer + len), (sizeof(buffer) - len), "  %s\n", p->mac); 
     408            len = strlen(buffer); 
     409        } 
     410    } 
     411 
     412    if (config->auth_servers != NULL) { 
     413        snprintf((buffer + len), (sizeof(buffer) - len), "\nAuthentication servers:\n"); 
     414        len = strlen(buffer); 
     415 
     416        LOCK_CONFIG(); 
     417 
     418        for (auth_server = config->auth_servers; auth_server != NULL; auth_server = auth_server->next) { 
     419            snprintf((buffer + len), (sizeof(buffer) - len), "  Host: %s (%s)\n", auth_server->authserv_hostname, auth_server->last_ip); 
     420            len = strlen(buffer); 
     421        } 
     422 
     423        UNLOCK_CONFIG(); 
     424    } else { 
     425        snprintf((buffer + len), (sizeof(buffer) - len), "\nRunning in splash only mode\n"); 
     426        len = strlen(buffer); 
     427    } 
    411428 
    412429        return safe_strdup(buffer); 
  • trunk/wifidog/wifidog.conf

    r763 r799  
    7979#    Path / 
    8080#} 
     81 
     82# Parameter: Portal 
     83# Default: none 
     84# Optional 
     85# 
     86# Set this to a URL for your portal, if you run without an auth server 
     87# Portal http://www.ilesansfil.org/ 
    8188 
    8289# Parameter: Daemon