1 2 #ifndef _ACFG_H 3 #define _ACFG_H 4 5 #include "config.h" 6 #include "meta.h" 7 #include <bitset> 8 9 #define NUM_PBKDF2_ITERATIONS 1 10 // 1757961 11 #define ACNG_DEF_PORT "3142" 12 13 namespace acng 14 { 15 16 struct ltstring { operatorltstring17 bool operator()(const mstring &s1, const mstring &s2) const { 18 return strcasecmp(s1.c_str(), s2.c_str()) < 0; 19 } 20 }; 21 22 typedef std::map<mstring, mstring, ltstring> NoCaseStringMap; 23 24 namespace cfg 25 { 26 static const int RESERVED_DEFVAL = -4223; 27 28 static const int REDIRMAX_DEFAULT = 5; 29 30 extern mstring cachedir, logdir, confdir, fifopath, user, group, pidfile, suppdir, 31 reportpage, vfilepat, pfilepat, wfilepat, agentname, adminauth, adminauthB64, 32 bindaddr, port, sUmask, 33 tmpDontcacheReq, tmpDontcachetgt, tmpDontcache, mirrorsrcs, requestapx, 34 cafile, capath, spfilepat, svfilepat, badredmime, sigbuscmd, connectPermPattern; 35 36 extern mstring pfilepatEx, vfilepatEx, wfilepatEx, spfilepatEx, svfilepatEx; // for customization by user 37 38 extern int debug, numcores, offlinemode, foreground, verbose, stupidfs, forcemanaged, keepnver, 39 verboselog, extreshhold, exfailabort, tpstandbymax, tpthreadmax, dnscachetime, dlbufsize, usewrap, 40 exporigin, logxff, oldupdate, recompbz2, nettimeout, updinterval, forwardsoap, dirperms, fileperms, 41 maxtempdelay, redirmax, vrangeops, stucksecs, persistoutgoing, pipelinelen, exsupcount, 42 optproxytimeout, patrace, maxdlspeed, maxredlsize, nsafriendly, trackfileuse, exstarttradeoff; 43 extern int allocspace; 44 45 // processed config settings 46 extern const tHttpUrl* GetProxyInfo(); 47 extern void MarkProxyFailure(); 48 extern mstring agentheader; 49 50 extern int conprotos[2]; 51 52 bool SetOption(const mstring &line, NoCaseStringMap *pDupeChecker); 53 void dump_config(bool includingDelicateValues=false); 54 void ReadConfigDirectory(const char*, bool bReadErrorIsFatal=true); 55 56 //! Prepare various things resulting from variable combinations, etc. 57 void PostProcConfig(); 58 59 bool DegradedMode(); 60 61 struct tRepoData 62 { 63 std::vector<tHttpUrl> m_backends; 64 65 // dirty little helper to execute custom actions when a jobs associates or forgets this data set 66 struct IHookHandler { 67 virtual void OnAccess()=0; 68 virtual void OnRelease()=0; ~IHookHandlertRepoData::IHookHandler69 virtual ~IHookHandler() { 70 } 71 } *m_pHooks = nullptr; 72 tStrVec m_keyfiles; 73 tHttpUrl m_deltasrc; 74 tHttpUrl *m_pProxy = nullptr; 75 virtual ~tRepoData(); 76 }; 77 78 struct tRepoResolvResult { 79 cmstring* psRepoName=nullptr; 80 mstring sRestPath; 81 const tRepoData* repodata=nullptr; 82 }; 83 84 /* 85 * Resolves a repository descriptor for the given URL, returns a reference to its descriptor 86 * (actually a pair with first: name, second: descriptor). 87 * 88 * @return: true IFF a repository was found and the by-reference arguments are set 89 */ 90 void GetRepNameAndPathResidual(const tHttpUrl & uri, tRepoResolvResult &result); 91 92 const tRepoData * GetRepoData(cmstring &vname); 93 94 time_t BackgroundCleanup(); 95 96 extern tStrMap localdirs; 97 cmstring & GetMimeType(cmstring &path); 98 #define TCP_PORT_MAX 65536 99 extern std::bitset<TCP_PORT_MAX> *pUserPorts; 100 101 extern mstring cacheDirSlash; // guaranteed to have a trailing path separator 102 103 void dump_trace(); 104 int * GetIntPtr(LPCSTR key); 105 mstring * GetStringPtr(LPCSTR key); 106 107 int CheckAdminAuth(LPCSTR auth); 108 109 extern bool g_bQuiet, g_bNoComplex; 110 111 static const cmstring privStoreRelSnapSufix("_xstore/rsnap"); 112 static const cmstring privStoreRelQstatsSfx("_xstore/qstats"); 113 114 } // namespace acfg 115 116 namespace rex 117 { 118 119 enum NOCACHE_PATTYPE : bool 120 { 121 NOCACHE_REQ, 122 NOCACHE_TGT 123 }; 124 125 enum eMatchType : int8_t 126 { 127 FILE_INVALID = -1, 128 FILE_SOLID = 0, FILE_VOLATILE, FILE_WHITELIST, 129 NASTY_PATH, PASSTHROUGH, 130 FILE_SPECIAL_SOLID, 131 FILE_SPECIAL_VOLATILE, 132 ematchtype_max 133 }; 134 bool Match(cmstring &in, eMatchType type); 135 136 eMatchType GetFiletype(const mstring &); 137 bool MatchUncacheable(const mstring &, NOCACHE_PATTYPE); 138 bool CompileUncExpressions(NOCACHE_PATTYPE type, cmstring& pat); 139 bool CompileExpressions(); 140 } 141 142 #define CACHE_BASE (acng::cfg::cacheDirSlash) 143 #define CACHE_BASE_LEN (CACHE_BASE.length()) // where the relative paths begin 144 #define SZABSPATH(x) (CACHE_BASE+(x)).c_str() 145 #define SABSPATH(x) (CACHE_BASE+(x)) 146 147 bool AppendPasswordHash(mstring &stringWithSalt, LPCSTR plainPass, size_t passLen); 148 149 // XXX: find a better place for this, shared between server and acngtool 150 enum ControLineType : uint8_t 151 { 152 NotForUs = 0, 153 BeforeError = 1, 154 Error = 2 155 }; 156 #define maark "41d_a6aeb8-26dfa" // random enough to not match anything existing *g* 157 158 } 159 160 #endif 161