Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

hostiles.c File Reference


Detailed Description

Support for the hostiles.txt of BearShare.

This file is based a lot on the whitelist stuff by vidar.

Author:
Markus Goetz
Date:
2003
Author:
Raphael Manfredi
Date:
2004

#include "common.h"
#include "hostiles.h"
#include "settings.h"
#include "nodes.h"
#include "lib/file.h"
#include "lib/misc.h"
#include "lib/glib-missing.h"
#include "lib/iprange.h"
#include "lib/walloc.h"
#include "lib/watcher.h"
#include "if/gnet_property.h"
#include "if/gnet_property_priv.h"
#include "if/bridge/c2ui.h"
#include "lib/override.h"

Enumerations

enum  hostiles_t { HOSTILE_GLOBAL = 0, HOSTILE_PRIVATE = 1, NUM_HOSTILES }

Functions

void hostiles_close_one (hostiles_t which)
 Frees all entries in the given hostiles.
gint hostiles_load (FILE *f, hostiles_t which)
 Load hostile data from the supplied FILE.
void hostiles_changed (const gchar *filename, gpointer udata)
 Watcher callback, invoked when the file from which we read the hostile addresses changed.
void hostiles_retrieve_from_file (FILE *f, hostiles_t which, const gchar *path, const gchar *filename)
void hostiles_retrieve (hostiles_t which)
 Loads the hostiles.txt into memory.
gboolean use_global_hostiles_txt_changed (property_t unused_prop)
 If the property was set to FALSE at startup time, hostile_db[HOSTILE_GLOBAL] is still NULL and we need to load the global hostiles.txt now.
void hostiles_init (void)
 Called on startup.
void hostiles_close (void)
 Frees all entries in all the hostiles.
gboolean hostiles_check (const host_addr_t ha)
 Check the given address against the entries in the hostiles.

Variables

const gchar hostile [] = "hostile"
const gchar hostiles_file [] = "hostiles.txt"
const gchar *const hostiles_what [NUM_HOSTILES]
iprange_dbhostile_db [NUM_HOSTILES]
 The hostile database.


Enumeration Type Documentation

enum hostiles_t
 

Enumeration values:
HOSTILE_GLOBAL 
HOSTILE_PRIVATE 
NUM_HOSTILES 


Function Documentation

void hostiles_changed const gchar *  filename,
gpointer  udata
[static]
 

Watcher callback, invoked when the file from which we read the hostile addresses changed.

gboolean hostiles_check const host_addr_t  ha  ) 
 

Check the given address against the entries in the hostiles.

Parameters:
ha the host address to check.
Returns:
TRUE if found, and FALSE if not.

void hostiles_close void   ) 
 

Frees all entries in all the hostiles.

void hostiles_close_one hostiles_t  which  )  [static]
 

Frees all entries in the given hostiles.

void hostiles_init void   ) 
 

Called on startup.

Loads the hostiles.txt into memory.

gint hostiles_load FILE *  f,
hostiles_t  which
[static]
 

Load hostile data from the supplied FILE.

Returns:
the amount of entries loaded.

void hostiles_retrieve hostiles_t  which  )  [static]
 

Loads the hostiles.txt into memory.

Choosing the first file we find among the several places we look at, typically:

  1. ~/.gtk-gnutella/hostiles.txt
  2. /usr/share/gtk-gnutella/hostiles.txt
  3. /home/src/gtk-gnutella/hostiles.txt

The selected file will then be monitored and a reloading will occur shortly after a modification.

void hostiles_retrieve_from_file FILE *  f,
hostiles_t  which,
const gchar *  path,
const gchar *  filename
[static]
 

gboolean use_global_hostiles_txt_changed property_t  unused_prop  )  [static]
 

If the property was set to FALSE at startup time, hostile_db[HOSTILE_GLOBAL] is still NULL and we need to load the global hostiles.txt now.

Otherwise, there's nothing to do, hostiles_check() will simply ignore hostile_db[HOSTILE_GLOBAL]. The file watcher keeps running though during this session and we keep the database in memory.


Variable Documentation

const gchar hostile[] = "hostile" [static]
 

struct iprange_db* hostile_db[NUM_HOSTILES] [static]
 

The hostile database.

const gchar hostiles_file[] = "hostiles.txt" [static]
 

const gchar* const hostiles_what[NUM_HOSTILES] [static]
 

Initial value:

 {
    "hostile IP addresses (global)",
    "hostile IP addresses (private)"
}


Generated on Sat Jun 30 17:53:27 2007 for gtk-gnutella by  doxygen 1.3.9.1