first run on gui integration

This commit is contained in:
sehraf 2015-09-07 12:59:21 +02:00
parent ba74c04581
commit 0107f4e406
6 changed files with 137 additions and 35 deletions

View File

@ -101,7 +101,8 @@ const uint32_t RS_PEER_CONNECTSTATE_TRYING_UDP = 3;
const uint32_t RS_PEER_CONNECTSTATE_CONNECTED_TCP = 4;
const uint32_t RS_PEER_CONNECTSTATE_CONNECTED_UDP = 5;
const uint32_t RS_PEER_CONNECTSTATE_CONNECTED_TOR = 6;
const uint32_t RS_PEER_CONNECTSTATE_CONNECTED_UNKNOWN = 7;
const uint32_t RS_PEER_CONNECTSTATE_CONNECTED_I2P = 7;
const uint32_t RS_PEER_CONNECTSTATE_CONNECTED_UNKNOWN = 8;
/* Error codes for certificate cleaning and cert parsing. Numbers should not overlap. */

View File

@ -435,8 +435,14 @@ bool p3Peers::getPeerDetails(const RsPeerId& id, RsPeerDetails &d)
}
else if (pcs.state & RS_PEER_S_CONNECTED)
{
if(isProxyAddress(RS_HIDDEN_TYPE_TOR, pcs.connectaddr) || isProxyAddress(RS_HIDDEN_TYPE_I2P, pcs.connectaddr) || mPeerMgr->isHidden())
if(isProxyAddress(RS_HIDDEN_TYPE_TOR, pcs.connectaddr) || mPeerMgr->isHidden(RS_HIDDEN_TYPE_TOR))
{
d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_TOR;
}
else if (isProxyAddress(RS_HIDDEN_TYPE_I2P, pcs.connectaddr) || mPeerMgr->isHidden(RS_HIDDEN_TYPE_I2P))
{
d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_I2P;
}
else if (pcs.connecttype == RS_NET_CONN_TCP_ALL)
{
d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_TCP;

View File

@ -182,6 +182,10 @@ QString StatusDefs::connectStateString(RsPeerDetails &details)
stateString = qApp->translate("StatusDefs", "Connected: Tor");
isConnected = true;
break;
case RS_PEER_CONNECTSTATE_CONNECTED_I2P:
stateString = qApp->translate("StatusDefs", "Connected: I2P");
isConnected = true;
break;
case RS_PEER_CONNECTSTATE_CONNECTED_UNKNOWN:
stateString = qApp->translate("StatusDefs", "Connected: Unknown");
isConnected = true;
@ -231,6 +235,7 @@ QString StatusDefs::connectStateWithoutTransportTypeString(RsPeerDetails &detail
case RS_PEER_CONNECTSTATE_CONNECTED_TCP:
case RS_PEER_CONNECTSTATE_CONNECTED_UDP:
case RS_PEER_CONNECTSTATE_CONNECTED_TOR:
case RS_PEER_CONNECTSTATE_CONNECTED_I2P:
case RS_PEER_CONNECTSTATE_CONNECTED_UNKNOWN:
stateString = qApp->translate("StatusDefs", "Connected");
break;
@ -258,6 +263,9 @@ QString StatusDefs::connectStateIpString(RsPeerDetails &details)
case RS_PEER_CONNECTSTATE_CONNECTED_TOR:
stateString += QString(details.actAsServer ? qApp->translate("StatusDefs", "Tor-in") : qApp->translate("StatusDefs", "Tor-out"));
break;
case RS_PEER_CONNECTSTATE_CONNECTED_I2P:
stateString += QString(details.actAsServer ? qApp->translate("StatusDefs", "I2P-in") : qApp->translate("StatusDefs", "I2P-out"));
break;
case RS_PEER_CONNECTSTATE_CONNECTED_UNKNOWN:
stateString += qApp->translate("StatusDefs", "unkown");
break;

View File

@ -306,9 +306,14 @@ void ServerPage::load()
std::string proxyaddr;
uint16_t proxyport;
uint32_t status ;
rsPeers->getProxyServer(proxyaddr, proxyport, status);
ui.torpage_proxyAddress -> setText(QString::fromStdString(proxyaddr));
ui.torpage_proxyPort -> setValue(proxyport);
// Tor
rsPeers->getProxyServer(RS_HIDDEN_TYPE_TOR, proxyaddr, proxyport, status);
ui.hiddenpage_proxyAddress_tor -> setText(QString::fromStdString(proxyaddr));
ui.hiddenpage_proxyPort_tor -> setValue(proxyport);
// I2P
rsPeers->getProxyServer(RS_HIDDEN_TYPE_I2P, proxyaddr, proxyport, status);
ui.hiddenpage_proxyAddress_i2p -> setText(QString::fromStdString(proxyaddr));
ui.hiddenpage_proxyPort_i2p -> setValue(proxyport);
updateTorOutProxyIndicator();
}
@ -807,17 +812,29 @@ void ServerPage::saveAddresses()
rsConfig->SetMaxDataRates( ui.totalDownloadRate->value(), ui.totalUploadRate->value() );
// HANDLE PROXY SERVER.
std::string orig_proxyaddr;
uint16_t orig_proxyport;
uint32_t status ;
rsPeers->getProxyServer(orig_proxyaddr, orig_proxyport,status);
std::string orig_proxyaddr,new_proxyaddr;
uint16_t orig_proxyport, new_proxyport;
uint32_t status ;
// Tor
rsPeers->getProxyServer(RS_HIDDEN_TYPE_TOR, orig_proxyaddr, orig_proxyport,status);
std::string new_proxyaddr = ui.torpage_proxyAddress -> text().toStdString();
uint16_t new_proxyport = ui.torpage_proxyPort -> value();
new_proxyaddr = ui.hiddenpage_proxyAddress_tor -> text().toStdString();
new_proxyport = ui.hiddenpage_proxyPort_tor -> value();
if ((new_proxyaddr != orig_proxyaddr) || (new_proxyport != orig_proxyport))
{
rsPeers->setProxyServer(new_proxyaddr, new_proxyport);
rsPeers->setProxyServer(RS_HIDDEN_TYPE_TOR, new_proxyaddr, new_proxyport);
}
// I2P
rsPeers->getProxyServer(RS_HIDDEN_TYPE_I2P, orig_proxyaddr, orig_proxyport,status);
new_proxyaddr = ui.hiddenpage_proxyAddress_i2p -> text().toStdString();
new_proxyport = ui.hiddenpage_proxyPort_i2p -> value();
if ((new_proxyaddr != orig_proxyaddr) || (new_proxyport != orig_proxyport))
{
rsPeers->setProxyServer(RS_HIDDEN_TYPE_I2P, new_proxyaddr, new_proxyport);
}
load();
@ -935,9 +952,9 @@ void ServerPage::loadHiddenNode()
std::string proxyaddr;
uint16_t proxyport;
uint32_t proxy_state_flags;
rsPeers->getProxyServer(proxyaddr, proxyport, proxy_state_flags);
ui.torpage_proxyAddress -> setText(QString::fromStdString(proxyaddr));
ui.torpage_proxyPort -> setValue(proxyport);
rsPeers->getProxyServer(RS_HIDDEN_TYPE_TOR, proxyaddr, proxyport, proxy_state_flags);
ui.hiddenpage_proxyAddress_tor -> setText(QString::fromStdString(proxyaddr));
ui.hiddenpage_proxyPort_tor -> setValue(proxyport);
updateTorOutProxyIndicator();
@ -1053,14 +1070,14 @@ void ServerPage::saveAddressesHiddenNode()
std::string orig_proxyaddr;
uint16_t orig_proxyport;
uint32_t state_flags ;
rsPeers->getProxyServer(orig_proxyaddr, orig_proxyport,state_flags);
rsPeers->getProxyServer(RS_HIDDEN_TYPE_TOR, orig_proxyaddr, orig_proxyport,state_flags);
std::string new_proxyaddr = ui.torpage_proxyAddress -> text().toStdString();
uint16_t new_proxyport = ui.torpage_proxyPort -> value();
std::string new_proxyaddr = ui.hiddenpage_proxyAddress_tor -> text().toStdString();
uint16_t new_proxyport = ui.hiddenpage_proxyPort_tor -> value();
if ((new_proxyaddr != orig_proxyaddr) || (new_proxyport != orig_proxyport))
{
rsPeers->setProxyServer(new_proxyaddr, new_proxyport);
rsPeers->setProxyServer(RS_HIDDEN_TYPE_TOR, new_proxyaddr, new_proxyport);
}
rsConfig->SetMaxDataRates( ui.totalDownloadRate->value(), ui.totalUploadRate->value() );
@ -1069,7 +1086,7 @@ void ServerPage::saveAddressesHiddenNode()
void ServerPage::updateTorOutProxyIndicator()
{
QTcpSocket socket ;
socket.connectToHost(ui.torpage_proxyAddress->text(),ui.torpage_proxyPort->text().toInt());
socket.connectToHost(ui.hiddenpage_proxyAddress_tor->text(),ui.hiddenpage_proxyPort_tor->text().toInt());
if(socket.waitForConnected(500))
{
@ -1113,8 +1130,8 @@ void ServerPage::updateTorInProxyIndicator()
QNetworkProxy proxy ;
proxy.setType(QNetworkProxy::Socks5Proxy);
proxy.setHostName(ui.torpage_proxyAddress->text());
proxy.setPort(ui.torpage_proxyPort->text().toInt());
proxy.setHostName(ui.hiddenpage_proxyAddress_tor->text());
proxy.setPort(ui.hiddenpage_proxyPort_tor->text().toInt());
proxy.setCapabilities(QNetworkProxy::HostNameLookupCapability | proxy.capabilities()) ;
//ui.iconlabel_tor_incoming->setPixmap(QPixmap(ICON_STATUS_UNKNOWN)) ;
@ -1127,7 +1144,7 @@ void ServerPage::updateTorInProxyIndicator()
QUrl url("https://"+ui.torpage_onionAddress->text() + ":" + ui.torpage_onionPort->text()) ;
std::cerr << "Setting proxy hostname+port to " << std::dec << ui.torpage_proxyAddress->text().toStdString() << ":" << ui.torpage_proxyPort->text().toInt() << std::endl;
std::cerr << "Setting proxy hostname+port to " << std::dec << ui.hiddenpage_proxyAddress_tor->text().toStdString() << ":" << ui.hiddenpage_proxyPort_tor->text().toInt() << std::endl;
std::cerr << "Connecting to " << url.toString().toStdString() << std::endl;
connect(manager, SIGNAL(finished(QNetworkReply*)),this,SLOT(handleNetworkReply(QNetworkReply*))) ;

View File

@ -52,6 +52,7 @@ public slots:
void updateStatus();
private slots:
// ban list
void updateSelectedBlackListIP(int row, int, int, int);
void updateSelectedWhiteListIP(int row,int,int,int);
void addIpRangeToBlackList();
@ -69,6 +70,8 @@ private slots:
void ipFilterContextMenu(const QPoint &);
void ipWhiteListContextMenu(const QPoint &point);
void removeBannedIp();
// server
void saveAddresses();
void toggleUPnP();
void toggleIpDetermination(bool) ;
@ -78,11 +81,12 @@ private slots:
void updateTorInProxyIndicator();
private:
// Alternative Versions for HiddenNode Mode.
// ban list
void addPeerToIPTable(QTableWidget *table, int row, const BanListPeer &blp);
bool removeCurrentRowFromBlackList(sockaddr_storage& collected_addr,int& masked_bytes);
bool removeCurrentRowFromWhiteList(sockaddr_storage &collected_addr, int &masked_bytes);
// Alternative Versions for HiddenNode Mode.
void loadHiddenNode();
void updateStatusHiddenNode();
void saveAddressesHiddenNode();

View File

@ -11,13 +11,22 @@
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="margin">
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>6</number>
</property>
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>2</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
@ -515,7 +524,7 @@ behind a firewall or a VPN.</string>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tabWidgetPage1" native="true">
<widget class="QWidget" name="tabWidgetPage1">
<attribute name="title">
<string>IP blacklist</string>
</attribute>
@ -756,15 +765,15 @@ behind a firewall or a VPN.</string>
</item>
</layout>
</widget>
<widget class="QWidget" name="TorTAB">
<widget class="QWidget" name="HiddenTAB">
<attribute name="title">
<string>Tor Configuration</string>
<string>Hidden Service Configuration</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="QGroupBox" name="torpage_outgoing">
<property name="title">
<string>Outgoing Tor Connections</string>
<string>Outgoing Connections</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
@ -779,10 +788,10 @@ behind a firewall or a VPN.</string>
</widget>
</item>
<item>
<widget class="QLineEdit" name="torpage_proxyAddress"/>
<widget class="QLineEdit" name="hiddenpage_proxyAddress_tor"/>
</item>
<item>
<widget class="QSpinBox" name="torpage_proxyPort">
<widget class="QSpinBox" name="hiddenpage_proxyPort_tor">
<property name="minimum">
<number>10</number>
</property>
@ -822,12 +831,67 @@ behind a firewall or a VPN.</string>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_15">
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_17">
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>I2P Socks Proxy</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="hiddenpage_proxyAddress_i2p"/>
</item>
<item>
<widget class="QSpinBox" name="hiddenpage_proxyPort_i2p">
<property name="minimum">
<number>10</number>
</property>
<property name="maximum">
<number>65535</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_18">
<item>
<widget class="QLabel" name="iconlabel_i2p_outgoing">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/ledoff1.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>I2P outgoing Okay</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QPlainTextEdit" name="plainTextEdit">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>100</height>
<height>145</height>
</size>
</property>
<property name="verticalScrollBarPolicy">
@ -839,8 +903,10 @@ behind a firewall or a VPN.</string>
<property name="plainText">
<string>Tor Socks Proxy default: 127.0.0.1:9050. Set in torrc config and update here.
I2P Socks Proxy: see http://127.0.0.1:7657/i2ptunnelmgr for setting up a client tunnel.
You can connect to Hidden Nodes, even if you
are running a standard Node, so why not setup Tor? </string>
are running a standard Node, so why not setup Tor and/or I2P? </string>
</property>
</widget>
</item>