ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/vendor/pxys2-2.0.0/pxyscand/src/PXConfig.cc
Revision: 3252
Committed: Wed Apr 2 20:41:43 2014 UTC (9 years, 11 months ago) by michael
Content type: text/x-c++src
File size: 2110 byte(s)
Log Message:
- Imported pxys2-2.0.0

File Contents

# Content
1 /* Copyright (C) 2003 Stephane Thiell
2 *
3 * This file is part of pxyservd (from pxys)
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 *
19 */
20 #define RCSID "$Id: PXConfig.cc,v 1.1.1.1 2003/12/30 17:09:00 mbuna Exp $"
21
22 #ifdef HAVE_CONFIG_H
23 #include "config.h"
24 #endif
25
26 #include "PXConfig.h"
27
28 #include <cstring>
29
30 PXConfig::PXConfig()
31 {
32 this->opas.local_address.s_addr = INADDR_ANY;
33 }
34
35 PXConfig::~PXConfig()
36 {
37 }
38
39 bool
40 PXConfig::OPASIsAllowed(const in_addr &in) const
41 {
42 for (size_t i = 0; i < opas.allow.size(); i++)
43 if (opas.allow[i].s_addr == in.s_addr)
44 return true;
45 return false;
46 }
47
48 in_addr
49 PXConfig::GetOneFromSourcePool() const
50 {
51 assert(scanner.source_pool.size() > 0);
52
53 StPXMutex m(&mutex);
54 return scanner.source_pool[(int)((double(rand())
55 / double((unsigned long)RAND_MAX + 1))
56 * scanner.source_pool.size())];
57 }
58
59 bool
60 PXConfig::ScannerStringCheck(const char *s) const
61 {
62 for (size_t i = 0; i < scanner.strings.size(); i++)
63 if (strstr(s, scanner.strings[i]))
64 return true;
65 return false;
66 }
67
68 bool
69 PXConfig::CheckNoScan(const in_addr &addr) const
70 {
71 for (size_t i = 0; i < this->noscan.address.size(); i++)
72 {
73 const NetworkNetmask * nn = &this->noscan.address[i];
74 if ((addr.s_addr & nn->netmask.s_addr)
75 == (nn->network.s_addr & nn->netmask.s_addr))
76 return true;
77 }
78 return false;
79 }