Skip to content

Commit 66522fe

Browse files
author
sinkcup
committed
Merge pull request #101 from sinkcup/master
start to use Semantic Versioning, will release 1.2.0 tag after this merge
2 parents 5cceeae + 54abfd2 commit 66522fe

File tree

5 files changed

+33
-27
lines changed

5 files changed

+33
-27
lines changed

ChangeLog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# $Id$
2+
2015-03-18
3+
* Add possibility to use domain whitelist in conf, and auto pass subdomains.
4+
(https://github.com/wifidog/wifidog-gateway/issues/14)
25
2015-02-20
36
* Add possibility to use a port range in wifidog
47
(https://github.com/wifidog/wifidog-gateway/commit/d1c3b596dcae6eb1f4980687a3633482613ca231)

NEWS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
# $Id$
2+
WiFiDog 1.2.0:
3+
* Add possibility to use domain whitelist in conf, and auto pass subdomains.
4+
* Use Semantic Versioning, yymmdd version number is out of use.
5+
* Use tag for release, don't using master for release.
6+
27
WiFiDog 1.1.5:
38
* First supported version on OpenWRT kamikaze
49

configure.in

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ AC_PROG_CXX
1818

1919
AC_SUBST(BUILDROOT)
2020

21+
# we use Semantic Versioning x.y.z tag for release, docs: http://semver.org/
2122
WIFIDOG_MAJOR_VERSION=1
22-
WIFIDOG_MINOR_VERSION=1
23-
WIFIDOG_MICRO_VERSION=6
24-
WIFIDOG_VERSION=20130917
23+
WIFIDOG_MINOR_VERSION=2
24+
WIFIDOG_MICRO_VERSION=0
25+
WIFIDOG_VERSION=$WIFIDOG_MAJOR_VERSION.$WIFIDOG_MINOR_VERSION.$WIFIDOG_MICRO_VERSION
2526

2627
AC_SUBST(WIFIDOG_MAJOR_VERSION)
2728
AC_SUBST(WIFIDOG_MINOR_VERSION)

src/conf.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -557,21 +557,6 @@ _parse_firewall_rule(const char *ruleset, char *leftover)
557557
}
558558
if (strncmp(other_kw, "to-ipset", 8) == 0 && !finished) {
559559
mask_is_ipset = 1;
560-
} else if (strncmp(other_kw, "to", 2) == 0 && !finished) {
561-
/* Check if mask is valid */
562-
all_nums = 1;
563-
for (i = 0; *(mask + i) != '\0'; i++)
564-
if (!isdigit((unsigned char)*(mask + i)) && (*(mask + i) != '.')
565-
&& (*(mask + i) != '/'))
566-
all_nums = 0; /*< No longer only digits */
567-
if (!all_nums) {
568-
debug(LOG_ERR, "Invalid mask %s", mask);
569-
return -3; /*< Fail */
570-
}
571-
} else {
572-
debug(LOG_ERR, "Invalid or unexpected keyword %s, "
573-
"expecting \"port\", \"to\" or \"to-ipset\"", other_kw);
574-
return -4; /*< Fail */
575560
}
576561
TO_NEXT_WORD(leftover, finished);
577562
if (!finished) {

src/http.c

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -134,25 +134,37 @@ http_callback_404(httpd *webserver, request *r, int error_code)
134134
free(mac);
135135
}
136136

137-
debug(LOG_INFO, "Check host %s is in whitelist or not", r->request.host); // eg. www.example.com
137+
// if host is not in whitelist, maybe not in conf or domain'IP changed, it will go to here.
138+
debug(LOG_INFO, "Check host %s is in whitelist or not", r->request.host); // e.g. www.example.com
138139
t_firewall_rule *rule;
139-
//eg. example.com is in whitelist
140+
//e.g. example.com is in whitelist
141+
// if request http://www.example.com/, it's not equal example.com.
140142
for (rule = get_ruleset("global"); rule != NULL; rule = rule->next) {
141-
// if request http://www.example.com/, it's not equal example.com. if request http://example.com, it will not go to here, it had been added into "iptables allow" when wifidog start.
142-
if (strstr(r->request.host, rule->mask)) {
143-
int host_length = strlen(r->request.host);
144-
int mask_length = strlen(rule->mask);
143+
debug(LOG_INFO, "rule mask %s", rule->mask);
144+
if (strstr(r->request.host, rule->mask) == NULL) {
145+
debug(LOG_INFO, "host %s is not in %s, contiue", r->request.host, rule->mask);
146+
continue;
147+
}
148+
int host_length = strlen(r->request.host);
149+
int mask_length = strlen(rule->mask);
150+
if (host_length != mask_length) {
145151
char prefix[1024] = {0};
146-
// must be *.example.com, if not have ".", maybe Phishing. eg. phishingexample.com
147-
strncpy(prefix, r->request.host, host_length - mask_length - 1); // www
152+
// must be *.example.com, if not have ".", maybe Phishing. e.g. phishingexample.com
153+
strncpy(prefix, r->request.host, host_length - mask_length - 1); // e.g. www
148154
strcat(prefix, "."); // www.
149155
strcat(prefix, rule->mask); // www.example.com
150156
if (strcasecmp(r->request.host, prefix) == 0) {
151-
debug(LOG_INFO, "allow subdomain, auto refresh request");
157+
debug(LOG_INFO, "allow subdomain");
152158
fw_allow_host(r->request.host);
153159
http_send_redirect(r, tmp_url, "allow subdomain");
154160
return;
155161
}
162+
} else {
163+
// e.g. "example.com" is in conf, so it had been parse to IP and added into "iptables allow" when wifidog start. but then its' A record(IP) changed, it will go to here.
164+
debug(LOG_INFO, "allow domain again, because IP changed");
165+
fw_allow_host(r->request.host);
166+
http_send_redirect(r, tmp_url, "allow domain");
167+
return;
156168
}
157169
}
158170

0 commit comments

Comments
 (0)