aboutsummaryrefslogtreecommitdiff
path: root/utils/cache-domains/files/test.sh
blob: 7963fc0deaeeb289e8ca589d41217a168d42a3a5 (plain)
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
#! /bin/sh

set -o errexit

test_url() {
    echo "INFO: Testing '${2}' has ${1} addresses" >&2

    case "${1}" in
        IPv4)
            nslookup -type=a "${2}"
            ;;
        IPv6)
            nslookup -type=aaaa "${2}"
            ;;
        *)
            echo "ERROR: Unknown IP version: ${1}" >&2
            exit 1
            ;;
    esac
}

cache_domains() {
    echo "INFO: cache-domains ${1}" >&2
    cache-domains "${1}"
    sleep 5
}

cache_domains cleanup

test_url IPv4 lancache.steamcontent.com | grep -q 'canonical name ='
test_url IPv6 lancache.steamcontent.com | grep -q 'canonical name ='

test_url IPv4 dist.blizzard.com | grep -q 'canonical name ='
test_url IPv6 dist.blizzard.com | grep -q 'canonical name ='

cache_domains configure

test_url IPv4 lancache.steamcontent.com | grep -q '10.10.3.10'
test_url IPv4 lancache.steamcontent.com | grep -q '10.10.3.11'
test_url IPv6 lancache.steamcontent.com > /dev/null # None configured

test_url IPv4 dist.blizzard.com | grep -q '10.10.3.13'
test_url IPv6 dist.blizzard.com > /dev/null # None configured

cache_domains cleanup

test_url IPv4 lancache.steamcontent.com | grep -q 'canonical name ='
test_url IPv6 lancache.steamcontent.com | grep -q 'canonical name ='

test_url IPv4 dist.blizzard.com | grep -q 'canonical name ='
test_url IPv6 dist.blizzard.com | grep -q 'canonical name ='