#!/bin/bash set -e source config/config.sh echo -n > "$PACFILE" # .pac header echo "// ProstoVPN.AntiZapret PAC-host File // Generated on $(date) // NOTE 1: Proxy.pac file content varies on User-Agent HTTP header. // NOTE 2: Some badly behaving User-Agents are banned, they get empty response. // NOTE 3: Do not request PAC file faster than once a minute, rate limiting is applied. // NOTE 4: Do not use the proxy servers outside of this file. " >> "$PACFILE" awk -f scripts/generate-pac-domains.awk result/hostlist_zones.txt >> "$PACFILE" # Collapse IP list scripts/collapse_blockedbyip_noid2971.py echo "// This variable now excludes IP addresses blocked by 33a-5536/2019 (since 17.05.2020) and 33-4/2018 (since 14.12.2020)" >> "$PACFILE" sort -Vu temp/include-ips.txt result/iplist_blockedbyip_noid2971_collapsed.txt | \ grep -v -F -x -f temp/exclude-ips.txt | awk -f scripts/generate-pac-ipaddrs.awk >> "$PACFILE" SPECIAL="$(cat result/iplist_special_range.txt | xargs -n1 sipcalc | \ awk 'BEGIN {notfirst=0} /Network address/ {n=$4} /Network mask \(bits\)/ {if (notfirst) {printf ","} printf "[\"%s\", %s]", n, $5; notfirst=1;}')" echo "var special = [ $SPECIAL ]; var az_initialized = 0; // CIDR to netmask, for special function nmfc(b) {var m=[];for(var i=0;i<4;i++) {var n=Math.min(b,8); m.push(256-Math.pow(2, 8-n)); b-=n;} return m.join('.');} function FindProxyForURL(url, host) {" >> "$PACFILE" echo " if (domains.length < 10) return \"DIRECT\"; // list is broken if (!('indexOf' in Array.prototype)) { Array.prototype.indexOf= function(find, i /*opt*/) { if (i===undefined) i= 0; if (i<0) i+= this.length; if (i<0) i= 0; for (var n= this.length; i> "$PACFILE" cp "$PACFILE" "$PACFILE_NOSSL" echo " return \"HTTPS ${PACHTTPSHOST}; PROXY ${PACPROXYHOST}; DIRECT\";" >> "$PACFILE" echo " return \"PROXY ${PACPROXYHOST}; DIRECT\";" >> "$PACFILE_NOSSL" echo " } return \"DIRECT\"; }" | tee -a "$PACFILE" "$PACFILE_NOSSL" >/dev/null