Changeset 798

Show
Ignore:
Timestamp:
10/09/05 22:49:04 (3 years ago)
Author:
aprilp
Message:

Changed HTML pages and added stuff to wdctl status

Files:

Legend:

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

    r793 r798  
    11# $Header$ 
     22005-10-09 Philippe April <philippe@ilesansfil.org> 
     3        * Changed html pages, added info to wdctl status 
     4 
    252005-10-07 Philippe April <philippe@ilesansfil.org> 
    36        * Released 1.1.3_beta1 
  • trunk/wifidog/src/auth.c

    r490 r798  
    4747#include "firewall.h" 
    4848#include "client_list.h" 
     49#include "util.h" 
    4950 
    5051/* Defined in clientlist.c */ 
    5152extern  pthread_mutex_t client_list_mutex; 
     53 
     54/* Defined in util.c */ 
     55extern long served_this_session; 
    5256 
    5357/** Launches a thread that periodically checks if any of the connections has timed out 
     
    206210                client->fw_connection_state = FW_MARK_KNOWN; 
    207211                fw_allow(client->ip, client->mac, FW_MARK_KNOWN); 
     212        served_this_session++; 
    208213                safe_asprintf(&newlocation, "Location: %s://%s:%d%sportal/?gw_id=%s", 
    209214                        protocol, 
  • trunk/wifidog/src/http.c

    r506 r798  
    7979        if (!is_online()) { 
    8080                /* The internet connection is down at the moment  - apologize and do not redirect anywhere */ 
    81                 http_wifidog_header(r, "Uh oh! Internet access unavailable"); 
    82                 httpdOutput(r, "We apologize, but it seems that the internet connection that powers this hotspot is temporarily unavailable."); 
    83                 httpdOutput(r, "<p>"); 
    84                 httpdOutput(r, "If at all possible, please notify the owners of this hotspot that the internet connection is out of service."); 
    85                 httpdOutput(r, "<p>"); 
    86                 httpdOutput(r, "The maintainers of this network are aware of this disruption.  We hope that this situation will be resolved soon."); 
    87                 httpdOutput(r, "<p>"); 
    88                 httpdPrintf(r, "In a while please <a href='%s'>click here</a> to try your request again.", tmp_url); 
     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); 
    8986                http_wifidog_footer(r); 
    9087                debug(LOG_INFO, "Sent %s an apology since I am not online - no point sending them to auth server", r->clientAddr); 
     
    9289        else if (!is_auth_online()) { 
    9390                /* The auth server is down at the moment - apologize and do not redirect anywhere */ 
    94                 http_wifidog_header(r, "Uh oh! Login screen unavailable"); 
    95                 httpdOutput(r, "We apologize, but it seems that we are currently unable to re-direct you to the login screen."); 
    96                 httpdOutput(r, "<p>"); 
    97                 httpdOutput(r, "The maintainers of this network are aware of this disruption.  We hope that this situation will be resolved soon."); 
    98                 httpdOutput(r, "<p>"); 
    99                 httpdPrintf(r, "In a couple of minutes please <a href='%s'>click here</a> to try your request again.", tmp_url); 
     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); 
    10095                http_wifidog_footer(r); 
    10196                debug(LOG_INFO, "Sent %s an apology since auth server not online - no point sending them to auth server", r->clientAddr); 
     
    136131{ 
    137132        http_wifidog_header(r, "WiFiDog"); 
    138         httpdOutput(r, "Please use the menu on the left to navigate the features of this WiFiDog installation."); 
     133        httpdOutput(r, "Please use the menu to navigate the features of this WiFiDog installation."); 
    139134        http_wifidog_footer(r); 
    140135} 
     
    204199http_wifidog_header(request *r, char *title) 
    205200{ 
    206         httpdOutput(r, "<html>\n"); 
    207         httpdOutput(r, "<head>\n"); 
    208         httpdPrintf(r, "<title>%s</title>\n", title); 
    209         httpdOutput(r, "<meta HTTP-EQUIV='Pragma' CONTENT='no-cache'>\n"); 
    210         httpdOutput(r, "</head>\n"); 
    211         httpdOutput(r, "<body topmargin=0 leftmargin=0 marginwidth=0 marginheight=0 bgcolor=white text=#628C53 link=blue alink=blue vlink=blue>\n"); 
    212  
    213         httpdOutput(r, "<table width=100%% height=100%% border=0 cellpadding=12 cellspacing=5>\n"); 
    214  
    215         httpdOutput(r, "<tr>\n"); 
    216  
    217         httpdOutput(r, "<td valign=top align=right width=30%% bgcolor=#e1f5da>\n"); 
    218         httpdOutput(r, "&nbsp;<p>\n"); 
    219         httpdOutput(r, "&nbsp;<p>\n"); 
    220         httpdOutput(r, "<a href='/wifidog/status'>WiFiDog Status</a>\n"); 
    221         httpdOutput(r, "<p>\n"); 
    222         httpdOutput(r, "<a href='/wifidog/about'>About WiFiDog</a>\n"); 
    223         httpdOutput(r, "<p>\n"); 
    224         httpdOutput(r, "<a href='http://www.ilesansfil.org/wiki/WiFiDog'>WiFiDog's homepage</a>\n"); 
    225         httpdOutput(r, "</td>\n"); 
    226  
    227         httpdOutput(r, "<td valign=top align=left>\n"); 
    228         httpdPrintf(r, "<h1>%s</h1>\n", title); 
    229         httpdOutput(r, "<hr>\n"); 
    230  
     201    httpdOutput(r, "<html>\n"); 
     202    httpdOutput(r, "<head>\n"); 
     203    httpdPrintf(r, "<title>%s</title>\n", title); 
     204    httpdOutput(r, "<meta HTTP-EQUIV='Pragma' CONTENT='no-cache'>\n"); 
     205 
     206    httpdOutput(r, "<style>\n"); 
     207    httpdOutput(r, "body {\n"); 
     208    httpdOutput(r, "  margin: 10px 60px 0 60px; \n"); 
     209    httpdOutput(r, "  font-family : bitstream vera sans, sans-serif;\n"); 
     210    httpdOutput(r, "  color: #46a43a;\n"); 
     211    httpdOutput(r, "}\n"); 
     212 
     213    httpdOutput(r, "a {\n"); 
     214    httpdOutput(r, "  color: #46a43a;\n"); 
     215    httpdOutput(r, "}\n"); 
     216 
     217    httpdOutput(r, "a:active {\n"); 
     218    httpdOutput(r, "  color: #46a43a;\n"); 
     219    httpdOutput(r, "}\n"); 
     220 
     221    httpdOutput(r, "a:link {\n"); 
     222    httpdOutput(r, "  color: #46a43a;\n"); 
     223    httpdOutput(r, "}\n"); 
     224 
     225    httpdOutput(r, "a:visited {\n"); 
     226    httpdOutput(r, "  color: #46a43a;\n"); 
     227    httpdOutput(r, "}\n"); 
     228 
     229    httpdOutput(r, "#header {\n"); 
     230    httpdOutput(r, "  height: 30px;\n"); 
     231    httpdOutput(r, "  background-color: #B4F663;\n"); 
     232    httpdOutput(r, "  padding: 20px;\n"); 
     233    httpdOutput(r, "  font-size: 20pt;\n"); 
     234    httpdOutput(r, "  text-align: center;\n"); 
     235    httpdOutput(r, "  border: 2px solid #46a43a;\n"); 
     236    httpdOutput(r, "  border-bottom: 0;\n"); 
     237    httpdOutput(r, "}\n"); 
     238 
     239    httpdOutput(r, "#menu {\n"); 
     240    httpdOutput(r, "  width: 200px;\n"); 
     241    httpdOutput(r, "  float: right;\n"); 
     242    httpdOutput(r, "  background-color: #B4F663;\n"); 
     243    httpdOutput(r, "  border: 2px solid #46a43a;\n"); 
     244    httpdOutput(r, "  font-size: 80%;\n"); 
     245    httpdOutput(r, "  min-height: 300px;\n"); 
     246    httpdOutput(r, "}\n"); 
     247 
     248    httpdOutput(r, "#menu h2 {\n"); 
     249    httpdOutput(r, "  margin: 0;\n"); 
     250    httpdOutput(r, "  background-color: #46a43a;\n"); 
     251    httpdOutput(r, "  text-align: center;\n"); 
     252    httpdOutput(r, "  color: #B4F663;\n"); 
     253    httpdOutput(r, "}\n"); 
     254 
     255    httpdOutput(r, "#copyright {\n"); 
     256    httpdOutput(r, "}\n"); 
     257 
     258    httpdOutput(r, "#content {\n"); 
     259    httpdOutput(r, "  padding: 20px;\n"); 
     260    httpdOutput(r, "  border: 2px solid #46a43a;\n"); 
     261    httpdOutput(r, "  min-height: 300px;\n"); 
     262    httpdOutput(r, "}\n"); 
     263    httpdOutput(r, "</style>\n"); 
     264 
     265    httpdOutput(r, "</head>\n"); 
     266 
     267    httpdOutput(r, "<body\n"); 
     268 
     269    httpdOutput(r, "<div id=\"header\">\n"); 
     270    httpdPrintf(r, "    %s\n", title); 
     271    httpdOutput(r, "</div>\n"); 
     272 
     273    httpdOutput(r, "<div id=\"menu\">\n"); 
     274 
     275 
     276    httpdOutput(r, "    <h2>Info</h2>\n"); 
     277    httpdOutput(r, "    <ul>\n"); 
     278    httpdOutput(r, "    <li>Version: " VERSION "\n"); 
     279    httpdPrintf(r, "    <li>Node ID: %s\n", config_get_config()->gw_id); 
     280    httpdOutput(r, "    </ul>\n"); 
     281    httpdOutput(r, "    <br>\n"); 
     282 
     283    httpdOutput(r, "    <h2>Menu</h2>\n"); 
     284    httpdOutput(r, "    <ul>\n"); 
     285    httpdOutput(r, "    <li><a href='/wifidog/status'>WiFiDog Status</a>\n"); 
     286    httpdOutput(r, "    <li><a href='/wifidog/about'>About WiFiDog</a>\n"); 
     287    httpdOutput(r, "    <li><a href='http://www.wifidog.org'>WiFiDog's homepage</a>\n"); 
     288    httpdOutput(r, "    </ul>\n"); 
     289    httpdOutput(r, "</div>\n"); 
     290 
     291    httpdOutput(r, "<div id=\"content\">\n"); 
     292    httpdPrintf(r, "<h2>%s</h2>\n", title); 
    231293} 
    232294 
     
    234296http_wifidog_footer(request *r) 
    235297{ 
    236         httpdOutput(r, "</td>\n"); 
    237  
    238         httpdOutput(r, "</tr>\n"); 
    239  
    240         httpdOutput(r, "<tr>\n"); 
    241  
    242         httpdOutput(r, "<td colspan=2 height=1 valign=bottom align=center>\n"); 
    243         httpdOutput(r, "<hr>\n"); 
    244         httpdOutput(r, "<font size=1>\n"); 
    245         httpdOutput(r, "Copyright (C) 2004-2005.  This software is released under the GNU GPL license.\n"); 
    246         httpdOutput(r, "</font>\n"); 
    247         httpdOutput(r, "</td>\n"); 
    248  
    249         httpdOutput(r, "</tr>\n"); 
    250  
    251         httpdOutput(r, "</table>\n"); 
     298        httpdOutput(r, "</div>\n"); 
     299 
     300    httpdOutput(r, "<div id=\"copyright\">\n"); 
     301    httpdOutput(r, "Copyright (C) 2004-2005.  This software is released under the GNU GPL license.\n"); 
     302    httpdOutput(r, "</div>\n"); 
     303 
    252304 
    253305        httpdOutput(r, "</body>\n"); 
  • trunk/wifidog/src/util.c

    r765 r798  
    5656#include "debug.h" 
    5757 
     58#include "../config.h" 
     59 
    5860static pthread_mutex_t ghbn_mutex = PTHREAD_MUTEX_INITIALIZER; 
    5961 
     
    7375static time_t last_auth_online_time = 0; 
    7476static time_t last_auth_offline_time = 0; 
     77 
     78long served_this_session = 0; 
    7579 
    7680/** Fork a child and execute a shell command, the parent 
     
    327331        seconds = uptime; 
    328332 
     333        snprintf((buffer + len), (sizeof(buffer) - len), "Version: " VERSION "\n"); 
     334        len = strlen(buffer); 
     335 
    329336        snprintf((buffer + len), (sizeof(buffer) - len), "Uptime: %ud %uh %um %us\n", days, hours, minutes, seconds); 
    330337        len = strlen(buffer); 
    331338 
    332         snprintf((buffer + len), (sizeof(buffer) - len), "Restarted: "); 
     339        snprintf((buffer + len), (sizeof(buffer) - len), "Has been restarted: "); 
    333340        len = strlen(buffer); 
    334341        if (restarted) { 
    335                 snprintf((buffer + len), (sizeof(buffer) - len), "Yes (from PID %d)\n", restarted); 
     342                snprintf((buffer + len), (sizeof(buffer) - len), "yes (from PID %d)\n", restarted); 
    336343                len = strlen(buffer); 
    337344        } 
    338345        else { 
    339                 snprintf((buffer + len), (sizeof(buffer) - len), "No\n"); 
    340                 len = strlen(buffer); 
    341         } 
    342          
    343         snprintf((buffer + len), (sizeof(buffer) - len), "is_online: %s\n", (is_online() ? "yes" : "no")); 
    344         len = strlen(buffer); 
    345          
    346         snprintf((buffer + len), (sizeof(buffer) - len), "is_auth_online: %s\n\n", (is_auth_online() ? "yes" : "no")); 
     346                snprintf((buffer + len), (sizeof(buffer) - len), "no\n"); 
     347                len = strlen(buffer); 
     348        } 
     349         
     350        snprintf((buffer + len), (sizeof(buffer) - len), "Internet Connectivity: %s\n", (is_online() ? "yes" : "no")); 
     351        len = strlen(buffer); 
     352         
     353        snprintf((buffer + len), (sizeof(buffer) - len), "Auth server reachable: %s\n", (is_auth_online() ? "yes" : "no")); 
     354        len = strlen(buffer); 
     355 
     356        snprintf((buffer + len), (sizeof(buffer) - len), "Clients served this session: %lu\n\n", served_this_session); 
    347357        len = strlen(buffer); 
    348358 
     
    369379        count = 0; 
    370380        while (first != NULL) { 
    371                 snprintf((buffer + len), (sizeof(buffer) - len), "Client %d\t" 
    372                                 "Ip: %s\tMac: %s\tToken: %s\n", count,  
    373                                 first->ip, first->mac, first->token); 
    374                 len = strlen(buffer); 
    375  
    376                 snprintf((buffer + len), (sizeof(buffer) - len), "\tIn: %llu\t" 
    377                                 "Out: %llu\n" , first->counters.incoming, 
    378                                 first->counters.outgoing); 
     381                snprintf((buffer + len), (sizeof(buffer) - len), "\nClient %d\n", count); 
     382                len = strlen(buffer); 
     383 
     384                snprintf((buffer + len), (sizeof(buffer) - len), "  IP: %s MAC: %s\n", first->ip, first->mac); 
     385                len = strlen(buffer); 
     386 
     387                snprintf((buffer + len), (sizeof(buffer) - len), "  Token: %s\n", first->token); 
     388                len = strlen(buffer); 
     389 
     390                snprintf((buffer + len), (sizeof(buffer) - len), "  Downloaded: %llu\n  Uploaded: %llu\n" , first->counters.incoming, first->counters.outgoing); 
    379391                len = strlen(buffer); 
    380392 
  • trunk/wifidog/src/wdctl_thread.c

    r765 r798  
    7272{ 
    7373        int     sock, 
    74                 fd, 
    75                 len; 
     74                fd; 
    7675        char    *sock_name; 
    7776        struct  sockaddr_un     sa_un; 
    7877        int result; 
    7978        pthread_t       tid; 
     79    socklen_t len; 
    8080 
    8181        debug(LOG_DEBUG, "Starting wdctl."); 
     
    232232{ 
    233233        int     sock, 
    234                 fd, 
    235                 len; 
     234                fd; 
    236235        char    *sock_name; 
    237236        struct  sockaddr_un     sa_un; 
     
    242241        pid_t pid; 
    243242        ssize_t written; 
     243        socklen_t len; 
    244244 
    245245        conf = config_get_config();