[add] added more route functions

Former-commit-id: 5107a76a67
This commit is contained in:
Leroy.H.Y 2019-10-31 22:40:51 +08:00
parent 5ebe245d35
commit 1f851d70a3
4 changed files with 74 additions and 3 deletions

View File

@ -1 +1 @@
193
205

View File

@ -415,6 +415,7 @@ void RouteEditor::on_routeProtocolBTCB_stateChanged(int arg1)
CurrentRule.protocol = protocols.toStdList();
STATUS("Protocol list changed.")
}
void RouteEditor::on_balabcerAddBtn_clicked()
{
if (!ui->balancerSelectionCombo->currentText().isEmpty()) {
@ -662,3 +663,58 @@ void RouteEditor::on_delRouteBtn_clicked()
}
}
}
void RouteEditor::on_addDefaultBtn_clicked()
{
// Add default connection from GlobalConfig
auto conf = GetGlobalConfig();
//
auto _in = conf.inBoundSettings;
//
auto _in_httpConf = GenerateHTTPIN(QList<AccountObject>() << _in.httpAccount);
auto _in_socksConf = GenerateSocksIN((_in.socks_useAuth ? "password" : "noauth"),
QList<AccountObject>() << _in.socksAccount,
_in.socksUDP, QSTRING(_in.socksLocalIP));
//
auto _in_HTTP = GenerateInboundEntry(QSTRING(_in.listenip), _in.http_port, "http", _in_httpConf, "HTTP_gConf");
auto _in_SOCKS = GenerateInboundEntry(QSTRING(_in.listenip), _in.socks_port, "socks", _in_socksConf, "SOCKS_gConf");
//
inbounds.append(_in_HTTP);
ui->inboundsList->addItem("HTTP Global Config");
ui->inboundsList->item(ui->inboundsList->count() - 1)->setCheckState(Qt::Unchecked);
//
inbounds.append(_in_SOCKS);
ui->inboundsList->addItem("SOCKS Global Config");
ui->inboundsList->item(ui->inboundsList->count() - 1)->setCheckState(Qt::Unchecked);
}
void RouteEditor::on_insertBlackBtn_clicked()
{
auto blackHole = GenerateBlackHoleOUT(false);
auto tag = "blackhole_" + QString::number(QTime::currentTime().msecsSinceStartOfDay());
auto _blackHoleOutbound = GenerateOutboundEntry("blackhole", blackHole, QJsonObject(), QJsonObject(), "0.0.0.0", tag);
outbounds.append(_blackHoleOutbound);
ui->outboundsList->addItem(tag);
}
void RouteEditor::on_delOutboundBtn_clicked()
{
if (ui->outboundsList->currentRow() < 0) {
return;
}
auto index = ui->outboundsList->currentRow();
outbounds.removeAt(index);
ui->outboundsList->takeItem(index);
}
void RouteEditor::on_delInboundBtn_clicked()
{
if (ui->inboundsList->currentRow() < 0) {
return;
}
auto index = ui->inboundsList->currentRow();
inbounds.removeAt(index);
ui->inboundsList->takeItem(index);
}

View File

@ -78,6 +78,14 @@ class RouteEditor : public QDialog
void on_delRouteBtn_clicked();
void on_addDefaultBtn_clicked();
void on_insertBlackBtn_clicked();
void on_delOutboundBtn_clicked();
void on_delInboundBtn_clicked();
private:
void ShowRuleDetail(RuleObject rule);
int currentRuleIndex;

View File

@ -22,7 +22,7 @@
<property name="modal">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_5" rowstretch="1,1,0" columnstretch="4,7">
<layout class="QGridLayout" name="gridLayout_5" rowstretch="2,2,0" columnstretch="4,7">
<item row="2" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
@ -251,7 +251,14 @@
<item>
<widget class="QToolButton" name="insertDirectBtn">
<property name="text">
<string>D</string>
<string>F</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="insertBlackBtn">
<property name="text">
<string>B</string>
</property>
</widget>
</item>