#include <serversettings.h>
Inheritance diagram for ServerSettings:
Public Member Functions | |
ServerSettings (TorControl *torControl) | |
void | revert () |
bool | changedSinceLastApply () |
bool | apply (QString *errmsg=0) |
void | setServerEnabled (bool enable) |
bool | isServerEnabled () |
void | setORPort (quint16 orPort) |
quint16 | getORPort () |
void | setDirPort (quint16 dirPort) |
quint16 | getDirPort () |
void | setNickname (QString nickname) |
QString | getNickname () |
void | setAddress (QString address) |
QString | getAddress () |
void | setContactInfo (QString info) |
QString | getContactInfo () |
void | setDirectoryMirror (bool mirror) |
bool | isDirectoryMirror () |
void | setMiddleman (bool middleman) |
bool | isMiddleman () |
void | setExitPolicy (ExitPolicy &policy) |
ExitPolicy | getExitPolicy () |
void | setBandwidthAvgRate (quint32 rate) |
quint32 | getBandwidthAvgRate () |
void | setBandwidthBurstRate (quint32 rate) |
quint32 | getBandwidthBurstRate () |
void | setAutoUpdateAddress (bool enabled) |
bool | getAutoUpdateAddress () |
Private Member Functions | |
void | setChanged (bool changed) |
QHash< QString, QString > | confValues () |
QMap< QString, QVariant > | allSettings () |
bool | isEmptyValue (QVariant value) |
QVariant | value (QString key) |
void | setValue (QString key, QVariant value) |
Private Attributes | |
TorControl * | _torControl |
QMap< QString, QVariant > | _backupSettings |
Definition at line 37 of file serversettings.h.
ServerSettings::ServerSettings | ( | TorControl * | torControl | ) |
Constructor
Definition at line 71 of file serversettings.cpp.
References _backupSettings, _torControl, allSettings(), ExitPolicy::Default, net_local_address(), VidaliaSettings::setDefault(), SETTING_SERVER_ADDRESS, SETTING_SERVER_AUTOUPDATE_ADDRESS, SETTING_SERVER_BWBURST, SETTING_SERVER_BWRATE, SETTING_SERVER_CHANGED, SETTING_SERVER_CONTACT, SETTING_SERVER_DIRMIRROR, SETTING_SERVER_DIRPORT, SETTING_SERVER_ENABLED, SETTING_SERVER_EXITPOLICY, SETTING_SERVER_MIDDLEMAN, SETTING_SERVER_NICKNAME, and SETTING_SERVER_ORPORT.
void ServerSettings::revert | ( | ) |
Reverts all settings changes since the last apply.
Definition at line 116 of file serversettings.cpp.
References _backupSettings, and setValue().
Referenced by ServerPage::save().
bool ServerSettings::changedSinceLastApply | ( | ) |
Returns true if the settings have changed since the last apply.
Definition at line 106 of file serversettings.cpp.
References SETTING_SERVER_CHANGED, and VidaliaSettings::value().
Referenced by MainWindow::connected(), isServerEnabled(), and ServerPage::save().
bool ServerSettings::apply | ( | QString * | errmsg = 0 |
) |
Applies changese to Tor.
Definition at line 250 of file serversettings.cpp.
References _backupSettings, _torControl, allSettings(), confValues(), isServerEnabled(), TorControl::resetConf(), TorControl::saveConf(), SERVER_NICKNAME, SERVER_ORPORT, setChanged(), and TorControl::setConf().
Referenced by MainWindow::connected(), ServerPage::save(), and ServerPage::updateServerIP().
void ServerSettings::setServerEnabled | ( | bool | enable | ) |
Enables running Tor as a server.
Definition at line 274 of file serversettings.cpp.
References SETTING_SERVER_ENABLED, and setValue().
Referenced by ServerPage::save().
bool ServerSettings::isServerEnabled | ( | ) |
Returns true if Tor is running as a server.
Definition at line 283 of file serversettings.cpp.
References _torControl, changedSinceLastApply(), confValues(), TorControl::getConf(), TorControl::isConnected(), SERVER_NICKNAME, SERVER_ORPORT, SETTING_SERVER_ENABLED, and VidaliaSettings::value().
Referenced by apply(), confValues(), ServerPage::load(), ServerPage::setAutoUpdateTimer(), and MainWindow::stop().
void ServerSettings::setORPort | ( | quint16 | orPort | ) |
Sets the server's ORPort value.
Definition at line 300 of file serversettings.cpp.
References SETTING_SERVER_ORPORT, and setValue().
Referenced by ServerPage::save().
quint16 ServerSettings::getORPort | ( | ) |
Gets the server's ORPort value.
Definition at line 307 of file serversettings.cpp.
References SETTING_SERVER_ORPORT, and value().
Referenced by ServerPage::load().
void ServerSettings::setDirPort | ( | quint16 | dirPort | ) |
Sets the server's DirPort value.
Definition at line 314 of file serversettings.cpp.
References SETTING_SERVER_DIRPORT, and setValue().
Referenced by ServerPage::save().
quint16 ServerSettings::getDirPort | ( | ) |
Gets the server's DirPort value.
Definition at line 321 of file serversettings.cpp.
References SETTING_SERVER_DIRPORT, and value().
Referenced by ServerPage::load().
void ServerSettings::setNickname | ( | QString | nickname | ) |
Sets the server's nickname.
Definition at line 342 of file serversettings.cpp.
References SETTING_SERVER_NICKNAME, and setValue().
Referenced by ServerPage::save().
QString ServerSettings::getNickname | ( | ) |
Gets the server's nickname.
Definition at line 349 of file serversettings.cpp.
References ensure_valid_chars(), MAX_NICKNAME_LEN, SETTING_SERVER_NICKNAME, VALID_NICKNAME_CHARS, and value().
Referenced by ServerPage::load().
void ServerSettings::setAddress | ( | QString | address | ) |
Sets the server's external IP address.
Definition at line 328 of file serversettings.cpp.
References SETTING_SERVER_ADDRESS, and setValue().
Referenced by ServerPage::save(), and ServerPage::updateServerIP().
QString ServerSettings::getAddress | ( | ) |
Gets the server's external IP address.
Definition at line 335 of file serversettings.cpp.
References SETTING_SERVER_ADDRESS, and value().
Referenced by ServerPage::load(), and ServerPage::updateServerIP().
void ServerSettings::setContactInfo | ( | QString | info | ) |
Sets the server operator's contact information.
Definition at line 359 of file serversettings.cpp.
References SETTING_SERVER_CONTACT, and setValue().
Referenced by ServerPage::save().
QString ServerSettings::getContactInfo | ( | ) |
Gets the server operator's contact information.
Definition at line 366 of file serversettings.cpp.
References SETTING_SERVER_CONTACT, and value().
Referenced by ServerPage::load().
void ServerSettings::setDirectoryMirror | ( | bool | mirror | ) |
Enables or disables the server to act as a directory mirror.
Definition at line 380 of file serversettings.cpp.
References SETTING_SERVER_DIRMIRROR, and setValue().
Referenced by ServerPage::save().
bool ServerSettings::isDirectoryMirror | ( | ) |
Returns true if the server will mirror the directory.
Definition at line 373 of file serversettings.cpp.
References SETTING_SERVER_DIRMIRROR, and VidaliaSettings::value().
Referenced by confValues(), and ServerPage::load().
void ServerSettings::setMiddleman | ( | bool | middleman | ) |
Sets whether the server will act as a middleman or not.
Definition at line 396 of file serversettings.cpp.
References SETTING_SERVER_MIDDLEMAN, and setValue().
Referenced by ServerPage::save().
bool ServerSettings::isMiddleman | ( | ) |
Returns true if the server is a middleman server.
Definition at line 389 of file serversettings.cpp.
References SETTING_SERVER_MIDDLEMAN.
Referenced by confValues(), and ServerPage::load().
void ServerSettings::setExitPolicy | ( | ExitPolicy & | policy | ) |
Sets the exit policy for this server.
Definition at line 410 of file serversettings.cpp.
References SETTING_SERVER_EXITPOLICY, setValue(), and ExitPolicy::toString().
Referenced by ServerPage::save().
ExitPolicy ServerSettings::getExitPolicy | ( | ) |
Gets the exit policy for this server.
Definition at line 403 of file serversettings.cpp.
References SETTING_SERVER_EXITPOLICY, and value().
Referenced by ServerPage::load().
void ServerSettings::setBandwidthAvgRate | ( | quint32 | rate | ) |
Sets the long-term average bandwidth rate (in KB/s) of this server.
Definition at line 424 of file serversettings.cpp.
References SETTING_SERVER_BWRATE, and setValue().
Referenced by ServerPage::save().
quint32 ServerSettings::getBandwidthAvgRate | ( | ) |
Gets the long-term average bandwidth rate (in KB/s) of this server.
Definition at line 417 of file serversettings.cpp.
References SETTING_SERVER_BWRATE, and value().
Referenced by ServerPage::load().
void ServerSettings::setBandwidthBurstRate | ( | quint32 | rate | ) |
Sets the maximum burst rate (in B/s) of this server.
Definition at line 438 of file serversettings.cpp.
References SETTING_SERVER_BWBURST, and setValue().
Referenced by ServerPage::save().
quint32 ServerSettings::getBandwidthBurstRate | ( | ) |
Gets the maximum burst rate (in B/s) of this server.
Definition at line 431 of file serversettings.cpp.
References SETTING_SERVER_BWBURST, and value().
Referenced by ServerPage::load().
void ServerSettings::setAutoUpdateAddress | ( | bool | enabled | ) |
Sets whether we automatically update the server address or not.
Definition at line 452 of file serversettings.cpp.
References SETTING_SERVER_AUTOUPDATE_ADDRESS, and setValue().
Referenced by ServerPage::save().
bool ServerSettings::getAutoUpdateAddress | ( | ) |
Gets whether we automatically update the server address.
Definition at line 445 of file serversettings.cpp.
References SETTING_SERVER_AUTOUPDATE_ADDRESS, and VidaliaSettings::value().
Referenced by ServerPage::load().
void ServerSettings::setChanged | ( | bool | changed | ) | [private] |
Sets a value indicating that the server settings have changed since apply() was last called.
Definition at line 97 of file serversettings.cpp.
References SETTING_SERVER_CHANGED.
Referenced by apply(), and setValue().
QHash< QString, QString > ServerSettings::confValues | ( | ) | [private] |
Returns Tor-recognizable configuration keys and current values.
Definition at line 201 of file serversettings.cpp.
References VidaliaSettings::defaultValue(), isDirectoryMirror(), isMiddleman(), isServerEnabled(), ExitPolicy::Middleman, scrub_email_addr(), SERVER_ADDRESS, SERVER_BANDWIDTH_BURST, SERVER_BANDWIDTH_RATE, SERVER_CONTACTINFO, SERVER_DIRPORT, SERVER_EXITPOLICY, SERVER_NICKNAME, SERVER_ORPORT, SETTING_SERVER_ADDRESS, SETTING_SERVER_BWBURST, SETTING_SERVER_BWRATE, SETTING_SERVER_CONTACT, SETTING_SERVER_DIRPORT, SETTING_SERVER_EXITPOLICY, SETTING_SERVER_NICKNAME, SETTING_SERVER_ORPORT, and VidaliaSettings::value().
Referenced by apply(), and isServerEnabled().
QMap< QString, QVariant > ServerSettings::allSettings | ( | ) | [private] |
Returns all currently stored server settings.
Definition at line 129 of file serversettings.cpp.
Referenced by apply(), and ServerSettings().
bool ServerSettings::isEmptyValue | ( | QVariant | value | ) | [private] |
Returns true if the specified QVariant contains an empty value.
Definition at line 144 of file serversettings.cpp.
Referenced by value().
QVariant ServerSettings::value | ( | QString | key | ) | [private] |
Retrieves a configuration value. If one isn't found, use a default.
Reimplemented from VidaliaSettings.
Definition at line 169 of file serversettings.cpp.
References _torControl, VidaliaSettings::defaultValue(), TorControl::getConf(), TorControl::isConnected(), isEmptyValue(), and VidaliaSettings::value().
Referenced by getAddress(), getBandwidthAvgRate(), getBandwidthBurstRate(), getContactInfo(), getDirPort(), getExitPolicy(), getNickname(), and getORPort().
void ServerSettings::setValue | ( | QString | key, | |
QVariant | value | |||
) | [private] |
Stores a configuration key-value.
Reimplemented from VidaliaSettings.
Definition at line 190 of file serversettings.cpp.
References setChanged(), VidaliaSettings::setValue(), and VidaliaSettings::value().
Referenced by revert(), setAddress(), setAutoUpdateAddress(), setBandwidthAvgRate(), setBandwidthBurstRate(), setContactInfo(), setDirectoryMirror(), setDirPort(), setExitPolicy(), setMiddleman(), setNickname(), setORPort(), and setServerEnabled().
TorControl* ServerSettings::_torControl [private] |
A TorControl object used to talk to Tor.
Definition at line 130 of file serversettings.h.
Referenced by apply(), isServerEnabled(), ServerSettings(), and value().
QMap<QString, QVariant> ServerSettings::_backupSettings [private] |
Values of all stored settings at the last apply() point.
Definition at line 132 of file serversettings.h.
Referenced by apply(), revert(), and ServerSettings().