Changeset 176
- Timestamp:
- 08/09/04 17:48:54 (9 years ago)
- Location:
- trunk/wifidog
- Files:
-
- 7 modified
-
ChangeLog (modified) (1 diff)
-
src/auth.c (modified) (1 diff)
-
src/centralserver.c (modified) (3 diffs)
-
src/conf.c (modified) (7 diffs)
-
src/conf.h (modified) (2 diffs)
-
src/fw_iptables.c (modified) (2 diffs)
-
wifidog.conf (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wifidog/ChangeLog
r173 r176 1 1 # $Header$ 2 2004-08-09 Alexandre Carmel-Veilleux <acv@acv.ca> 3 * WiFiDog now can read multiple auth servers (only uses the first one 4 however.) 5 2 6 2004-08-06 Alexandre Carmel-Veilleux <acv@acv.ca> 3 7 * AuthservPath no longer mandatory in config file. -
trunk/wifidog/src/auth.c
r170 r176 194 194 client->fw_connection_state = FW_MARK_KNOWN; 195 195 fw_allow(client->ip, client->mac, FW_MARK_KNOWN); 196 _http_redirect(client->fd, "http://%s/wifidog/portal/?gw_id=%s", config_get_config()->auth serv_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); 197 197 break; 198 198 case AUTH_VALIDATION_FAILED: -
trunk/wifidog/src/centralserver.c
r138 r176 68 68 s_config *config = config_get_config(); 69 69 70 if ((he = gethostbyname(config->auth serv_hostname)) == NULL) {70 if ((he = gethostbyname(config->auth_servers->authserv_hostname)) == NULL) { 71 71 debug(LOG_ERR, "Failed to resolve %s via gethostbyname(): " 72 "%s", config->auth serv_hostname, strerror(errno));72 "%s", config->auth_servers->authserv_hostname, strerror(errno)); 73 73 return(-1); 74 74 } … … 80 80 81 81 their_addr.sin_family = AF_INET; 82 their_addr.sin_port = htons(config->auth serv_port);82 their_addr.sin_port = htons(config->auth_servers->authserv_port); 83 83 their_addr.sin_addr = *((struct in_addr *)he->h_addr); 84 84 memset(&(their_addr.sin_zero), '\0', sizeof(their_addr.sin_zero)); 85 85 86 86 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); 88 89 89 90 if (connect(sockfd, (struct sockaddr *)&their_addr, … … 100 101 "Host: %s\n" 101 102 "\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); 103 106 send(sockfd, buf, strlen(buf), 0); 104 107 -
trunk/wifidog/src/conf.c
r173 r176 60 60 oGatewayAddress, 61 61 oGatewayPort, 62 oAuthservHostname, 63 oAuthservPort, 62 oAuthServer, 64 63 oAuthservPath, 65 64 oAuthservLoginUrl, … … 86 85 { "gatewayaddress", oGatewayAddress }, 87 86 { "gatewayport", oGatewayPort }, 88 { "authservhostname", oAuthservHostname }, 89 { "authservport", oAuthservPort }, 87 { "authserver", oAuthServer }, 90 88 { "authservpath", oAuthservPath }, 91 89 { "authservloginurl", oAuthservLoginUrl }, … … 99 97 }; 100 98 99 static OpCodes config_parse_token(const char *cp, const char *filename, int linenum); 101 100 static void config_notnull(void *parm, char *parmname); 102 101 static int parse_boolean_value(char *); 102 static void new_auth_server(char *, int); 103 103 104 104 /** Accessor for the current gateway configuration … … 124 124 config.gw_address = NULL; 125 125 config.gw_port = DEFAULT_GATEWAYPORT; 126 config.authserv_hostname = NULL; 127 config.authserv_port = DEFAULT_AUTHSERVPORT; 126 config.auth_servers = NULL; 128 127 config.authserv_path = strdup(DEFAULT_AUTHSERVPATH); 129 128 config.authserv_loginurl = NULL; … … 235 234 sscanf(p1, "%d", &config.gw_port); 236 235 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 } 240 246 break; 241 247 case oHTTPDName: … … 307 313 config_notnull(config.gw_interface, "GatewayInterface"); 308 314 config_notnull(config.gw_address, "GatewayAddress"); 309 config_notnull(config.auth serv_hostname, "AuthservHostname");315 config_notnull(config.auth_servers, "AuthServer"); 310 316 config_notnull(config.authserv_loginurl, "AuthservLoginUrl"); 311 317 … … 328 334 } 329 335 336 /** @internal 337 Register a new auth server. 338 */ 339 static void 340 new_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 46 46 /*@}*/ 47 47 48 typedef 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 48 54 /** 49 55 * Configuration structure … … 62 68 server */ 63 69 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 */ 66 72 char *authserv_path; /**< @brief Path to the authentication script on 67 73 the central server */ -
trunk/wifidog/src/fw_iptables.c
r170 r176 81 81 iptables_do_command("-t nat -N " TABLE_WIFIDOG_VALIDATE); 82 82 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->auth serv_hostname);83 iptables_do_command("-t nat -A " TABLE_WIFIDOG_VALIDATE " -d %s -j ACCEPT", config->auth_servers->authserv_hostname); 84 84 iptables_do_command("-t nat -A " TABLE_WIFIDOG_VALIDATE " -p udp --dport 67 -j ACCEPT"); 85 85 iptables_do_command("-t nat -A " TABLE_WIFIDOG_VALIDATE " -p tcp --dport 67 -j ACCEPT"); … … 97 97 iptables_do_command("-t nat -N " TABLE_WIFIDOG_UNKNOWN); 98 98 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->auth serv_hostname);99 iptables_do_command("-t nat -A " TABLE_WIFIDOG_UNKNOWN " -d %s -j ACCEPT", config->auth_servers->authserv_hostname); 100 100 iptables_do_command("-t nat -A " TABLE_WIFIDOG_UNKNOWN " -p udp --dport 67 -j ACCEPT"); 101 101 iptables_do_command("-t nat -A " TABLE_WIFIDOG_UNKNOWN " -p tcp --dport 67 -j ACCEPT"); -
trunk/wifidog/wifidog.conf
r173 r176 60 60 GatewayAddress 10.0.0.1 61 61 62 # Parm: Auth servHostname62 # Parm: AuthServer 63 63 # Default: NONE 64 64 # Mandatory 65 65 # 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 69 AuthServer yourauthserv.com 68 70 69 71 # Parm: AuthservPath
