Vidalia 0.2.10

ExitPolicy.h

Go to the documentation of this file.
00001 /*
00002 **  This file is part of Vidalia, and is subject to the license terms in the
00003 **  LICENSE file, found in the top level directory of this distribution. If you
00004 **  did not receive the LICENSE file with this file, you may obtain it from the
00005 **  Vidalia source package distributed by the Vidalia Project at
00006 **  http://www.vidalia-project.net/. No part of Vidalia, including this file,
00007 **  may be copied, modified, propagated, or distributed except according to the
00008 **  terms described in the LICENSE file.
00009 */
00010 
00011 /*
00012 ** \file ExitPolicy.h
00013 ** \version $Id: ExitPolicy.h 3735 2009-04-28 20:28:01Z edmanm $
00014 ** \brief Collection of Policy objects representing an exit policy
00015 */
00016 
00017 #ifndef _EXITPOLICY_H
00018 #define _EXITPOLICY_H
00019 
00020 #include "Policy.h"
00021 
00022 #include <QList>
00023 #include <QString>
00024 #include <QStringList>
00025 
00026 
00027 class ExitPolicy
00028 {
00029 public:
00030   /** Special exit policy types. */
00031   enum SpecialExitPolicy {
00032     Default,  /**< Specifies the default exit policy. */
00033     Middleman /**< Specifies a middleman-only exit policy. */
00034   };
00035   
00036   /** Default constructor. */
00037   ExitPolicy();
00038   /** Creates an exit policy of the given special type. */
00039   ExitPolicy(SpecialExitPolicy exitPolicy);
00040   /** Creates an exit policy from the given comma-delimited list of policies. */
00041   ExitPolicy(QString exitPolicy);
00042   
00043   /** Adds the ports specified in <b>portList</b> to a list of ports accepted
00044    * by this exit policy. Ports may be given either individually or as ranges. */
00045   void addAcceptedPorts(QStringList portList);
00046   /** Returns true if this exit policy accepts all ports specified in
00047    * <b>portList</b>. Ports in <b>portList</b> may be given either individually
00048    * or as ranges. */
00049   bool acceptsPorts(QStringList portList);
00050   /** Adds the ports specified in <b>portList</b> to a list of ports rejected
00051    * by this exit policy. Ports may be given either individually or as ranges. */
00052   void addRejectedPorts(QStringList portList);
00053   /** Returns true if this exit policy rejects all ports specified in
00054    * <b>portList</b>. Ports in <b>portList</b> may be given either individually
00055    * or as ranges. */
00056   bool rejectsPorts(QStringList portList);
00057   
00058   /** Adds a rule to the exit policy. */
00059   void addPolicy(Policy policy);
00060   /** Removes a rule from the exit policy. */
00061   void removePolicy(Policy policy);
00062   /** Checks if the current exit policy contains the given rule. */
00063   bool contains(Policy policy);
00064 
00065   /** Returns the list of policies for this exit policy. */
00066   QList<Policy> policyList() { return  _exitPolicy; }
00067   
00068   /** Converts the exit policy to a format Tor understands. */  
00069   QString toString();
00070   
00071 private:
00072   /** A collection of policies forming the exit policy. */
00073   QList<Policy> _exitPolicy;
00074 };
00075 
00076 #endif
00077