00001 /**************************************************************** 00002 * Vidalia is distributed under the following license: 00003 * 00004 * Copyright (C) 2006, Matt Edman, Justin Hipple 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 * Boston, MA 02110-1301, USA. 00020 ****************************************************************/ 00021 00022 /** 00023 * \file exitpolicy.h 00024 * \version $Id: exitpolicy.h 1563 2006-12-26 06:06:04Z edmanm $ 00025 * \brief Collection of Policy objects representing an exit policy 00026 */ 00027 00028 #ifndef _EXITPOLICY_H 00029 #define _EXITPOLICY_H 00030 00031 #include <QList> 00032 #include <QString> 00033 #include <QStringList> 00034 00035 #include "policy.h" 00036 00037 00038 class ExitPolicy 00039 { 00040 public: 00041 /** Special exit policy types. */ 00042 enum SpecialExitPolicy { 00043 Default, /**< Specifies the default exit policy. */ 00044 Middleman /**< Specifies a middleman-only exit policy. */ 00045 }; 00046 00047 /** Default constructor. */ 00048 ExitPolicy(); 00049 /** Creates an exit policy of the given special type. */ 00050 ExitPolicy(SpecialExitPolicy exitPolicy); 00051 /** Creates an exit policy from the given comma-delimited list of policies. */ 00052 ExitPolicy(QString exitPolicy); 00053 00054 /** Adds the ports specified in <b>portList</b> to a list of ports accepted 00055 * by this exit policy. Ports may be given either individually or as ranges. */ 00056 void addAcceptedPorts(QStringList portList); 00057 /** Returns true if this exit policy accepts all ports specified in 00058 * <b>portList</b>. Ports in <b>portList</b> may be given either individually 00059 * or as ranges. */ 00060 bool acceptsPorts(QStringList portList); 00061 /** Adds the ports specified in <b>portList</b> to a list of ports rejected 00062 * by this exit policy. Ports may be given either individually or as ranges. */ 00063 void addRejectedPorts(QStringList portList); 00064 /** Returns true if this exit policy rejects all ports specified in 00065 * <b>portList</b>. Ports in <b>portList</b> may be given either individually 00066 * or as ranges. */ 00067 bool rejectsPorts(QStringList portList); 00068 00069 /** Adds a rule to the exit policy. */ 00070 void addPolicy(Policy policy); 00071 /** Removes a rule from the exit policy. */ 00072 void removePolicy(Policy policy); 00073 /** Checks if the current exit policy contains the given rule. */ 00074 bool contains(Policy policy); 00075 00076 /** Returns the list of policies for this exit policy. */ 00077 QList<Policy> policyList() { return _exitPolicy; } 00078 00079 /** Converts the exit policy to a format Tor understands. */ 00080 QString toString(); 00081 00082 private: 00083 /** A collection of policies forming the exit policy. */ 00084 QList<Policy> _exitPolicy; 00085 }; 00086 00087 #endif 00088