The Battle for Wesnoth  1.19.7+dev
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 42 of file blacklist.hpp.

Member Typedef Documentation

◆ globlist

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

Definition at line 45 of file blacklist.hpp.

Constructor & Destructor Documentation

◆ blacklist() [1/3]

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

◆ blacklist() [2/3]

campaignd::blacklist::blacklist ( )

Definition at line 28 of file blacklist.cpp.

◆ blacklist() [3/3]

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

Definition at line 38 of file blacklist.cpp.

References read().

Member Function Documentation

◆ clear()

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().

◆ ip_matches()

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

Definition at line 127 of file blacklist.cpp.

References utils::wildcard_string_match().

Referenced by is_in_ip_masklist().

◆ is_blacklisted()

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 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().

◆ is_in_globlist()

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

Definition at line 93 of file blacklist.cpp.

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

Referenced by is_blacklisted().

◆ is_in_ip_masklist()

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

Definition at line 111 of file blacklist.cpp.

References ip_matches(), and LOG_BL.

Referenced by is_blacklisted().

◆ operator=()

blacklist& campaignd::blacklist::operator= ( const blacklist )
delete

◆ parse_str_to_globlist()

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

Definition at line 71 of file blacklist.cpp.

References utils::split().

Referenced by read().

◆ 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 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().

◆ write()

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

◆ authors_

globlist campaignd::blacklist::authors_
private

Definition at line 87 of file blacklist.hpp.

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

◆ descriptions_

globlist campaignd::blacklist::descriptions_
private

Definition at line 85 of file blacklist.hpp.

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

◆ emails_

globlist campaignd::blacklist::emails_
private

Definition at line 89 of file blacklist.hpp.

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

◆ ips_

globlist campaignd::blacklist::ips_
private

Definition at line 88 of file blacklist.hpp.

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

◆ names_

globlist campaignd::blacklist::names_
private

Definition at line 83 of file blacklist.hpp.

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

◆ titles_

globlist campaignd::blacklist::titles_
private

Definition at line 84 of file blacklist.hpp.

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


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