1 2 // some variable instances with default values 3 // shared among different applications 4 5 #include "config.h" 6 #include "meta.h" 7 #include "acfg.h" 8 #include "sockio.h" 9 10 #include <atomic> 11 12 using namespace std; 13 14 namespace acng 15 { 16 namespace cfg 17 { 18 19 string cachedir("/var/tmp"), logdir("/var/tmp"), fifopath, pidfile, reportpage, 20 confdir, adminauth, adminauthB64, bindaddr, mirrorsrcs, suppdir(LIBDIR), 21 capath("/etc/ssl/certs"), cafile, badredmime("text/html"); 22 23 #define INFOLDER "(^|.*/)" 24 #define COMPRLIST "(\\.gz|\\.bz2|\\.lzma|\\.xz)" 25 #define ALXPATTERN ".*\\.(db|files|abs)(\\.tar" COMPRLIST ")?" 26 #define COMPOPT COMPRLIST"?" 27 //#define COMPONENT_OPTIONAL "(-[a-z0-9-])" 28 //#define PARANOIASOURCE "(\\.orig|\\.debian)" 29 30 string spfilepat; 31 32 string pfilepat(".*(\\.(u|d)?deb|\\.rpm|\\.drpm|\\.dsc|\\.tar" COMPRLIST 33 "|\\.diff" COMPRLIST "|\\.jigdo|\\.template|changelog|copyright" 34 "|\\.debdelta|\\.diff/.*\\.gz" 35 "|[a-f0-9]+-(susedata|updateinfo|primary|deltainfo).xml.gz" //opensuse, index data, hash in filename 36 "|fonts/(final/)?[a-z]+32.exe(\\?download.*)?" // msttcorefonts, fonts/final/comic32.exe /corefonts/comic32.exe plus SF's parameters 37 "|/dists/.*/installer-[^/]+/[0-9][^/]+/images/.*" // d-i stuff with revision 38 "|/[[:alpha:]]{1,2}/[a-f0-9]{64}(-[a-f0-9]{64})?(\\.gz)?" // FreeBSD, after https://alioth.debian.org/tracker/?func=detail&atid=413111&aid=315254&group_id=100566 39 "|/by-hash/(SHA|MD)[0-9]+/.*" // support Debian/Ubuntu by-hash index files 40 "|\\.asc$" // all remaining PGP signatures. Assuming that volatile ones are matched below. 41 "|changelogs/pool/.*/changelog.txt$" // packages.ultimediaos.com 42 "|/objects/.*/.*\\.(dirtree|filez|commit|commitmeta)|/repo/deltas/.*" // FlatPak 43 "|(base|doc|games|kernel|lib32|ports|src)\\.txz$" // FreeBSD releases 44 "|(packagesite|meta)\\.txz?$" // FreeBSD packagesite 45 "|\\.txz(\\.sig)?$" // FreeBSD package/signature 46 ")$"); 47 48 string svfilepat("/development/rawhide/.*" 49 // more stuff for ubuntu dist-upgrader 50 "|dists/.*dist-upgrader.*/current/.*" // /dists/xenial/main/dist-upgrader-all/current/xenial.tar.gz 51 "|changelogs.ubuntu.com/meta.*" // changelogs.ubuntu.com/meta-release-lts-development 52 // XXX: signature might change afterwards... any better solution than this location? 53 "|" INFOLDER ".*(\\.(d|u)?deb|\\.rpm|\\.drpm|\\.dsc|\\.tar" COMPRLIST ")\\.gpg$" 54 ); 55 56 string vfilepat(INFOLDER 57 "(Index|Packages" COMPOPT "|InRelease|Release|mirrors\\.txt|.*\\.gpg|NEWS\\.Debian" 58 "|Sources" COMPOPT "|release|index\\.db-.*\\.gz|Contents-[^/]*" COMPOPT 59 "|pkglist[^/]*\\.bz2|rclist[^/]*\\.bz2|meta-release[^/]*|Translation[^/]*" COMPOPT 60 "|MD5SUMS|SHA256SUMS|SHA1SUMS" // d-i stuff 61 "|((setup|setup-legacy)(\\.ini|\\.bz2|\\.hint)(\\.sig)?)|mirrors\\.lst" // cygwin 62 "|repo(index|md)\\.xml(\\.asc|\\.key)?|directory\\.yast" // opensuse 63 "|products|content(\\.asc|\\.key)?|media" // opensuse 2, are they important? 64 "|filelists\\.xml\\.gz|filelists\\.sqlite\\.bz2|repomd\\.xml" // SL, http://ra.khe.sh/computers/linux/apt-cacher-ng-with-yum.html 65 "|packages\\.[a-zA-Z][a-zA-Z]\\.gz|info\\.txt|license\\.tar\\.gz|license\\.zip" //opensuse 66 "|" ALXPATTERN // Arch Linux 67 "|metalink\\?repo|.*prestodelta\\.xml\\.gz|repodata/.*\\.(xml|sqlite)" COMPOPT // CentOS 68 "|\\.treeinfo|vmlinuz|(initrd|product|squashfs|updates)\\.img" // Fedora 69 "|\\.o" // https://bugs.launchpad.net/ubuntu/+source/apt-cacher-ng/+bug/1078224 70 "|Components-.*yml" COMPOPT // DEP-11 aka AppStream" 71 "|icons-[x0-9]+\\.tar" COMPOPT 72 "|(latest|pub|snapshot)\\.ssl|[0-9a-f]{64}.tgz|MANIFEST|/ports-distfiles/.*" // FreeBSD 73 ")$" // end of filename-only patterns 74 75 "|/dists/.*/installer-[^/]+/[^0-9][^/]+/images/.*" // d-i stuff but not containing a date (year number) in the revision directory (like "current", "beta", ...) 76 "|/pks/lookup.op.get" // some Ubuntu PPA management activity 77 "|centos/.*/images/.*img" // [#314924] Allow access to CentOS images 78 79 "|connectivity-check.html|ubiquity/.*update|getubuntu/releasenotes" // Ubuntu installer network check, etc. 80 "|wiki.ubuntu.com/.*/ReleaseNotes" // this is actually for an internal check and therefore contains the hostname 81 "|ubuntu/dists/.*\\.html" // http://archive.ubuntu.com/ubuntu/dists/vivid-updates/main/dist-upgrader-all/current/ReleaseAnnouncement.html 82 "|metadata.(ftp-master.debian|tanglu).org/changelogs/.*" // some of them are not static 83 "|/refs/heads/app.*|/repo/(summary|config)(\\.sig)?|/Service/News$" // FlatPak 84 ); 85 86 //string wfilepat( VPATPREFIX "(Release|Release\\.gpg|release|meta-release|Translation[^/]*\\.bz2)$"); 87 //string wfilepat(vfilepat); 88 string wfilepat(INFOLDER 89 "(Release|InRelease|.*\\.gpg" 90 "|(Packages|Sources)" COMPRLIST "?" // hm... private repos without Release file :-( 91 "|.*\\.xml" // SUSE 92 "|setup\\.bz2(.sig)?" // Cygwin 93 "|" ALXPATTERN // Arch Linux 94 "|[a-z]+32.exe" 95 "|mirrors.ubuntu.com/mirrors.txt" 96 "|/[[:alpha:]]{1,2}/[a-f0-9]{64}(-[a-f0-9]{64})?(\\.gz)?" // FIXME: add expiration code 97 ")$"); 98 99 string pfilepatEx, spfilepatEx, vfilepatEx, svfilepatEx, wfilepatEx; // for customization by user 100 int offlinemode(false), verboselog(true), stupidfs(false), forcemanaged(false), 101 extreshhold(20), tpstandbymax(8), tpthreadmax(-1), dirperms(00755), fileperms(00664), 102 keepnver(0), maxtempdelay(27), vrangeops(1); 103 104 int dlbufsize(70000), exfailabort(1), exporigin(false), numcores(1), 105 logxff(false), oldupdate(false), recompbz2(false), nettimeout(60), updinterval(0), 106 forwardsoap(RESERVED_DEFVAL), usewrap(RESERVED_DEFVAL), redirmax(RESERVED_DEFVAL), 107 stucksecs(500), persistoutgoing(1), pipelinelen(10), exsupcount(RESERVED_DEFVAL), 108 optproxytimeout(-1), patrace(false), maxredlsize(1<<16), nsafriendly(false), 109 trackfileuse(false), exstarttradeoff(500000000); 110 111 int maxdlspeed(RESERVED_DEFVAL); 112 113 string optproxycmd; 114 int optproxycheckint=-1; 115 116 #ifdef DEBUG 117 int dnscachetime(30); 118 #else 119 int dnscachetime(1800); 120 #endif 121 122 string agentname("Debian Apt-Cacher-NG/" ACVERSION); 123 string remoteport("80"), port(ACNG_DEF_PORT); 124 string agentheader; 125 126 string requestapx; 127 string sigbuscmd; 128 mstring connectPermPattern("~~~"); 129 130 #ifdef DEBUG 131 int debug(3), foreground(true); 132 //string cachedir("/var/cache/acng"), logdir("/var/log/acng"), fifopath, pidfile; 133 #else 134 int debug(0), foreground(false); 135 #endif 136 137 string cacheDirSlash; // guaranteed to have a trailing path separator 138 139 int conprotos[2] = { PF_UNSPEC, PF_UNSPEC }; 140 141 std::atomic_bool degraded(false); 142 143 int allocspace = 1024*1024; 144 145 } 146 147 } 148