mirror of
https://github.com/privacore/open-source-search-engine.git
synced 2025-01-22 02:18:42 -05:00
51 lines
1.0 KiB
C++
51 lines
1.0 KiB
C++
#ifndef GB_URLMATCHLIST_H_
|
|
#define GB_URLMATCHLIST_H_
|
|
|
|
#include "UrlMatch.h"
|
|
#include <map>
|
|
#include <memory>
|
|
#include <atomic>
|
|
|
|
struct UrlMatchListItem;
|
|
|
|
typedef std::shared_ptr<UrlMatchListItem> urlmatchlistitem_ptr_t;
|
|
typedef std::shared_ptr<const UrlMatchListItem> urlmatchlistitemconst_ptr_t;
|
|
|
|
class Url;
|
|
|
|
class UrlMatchList {
|
|
public:
|
|
explicit UrlMatchList(const char *filename);
|
|
|
|
bool init();
|
|
|
|
bool isUrlMatched(const Url &url);
|
|
|
|
static void reload(int /*fd*/, void *state);
|
|
static void reload(void *state);
|
|
|
|
protected:
|
|
bool load();
|
|
|
|
private:
|
|
urlmatchlistitemconst_ptr_t getUrlMatchList();
|
|
void swapUrlMatchList(urlmatchlistitemconst_ptr_t urlMatchList);
|
|
|
|
std::string m_filename;
|
|
std::string m_dirname;
|
|
|
|
std::atomic_bool m_loading;
|
|
|
|
urlmatchlistitemconst_ptr_t m_urlMatchList;
|
|
|
|
std::map<std::string, time_t> m_lastModifiedTimes;
|
|
};
|
|
|
|
extern UrlMatchList g_urlBlackList;
|
|
extern UrlMatchList g_urlWhiteList;
|
|
|
|
extern UrlMatchList g_urlProxyList;
|
|
extern UrlMatchList g_urlRetryProxyList;
|
|
|
|
#endif //GB_URLMATCHLIST_H_
|