Vidalia 0.3.1
ExitPolicy.h
Go to the documentation of this file.
1/*
2** This file is part of Vidalia, and is subject to the license terms in the
3** LICENSE file, found in the top level directory of this distribution. If you
4** did not receive the LICENSE file with this file, you may obtain it from the
5** Vidalia source package distributed by the Vidalia Project at
6** http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
7** including this file, may be copied, modified, propagated, or distributed
8** except according to the terms described in the LICENSE file.
9*/
10
11/*
12** \file ExitPolicy.h
13** \brief Collection of Policy objects representing an exit policy
14*/
15
16#ifndef _EXITPOLICY_H
17#define _EXITPOLICY_H
18
19#include "Policy.h"
20
21#include <QList>
22#include <QString>
23#include <QStringList>
24
25
27{
28public:
29 /** Special exit policy types. */
31 Default, /**< Specifies the default exit policy. */
32 Middleman /**< Specifies a middleman-only exit policy. */
33 };
34
35 /** Default constructor. */
36 ExitPolicy();
37 /** Creates an exit policy of the given special type. */
38 ExitPolicy(SpecialExitPolicy exitPolicy);
39 /** Creates an exit policy from the given comma-delimited list of policies. */
40 ExitPolicy(QString exitPolicy);
41
42 /** Adds the ports specified in <b>portList</b> to a list of ports accepted
43 * by this exit policy. Ports may be given either individually or as ranges. */
44 void addAcceptedPorts(QStringList portList);
45 /** Returns true if this exit policy accepts all ports specified in
46 * <b>portList</b>. Ports in <b>portList</b> may be given either individually
47 * or as ranges. */
48 bool acceptsPorts(QStringList portList);
49 /** Adds the ports specified in <b>portList</b> to a list of ports rejected
50 * by this exit policy. Ports may be given either individually or as ranges. */
51 void addRejectedPorts(QStringList portList);
52 /** Returns true if this exit policy rejects all ports specified in
53 * <b>portList</b>. Ports in <b>portList</b> may be given either individually
54 * or as ranges. */
55 bool rejectsPorts(QStringList portList);
56
57 /** Adds a rule to the exit policy. */
58 void addPolicy(Policy policy);
59 /** Removes a rule from the exit policy. */
60 void removePolicy(Policy policy);
61 /** Checks if the current exit policy contains the given rule. */
62 bool contains(Policy policy);
63
64 /** Returns the list of policies for this exit policy. */
65 QList<Policy> policyList() { return _exitPolicy; }
66
67 /** Converts the exit policy to a format Tor understands. */
68 QString toString();
69
70private:
71 /** A collection of policies forming the exit policy. */
72 QList<Policy> _exitPolicy;
73};
74
75#endif
76
bool contains(Policy policy)
Definition: ExitPolicy.cpp:130
void addRejectedPorts(QStringList portList)
Definition: ExitPolicy.cpp:107
void addPolicy(Policy policy)
Definition: ExitPolicy.cpp:61
QList< Policy > policyList()
Definition: ExitPolicy.h:65
bool rejectsPorts(QStringList portList)
Definition: ExitPolicy.cpp:118
QList< Policy > _exitPolicy
Definition: ExitPolicy.h:72
bool acceptsPorts(QStringList portList)
Definition: ExitPolicy.cpp:94
QString toString()
Definition: ExitPolicy.cpp:156
void addAcceptedPorts(QStringList portList)
Definition: ExitPolicy.cpp:83
void removePolicy(Policy policy)
Definition: ExitPolicy.cpp:70
Definition: Policy.h:25