4 #ifndef ADDRESS_LIMITER_CLASS
5 #define ADDRESS_LIMITER_CLASS
7 /*****************************************************************************\
9 * Name : range_limiter *
10 * Author : Chris Koeritz *
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 *
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 \*****************************************************************************/
27 #include <basis/astring.h>
32 class limiter_range_list;
35 //! provides a mechanism for restricting access to a resource by the client's IP address.
40 // constructs a blank range_limiter.
42 range_limiter(const basis::astring &source_file, const basis::astring §ion);
43 // constructs an range_limiter by loading from the "source_file" in
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").
60 // observes or modifies the default access permission. the default will
61 // be used when no other permissions apply.
62 capabilities get_default();
63 void set_default(capabilities rights);
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,
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);
76 // retrieves or stores the range and capability information.
77 bool load(const basis::astring &file_name, const basis::astring §ion);
78 bool save(const basis::astring &file_name, const basis::astring §ion);
81 limiter_range_list *_ranges;