torsettings.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 torsettings.h
00013 ** \version $Id: torsettings.h 3291 2008-11-10 01:18:11Z edmanm $
00014 ** \brief Settings used for starting and running Tor
00015 */
00016 
00017 #ifndef _TORSETTINGS_H
00018 #define _TORSETTINGS_H
00019 
00020 #include <QHostAddress>
00021 
00022 #include "abstracttorsettings.h"
00023 
00024 
00025 /** Manages Tor-specific settings, such as location, command-line arguments,
00026  * and control interface information. */
00027 class TorSettings : public AbstractTorSettings
00028 {
00029   Q_OBJECT
00030 
00031 public:
00032   /** Available Tor authentication methods. */
00033   enum AuthenticationMethod {
00034     NullAuth,      /**< No authentication. */
00035     CookieAuth,    /**< Use a "magic" cookie for authentication. */
00036     PasswordAuth,  /**< Use a hashed password for authentication. */
00037     UnknownAuth    /**< Unknown authentication method. */
00038   };
00039   
00040   /** Default constructor. */
00041   TorSettings(TorControl *torControl = 0);
00042   /** Applies any changes to Tor's control port or authentication settings. */ 
00043   bool apply(QString *errmsg = 0);
00044 
00045   /** Gets the name and path of Tor's executable. */
00046   QString getExecutable() const;
00047   /** Sets the name and path of Tor's executable. */
00048   void setExecutable(const QString &torExecutable);
00049  
00050   /** Gets the location of Tor's data directory. */
00051   QString getDataDirectory() const;
00052   /** Sets the location to use for Tor's data directory. */
00053   void setDataDirectory(const QString &dataDir);
00054   
00055   /** Gets the torrc to use when starting Tor. */
00056   QString getTorrc() const;
00057   /** Sets the torrc to use when starting Tor. */
00058   void setTorrc(const QString &torrc);
00059   
00060   /** Get Tor's control interface address. */
00061   QHostAddress getControlAddress() const;
00062   /** Set Tor's control interface address. */
00063   void setControlAddress(const QHostAddress &addr);
00064   
00065   /** Get the control port. */
00066   quint16 getControlPort() const;
00067   /** Set the control port. */
00068   void setControlPort(quint16 port);
00069   
00070   /** Returns the plaintext (i.e., not hashed) control password used when
00071    * authenticating to Tor. */
00072   QString getControlPassword() const;
00073   /** Sets the control password used when starting Tor with
00074    * HashedControlPassword to <b>password</b>. */
00075   void setControlPassword(const QString &password);
00076 
00077  /** Returns true if a new, random control password is to be used each time
00078   * Tor is started. */
00079   bool useRandomPassword() const;
00080   /** Sets whether or not to generate and use a random control password each
00081    * time Tor is started. */
00082   void setUseRandomPassword(bool useRandomPassword);
00083 
00084   /** Returns the current authentication method used when connecting to Tor.*/
00085   AuthenticationMethod getAuthenticationMethod() const;
00086   /** Sets the authentication method used when starting Tor to <b>method</b>.*/
00087   void setAuthenticationMethod(AuthenticationMethod method);
00088 
00089   /** Generates a random control password consisting of PASSWORD_LEN
00090    * characters. */
00091   static QString randomPassword();
00092   /** Returns the hash of <b>password</b> as given by the command 
00093    * "tor --hash-password foo". */
00094   static QString hashPassword(const QString &password);
00095 
00096 private:
00097   /** Returns the AuthenticationMethod enum value for the string
00098    * description of the authentication method given in <b>authMethod</b>. */
00099   AuthenticationMethod toAuthenticationMethod(const QString &authMethod) const;
00100   /** Returns the string description of the authentication method specified by
00101    * <b>method</b>. The authentication method string is stored in  Vidalia's
00102    * configuration file. */
00103   QString toString(AuthenticationMethod type) const;
00104 };
00105 
00106 #endif
00107 

Generated on Wed Dec 23 21:06:55 2009 for Vidalia by  doxygen 1.6.1