feisty meow concerns codebase  2.140
range_limiter.h
Go to the documentation of this file.
1 
2 //not implemented yet.
3 
4 #ifndef ADDRESS_LIMITER_CLASS
5 #define ADDRESS_LIMITER_CLASS
6 
7 /*****************************************************************************\
8 * *
9 * Name : range_limiter *
10 * Author : Chris Koeritz *
11 * *
12 * Purpose: *
13 * *
14 * Provides a way to check whether an IP address is within a range of *
15 * allowed addresses. Also manages a configuration file that stores the *
16 * sets of ranges. *
17 * *
18 *******************************************************************************
19 * Copyright (c) 2002-$now By Author. This program is free software; you can *
20 * redistribute it and/or modify it under the terms of the GNU General Public *
21 * License as published by the Free Software Foundation; either version 2 of *
22 * the License or (at your option) any later version. This is online at: *
23 * http://www.fsf.org/copyleft/gpl.html *
24 * Please send any updates to: fred@gruntose.com *
25 \*****************************************************************************/
26 
27 #include <basis/astring.h>
28 
29 namespace sockets {
30 
31 // forward.
32 class limiter_range_list;
33 class machine_uid;
34 
37 {
38 public:
39  range_limiter();
40  // constructs a blank range_limiter.
41 
42  range_limiter(const basis::astring &source_file, const basis::astring &section);
43  // constructs an range_limiter by loading from the "source_file" in
44  // the ini "section".
45 
47 
48  enum capabilities {
50  DENY
51  };
52 
53  bool is_allowed(const machine_uid &host);
54  // checks whether a "host" is in one of the allowed ranges.
55  bool is_allowed(const basis::astring &hostname);
56  // checks whether a "hostname" is in one of the allowed ranges. this can
57  // either be a text string such as "jumbo.gruntose.blurgh" or it can be
58  // a dotted number representation (like "128.28.48.119").
59 
60  // observes or modifies the default access permission. the default will
61  // be used when no other permissions apply.
63  void set_default(capabilities rights);
64 
65  // these add addresses to the list with the "rights" specified.
66  bool add(const machine_uid &address, capabilities rights);
67  bool add(const basis::astring &hostname, capabilities rights);
68  bool add(const machine_uid &first, const machine_uid &second,
69  capabilities rights);
70 
71  // takes addresses out of the list of filters.
72  bool remove(const machine_uid &address);
73  bool remove(const basis::astring &hostname);
74  bool remove(const machine_uid &first, const machine_uid &second);
75 
76  // retrieves or stores the range and capability information.
77  bool load(const basis::astring &file_name, const basis::astring &section);
78  bool save(const basis::astring &file_name, const basis::astring &section);
79 
80 private:
81  limiter_range_list *_ranges;
82 };
83 
84 } //namespace.
85 
86 #endif
87 
Provides a dynamically resizable ASCII character string.
Definition: astring.h:35
provides a mechanism for restricting access to a resource by the client's IP address.
Definition: range_limiter.h:37
bool add(const machine_uid &address, capabilities rights)
bool remove(const machine_uid &address)
bool load(const basis::astring &file_name, const basis::astring &section)
bool save(const basis::astring &file_name, const basis::astring &section)
capabilities get_default()
bool is_allowed(const machine_uid &host)
void set_default(capabilities rights)
Provides access to the operating system's socket methods.
Definition: base_address.h:26