Changeset 424
- Timestamp:
- 02/03/05 23:05:28 (8 years ago)
- Location:
- trunk/wifidog
- Files:
-
- 10 modified
-
ChangeLog (modified) (1 diff)
-
ipkg/rules (modified) (2 diffs)
-
src/auth.c (modified) (1 diff)
-
src/centralserver.c (modified) (2 diffs)
-
src/conf.c (modified) (2 diffs)
-
src/fw_iptables.c (modified) (1 diff)
-
src/http.c (modified) (4 diffs)
-
src/ping_thread.c (modified) (1 diff)
-
src/util.c (modified) (3 diffs)
-
src/util.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wifidog/ChangeLog
r423 r424 1 1 # $Header$ 2 3 2005-02-03 Mina Naguib <mina@ilesansfil.org> 4 * Keep track of last times we successfully & unsuccessfully spoke to the 5 auth server/used DNS. Then, if we know we're not online, show a little 6 apology to the user instead of re-directing them to the auth server. 7 * ipkg/rules: Added some extra version detection to auto-detect versions 8 of kernel, iptables and ipkg-utils instead of having them hardcoded. This 9 makes creating ipkg's work with different OpenWRT releases 10 * fw_iptables.c: Fixed memory leak caused by not freeing return from 11 iptables_compile in iptables_load_ruleset 12 * http.c: Deleted unused call to client_list_find 13 * http.c: /about URL now shows wifidog version 14 * Cosmetic typo fixes 15 2 16 2005-02-03 Philippe April <isf_lists@philippeapril.com> 3 17 * Ping the users everytime we check their counters, that way we keep them -
trunk/wifidog/ipkg/rules
r281 r424 15 15 TMP_DIR:=$(BUILD_DIR)/tmp 16 16 STAGING_DIR=$(BUILDROOT)/build_$(ARCH)/staging_dir 17 IPTABLES_DIR := $(BUILDROOT)/build_$(ARCH)/iptables-1.2.9 18 IPKG_DIR := $(BUILDROOT)/build_$(ARCH)/ipkg-utils-1.7 19 KERNEL_MODULES_DIR := $(BUILDROOT)/build_$(ARCH)/WRT54GS/release/src/linux/linux/modules/lib/modules/2.4.20 17 IPTABLES_DIR := $(wildcard $(BUILDROOT)/build_$(ARCH)/iptables-*/) 18 IPKG_DIR := $(wildcard $(BUILDROOT)/build_$(ARCH)/ipkg-utils-*/) 19 KERNEL_VERSION := $(shell awk '$$1 == "\#define" && $$2 == "UTS_RELEASE" {gsub(/["]/, "", $$3); print $$3}' $(BUILDROOT)/build_$(ARCH)/WRT54GS/release/src/linux/linux/include/linux/version.h) 20 KERNEL_MODULES_DIR := $(BUILDROOT)/build_$(ARCH)/WRT54GS/release/src/linux/linux/modules/lib/modules/$(KERNEL_VERSION) 20 21 UCLIBC_DIR := $(BUILDROOT)/build_$(ARCH)/uClibc 21 22 … … 88 89 89 90 install-kernel-modules: 90 mkdir -p $(TMP_DIR)/lib/modules/ 2.4.20/kernel/net/ipv4/netfilter91 cp $(KERNEL_MODULES_DIR)/kernel/net/ipv4/netfilter/ipt_mac.o $(TMP_DIR)/lib/modules/ 2.4.20/kernel/net/ipv4/netfilter91 mkdir -p $(TMP_DIR)/lib/modules/$(KERNEL_VERSION)/kernel/net/ipv4/netfilter 92 cp $(KERNEL_MODULES_DIR)/kernel/net/ipv4/netfilter/ipt_mac.o $(TMP_DIR)/lib/modules/$(KERNEL_VERSION)/kernel/net/ipv4/netfilter 92 93 93 94 install-pthread: -
trunk/wifidog/src/auth.c
r391 r424 168 168 169 169 if (client == NULL) { 170 debug(LOG_ERR, "Could not find client clientfor %s (%s)",170 debug(LOG_ERR, "Could not find client node for %s (%s)", 171 171 r->clientAddr, mac); 172 172 pthread_mutex_unlock(&client_list_mutex); -
trunk/wifidog/src/centralserver.c
r274 r424 101 101 debug(LOG_ERR, "connect(): %s", strerror(errno)); 102 102 debug(LOG_ERR, "Trying next Auth Server (if any)"); 103 if (num_tries++ < config->authserv_maxtries) { 104 mark_auth_server_bad(auth_server); 105 } else { 106 mark_auth_server_bad(auth_server); 103 mark_auth_server_bad(auth_server); 104 if (++num_tries > config->authserv_maxtries) { 107 105 debug(LOG_ERR, "Aborting request"); 108 106 free(h_addr); … … 115 113 free(h_addr); 116 114 } 115 116 mark_online(); 117 117 118 /** 118 119 * TODO: XXX change the PHP so we can harmonize stage as request_type -
trunk/wifidog/src/conf.c
r422 r424 43 43 #include "auth.h" 44 44 #include "firewall.h" 45 46 #include "util.h" 45 47 46 48 /** @internal … … 766 768 } 767 769 770 mark_offline(); 771 768 772 pthread_mutex_unlock(&config_mutex); 769 773 -
trunk/wifidog/src/fw_iptables.c
r422 r424 140 140 debug(LOG_DEBUG, "Loading rule \"%s\" into %s", cmd, chain); 141 141 iptables_do_command(cmd); 142 free(cmd); 142 143 } 143 144 -
trunk/wifidog/src/http.c
r274 r424 45 45 #include "common.h" 46 46 47 #include "util.h" 48 49 #include "../config.h" 50 47 51 extern pthread_mutex_t client_list_mutex; 48 52 … … 58 62 t_auth_serv *auth_server = get_auth_server(); 59 63 64 if (!is_online()) { 65 /* No point re-directing them to the auth server if we haven't been able to talk 66 * to it for a while */ 67 httpdOutput(r, "<html><head><title>Currently unavailable</title></head><body><h1>Uh oh!</h1>"); 68 httpdOutput(r, "We apologize, but it seems that we are currently unable to re-direct you to the login screen."); 69 httpdOutput(r, "<p>"); 70 httpdOutput(r, "The maintainers of this network are aware of this disruption. We hope that this situation will be resolved soon."); 71 httpdOutput(r, "<p>"); 72 httpdOutput(r, "Please try again another time."); 73 httpdOutput(r, "</body></html>"); 74 return; 75 } 76 60 77 if (auth_server->authserv_use_ssl) { 61 78 strcpy(protocol, "https"); … … 111 128 http_callback_about(httpd *webserver, request *r) 112 129 { 113 httpdOutput(r, "<html><body><h1>About:</h1>"); 114 httpdOutput(r, "This is WiFiDog. Copyright (C) 2004 and " 115 "released under the GNU GPL license."); 130 httpdOutput(r, "<html><head><title>About WiFiDog</title></head><body><h1>About WiFiDog:</h1>"); 131 httpdOutput(r, "This is WiFiDog version <b>" VERSION "</b>"); 132 httpdOutput(r, "<p>"); 133 httpdOutput(r, "Copyright (C) 2004-2005. This software is released under the GNU GPL license."); 116 134 httpdOutput(r, "<p>"); 117 135 httpdOutput(r, "For more information visit <a href='http://" … … 150 168 } 151 169 152 client = client_list_find(r->clientAddr, mac);153 154 170 UNLOCK_CLIENT_LIST(); 155 171 -
trunk/wifidog/src/ping_thread.c
r422 r424 165 165 free(h_addr); 166 166 167 mark_online(); 168 167 169 snprintf(request, sizeof(request) - 1, "GET %sping/?gw_id=%s HTTP/1.0\n" 168 170 "User-Agent: WiFiDog %s\n" -
trunk/wifidog/src/util.c
r422 r424 51 51 52 52 static pthread_mutex_t ghbn_mutex = PTHREAD_MUTEX_INITIALIZER; 53 54 /* XXX Do these need to be locked ? */ 55 static time_t last_online_time = 0; 56 static time_t last_offline_time = 0; 53 57 54 58 /** Fork a child and execute a shell command, the parent … … 108 112 if (he == NULL) { 109 113 free(h_addr); 114 mark_offline(); 110 115 UNLOCK_GHBN(); 111 116 return NULL; 112 117 } 118 119 mark_online(); 113 120 114 121 in_addr_temp = (struct in_addr *)he->h_addr_list[0]; … … 145 152 return (char *)inet_ntoa(in); 146 153 } 154 155 void mark_online() { 156 time(&last_online_time); 157 } 158 159 void mark_offline() { 160 time(&last_offline_time); 161 } 162 163 int is_online() { 164 if (last_online_time == 0 || (last_offline_time - last_online_time) >= (config_get_config()->checkinterval * 2) ) { 165 /* We're probably offline */ 166 return (0); 167 } 168 else { 169 /* We're probably online */ 170 return (1); 171 } 172 } 173 -
trunk/wifidog/src/util.h
r422 r424 36 36 char *get_iface_ip(char *ifname); 37 37 38 /* @brief Sets hint that an online action (dns/connect/etc using WAN) succeeded */ 39 void mark_online(); 40 /* @brief Sets hint that an online action (dns/connect/etc using WAN) failed */ 41 void mark_offline(); 42 /* @brief Returns a guess (true or false) on whether we're online or not based on previous calls to mark_online and mark_offline */ 43 int is_online(); 44 38 45 #define LOCK_GHBN() do { \ 39 46 debug(LOG_DEBUG, "Locking wd_gethostbyname()"); \
