Skip to content

Commit c447973

Browse files
committed
Remove IP Match module
Cool concept, but didn't actually work in practice beyond being able to filter IPs on a local network. The problem is that ztcp doesn't necessarily record the IP address of the client in the session table. Instead, it saves the "fully qualified domain name of the peer, if available, else an IP address." It helps to properly read the documentation, kids. Plus, there was a horrible bug in parse_ztcp that was hidden by virtue of our unit tests running on localhost. In a nutshell, client_ip was being set to the local host name, usually "0.0.0.0", due to a wrong index position --- fix coming later since it still affects logging.
1 parent 625c2b9 commit c447973

File tree

5 files changed

+0
-130
lines changed

5 files changed

+0
-130
lines changed

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ Additionally, to run the full test suite the following external commands are req
3232
- Gzip compression
3333
- Basic CGI/1.1 support
3434
- phpMyAdmin appears fully functional, and partially Wordpress (requires configuring for an alternative port)
35-
- IP filtering
3635
- Basic url rewrite
3736

3837
### Configuration

conf/ip_match.conf

-12
This file was deleted.

conf/main.conf

-2
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,12 @@
1010
# source ~/.config/czhttpd/conf/mime_types.conf
1111
# source ~/.config/czhttpd/conf/cgi.conf
1212
# source ~/.config/czhttpd/conf/compress.conf
13-
# source ~/.config/czhttpd/conf/ip_match.conf
1413
# source ~/.config/czhttpd/conf/url_rewrite.conf
1514
# source ~/.config/czhttpd/conf/debug.conf
1615

1716
# Modules
1817
# source ~/.config/czhttpd/modules/cgi.sh
1918
# source ~/.config/czhttpd/modules/compress.sh
20-
# source ~/.config/czhttpd/modules/ip_match.sh
2119
# source ~/.config/czhttpd/modules/url_rewrite.sh
2220
# source ~/.config/czhttpd/modules/debug.sh
2321

modules/ip_match.sh

-30
This file was deleted.

test/integration/test_modules.sh

-85
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ source $SRC_DIR/modules/debug.sh
88
typeset -g URL_REWRITE=0
99
typeset -g CGI_ENABLE=0
1010
typeset -g COMPRESS=0
11-
typeset -g IP_MATCH=0
1211
1312
typeset -gA URL_PATTERNS
1413
URL_PATTERNS=( "/file.txt" "/.dot.txt" )
@@ -189,87 +188,3 @@ check 127.0.0.1:$PORT/test_app_fail2.sh \
189188
--http_code 500
190189

191190
rm $TESTROOT/*.sh
192-
193-
###
194-
# Finally, test ip match module.
195-
#
196-
# Now this is pretty dumb, so hold with me. The IP match module will
197-
# never reject a connection from localhost. So, in order to test it we
198-
# try to find a local ip address. If we can't, simply print a warning
199-
# message instead of crashing our tests.
200-
case $OSTYPE in
201-
(linux*)
202-
ip=$(hostname -I | awk '{ print $1 }');;
203-
(darwin*|*bsd*)
204-
ip=$(ifconfig | awk '$1 == "inet" && $2 != "127.0.0.1" { print $2 }');;
205-
esac
206-
207-
if [[ -z $ip || ip == "127.0.0.1" ]]; then
208-
print "Unable to find suitable IP, skipping IP match tests..."
209-
return
210-
fi
211-
212-
<<EOF > $CONF
213-
DEBUG=1
214-
typeset -ga DEBUG_TRACE_FUNCS
215-
DEBUG_TRACE_FUNCS=($TRACE_FUNCS)
216-
source $SRC_DIR/modules/debug.sh
217-
218-
URL_REWRITE=0
219-
COMPRESS=0
220-
CGI_ENABLE=0
221-
IP_MATCH=1
222-
223-
source $SRC_DIR/modules/ip_match.sh
224-
EOF
225-
reload_conf
226-
227-
describe "Accept all IPs"
228-
check $ip:$PORT/ \
229-
--http_code 200
230-
231-
<<EOF > $CONF
232-
DEBUG=1
233-
typeset -ga DEBUG_TRACE_FUNCS
234-
DEBUG_TRACE_FUNCS=($TRACE_FUNCS)
235-
source $SRC_DIR/modules/debug.sh
236-
237-
URL_REWRITE=0
238-
COMPRESS=0
239-
CGI_ENABLE=0
240-
241-
IP_MATCH=1
242-
IP_ACCEPT=127.0.0.1
243-
244-
source $SRC_DIR/modules/ip_match.sh
245-
EOF
246-
reload_conf
247-
248-
describe "Reject unmatched ip"
249-
check $ip:$PORT/file.txt \
250-
--fail
251-
252-
<<EOF > $CONF
253-
DEBUG=1
254-
typeset -ga DEBUG_TRACE_FUNCS
255-
DEBUG_TRACE_FUNCS=($TRACE_FUNCS)
256-
source $SRC_DIR/modules/debug.sh
257-
258-
URL_REWRITE=0
259-
COMPRESS=0
260-
CGI_ENABLE=0
261-
262-
IP_MATCH=1
263-
IP_ACCEPT='${ip%.*}.*'
264-
265-
source $SRC_DIR/modules/ip_match.sh
266-
EOF
267-
reload_conf
268-
269-
describe "Accept matched ip"
270-
check $ip:$PORT/file.txt \
271-
--http_code 200
272-
273-
describe "Accept localhost"
274-
check 127.0.0.1:$PORT/file.txt \
275-
--http_code 200

0 commit comments

Comments
 (0)