Export shadowsocks over cloak config support
This commit is contained in:
parent
74a517d985
commit
e7a22ad159
7 changed files with 170 additions and 43 deletions
|
@ -16,6 +16,10 @@ RUN chmod a+x /opt/amnezia/start.sh
|
|||
RUN curl -L https://github.com/cbeuw/Cloak/releases/download/v2.5.3/ck-server-linux-amd64-v2.5.3 > /usr/bin/ck-server
|
||||
RUN chmod a+x /usr/bin/ck-server
|
||||
|
||||
RUN curl -L https://github.com/shadowsocks/shadowsocks-rust/releases/download/v1.10.9/shadowsocks-v1.10.9.x86_64-unknown-linux-musl.tar.xz > /usr/bin/ss.tar.xz
|
||||
RUN tar -Jxvf /usr/bin/ss.tar.xz -C /usr/bin/
|
||||
RUN chmod a+x /usr/bin/ssserver
|
||||
|
||||
# Tune network
|
||||
RUN echo -e " \n\
|
||||
fs.file-max = 51200 \n\
|
||||
|
|
|
@ -39,6 +39,10 @@ echo -e "{\\n\
|
|||
\"openvpn\": [\\n\
|
||||
\"$OPENVPN_TRANSPORT_PROTO\",\\n\
|
||||
\"localhost:$OPENVPN_PORT\"\\n\
|
||||
],\\n\
|
||||
\"shadowsocks\": [\\n\
|
||||
\"tcp\",\\n\
|
||||
\"localhost:$SHADOWSOCKS_SERVER_PORT\"\\n\
|
||||
]\\n\
|
||||
},\\n\
|
||||
\"BypassUID\": [\\n\
|
||||
|
@ -51,3 +55,17 @@ echo -e "{\\n\
|
|||
\"DatabasePath\": \"userinfo.db\",\\n\
|
||||
\"StreamTimeout\": 300\\n\
|
||||
}" >/opt/amnezia/cloak/ck-config.json'
|
||||
|
||||
# ShadowSocks config
|
||||
sudo docker exec -i $CONTAINER_NAME bash -c '\
|
||||
mkdir -p /opt/amnezia/shadowsocks; \
|
||||
cd /opt/amnezia/shadowsocks || exit 1; \
|
||||
SHADOWSOCKS_PASSWORD=$(openssl rand -base64 32 | tr "=" "A" | tr "+" "A" | tr "/" "A") && echo $SHADOWSOCKS_PASSWORD > /opt/amnezia/shadowsocks/shadowsocks.key; \
|
||||
echo -e "{\\n\
|
||||
\"local_port\": 8585,\\n\
|
||||
\"method\": \"$SHADOWSOCKS_CIPHER\",\\n\
|
||||
\"password\": \"$SHADOWSOCKS_PASSWORD\",\\n\
|
||||
\"server\": \"0.0.0.0\",\\n\
|
||||
\"server_port\": $SHADOWSOCKS_SERVER_PORT,\\n\
|
||||
\"timeout\": 60\\n\
|
||||
}" >/opt/amnezia/shadowsocks/ss-config.json'
|
||||
|
|
|
@ -21,9 +21,11 @@ iptables -t nat -A POSTROUTING -s $OPENVPN_SUBNET_IP/$OPENVPN_SUBNET_CIDR -o eth
|
|||
# kill daemons in case of restart
|
||||
killall -KILL openvpn
|
||||
killall -KILL ck-server
|
||||
killall -KILL ssserver
|
||||
|
||||
# start daemons if configured
|
||||
if [ -f /opt/amnezia/openvpn/ca.crt ]; then (openvpn --config /opt/amnezia/openvpn/server.conf --daemon); fi
|
||||
if [ -f /opt/amnezia/shadowsocks/ss-config.json ]; then (ssserver -c /opt/amnezia/shadowsocks/ss-config.json &); fi
|
||||
if [ -f /opt/amnezia/cloak/ck-config.json ]; then (ck-server -c /opt/amnezia/cloak/ck-config.json &); fi
|
||||
|
||||
tail -f /dev/null
|
||||
|
|
|
@ -25,7 +25,7 @@ tls-server \\n\
|
|||
tls-version-min 1.2 \\n\
|
||||
$OPENVPN_TLS_AUTH" >/opt/amnezia/openvpn/server.conf'
|
||||
|
||||
# Cloak config
|
||||
# ShadowSocks config
|
||||
sudo docker exec -i $CONTAINER_NAME bash -c '\
|
||||
mkdir -p /opt/amnezia/shadowsocks; \
|
||||
cd /opt/amnezia/shadowsocks || exit 1; \
|
||||
|
|
|
@ -25,4 +25,5 @@ killall -KILL ssserver
|
|||
# start daemons if configured
|
||||
if [ -f /opt/amnezia/openvpn/ca.crt ]; then (openvpn --config /opt/amnezia/openvpn/server.conf --daemon); fi
|
||||
if [ -f /opt/amnezia/shadowsocks/ss-config.json ]; then (ssserver -c /opt/amnezia/shadowsocks/ss-config.json &); fi
|
||||
|
||||
tail -f /dev/null
|
||||
|
|
|
@ -1216,7 +1216,7 @@ void MainWindow::setupAppSettingsConnections()
|
|||
|
||||
connect(ui->pushButton_app_settings_open_logs, &QPushButton::clicked, this, [this](){
|
||||
Debug::openLogsFolder();
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(Utils::systemLogPath()));
|
||||
//QDesktopServices::openUrl(QUrl::fromLocalFile(Utils::systemLogPath()));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1566,6 +1566,17 @@ void MainWindow::setupSharePageConnections()
|
|||
});
|
||||
});
|
||||
|
||||
connect(ui->pushButton_share_full_save, &QPushButton::clicked, this, [this](){
|
||||
if (ui->textEdit_share_full_code->toPlainText().isEmpty()) return;
|
||||
|
||||
QString fileName = QFileDialog::getSaveFileName(this, tr("Save AmneziaVPN config"),
|
||||
QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "*.amnezia");
|
||||
QSaveFile save(fileName);
|
||||
save.open(QIODevice::WriteOnly);
|
||||
save.write(ui->textEdit_share_full_code->toPlainText().toUtf8());
|
||||
save.commit();
|
||||
});
|
||||
|
||||
connect(ui->pushButton_share_amnezia_copy, &QPushButton::clicked, this, [this](){
|
||||
if (ui->textEdit_share_amnezia_code->toPlainText().isEmpty()) return;
|
||||
|
||||
|
@ -1606,14 +1617,14 @@ void MainWindow::setupSharePageConnections()
|
|||
});
|
||||
});
|
||||
|
||||
// connect(ui->pushButton_share_cloak_copy, &QPushButton::clicked, this, [this](){
|
||||
// QGuiApplication::clipboard()->setText(ui->textEdit_share_openvpn_code->toPlainText());
|
||||
// ui->pushButton_share_cloak_copy->setText(tr("Copied"));
|
||||
connect(ui->pushButton_share_cloak_copy, &QPushButton::clicked, this, [this](){
|
||||
QGuiApplication::clipboard()->setText(ui->plainTextEdit_share_cloak->toPlainText());
|
||||
ui->pushButton_share_cloak_copy->setText(tr("Copied"));
|
||||
|
||||
// QTimer::singleShot(3000, this, [this]() {
|
||||
// ui->pushButton_share_cloak_copy->setText(tr("Copy"));
|
||||
// });
|
||||
// });
|
||||
QTimer::singleShot(3000, this, [this]() {
|
||||
ui->pushButton_share_cloak_copy->setText(tr("Copy"));
|
||||
});
|
||||
});
|
||||
|
||||
connect(ui->pushButton_share_amnezia_generate, &QPushButton::clicked, this, [this](){
|
||||
ui->pushButton_share_amnezia_generate->setEnabled(false);
|
||||
|
@ -2129,22 +2140,11 @@ void MainWindow::updateSharingPage(int serverIndex, const ServerCredentials &cre
|
|||
ui->pushButton_share_openvpn_copy->setEnabled(false);
|
||||
ui->pushButton_share_openvpn_save->setEnabled(false);
|
||||
|
||||
// QJsonObject protoConfig = m_settings.protocolConfig(serverIndex, container, Protocol::OpenVpn);
|
||||
// QString cfg = protoConfig.value(config_key::last_config).toString();
|
||||
// if (!cfg.isEmpty()) {
|
||||
// // TODO add redirect-gateway def1 bypass-dhcp here and on click Generate config
|
||||
// ui->textEdit_share_openvpn_code->setPlainText(cfg);
|
||||
// }
|
||||
// else {
|
||||
// cfg = tr("Press Generate config");
|
||||
// ui->textEdit_share_openvpn_code->setPlainText(cfg);
|
||||
// ui->pushButton_share_openvpn_copy->setEnabled(false);
|
||||
// ui->pushButton_share_openvpn_save->setEnabled(false);
|
||||
// }
|
||||
ui->toolBox_share_connection->setCurrentWidget(ui->page_share_openvpn);
|
||||
}
|
||||
|
||||
if (container == DockerContainer::OpenVpnOverShadowSocks) {
|
||||
if (container == DockerContainer::OpenVpnOverShadowSocks ||
|
||||
container == DockerContainer::OpenVpnOverCloak) {
|
||||
ui->toolBox_share_connection->addItem(ui->page_share_amnezia, tr(" Share for Amnezia client"));
|
||||
ui->toolBox_share_connection->addItem(ui->page_share_shadowsocks, tr(" Share for ShadowSocks client"));
|
||||
|
||||
|
@ -2185,7 +2185,27 @@ void MainWindow::updateSharingPage(int serverIndex, const ServerCredentials &cre
|
|||
}
|
||||
|
||||
if (container == DockerContainer::OpenVpnOverCloak) {
|
||||
ui->toolBox_share_connection->addItem(ui->page_share_amnezia, tr(" Share for Amnezia client"));
|
||||
//ui->toolBox_share_connection->addItem(ui->page_share_amnezia, tr(" Share for Amnezia client"));
|
||||
ui->toolBox_share_connection->addItem(ui->page_share_cloak, tr(" Share for Cloak client"));
|
||||
ui->plainTextEdit_share_cloak->setPlainText(QString(""));
|
||||
|
||||
QJsonObject protoConfig = m_settings.protocolConfig(serverIndex, container, Protocol::Cloak);
|
||||
QString cfg = protoConfig.value(config_key::last_config).toString();
|
||||
|
||||
if (cfg.isEmpty()) {
|
||||
const QJsonObject &containerConfig = m_settings.containerConfig(serverIndex, container);
|
||||
|
||||
ErrorCode e = ErrorCode::NoError;
|
||||
cfg = CloakConfigurator::genCloakConfig(credentials, container, containerConfig, &e);
|
||||
|
||||
ui->pushButton_share_cloak_copy->setEnabled(true);
|
||||
}
|
||||
|
||||
QJsonObject cloakConfig = QJsonDocument::fromJson(cfg.toUtf8()).object();
|
||||
cloakConfig.remove(config_key::transport_proto);
|
||||
cloakConfig.insert("ProxyMethod", "shadowsocks");
|
||||
|
||||
ui->plainTextEdit_share_cloak->setPlainText(QJsonDocument(cloakConfig).toJson());
|
||||
}
|
||||
|
||||
// Full access
|
||||
|
|
|
@ -274,7 +274,7 @@ QPushButton:hover {
|
|||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>8</number>
|
||||
<number>17</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="page_start">
|
||||
<widget class="QLabel" name="label_25">
|
||||
|
@ -5815,7 +5815,7 @@ QToolBox::tab:hover {
|
|||
<number>0</number>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="tabSpacing">
|
||||
<number>6</number>
|
||||
|
@ -5825,8 +5825,8 @@ QToolBox::tab:hover {
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>100</width>
|
||||
<height>30</height>
|
||||
<width>360</width>
|
||||
<height>360</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
|
@ -5884,7 +5884,7 @@ p, li { white-space: pre-wrap; }
|
|||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>180</y>
|
||||
<y>260</y>
|
||||
<width>341</width>
|
||||
<height>111</height>
|
||||
</rect>
|
||||
|
@ -5947,14 +5947,50 @@ background: #282932;
|
|||
<string>Copy</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_share_full_save">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>180</y>
|
||||
<width>341</width>
|
||||
<height>40</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="cursor">
|
||||
<cursorShape>PointingHandCursor</cursorShape>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QPushButton {
|
||||
font-size: 13pt;
|
||||
font: "Open Sans Semibold";
|
||||
color:rgb(212, 212, 212);
|
||||
|
||||
background: #181922;
|
||||
border-radius: 4px;
|
||||
|
||||
font-family: Lato;
|
||||
font-style: normal;
|
||||
font-weight: normal;
|
||||
font-size: 16px;
|
||||
line-height: 21px;
|
||||
|
||||
}
|
||||
QPushButton:hover {
|
||||
background: #282932;
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save file</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_share_amnezia">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>100</width>
|
||||
<height>30</height>
|
||||
<width>360</width>
|
||||
<height>360</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
|
@ -6149,8 +6185,8 @@ background: #282932;
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>100</width>
|
||||
<height>30</height>
|
||||
<width>360</width>
|
||||
<height>360</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
|
@ -6315,8 +6351,8 @@ background: #282932;
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>100</width>
|
||||
<height>30</height>
|
||||
<width>360</width>
|
||||
<height>360</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
|
@ -6493,10 +6529,10 @@ background: #282932;
|
|||
<widget class="QLabel" name="label_share_ss_qr_code">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>65</x>
|
||||
<y>250</y>
|
||||
<width>240</width>
|
||||
<height>240</height>
|
||||
<x>85</x>
|
||||
<y>235</y>
|
||||
<width>200</width>
|
||||
<height>200</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
|
@ -6539,13 +6575,59 @@ color: #15CDCB;
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>100</width>
|
||||
<height>30</height>
|
||||
<width>360</width>
|
||||
<height>360</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
<string> Share for Cloak client</string>
|
||||
</attribute>
|
||||
<widget class="QPushButton" name="pushButton_share_cloak_copy">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>290</y>
|
||||
<width>331</width>
|
||||
<height>40</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="cursor">
|
||||
<cursorShape>PointingHandCursor</cursorShape>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QPushButton {
|
||||
font-size: 13pt;
|
||||
font: "Open Sans Semibold";
|
||||
color:rgb(212, 212, 212);
|
||||
|
||||
background: #181922;
|
||||
border-radius: 4px;
|
||||
|
||||
font-family: Lato;
|
||||
font-style: normal;
|
||||
font-weight: normal;
|
||||
font-size: 16px;
|
||||
line-height: 21px;
|
||||
|
||||
}
|
||||
QPushButton:hover {
|
||||
background: #282932;
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Copy</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPlainTextEdit" name="plainTextEdit_share_cloak">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>30</y>
|
||||
<width>331</width>
|
||||
<height>221</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue