diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..2e62126 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,8 @@ +root = true + +[*] +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true +end_of_line = lf +insert_final_newline = true diff --git a/.gitea/workflows/gen.yaml b/.gitea/workflows/gen.yaml new file mode 100644 index 0000000..1a7cb36 --- /dev/null +++ b/.gitea/workflows/gen.yaml @@ -0,0 +1,47 @@ +name: Run temp script and capture output + +on: + schedule: + - cron: "0 0 * * *" # tous les jours à 3h du mat + workflow_dispatch: # optionnel : exécution manuelle + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Send ntfy notification (Run Started) + run: | + curl \ + -u ${{ secrets.NTFY_AUTH }} \ + -H "Title: LanCache AGH conf generation started" \ + -H "Priority: 5" \ + -d "Generating AdguardHome config for Lancache" \ + https://ntfy.uzurka.fr/lancache + + - name: Setup jq + run: | + apt update && apt install -y jq + + - name: Generate new config + run: | + bash scripts/create-adguardhome.sh + + - name: Send ntfy notification (Success) + if: success() + run: | + curl \ + -u ${{ secrets.NTFY_AUTH }} \ + -H "LanCache AGH conf generation succeed" \ + -H "Priority: 5" \ + -d "LanCache AGH conf generation succeed" \ + https://ntfy.uzurka.fr/lancache + + - name: Send ntfy notification (Failure) + if: failure() + run: | + curl \ + -u ${{ secrets.NTFY_AUTH }} \ + -H "LanCache AGH conf generation failed" \ + -H "Priority: 5" \ + -d "LanCache AGH conf generation failed" \ + https://ntfy.uzurka.fr/lancache diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dfa9afb --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +scripts/output +scripts/config.json diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..0d9accf --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 UK LAN Techs + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md old mode 100644 new mode 100755 index e69de29..afdc413 --- a/README.md +++ b/README.md @@ -0,0 +1,106 @@ +# Game Content Cache Hostnames + +## Introduction + +This is a list of all hostnames that are required to be redirected for running a game content cache. This list will change frequently so this is designed to be a definitive list. + +## Usage + +You can use this list one of two ways: + + - Overriding DNS for these hostnames to point to the IP of your cache server. + - Use them in Squid with WCCP to redirect content to the right cache server. + +There is a cache_domains.json file to define CDNs and additional metadata with the following structure + +- cache_domains: Array of cache_domain object + - name: shortname for the cache domain. Should match `^[0-9A-Za-z]$` + - description: a longer description to aid others in identifying what this domain does (not all users of this repo will want to enable all caches) + - notes: implementation specific notes which may be useful for other users + - domain_files: array of files within the repo associated to the cdn. Most CDNs only need one file + - Example domain entry for steam +```json +{ + "cache_domains": [ + { + "name": "steam", + "description": "CDN for steam platform", + "domain_files": ["steam.txt"] + } + ] +} +``` + +### Host file format + +There is a separate file for each cacheable service. Some notes on formatting: + + - Every line should be a separate hostname for that service. + - Only one entry is permitted per line. + - Wildcards are permitted as per below + - Lines starting with a # will be treated as a comment. + - Files must end with an empty newline. + - File names must match the regular expression `^[0-9A-Za-z].txt` + +#### Wildcards + +The wildcard format shall be defined as per the below + + - Wildcards should be represented with an asterisk. + - If a wildcard is used, it should be the first character on the line. + - Wildcards are not treated as matching null, e.g. `*.example.com` will match `a.example.com` but will not match `example.com` + - Only simple domain wildcards will be accepted e.g. `*.example.com` not `*ww.example.com` + +##### Notes for Squid users + +If you are using these files within a squid dst_domain acl you will need to reformat the wildcard entries to be compliant with the squid acl format. The following regex should suffice `s/*\./\./` however latest versions of squid are very particular about duplicate domains. The scripts/create-squid.sh should help you out here! + +## Updates + +Please fork this repository and submit pull requests if you have any extra hostnames or services to add. We want this list to be definitive and collaborative! + +### New CDNs + +If the CDN you are adding does not already exist please remember to add an entry within cache_domains.json as well as a new .txt file + +### Uncacheable CDNs + +Certain CDNs are not suitable for inclusion on this list because the content is entirely delivered over HTTPS and thus cannot be cached. + +For a list of currently identified uncacheable CDNs please see these issues: https://github.com/uklans/cache-domains/issues?q=is%3Aissue+is%3Aopen+label%3Ahttps-cantfix + +## Frequently Asked Questions + +If you have any questions, please check [our FAQs](faq.md). + +## Issues and Feedback + +Please raise all issues and feedback on GitHub at [uklans/cache-domains](https://github.com/uklans/cache-domains/issues). + +## Useful Information + +There are a few useful anecdotes on cache domains usage in some old issues https://github.com/uklans/cache-domains/issues?q=is%3Aissue+is%3Aclosed+label%3Afor-reference-only + +## License + +The MIT License (MIT) + +Copyright (c) 2017 UK LAN Techs + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/arenanet.txt b/arenanet.txt new file mode 100644 index 0000000..9943b21 --- /dev/null +++ b/arenanet.txt @@ -0,0 +1,3 @@ +assetcdn.101.arenanetworks.com +assetcdn.102.arenanetworks.com +assetcdn.103.arenanetworks.com diff --git a/blizzard.txt b/blizzard.txt new file mode 100644 index 0000000..4093330 --- /dev/null +++ b/blizzard.txt @@ -0,0 +1,11 @@ +dist.blizzard.com +dist.blizzard.com.edgesuite.net +blizzard.vo.llnwd.net +blzddist1-a.akamaihd.net +blzddist2-a.akamaihd.net +blzddist3-a.akamaihd.net +level3.blizzard.com +nydus.battle.net +edge.blizzard.top.comcast.net +cdn.blizzard.com +*.cdn.blizzard.com diff --git a/bsg.txt b/bsg.txt new file mode 100644 index 0000000..50eac29 --- /dev/null +++ b/bsg.txt @@ -0,0 +1,2 @@ +cdn-11.eft-store.com +cl-453343cd.gcdn.co diff --git a/cache_domains.json b/cache_domains.json new file mode 100644 index 0000000..cc584d2 --- /dev/null +++ b/cache_domains.json @@ -0,0 +1,131 @@ +{ + "cache_domains": [ + { + "name": "arenanet", + "description": "CDN for guild wars, HoT", + "domain_files": ["arenanet.txt"] + }, + { + "name": "blizzard", + "description": "CDN for blizzard/battle.net", + "domain_files": ["blizzard.txt"] + }, + { + "name": "cod", + "description": "CDN for Call of Duty", + "domain_files": ["cod.txt"] + }, + { + "name": "bsg", + "description": "CDN for Battle State Games, Tarkov", + "domain_files": ["bsg.txt"] + }, + { + "name": "cityofheroes", + "description": "CDN for City of Heroes (Homecoming)", + "domain_files": ["cityofheroes.txt"] + }, + { + "name": "daybreak", + "description": "Daybreak games CDN", + "domain_files": ["daybreak.txt"] + }, + { + "name": "epicgames", + "description": "CDN for Epic Games", + "domain_files": ["epicgames.txt"] + }, + { + "name": "frontier", + "description": "CDN for frontier games", + "domain_files": ["frontier.txt"] + }, + { + "name": "nexusmods", + "description": "Nexus mods / skyrim content", + "domain_files": ["nexusmods.txt"] + }, + { + "name": "neverwinter", + "description": "Cryptic CDN for Neverwinter", + "domain_files": ["neverwinter.txt"] + }, + { + "name": "nintendo", + "description": "CDN for Nintendo consoles and download servers", + "domain_files": ["nintendo.txt"] + }, + { + "name": "origin", + "description": "CDN for origin", + "notes": "Should be enabled for HTTP traffic only or with a HTTPS proxy else origin client download fails", + "mixed_content": true, + "domain_files": ["origin.txt"] + }, + { + "name": "pathofexile", + "description": "CDN for Path Of Exile", + "domain_files": ["pathofexile.txt"] + }, + { + "name": "renegadex", + "description": "CDN for Renegade X", + "domain_files": ["renegadex.txt"] + }, + { + "name": "riot", + "description": "CDN for riot games", + "domain_files": ["riot.txt"] + }, + { + "name": "rockstar", + "description": "CDN for rockstar games", + "domain_files": ["rockstar.txt"] + }, + { + "name": "sony", + "description": "CDN for sony / playstation", + "domain_files": ["sony.txt"] + }, + { + "name": "square", + "description": "CDN for Final Fantasy XIV", + "domain_files": ["square.txt"] + }, + { + "name": "steam", + "description": "CDN for steam platform", + "domain_files": ["steam.txt"] + }, + { + "name": "uplay", + "description": "CDN for uplay downloader", + "domain_files": ["uplay.txt"] + }, + { + "name": "teso", + "description": "CDN for The Elder Scrolls Online", + "domain_files": ["teso.txt"] + }, + { + "name": "warframe", + "description": "CDN for Warframe", + "domain_files": ["warframe.txt"] + }, + { + "name": "wargaming", + "description": "CDN for wargaming.net", + "domain_files": ["wargaming.net.txt"] + }, + { + "name": "wsus", + "description": "CDN for windows updates", + "domain_files": ["windowsupdates.txt"] + }, + { + "name": "xboxlive", + "description": "CDN for xboxlive", + "domain_files": ["xboxlive.txt"] + } + ] +} diff --git a/cityofheroes.txt b/cityofheroes.txt new file mode 100644 index 0000000..19aa469 --- /dev/null +++ b/cityofheroes.txt @@ -0,0 +1,4 @@ +cdn-na1.homecomingservers.com +cdn-na2.homecomingservers.com +cdn-na3.homecomingservers.com +cdn-eu1.homecomingservers.com diff --git a/cod.txt b/cod.txt new file mode 100644 index 0000000..5e3becd --- /dev/null +++ b/cod.txt @@ -0,0 +1,2 @@ +cod-assets.cdn.callofduty.com +cod-assets.cdn.callofduty.com.edgesuite.net diff --git a/daybreak.txt b/daybreak.txt new file mode 100644 index 0000000..56c62d0 --- /dev/null +++ b/daybreak.txt @@ -0,0 +1,6 @@ +# Daybreak games +# +# Do NOT cache manifest.patch.daybreakgames.com +# +#PS2 +pls.patch.daybreakgames.com diff --git a/epicgames.txt b/epicgames.txt new file mode 100644 index 0000000..fbd1ca2 --- /dev/null +++ b/epicgames.txt @@ -0,0 +1,13 @@ +cdn1.epicgames.com +cdn2.epicgames.com +cdn.unrealengine.com +cdn1.unrealengine.com +cdn2.unrealengine.com +cdn3.unrealengine.com +download.epicgames.com +download2.epicgames.com +download3.epicgames.com +download4.epicgames.com +epicgames-download1.akamaized.net +fastly-download.epicgames.com +cloudflare.epicgamescdn.com diff --git a/faq.md b/faq.md new file mode 100644 index 0000000..d4ab901 --- /dev/null +++ b/faq.md @@ -0,0 +1,41 @@ +# Frequently Asked Questions + +## What is this list? + +This is a list of hostnames for various CDNs or companies that host game related content that can be cached. + +## Who is this list for? + +The list is maintained primarily for people running LAN parties / gaming events, whether that's 10 people gaming in a friend's garage or thousands bringing their own machines to an exhibition centre. Anyone running a LAN will likely benefit from caching game downloads and other suitable content, by saving internet bandwidth and preventing multiple people downloading the same content from the internet. However anyone running any network that includes multiple gaming computers (such as an internet or gaming cafe) may also benefit. + +## How do I use this list? + +There are multiple ways to use this list in a caching solution. See [the readme](https://github.com/uklans/cache-domains#usage) for more information. + +## Do you recommend any cache solutions? + +Many of the maintainers of this repo also contribute to [the lancachenet project](https://github.com/lancachenet/monolithic) which uses this list as its source of host names. + +## Why isn't *some other service* on the list? + +There are several reasons why a particular service / CDN / website might not be on this list. Here are some of the more common ones: + +1. It's not technically possible to cache it. Many popular websites, including video streaming sites and even some games CDN's use SSL Encryption (i.e https URLs) to serve their content. Because the client opens a secure connection directly to the host, there is no way for the network operator to see what they are downloading, nor cache it. Whilst there are several approaches to work around this, such as MITM techniques, they usually rely on control over the client device to affect SSL Certificates - control somebody running a BYOC LAN typically does not have over the devices customers bring. + + - [These issues](https://github.com/uklans/cache-domains/issues?q=is%3Aissue+is%3Aopen+label%3Ahttps-cantfix) contain game CDNs that we would like to include, but cannot for this reason. + +2. It's out of scope for a LAN. We try to keep this list targeted towards people running LANs. Whilst some none game-related CDNs are included for things like windows updates that use internet bandwidth at LANs, we do not go searching for unrelated sites / hostnames. + +3. It's not a good cache target / it would not get a good hit ratio. Game downloads are a great cache target because they are large, remain the same for every user and are likely to be downloaded multiple times at a LAN. Other hostnames that only serve dynamic or media files, or content that is not likely to be downloaded multiple times is not a good cache target and can waste valuable storage space on your cache server. This can lead to potentially more valuable content being evicted from the cache due to low space. + +4. We simply don't yet have a tested list of hostnames for it yet. This is the category you can help with - if you have something that doesn't fall into one of the above reasons not to include it, we would love to review your PR. See [the readme](https://github.com/uklans/cache-domains) for instructions on how to add a new CDN. + +## SNI Proxy / HTTPS + +[lancachenet/sniproxy](https://github.com/lancachenet/sniproxy) is part of the lancache project and allows hostnames that serve BOTH http and https content to be included in this list. Traffic going to that hostname on port 80 (http) will hit lancache and be cached, whilst traffic on port 443 (HTTPS) is passed straight through to the internet by sniproxy. + +It does not allow https / SSL content to be inspected or cached. Hostnames that serve all or almost all https traffic are still unlikely to be good candidates for this list, as it just places load on the cache box but does not save any internet bandwidth. + +## How can I test an addition to this list? + +If you are using the lancachenet project, you can fork this repo, add your test hostnames and then use [these instructions](https://github.com/lancachenet/lancache-dns#custom-forksbranches) to use it with your cache instance rather than the main repo. diff --git a/frontier.txt b/frontier.txt new file mode 100644 index 0000000..132127e --- /dev/null +++ b/frontier.txt @@ -0,0 +1 @@ +cdn.zaonce.net diff --git a/neverwinter.txt b/neverwinter.txt new file mode 100644 index 0000000..35e4eb1 --- /dev/null +++ b/neverwinter.txt @@ -0,0 +1 @@ +level3.nwhttppatch.crypticstudios.com diff --git a/nexusmods.txt b/nexusmods.txt new file mode 100644 index 0000000..20f38c5 --- /dev/null +++ b/nexusmods.txt @@ -0,0 +1 @@ +filedelivery.nexusmods.com diff --git a/nintendo.txt b/nintendo.txt new file mode 100644 index 0000000..eee7b01 --- /dev/null +++ b/nintendo.txt @@ -0,0 +1,12 @@ +ccs.cdn.wup.shop.nintendo.net +ccs.cdn.wup.shop.nintendo.net.edgesuite.net +geisha-wup.cdn.nintendo.net +geisha-wup.cdn.nintendo.net.edgekey.net +idbe-wup.cdn.nintendo.net +idbe-wup.cdn.nintendo.net.edgekey.net +ecs-lp1.hac.shop.nintendo.net +receive-lp1.dg.srv.nintendo.net +*.wup.shop.nintendo.net +*.wup.eshop.nintendo.net +*.hac.lp1.d4c.nintendo.net +*.hac.lp1.eshop.nintendo.net diff --git a/origin.txt b/origin.txt new file mode 100644 index 0000000..0a24713 --- /dev/null +++ b/origin.txt @@ -0,0 +1,3 @@ +origin-a.akamaihd.net +lvlt.cdn.ea.com +cdn-patch.swtor.com diff --git a/pathofexile.txt b/pathofexile.txt new file mode 100644 index 0000000..10c5217 --- /dev/null +++ b/pathofexile.txt @@ -0,0 +1 @@ +patchcdn.pathofexile.com diff --git a/renegadex.txt b/renegadex.txt new file mode 100644 index 0000000..02a4fc3 --- /dev/null +++ b/renegadex.txt @@ -0,0 +1,2 @@ +patches.totemarts.services +patches.totemarts.games diff --git a/riot.txt b/riot.txt new file mode 100644 index 0000000..b75b6f5 --- /dev/null +++ b/riot.txt @@ -0,0 +1,5 @@ +l3cdn.riotgames.com +worldwide.l3cdn.riotgames.com +riotgamespatcher-a.akamaihd.net +riotgamespatcher-a.akamaihd.net.edgesuite.net +*.dyn.riotcdn.net diff --git a/rockstar.txt b/rockstar.txt new file mode 100644 index 0000000..4922bbe --- /dev/null +++ b/rockstar.txt @@ -0,0 +1 @@ +patches.rockstargames.com diff --git a/scripts/README.md b/scripts/README.md new file mode 100755 index 0000000..c9c7bdf --- /dev/null +++ b/scripts/README.md @@ -0,0 +1,53 @@ +# DNS Generation Scripts + +## Introduction + +The respective shell scripts contained within this directory can be utilised to generate application specific compliant +configuration which can be utilised with: + +* AdGuard Home +* BIND9 +* Dnsmasq/Pi-hole +* Squid +* Unbound + +## Usage + +1. Copy `config.example.json` to `config.json`. +2. Modify `config.json` to include your Cacheserver's IP(s) and the CDNs you plan to cache. + +The following example assumes a single shared Cacheserver IP: +```json +{ + "combined_output": false, + "ips": { + "monolithic": ["10.10.10.200"] + }, + "cache_domains": { + "blizzard": "monolithic", + "epicgames": "monolithic", + "nintendo": "monolithic", + "origin": "monolithic", + "riot": "monolithic", + "sony": "monolithic", + "steam": "monolithic", + "uplay": "monolithic", + "wsus": "monolithic" + } +} +``` +3. Run generation script relative to your DNS implementation: `bash create-dnsmasq.sh`. +4. If `combined_output` is set to `true` this will result in a single output file: `lancache.conf` with all your enabled services (applies to Adguard Home, Dnsmasq or Unbound). +5. Copy files from `output/{adguardhome,dnsmasq,rpz,squid,unbound}/*` to the respective locations for Dnsmasq/Unbound. +6. Restart the appropriate service. + +### Notes for Dnsmasq users + +**This also applies to users utilising the script alongside Pi-hole.** + +Multi-IP Lancache setups are only supported with Dnsmasq or Pi-hole versions >= 2.86 or 2021.09 respectively. + +### Notes for AdGuard Home users + +1. Utilising `"combined_output": true` is more convenient. +2. Once you have run the script and uploaded the file to the appropriate location, you should navigate to Adguard Home -> Filters -> DNS blocklists -> Add blocklist -> Add a custom list. diff --git a/scripts/create-adguardhome.sh b/scripts/create-adguardhome.sh new file mode 100755 index 0000000..abcd1c9 --- /dev/null +++ b/scripts/create-adguardhome.sh @@ -0,0 +1,80 @@ +#!/bin/bash +basedir=".." +outputdir="output/adguardhome" +path="${basedir}/cache_domains.json" + +export IFS=' ' + +test=$(which jq); +if [ $? -gt 0 ] ; then + echo "This script requires jq to be installed." + echo "Your package manager should be able to find it" + exit 1 +fi + +cachenamedefault="disabled" +combinedoutput=$(jq -r ".combined_output" config.json) + +while read line; do + ip=$(jq ".ips[\"${line}\"]" config.json) + declare "cacheip${line}"="${ip}" +done <<< $(jq -r '.ips | to_entries[] | .key' config.json) + +while read line; do + name=$(jq -r ".cache_domains[\"${line}\"]" config.json) + declare "cachename$line"="$name" +done <<< $(jq -r '.cache_domains | to_entries[] | .key' config.json) + +rm -rf ${outputdir} +mkdir -p ${outputdir} +while read entry; do + unset cacheip + unset cachename + key=$(jq -r ".cache_domains[$entry].name" ${path}) + cachename="cachename${key}" + if [ -z "${!cachename}" ]; then + cachename="cachenamedefault" + fi + if [[ ${!cachename} == "disabled" ]]; then + continue; + fi + cacheipname="cacheip${!cachename}" + cacheip=$(jq -r 'if type == "array" then .[] else . end' <<< ${!cacheipname} | xargs) + while read fileid; do + while read filename; do + destfilename=$(echo ${filename} | sed -e 's/txt/conf/') + outputfile=${outputdir}/${destfilename} + touch ${outputfile} + while read fileentry; do + # Ignore comments and newlines + if [[ ${fileentry} == \#* ]] || [[ -z ${fileentry} ]]; then + continue + fi + domainprefix="|" + if [[ $fileentry =~ ^\*\. ]]; then + domainprefix="||" + fi + parsed=$(echo ${fileentry} | sed -e "s/^\*\.//") + if grep -q "${domainprefix}${parsed}^\$dnsrewrite" ${outputfile}; then + continue + fi + for i in ${cacheip}; do + echo "${domainprefix}${parsed}^\$dnsrewrite=${i}" >> ${outputfile} + done + done <<< $(cat ${basedir}/$filename | sort); + done <<< $(jq -r ".cache_domains[${entry}].domain_files[${fileid}]" ${path}) + done <<< $(jq -r ".cache_domains[${entry}].domain_files | to_entries[] | .key" ${path}) +done <<< $(jq -r '.cache_domains | to_entries[] | .key' ${path}) + +if [[ ${combinedoutput} == "true" ]]; then + for file in ${outputdir}/*; do f=${file//${outputdir}\/} && f=${f//.conf} && echo "# ${f^}" >> ${outputdir}/lancache.conf && cat ${file} >> ${outputdir}/lancache.conf && rm ${file}; done +fi + +cat << EOF +Configuration generation completed. + +Please copy the following files: +- ./${outputdir}/*.conf to /opt/adguardhome/work/userfilters/ +- Navigate to Adguard Home -> Filters -> DNS blocklists -> Add blocklist -> Add a custom list +- Add list for each service or utilise the combined output for a single list +EOF diff --git a/scripts/create-dnsmasq.sh b/scripts/create-dnsmasq.sh new file mode 100755 index 0000000..49a6e25 --- /dev/null +++ b/scripts/create-dnsmasq.sh @@ -0,0 +1,76 @@ +#!/bin/bash +basedir=".." +outputdir="output/dnsmasq" +path="${basedir}/cache_domains.json" + +export IFS=' ' + +test=$(which jq); +if [ $? -gt 0 ] ; then + echo "This script requires jq to be installed." + echo "Your package manager should be able to find it" + exit 1 +fi + +cachenamedefault="disabled" +combinedoutput=$(jq -r ".combined_output" config.json) + +while read -r line; do + ip=$(jq ".ips[\"${line}\"]" config.json) + declare "cacheip${line}"="${ip}" +done <<< $(jq -r '.ips | to_entries[] | .key' config.json) + +while read -r line; do + name=$(jq -r ".cache_domains[\"${line}\"]" config.json) + declare "cachename${line}"="${name}" +done <<< $(jq -r '.cache_domains | to_entries[] | .key' config.json) + +rm -rf ${outputdir} +mkdir -p ${outputdir} +while read -r entry; do + unset cacheip + unset cachename + key=$(jq -r ".cache_domains[${entry}].name" ${path}) + cachename="cachename${key}" + if [ -z "${!cachename}" ]; then + cachename="cachenamedefault" + fi + if [[ ${!cachename} == "disabled" ]]; then + continue; + fi + cacheipname="cacheip${!cachename}" + cacheip=$(jq -r 'if type == "array" then .[] else . end' <<< ${!cacheipname} | xargs) + while read -r fileid; do + while read -r filename; do + destfilename=$(echo ${filename} | sed -e 's/txt/conf/') + outputfile=${outputdir}/${destfilename} + touch ${outputfile} + while read -r fileentry; do + # Ignore comments, newlines and wildcards + if [[ ${fileentry} == \#* ]] || [[ -z ${fileentry} ]]; then + continue + fi + parsed=$(echo ${fileentry} | sed -e "s/^\*\.//") + for i in ${cacheip}; do + if ! grep -qx "address=/${parsed}/${i}" "${outputfile}"; then + echo "address=/${parsed}/${i}" >> "${outputfile}" + fi + if ! grep -qx "local=/${parsed}/" "${outputfile}"; then + echo "local=/${parsed}/" >> "${outputfile}" + fi + done + done <<< $(cat ${basedir}/${filename} | sort); + done <<< $(jq -r ".cache_domains[${entry}].domain_files[$fileid]" ${path}) + done <<< $(jq -r ".cache_domains[${entry}].domain_files | to_entries[] | .key" ${path}) +done <<< $(jq -r '.cache_domains | to_entries[] | .key' ${path}) + +if [[ ${combinedoutput} == "true" ]]; then + for file in ${outputdir}/*; do f=${file//${outputdir}\/} && f=${f//.conf} && echo "# ${f^}" >> ${outputdir}/lancache.conf && cat ${file} >> ${outputdir}/lancache.conf && rm ${file}; done +fi + +cat << EOF +Configuration generation completed. + +Please copy the following files: +- ./${outputdir}/*.conf to /etc/dnsmasq/dnsmasq.d/ +EOF diff --git a/scripts/create-rpz.sh b/scripts/create-rpz.sh new file mode 100755 index 0000000..a2bd94f --- /dev/null +++ b/scripts/create-rpz.sh @@ -0,0 +1,113 @@ +#!/bin/bash +basedir=".." +outputdir="output/rpz" +path="${basedir}/cache_domains.json" +basedomain=${1:-lancache.net} + +export IFS=' ' + +test=$(which jq); +if [ $? -gt 0 ] ; then + echo "This script requires jq to be installed." + echo "Your package manager should be able to find it" + exit 1 +fi + +cachenamedefault="disabled" + +while read line; do + ip=$(jq ".ips[\"${line}\"]" config.json) + declare "cacheip${line}"="${ip}" +done <<< $(jq -r '.ips | to_entries[] | .key' config.json) + +while read line; do + name=$(jq -r ".cache_domains[\"${line}\"]" config.json) + declare "cachename${line}"="${name}" +done <<< $(jq -r '.cache_domains | to_entries[] | .key' config.json) + +rm -rf ${outputdir} +mkdir -p ${outputdir} +outputfile=${outputdir}/db.rpz.${basedomain} +cat > ${outputfile} << EOF +\$TTL 60 ; default TTL +\$ORIGIN rpz.${basedomain}. +@ SOA ns1.${basedomain}. admin.${basedomain}. ( + $(date +%Y%m%d01) ; serial + 604800 ; refresh (1 week) + 600 ; retry (10 mins) + 600 ; expire (10 mins) + 600 ; minimum (10 mins) + ) + NS ns1.${basedomain}. + NS ns2.${basedomain}. + +EOF + +while read entry; do + unset cacheip + unset cachename + key=$(jq -r ".cache_domains[${entry}].name" ${path}) + cachename="cachename${key}" + if [ -z "${!cachename}" ]; then + cachename="cachenamedefault" + fi + if [[ ${!cachename} == "disabled" ]]; then + continue; + fi + cacheipname="cacheip${!cachename}" + cacheip=$(jq -r 'if type == "array" then .[] else . end' <<< ${!cacheipname} | xargs) + while read fileid; do + while read filename; do + echo "" >> ${outputfile} + echo "; $(echo ${filename} | sed -e 's/.txt$//')" >> ${outputfile} + destfilename=$(echo ${filename} | sed -e 's/txt/conf/') + while read fileentry; do + # Ignore comments and newlines + if [[ ${fileentry} == \#* ]] || [[ -z ${fileentry} ]]; then + continue + fi + parsed=$(echo ${fileentry}) + if grep -qx "^\"${parsed}\". " ${outputfile}; then + continue + fi + t="" + for i in ${cacheip}; do + # only one cname per domain is allowed + if [[ ${t} = "CNAME" ]]; then + continue + fi + # for cnames you must use a fqdn with trailing dot + t="CNAME" + if [[ ${i} =~ ^[0-9\.]+$ ]] ; then + t="A" + elif [[ ! ${i} =~ \.$ ]] ; then + i="${i}." + fi + printf "%-50s IN %s %s\n" \ + "${parsed}" \ + "${t}" \ + "${i}" \ + >> ${outputfile} + done + done <<< $(cat ${basedir}/${filename} | sort); + done <<< $(jq -r ".cache_domains[${entry}].domain_files[${fileid}]" ${path}) + done <<< $(jq -r ".cache_domains[${entry}].domain_files | to_entries[] | .key" ${path}) +done <<< $(jq -r '.cache_domains | to_entries[] | .key' ${path}) + +cat << EOF +Configuration generation completed. + +Please include the rpz zone in your bind configuration" +- cp ${outputfile} /etc/bind +- configure the zone and use it + +options { + [...] + response-policy {zone "rpz.${basedomain}";}; + [...] +} +zone "rpz.$basedomain" { + type master; + file "/etc/bind/db.rpz.${basedomain}"; +}; +EOF diff --git a/scripts/create-squid.sh b/scripts/create-squid.sh new file mode 100755 index 0000000..9607ccb --- /dev/null +++ b/scripts/create-squid.sh @@ -0,0 +1,70 @@ +#!/bin/bash +basedir=".." +outputdir="output/squid" +path="${basedir}/cache_domains.json" +REGEX="^\\*\\.(.*)$" + +export IFS=' ' + +test=$(which jq); +if [ $? -gt 0 ] ; then + echo "This script requires jq to be installed." + echo "Your package manager should be able to find it" + exit 1 +fi + +cachenamedefault="disabled" + +while read -r line; do + name=$(jq -r ".cache_domains[\"${line}\"]" config.json) + declare "cachename${line}"="${name}" +done <<< $(jq -r '.cache_domains | to_entries[] | .key' config.json) + +rm -rf ${outputdir} +mkdir -p ${outputdir} +while read -r entry; do + unset cachename + key=$(jq -r ".cache_domains[$entry].name" ${path}) + cachename="cachename${key}" + if [ -z "${!cachename}" ]; then + cachename="cachenamedefault" + fi + if [[ ${!cachename} == "disabled" ]]; then + continue; + fi + while read -r fileid; do + while read -r filename; do + destfilename=$(echo ${!cachename}.txt) + outputfile=${outputdir}/${destfilename} + touch ${outputfile} + while read -r fileentry; do + # Ignore comments + if [[ ${fileentry} == \#* ]] || [[ -z ${fileentry} ]]; then + continue + fi + # Ha wildcards to squid wildcards + parsed=$(echo ${fileentry} | sed -e "s/^\*\./\./") + # If we have cdn.thing and *.cdn.thing in cache_domains + # Squid requires ONLY cdn.thing + # + # If the fileentry starts with *.cdn.thing + if [[ ${fileentry} =~ $REGEX ]]; then + # Does the cache_domains file also contain cdn.thing + grep "${BASH_REMATCH[1]}" ${basedir}/${filename} | grep -v "${fileentry}" > /dev/null + if [[ $? -eq 0 ]]; then + # Skip *.cdn.thing as cdn.thing will be collected earlier/later + continue + fi + fi + echo "${parsed}" >> "${outputfile}" + done <<< $(cat ${basedir}/${filename} | sort); + done <<< $(jq -r ".cache_domains[${entry}].domain_files[${fileid}]" ${path}) + done <<< $(jq -r ".cache_domains[${entry}].domain_files | to_entries[] | .key" ${path}) +done <<< $(jq -r '.cache_domains | to_entries[] | .key' ${path}) + +cat << EOF +Configuration generation completed. + +Please copy the following files: +- ./${outputdir}/*.txt to /etc/squid/domains/ +EOF diff --git a/scripts/create-unbound.sh b/scripts/create-unbound.sh new file mode 100755 index 0000000..52de21b --- /dev/null +++ b/scripts/create-unbound.sh @@ -0,0 +1,78 @@ +#!/bin/bash +basedir=".." +outputdir="output/unbound" +path="${basedir}/cache_domains.json" + +export IFS=' ' + +test=$(which jq); +if [ $? -gt 0 ] ; then + echo "This script requires jq to be installed." + echo "Your package manager should be able to find it" + exit 1 +fi + +cachenamedefault="disabled" +combinedoutput=$(jq -r ".combined_output" config.json) + +while read line; do + ip=$(jq ".ips[\"${line}\"]" config.json) + declare "cacheip${line}"="${ip}" +done <<< $(jq -r '.ips | to_entries[] | .key' config.json) + +while read line; do + name=$(jq -r ".cache_domains[\"${line}\"]" config.json) + declare "cachename${line}"="${name}" +done <<< $(jq -r '.cache_domains | to_entries[] | .key' config.json) + +rm -rf ${outputdir} +mkdir -p ${outputdir} +while read entry; do + unset cacheip + unset cachename + key=$(jq -r ".cache_domains[${entry}].name" ${path}) + cachename="cachename${key}" + if [ -z "${!cachename}" ]; then + cachename="cachenamedefault" + fi + if [[ ${!cachename} == "disabled" ]]; then + continue; + fi + cacheipname="cacheip${!cachename}" + cacheip=$(jq -r 'if type == "array" then .[] else . end' <<< ${!cacheipname} | xargs) + while read fileid; do + while read filename; do + destfilename=$(echo ${filename} | sed -e 's/txt/conf/') + outputfile=${outputdir}/${destfilename} + touch ${outputfile} + while read fileentry; do + # Ignore comments and newlines + if [[ ${fileentry} == \#* ]] || [[ -z ${fileentry} ]]; then + continue + fi + parsed=$(echo ${fileentry} | sed -e "s/^\*\.//") + if grep -qx " local-zone: \"${parsed}\" redirect" ${outputfile}; then + continue + fi + if [[ $(head -n 1 ${outputfile}) != "server:" ]]; then + echo "server:" >> ${outputfile} + fi + echo " local-zone: \"${parsed}\" redirect" >> ${outputfile} + for i in ${cacheip}; do + echo " local-data: \"${parsed} 30 IN A ${i}\"" >> ${outputfile} + done + done <<< $(cat ${basedir}/${filename} | sort); + done <<< $(jq -r ".cache_domains[${entry}].domain_files[${fileid}]" ${path}) + done <<< $(jq -r ".cache_domains[${entry}].domain_files | to_entries[] | .key" ${path}) +done <<< $(jq -r '.cache_domains | to_entries[] | .key' ${path}) + +if [[ ${combinedoutput} == "true" ]]; then + for file in ${outputdir}/*; do f=${file//${outputdir}\/} && f=${f//.conf} && echo "# ${f^}" >> ${outputdir}/lancache.conf && cat ${file} >> ${outputdir}/lancache.conf && rm ${file}; done +fi + +cat << EOF +Configuration generation completed. + +Please copy the following files: +- ./${outputdir}/*.conf to /etc/unbound/unbound.conf.d/ +EOF diff --git a/sony.txt b/sony.txt new file mode 100644 index 0000000..2c2d638 --- /dev/null +++ b/sony.txt @@ -0,0 +1,16 @@ +gs2.ww.prod.dl.playstation.net +*.gs2.ww.prod.dl.playstation.net +*.gs2.sonycoment.loris-e.llnwd.net +gs2-ww-prod.psn.akadns.net +*.gs2-ww-prod.psn.akadns.net +gs2.ww.prod.dl.playstation.net.edgesuite.net +*.gs2.ww.prod.dl.playstation.net.edgesuite.net +playstation4.sony.akadns.net +theia.dl.playstation.net +tmdb.np.dl.playstation.net +gs-sec.ww.np.dl.playstation.net +uef.np.dl.playstation.net +gst.prod.dl.playstation.net +vulcan.dl.playstation.net +sgst.prod.dl.playstation.net +psnobj.prod.dl.playstation.net diff --git a/square.txt b/square.txt new file mode 100644 index 0000000..0cf5e15 --- /dev/null +++ b/square.txt @@ -0,0 +1 @@ +patch-dl.ffxiv.com diff --git a/steam.txt b/steam.txt new file mode 100644 index 0000000..b21270f --- /dev/null +++ b/steam.txt @@ -0,0 +1 @@ +lancache.steamcontent.com diff --git a/teso.txt b/teso.txt new file mode 100644 index 0000000..f4b529e --- /dev/null +++ b/teso.txt @@ -0,0 +1 @@ +live.patcher.elderscrollsonline.com diff --git a/uplay.txt b/uplay.txt new file mode 100644 index 0000000..4042a60 --- /dev/null +++ b/uplay.txt @@ -0,0 +1 @@ +*.cdn.ubi.com diff --git a/warframe.txt b/warframe.txt new file mode 100644 index 0000000..379d22e --- /dev/null +++ b/warframe.txt @@ -0,0 +1 @@ +content.warframe.com diff --git a/wargaming.net.txt b/wargaming.net.txt new file mode 100644 index 0000000..795795c --- /dev/null +++ b/wargaming.net.txt @@ -0,0 +1,16 @@ +dl2.wargaming.net +wg.gcdn.co +wgus-wotasia.wargaming.net +dl-wot-ak.wargaming.net +dl-wot-gc.wargaming.net +dl-wot-se.wargaming.net +dl-wot-cdx.wargaming.net +dl-wows-ak.wargaming.net +dl-wows-gc.wargaming.net +dl-wows-se.wargaming.net +dl-wows-cdx.wargaming.net +dl-wowp-ak.wargaming.net +dl-wowp-gc.wargaming.net +dl-wowp-se.wargaming.net +dl-wowp-cdx.wargaming.net +wgus-woteu.wargaming.net diff --git a/windowsupdates.txt b/windowsupdates.txt new file mode 100644 index 0000000..059c96e --- /dev/null +++ b/windowsupdates.txt @@ -0,0 +1,11 @@ +*.windowsupdate.com +*.dl.delivery.mp.microsoft.com +dl.delivery.mp.microsoft.com +*.update.microsoft.com +*.do.dsp.mp.microsoft.com +*.microsoft.com.edgesuite.net +amupdatedl.microsoft.com +amupdatedl2.microsoft.com +amupdatedl3.microsoft.com +amupdatedl4.microsoft.com +amupdatedl5.microsoft.com diff --git a/xboxlive.txt b/xboxlive.txt new file mode 100644 index 0000000..74fff2b --- /dev/null +++ b/xboxlive.txt @@ -0,0 +1,7 @@ +assets1.xboxlive.com +assets2.xboxlive.com +xbox-mbr.xboxlive.com +assets1.xboxlive.com.nsatc.net +xvcf1.xboxlive.com +xvcf2.xboxlive.com +d1.xboxlive.com