Add-on blacklist table. More...
#include <blacklist.hpp>
Public Types | |
typedef std::vector< std::string > | globlist |
Public Member Functions | |
blacklist (const blacklist &)=delete | |
blacklist & | operator= (const blacklist &)=delete |
blacklist () | |
blacklist (const config &cfg) | |
void | clear () |
void | read (const config &cfg) |
Initializes the blacklist from WML. More... | |
void | write (config &cfg) const |
Writes the blacklist to a WML node. More... | |
bool | is_blacklisted (const std::string &name, const std::string &title, const std::string &description, const std::string &author, const std::string &ip, const std::string &email) const |
Whether an add-on described by these fields is blacklisted. More... | |
Private Member Functions | |
void | parse_str_to_globlist (const std::string &str, globlist &glist) |
bool | is_in_globlist (const std::string &str, const globlist &glist) const |
bool | is_in_ip_masklist (const std::string &ip, const globlist &mlist) const |
bool | ip_matches (const std::string &ip, const std::string &ip_mask) const |
Private Attributes | |
globlist | names_ |
globlist | titles_ |
globlist | descriptions_ |
globlist | authors_ |
globlist | ips_ |
globlist | emails_ |
Add-on blacklist table.
A path to a blacklist WML file may be provided in the campaignd configuration. The file's contents are used to maintain a blacklist to check certain add-on metadata fields against it every time a new or existing add-on is uploaded ([upload] request).
Blacklist entries are glob patterns accepting the '*' and '?' wildcards for matching any number of characters and a single character, respectively. The lists are expected to be comma-delimited.
ip = (net address masks) email = (email address patterns) name = (add-on id/dirname patterns) title = (add-on title patterns) author = (add-on author patterns) description = (add-on description patterns)
Definition at line 42 of file blacklist.hpp.
typedef std::vector<std::string> campaignd::blacklist::globlist |
Definition at line 45 of file blacklist.hpp.
|
delete |
campaignd::blacklist::blacklist | ( | ) |
Definition at line 28 of file blacklist.cpp.
|
explicit |
Definition at line 38 of file blacklist.cpp.
References read().
void campaignd::blacklist::clear | ( | ) |
Definition at line 49 of file blacklist.cpp.
References authors_, descriptions_, emails_, ips_, names_, and titles_.
Referenced by campaignd::server::load_blacklist().
|
private |
Definition at line 127 of file blacklist.cpp.
References utils::wildcard_string_match().
Referenced by is_in_ip_masklist().
bool campaignd::blacklist::is_blacklisted | ( | const std::string & | name, |
const std::string & | title, | ||
const std::string & | description, | ||
const std::string & | author, | ||
const std::string & | ip, | ||
const std::string & | |||
) | const |
Whether an add-on described by these fields is blacklisted.
Empty parameters are ignored.
Definition at line 76 of file blacklist.cpp.
References authors_, descriptions_, emails_, ips_, is_in_globlist(), is_in_ip_masklist(), names_, and titles_.
Referenced by campaignd::server::validate_addon().
|
private |
Definition at line 93 of file blacklist.cpp.
References LOG_BL, utf8::lowercase(), and utils::wildcard_string_match().
Referenced by is_blacklisted().
|
private |
Definition at line 111 of file blacklist.cpp.
References ip_matches(), and LOG_BL.
Referenced by is_blacklisted().
|
private |
void campaignd::blacklist::read | ( | const config & | cfg | ) |
Initializes the blacklist from WML.
cfg | WML node object with the contents of the [blacklist] tag. |
Definition at line 60 of file blacklist.cpp.
References authors_, descriptions_, emails_, ips_, names_, parse_str_to_globlist(), and titles_.
Referenced by blacklist(), and campaignd::server::load_blacklist().
void campaignd::blacklist::write | ( | config & | cfg | ) | const |
Writes the blacklist to a WML node.
cfg | WML node object to write to. Any existing contents are erased by this method. |
|
private |
Definition at line 87 of file blacklist.hpp.
Referenced by clear(), is_blacklisted(), and read().
|
private |
Definition at line 85 of file blacklist.hpp.
Referenced by clear(), is_blacklisted(), and read().
|
private |
Definition at line 89 of file blacklist.hpp.
Referenced by clear(), is_blacklisted(), and read().
|
private |
Definition at line 88 of file blacklist.hpp.
Referenced by clear(), is_blacklisted(), and read().
|
private |
Definition at line 83 of file blacklist.hpp.
Referenced by clear(), is_blacklisted(), and read().
|
private |
Definition at line 84 of file blacklist.hpp.
Referenced by clear(), is_blacklisted(), and read().