The Battle for Wesnoth  1.13.10+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
campaignd::blacklist Class Reference

Add-on blacklist table. More...

#include <blacklist.hpp>

Public Types

typedef std::vector< std::string > globlist
 

Public Member Functions

 blacklist (const blacklist &)=delete
 
blacklistoperator= (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_
 

Detailed Description

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 41 of file blacklist.hpp.

Member Typedef Documentation

typedef std::vector<std::string> campaignd::blacklist::globlist

Definition at line 44 of file blacklist.hpp.

Constructor & Destructor Documentation

campaignd::blacklist::blacklist ( const blacklist )
delete
campaignd::blacklist::blacklist ( )

Definition at line 27 of file blacklist.cpp.

campaignd::blacklist::blacklist ( const config cfg)
explicit

Definition at line 37 of file blacklist.cpp.

References read().

Member Function Documentation

void campaignd::blacklist::clear ( )

Definition at line 48 of file blacklist.cpp.

References authors_, descriptions_, emails_, ips_, names_, and titles_.

Referenced by campaignd::server::load_blacklist().

bool campaignd::blacklist::ip_matches ( const std::string &  ip,
const std::string &  ip_mask 
) const
private

Definition at line 126 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 &  email 
) const

Whether an add-on described by these fields is blacklisted.

Empty parameters are ignored.

Definition at line 75 of file blacklist.cpp.

References authors_, descriptions_, emails_, ips_, is_in_globlist(), is_in_ip_masklist(), names_, and titles_.

Referenced by campaignd::server::handle_upload().

bool campaignd::blacklist::is_in_globlist ( const std::string &  str,
const globlist glist 
) const
private

Definition at line 92 of file blacklist.cpp.

References LOG_BL, utf8::lowercase(), and utils::wildcard_string_match().

Referenced by is_blacklisted().

bool campaignd::blacklist::is_in_ip_masklist ( const std::string &  ip,
const globlist mlist 
) const
private

Definition at line 110 of file blacklist.cpp.

References ip_matches(), and LOG_BL.

Referenced by is_blacklisted().

blacklist& campaignd::blacklist::operator= ( const blacklist )
delete
void campaignd::blacklist::parse_str_to_globlist ( const std::string &  str,
blacklist::globlist glist 
)
private

Definition at line 70 of file blacklist.cpp.

References utils::split().

Referenced by read().

void campaignd::blacklist::read ( const config cfg)

Initializes the blacklist from WML.

Parameters
cfgWML node object with the contents of the [blacklist] tag.

Definition at line 59 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.

Parameters
cfgWML node object to write to. Any existing contents are erased by this method.

Member Data Documentation

globlist campaignd::blacklist::authors_
private

Definition at line 86 of file blacklist.hpp.

Referenced by clear(), is_blacklisted(), and read().

globlist campaignd::blacklist::descriptions_
private

Definition at line 84 of file blacklist.hpp.

Referenced by clear(), is_blacklisted(), and read().

globlist campaignd::blacklist::emails_
private

Definition at line 88 of file blacklist.hpp.

Referenced by clear(), is_blacklisted(), and read().

globlist campaignd::blacklist::ips_
private

Definition at line 87 of file blacklist.hpp.

Referenced by clear(), is_blacklisted(), and read().

globlist campaignd::blacklist::names_
private

Definition at line 82 of file blacklist.hpp.

Referenced by clear(), is_blacklisted(), and read().

globlist campaignd::blacklist::titles_
private

Definition at line 83 of file blacklist.hpp.

Referenced by clear(), is_blacklisted(), and read().


The documentation for this class was generated from the following files: