server scripts fix
This commit is contained in:
parent
77f830acd5
commit
68e0ba9923
9 changed files with 45 additions and 25 deletions
|
@ -190,6 +190,8 @@ OpenVpnConfigurator::ConnectionData OpenVpnConfigurator::prepareOpenVpnConfig(co
|
||||||
if (errorCode) *errorCode = ErrorCode::RemoteProcessCrashError;
|
if (errorCode) *errorCode = ErrorCode::RemoteProcessCrashError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ServerController::setupServerFirewall(credentials);
|
||||||
|
|
||||||
return connData;
|
return connData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,6 @@ private:
|
||||||
|
|
||||||
static ConnectionData prepareOpenVpnConfig(const ServerCredentials &credentials,
|
static ConnectionData prepareOpenVpnConfig(const ServerCredentials &credentials,
|
||||||
Protocol proto, ErrorCode *errorCode = nullptr);
|
Protocol proto, ErrorCode *errorCode = nullptr);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // OPENVPNCONFIGURATOR_H
|
#endif // OPENVPNCONFIGURATOR_H
|
||||||
|
|
|
@ -54,7 +54,7 @@ ErrorCode ServerController::runScript(DockerContainer container,
|
||||||
}
|
}
|
||||||
|
|
||||||
QEventLoop wait;
|
QEventLoop wait;
|
||||||
int exitStatus;
|
int exitStatus = -1;
|
||||||
|
|
||||||
// QObject::connect(proc.data(), &SshRemoteProcess::started, &wait, [](){
|
// QObject::connect(proc.data(), &SshRemoteProcess::started, &wait, [](){
|
||||||
// qDebug() << "Command started";
|
// qDebug() << "Command started";
|
||||||
|
@ -66,22 +66,22 @@ ErrorCode ServerController::runScript(DockerContainer container,
|
||||||
wait.quit();
|
wait.quit();
|
||||||
});
|
});
|
||||||
|
|
||||||
// QObject::connect(proc.data(), &SshRemoteProcess::readyReadStandardOutput, [proc](){
|
QObject::connect(proc.data(), &SshRemoteProcess::readyReadStandardOutput, [proc](){
|
||||||
// QString s = proc->readAllStandardOutput();
|
QString s = proc->readAllStandardOutput();
|
||||||
// if (s != "." && !s.isEmpty()) {
|
if (s != "." && !s.isEmpty()) {
|
||||||
// qDebug().noquote() << s;
|
qDebug().noquote() << s;
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
|
|
||||||
// QObject::connect(proc.data(), &SshRemoteProcess::readyReadStandardError, [proc](){
|
QObject::connect(proc.data(), &SshRemoteProcess::readyReadStandardError, [proc](){
|
||||||
// QString s = proc->readAllStandardError();
|
QString s = proc->readAllStandardError();
|
||||||
// if (s != "." && !s.isEmpty()) {
|
if (s != "." && !s.isEmpty()) {
|
||||||
// qDebug().noquote() << s;
|
qDebug().noquote() << s;
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
|
|
||||||
proc->start();
|
proc->start();
|
||||||
if (i < lines.count()) {
|
if (i < lines.count() && exitStatus < 0) {
|
||||||
wait.exec();
|
wait.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ ErrorCode ServerController::uploadTextFileToContainer(DockerContainer container,
|
||||||
}
|
}
|
||||||
|
|
||||||
QEventLoop wait;
|
QEventLoop wait;
|
||||||
int exitStatus = 0;
|
int exitStatus = -1;
|
||||||
|
|
||||||
// QObject::connect(proc.data(), &SshRemoteProcess::started, &wait, [](){
|
// QObject::connect(proc.data(), &SshRemoteProcess::started, &wait, [](){
|
||||||
// qDebug() << "Command started";
|
// qDebug() << "Command started";
|
||||||
|
@ -138,11 +138,11 @@ ErrorCode ServerController::uploadTextFileToContainer(DockerContainer container,
|
||||||
});
|
});
|
||||||
|
|
||||||
proc->start();
|
proc->start();
|
||||||
wait.exec();
|
//wait.exec();
|
||||||
|
|
||||||
// if (proc->isRunning()) {
|
if (exitStatus < 0) {
|
||||||
// wait.exec();
|
wait.exec();
|
||||||
// }
|
}
|
||||||
|
|
||||||
return fromSshProcessExitStatus(exitStatus);
|
return fromSshProcessExitStatus(exitStatus);
|
||||||
}
|
}
|
||||||
|
@ -176,10 +176,15 @@ QString ServerController::getTextFileFromContainer(DockerContainer container,
|
||||||
wait.quit();
|
wait.quit();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
QObject::connect(proc.data(), &SshRemoteProcess::started, &wait, [&](){
|
||||||
|
qDebug() << "ServerController::getTextFileFromContainer proc started";
|
||||||
|
exitStatus = -1;
|
||||||
|
});
|
||||||
|
|
||||||
proc->start();
|
proc->start();
|
||||||
wait.exec();
|
wait.exec();
|
||||||
|
|
||||||
// if (proc->isRunning()) {
|
// if (exitStatus < 0) {
|
||||||
// wait.exec();
|
// wait.exec();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
@ -421,3 +426,12 @@ SshConnection *ServerController::connectToHost(const SshConnectionParameters &ss
|
||||||
|
|
||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ErrorCode ServerController::setupServerFirewall(const ServerCredentials &credentials)
|
||||||
|
{
|
||||||
|
QFile file(":/server_scripts/setup_firewall.sh");
|
||||||
|
file.open(QIODevice::ReadOnly);
|
||||||
|
|
||||||
|
QString script = file.readAll();
|
||||||
|
return runScript(DockerContainer::OpenVpn, sshParams(credentials), script);
|
||||||
|
}
|
||||||
|
|
|
@ -44,6 +44,7 @@ public:
|
||||||
static int ssContainerPort() { return 8585; } // TODO move to ShadowSocksDefs.h
|
static int ssContainerPort() { return 8585; } // TODO move to ShadowSocksDefs.h
|
||||||
static QString ssEncryption() { return "chacha20-ietf-poly1305"; } // TODO move to ShadowSocksDefs.h
|
static QString ssEncryption() { return "chacha20-ietf-poly1305"; } // TODO move to ShadowSocksDefs.h
|
||||||
|
|
||||||
|
static ErrorCode setupServerFirewall(const ServerCredentials &credentials);
|
||||||
private:
|
private:
|
||||||
static QSsh::SshConnection *connectToHost(const QSsh::SshConnectionParameters &sshParams);
|
static QSsh::SshConnection *connectToHost(const QSsh::SshConnectionParameters &sshParams);
|
||||||
static ErrorCode runScript(DockerContainer container,
|
static ErrorCode runScript(DockerContainer container,
|
||||||
|
|
|
@ -18,7 +18,7 @@ IDI_ICON1 ICON "../images/app.ico"
|
||||||
#define VER_ORIGINALFILENAME_STR "amneziavpn.exe"
|
#define VER_ORIGINALFILENAME_STR "amneziavpn.exe"
|
||||||
#define VER_PRODUCTNAME_STR "AmneziaVPN"
|
#define VER_PRODUCTNAME_STR "AmneziaVPN"
|
||||||
|
|
||||||
#define VER_COMPANYDOMAIN_STR "http://amnezia.org/"
|
#define VER_COMPANYDOMAIN_STR "https://amnezia.org/"
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
VS_VERSION_INFO VERSIONINFO
|
||||||
FILEVERSION VER_FILEVERSION
|
FILEVERSION VER_FILEVERSION
|
||||||
|
|
|
@ -39,5 +39,6 @@
|
||||||
<file>images/background_connected.png</file>
|
<file>images/background_connected.png</file>
|
||||||
<file>server_scripts/setup_shadowsocks_server.sh</file>
|
<file>server_scripts/setup_shadowsocks_server.sh</file>
|
||||||
<file>server_scripts/template_shadowsocks.ovpn</file>
|
<file>server_scripts/template_shadowsocks.ovpn</file>
|
||||||
|
<file>server_scripts/setup_firewall.sh</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
3
client/server_scripts/setup_firewall.sh
Normal file
3
client/server_scripts/setup_firewall.sh
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
sysctl -w net.ipv4.ip_forward=1
|
||||||
|
iptables -P FORWARD ACCEPT
|
||||||
|
iptables -A INPUT -p icmp --icmp-type echo-request -j DROP
|
|
@ -7,7 +7,7 @@ systemctl start docker
|
||||||
docker stop $CONTAINER_NAME
|
docker stop $CONTAINER_NAME
|
||||||
docker rm -f $CONTAINER_NAME
|
docker rm -f $CONTAINER_NAME
|
||||||
docker pull amneziavpn/openvpn:latest
|
docker pull amneziavpn/openvpn:latest
|
||||||
docker run -d --restart always --cap-add=NET_ADMIN -p 1194:1194/udp --name $CONTAINER_NAME amneziavpn/openvpn:latest
|
docker run -d --restart always --cap-add=NET_ADMIN -e HOST_ADDR=$(curl -s https://api.ipify.org) -p 1194:1194/udp --name $CONTAINER_NAME amneziavpn/openvpn:latest
|
||||||
|
|
||||||
|
|
||||||
docker exec -i $CONTAINER_NAME sh -c "mkdir -p /opt/amneziavpn_data/clients"
|
docker exec -i $CONTAINER_NAME sh -c "mkdir -p /opt/amneziavpn_data/clients"
|
||||||
|
@ -18,4 +18,4 @@ docker exec -i $CONTAINER_NAME sh -c "cd /opt/amneziavpn_data && cp pki/dh.pem /
|
||||||
docker exec -i $CONTAINER_NAME sh -c "cd /opt/amneziavpn_data && easyrsa sign-req server MyReq << EOF3 yes EOF3"
|
docker exec -i $CONTAINER_NAME sh -c "cd /opt/amneziavpn_data && easyrsa sign-req server MyReq << EOF3 yes EOF3"
|
||||||
docker exec -i $CONTAINER_NAME sh -c "cd /opt/amneziavpn_data && openvpn --genkey --secret ta.key << EOF4"
|
docker exec -i $CONTAINER_NAME sh -c "cd /opt/amneziavpn_data && openvpn --genkey --secret ta.key << EOF4"
|
||||||
docker exec -i $CONTAINER_NAME sh -c "cd /opt/amneziavpn_data && cp pki/ca.crt pki/issued/MyReq.crt pki/private/MyReq.key ta.key /etc/openvpn"
|
docker exec -i $CONTAINER_NAME sh -c "cd /opt/amneziavpn_data && cp pki/ca.crt pki/issued/MyReq.crt pki/private/MyReq.key ta.key /etc/openvpn"
|
||||||
docker exec -i $CONTAINER_NAME sh -c "openvpn --config /etc/openvpn/server.conf &"
|
docker exec -d $CONTAINER_NAME sh -c "openvpn --config /etc/openvpn/server.conf"
|
||||||
|
|
|
@ -18,4 +18,4 @@ docker exec -i $CONTAINER_NAME sh -c "cd /opt/amneziavpn_data && cp pki/dh.pem /
|
||||||
docker exec -i $CONTAINER_NAME sh -c "cd /opt/amneziavpn_data && easyrsa sign-req server MyReq << EOF3 yes EOF3"
|
docker exec -i $CONTAINER_NAME sh -c "cd /opt/amneziavpn_data && easyrsa sign-req server MyReq << EOF3 yes EOF3"
|
||||||
docker exec -i $CONTAINER_NAME sh -c "cd /opt/amneziavpn_data && openvpn --genkey --secret ta.key << EOF4"
|
docker exec -i $CONTAINER_NAME sh -c "cd /opt/amneziavpn_data && openvpn --genkey --secret ta.key << EOF4"
|
||||||
docker exec -i $CONTAINER_NAME sh -c "cd /opt/amneziavpn_data && cp pki/ca.crt pki/issued/MyReq.crt pki/private/MyReq.key ta.key /etc/openvpn"
|
docker exec -i $CONTAINER_NAME sh -c "cd /opt/amneziavpn_data && cp pki/ca.crt pki/issued/MyReq.crt pki/private/MyReq.key ta.key /etc/openvpn"
|
||||||
docker exec -i $CONTAINER_NAME sh -c "openvpn --config /etc/openvpn/server.conf &"
|
docker exec -d $CONTAINER_NAME sh -c "openvpn --config /etc/openvpn/server.conf"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue