Changeset 176

Show
Ignore:
Timestamp:
08/09/04 17:48:54 (9 years ago)
Author:
alexcv
Message:

WiFiDog will now read multiple AuthServer? line in the config file but it
will only use the first one.

Location:
trunk/wifidog
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • trunk/wifidog/ChangeLog

    r173 r176  
    11# $Header$ 
     22004-08-09 Alexandre Carmel-Veilleux <acv@acv.ca> 
     3        * WiFiDog now can read multiple auth servers (only uses the first one 
     4however.) 
     5 
    262004-08-06 Alexandre Carmel-Veilleux <acv@acv.ca> 
    37        * AuthservPath no longer mandatory in config file. 
  • trunk/wifidog/src/auth.c

    r170 r176  
    194194                client->fw_connection_state = FW_MARK_KNOWN; 
    195195                fw_allow(client->ip, client->mac, FW_MARK_KNOWN); 
    196                 _http_redirect(client->fd, "http://%s/wifidog/portal/?gw_id=%s", config_get_config()->authserv_hostname, config_get_config()->gw_id); 
     196                _http_redirect(client->fd, "http://%s/wifidog/portal/?gw_id=%s", config_get_config()->auth_servers->authserv_hostname, config_get_config()->gw_id); 
    197197                break; 
    198198        case AUTH_VALIDATION_FAILED: 
  • trunk/wifidog/src/centralserver.c

    r138 r176  
    6868        s_config *config = config_get_config(); 
    6969 
    70         if ((he = gethostbyname(config->authserv_hostname)) == NULL) { 
     70        if ((he = gethostbyname(config->auth_servers->authserv_hostname)) == NULL) { 
    7171                debug(LOG_ERR, "Failed to resolve %s via gethostbyname(): " 
    72                         "%s", config->authserv_hostname, strerror(errno)); 
     72                        "%s", config->auth_servers->authserv_hostname, strerror(errno)); 
    7373                return(-1); 
    7474        } 
     
    8080 
    8181        their_addr.sin_family = AF_INET; 
    82         their_addr.sin_port = htons(config->authserv_port); 
     82        their_addr.sin_port = htons(config->auth_servers->authserv_port); 
    8383        their_addr.sin_addr = *((struct in_addr *)he->h_addr); 
    8484        memset(&(their_addr.sin_zero), '\0', sizeof(their_addr.sin_zero)); 
    8585 
    8686        debug(LOG_INFO, "Connecting to auth server %s on port %d",  
    87                 config->authserv_hostname, config->authserv_port); 
     87                config->auth_servers->authserv_hostname,  
     88                config->auth_servers->authserv_port); 
    8889 
    8990        if (connect(sockfd, (struct sockaddr *)&their_addr, 
     
    100101                "Host: %s\n" 
    101102                "\n", 
    102             config->authserv_path, request_type, ip, mac, token, incoming, outgoing, VERSION, config->authserv_hostname); 
     103            config->authserv_path, request_type, ip, mac,  
     104            token, incoming, outgoing, VERSION,  
     105            config->auth_servers->authserv_hostname); 
    103106        send(sockfd, buf, strlen(buf), 0); 
    104107 
  • trunk/wifidog/src/conf.c

    r173 r176  
    6060        oGatewayAddress, 
    6161        oGatewayPort, 
    62         oAuthservHostname, 
    63         oAuthservPort, 
     62        oAuthServer, 
    6463        oAuthservPath, 
    6564        oAuthservLoginUrl, 
     
    8685        { "gatewayaddress",     oGatewayAddress }, 
    8786        { "gatewayport",        oGatewayPort }, 
    88         { "authservhostname",   oAuthservHostname }, 
    89         { "authservport",       oAuthservPort }, 
     87        { "authserver",         oAuthServer }, 
    9088        { "authservpath",       oAuthservPath }, 
    9189        { "authservloginurl",   oAuthservLoginUrl }, 
     
    9997}; 
    10098 
     99static OpCodes config_parse_token(const char *cp, const char *filename, int linenum); 
    101100static void config_notnull(void *parm, char *parmname); 
    102101static int parse_boolean_value(char *); 
     102static void new_auth_server(char *, int); 
    103103 
    104104/** Accessor for the current gateway configuration 
     
    124124        config.gw_address = NULL; 
    125125        config.gw_port = DEFAULT_GATEWAYPORT; 
    126         config.authserv_hostname = NULL; 
    127         config.authserv_port = DEFAULT_AUTHSERVPORT; 
     126        config.auth_servers = NULL; 
    128127        config.authserv_path = strdup(DEFAULT_AUTHSERVPATH); 
    129128        config.authserv_loginurl = NULL; 
     
    235234                                        sscanf(p1, "%d", &config.gw_port); 
    236235                                        break; 
    237                                 case oAuthservHostname: 
    238                                         config.authserv_hostname =  
    239                                                 strdup(p1); 
     236                                case oAuthServer: 
     237                                        /* Check for the presence of more then 
     238                                         * one argument. */ 
     239                                        if (p2 != NULL && (*(p2 + 1) != '\n') 
     240                                                       && (*(p2 + 1) != '\0')) { 
     241                                                p2++; 
     242                                                new_auth_server(p1, atoi(p2)); 
     243                                        } else { 
     244                                                new_auth_server(p1, DEFAULT_AUTHSERVPORT); 
     245                                        } 
    240246                                        break; 
    241247                                case oHTTPDName: 
     
    307313        config_notnull(config.gw_interface, "GatewayInterface"); 
    308314        config_notnull(config.gw_address, "GatewayAddress"); 
    309         config_notnull(config.authserv_hostname, "AuthservHostname"); 
     315        config_notnull(config.auth_servers, "AuthServer"); 
    310316        config_notnull(config.authserv_loginurl, "AuthservLoginUrl"); 
    311317 
     
    328334} 
    329335 
     336/** @internal 
     337    Register a new auth server. 
     338*/ 
     339static void 
     340new_auth_server(char *host, int port) 
     341{ 
     342        t_auth_serv     *new, *tmp; 
     343 
     344        debug(LOG_DEBUG, "Adding %s:%d to the auth server list", host, port); 
     345 
     346        /* Allocate memory */ 
     347        new = (t_auth_serv *)malloc(sizeof(t_auth_serv)); 
     348        if (new == NULL) { 
     349                debug(LOG_ERR, "Could not allocate memory for auth server " 
     350                                "configuration"); 
     351                exit(1); 
     352        } 
     353         
     354        /* Fill in struct */ 
     355        new->authserv_hostname = strdup(host); 
     356        new->authserv_port = port; 
     357        new->next = NULL; 
     358         
     359        /* If it's the first, add to config, else append to last server */ 
     360        if (config.auth_servers == NULL) { 
     361                config.auth_servers = new; 
     362        } else { 
     363                for (tmp = config.auth_servers; tmp->next != NULL; 
     364                                tmp = tmp->next); 
     365                tmp->next = new; 
     366        } 
     367         
     368        debug(LOG_DEBUG, "Auth server added"); 
     369} 
  • trunk/wifidog/src/conf.h

    r173 r176  
    4646/*@}*/  
    4747 
     48typedef struct _auth_serv_t { 
     49    char *authserv_hostname;    /**< @brief Hostname of the central server */ 
     50    int authserv_port;      /**< @brief Port the central server listens on */ 
     51    struct _auth_serv_t *next; 
     52} t_auth_serv; 
     53 
    4854/** 
    4955 * Configuration structure 
     
    6268                                     server */ 
    6369    int gw_port;                /**< @brief Port the webserver will run on */ 
    64     char *authserv_hostname;    /**< @brief Hostname of the central server */ 
    65     int authserv_port;          /**< @brief Port the central server listens on */ 
     70 
     71    t_auth_serv *auth_servers;  /**< @brief Auth servers list */ 
    6672    char *authserv_path;        /**< @brief Path to the authentication script on 
    6773                                     the central server */ 
  • trunk/wifidog/src/fw_iptables.c

    r170 r176  
    8181    iptables_do_command("-t nat -N " TABLE_WIFIDOG_VALIDATE); 
    8282    iptables_do_command("-t nat -A " TABLE_WIFIDOG_VALIDATE " -d %s -j ACCEPT", config->gw_address); 
    83     iptables_do_command("-t nat -A " TABLE_WIFIDOG_VALIDATE " -d %s -j ACCEPT", config->authserv_hostname); 
     83    iptables_do_command("-t nat -A " TABLE_WIFIDOG_VALIDATE " -d %s -j ACCEPT", config->auth_servers->authserv_hostname); 
    8484    iptables_do_command("-t nat -A " TABLE_WIFIDOG_VALIDATE " -p udp --dport 67 -j ACCEPT"); 
    8585    iptables_do_command("-t nat -A " TABLE_WIFIDOG_VALIDATE " -p tcp --dport 67 -j ACCEPT"); 
     
    9797    iptables_do_command("-t nat -N " TABLE_WIFIDOG_UNKNOWN); 
    9898    iptables_do_command("-t nat -A " TABLE_WIFIDOG_UNKNOWN " -d %s -j ACCEPT", config->gw_address); 
    99     iptables_do_command("-t nat -A " TABLE_WIFIDOG_UNKNOWN " -d %s -j ACCEPT", config->authserv_hostname); 
     99    iptables_do_command("-t nat -A " TABLE_WIFIDOG_UNKNOWN " -d %s -j ACCEPT", config->auth_servers->authserv_hostname); 
    100100    iptables_do_command("-t nat -A " TABLE_WIFIDOG_UNKNOWN " -p udp --dport 67 -j ACCEPT"); 
    101101    iptables_do_command("-t nat -A " TABLE_WIFIDOG_UNKNOWN " -p tcp --dport 67 -j ACCEPT"); 
  • trunk/wifidog/wifidog.conf

    r173 r176  
    6060GatewayAddress 10.0.0.1 
    6161 
    62 # Parm: AuthservHostname 
     62# Parm: AuthServer 
    6363# Default: NONE 
    6464# Mandatory 
    6565# 
    66 # Set this to the hostname or IP of your auth server 
    67 AuthservHostname yourauthserv.com 
     66# Set this to the hostname or IP of your auth server and optionally as 
     67# a second argument, the port it listens on. 
     68# AuthServer yourauthserv.com 8080 
     69AuthServer yourauthserv.com 
    6870 
    6971# Parm: AuthservPath