File: should-find-proxy

package info (click to toggle)
proxycheck 0.49a-10
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 376 kB
  • sloc: ansic: 4,461; sh: 748; makefile: 130
file content (61 lines) | stat: -rw-r--r-- 1,508 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/sh

# Functions test_apache(), test_wget() and test_ziproxy() were copied from
# the validation script of the ziproxy package

ZIPROXY_TCP_PORT=8080

STATUS_ERROR=1
STATUS_SKIP=77

test_apache() {
    netstat --tcp -lnp | grep apache | grep 80

    if [ "$?" != 0 ]; then
        echo "apache2 is not listening at port TCP/80"
        echo "ending $0 with status $STATUS_SKIP"
        exit $STATUS_SKIP
    fi
}

test_wget() {
    wget -q -O /dev/null -4 localhost:80

    if [ "$?" != 0 ]; then
        echo "wget on localhost:80 failed"
        echo "ending $0 with status $STATUS_SKIP"
        exit $STATUS_SKIP
    fi
}

test_ziproxy() {
    netstat --tcp -lnp | grep ziproxy | grep $ZIPROXY_TCP_PORT

    if [ "$?" != 0 ]; then
        echo "Ziproxy is not listening at port TCP/$ZIPROXY_TCP_PORT"
        echo "ending $0 with status $STATUS_ERROR"
        exit $STATUS_ERROR
    fi
}

test_proxycheck() {
    # Reach port 80 through Ziproxy and expect response containing
    # string "HTTP" from Apache web server.
    proxycheck -d localhost:80 -c chat::"HTTP" localhost:$ZIPROXY_TCP_PORT -aaaaa

    # Proxycheck should terminate with status 100 when the expected string
    # is received, which means an open proxy was detected.
    if [ "$?" != 100 ]; then
        echo "Proxycheck failed to find proxy at localhost:$ZIPROXY_TCP_PORT"
        echo "ending $0 with status $STATUS_ERROR"
        exit $STATUS_ERROR
    fi
}

## main
test_apache
test_wget
test_ziproxy
test_proxycheck

exit 0