Skip to content
Snippets Groups Projects
Commit 54556afb authored by Alexandr Mruchok's avatar Alexandr Mruchok
Browse files

Merge branch 'bugs-4276-4' into 'master'

Bugs 4276 4

See merge request !9
parents 2dd0083e 5f39f6ae
No related branches found
No related tags found
1 merge request!9Bugs 4276 4
......@@ -214,15 +214,15 @@ ChChainNetSrvVpn::ChChainNetSrvVpn(DapStreamer * a_streamer, DapSession * mainDa
{
tun = new DapTunNative();
m_fdListener = nullptr;
connect(tun, &DapTunNative::created, this, &ChChainNetSrvVpn::tunCreated);
connect(tun, &DapTunNative::destroyed, this, &ChChainNetSrvVpn::tunDestroyed);
connect(tun, &DapTunNative::error , this, &ChChainNetSrvVpn::tunError);
connect(tun, &DapTunNative::packetOut, this, &ChChainNetSrvVpn::packetOut);
connect(tun, &DapTunNative::sendCmd, this, &ChChainNetSrvVpn::sendCmdAll);
connect(tun, &DapTunNative::bytesRead, this, &ChChainNetSrvVpn::bytesRead);
connect(tun, &DapTunNative::bytesWrite, this, &ChChainNetSrvVpn::bytesWrite);
connect(tun, &DapTunNative::nativeCreateRequest, this, &ChChainNetSrvVpn::sigTunNativeCreate);
connect(tun, &DapTunNative::nativeDestroyRequest, this, &ChChainNetSrvVpn::sigNativeDestroy);
connect(tun, &DapTunNative::created, this, &ChChainNetSrvVpn::tunCreated);
connect(tun, &DapTunNative::destroyed, this, &ChChainNetSrvVpn::tunDestroyed);
connect(tun, &DapTunNative::error, this, &ChChainNetSrvVpn::tunError);
connect(tun, &DapTunNative::packetOut, this, &ChChainNetSrvVpn::packetOut);
connect(tun, &DapTunNative::sendCmd, this, &ChChainNetSrvVpn::sendCmdAll);
connect(tun, &DapTunNative::bytesRead, this, &ChChainNetSrvVpn::bytesRead);
connect(tun, &DapTunNative::bytesWrite, this, &ChChainNetSrvVpn::bytesWrite);
connect(tun, &DapTunNative::nativeCreateRequest, this, &ChChainNetSrvVpn::sigTunNativeCreate);
connect(tun, &DapTunNative::nativeDestroyRequest, this, &ChChainNetSrvVpn::sigNativeDestroy);
}
/**
......@@ -257,13 +257,11 @@ void ChChainNetSrvVpn::packetOut(Dap::Stream::Packet *pkt)
*/
void ChChainNetSrvVpn::requestIP(quint32 a_usageId)
{
emit netConfigRequested();
Dap::Stream::Packet * pktOut = reinterpret_cast<Dap::Stream::Packet*>(::calloc(1 ,sizeof(pktOut->header)));
pktOut->header.op_code=STREAM_SF_PACKET_OP_CODE_RAW_L3_ADDR_REQUEST;
pktOut->header.usage_id = a_usageId;
qInfo() << "Request for IP with usage_id: " << pktOut->header.usage_id;
packetOut(pktOut);
emit ipRequested();
}
/**
......@@ -273,7 +271,6 @@ void ChChainNetSrvVpn::netConfigClear()
{
m_addr.clear();
m_gw.clear();
emit netConfigCleared();
}
/**
......@@ -309,6 +306,11 @@ void ChChainNetSrvVpn::tunCreate()
QThread::msleep(1000);
tunSocket = QtAndroid::androidService().callMethod<jint>("getTunSocket");
}
if (tunSocket == -1) {
qCritical() << "Permission denied!";
emit androidPermissionDenied();
return;
}
qInfo() << "Socket num: " << tunSocket;
workerStart(tunSocket);
#else
......@@ -318,6 +320,11 @@ void ChChainNetSrvVpn::tunCreate()
//
void ChChainNetSrvVpn::tunStandby()
{
tun->standby();
}
void ChChainNetSrvVpn::tunDestroy()
{
tun->destroy();
......@@ -334,6 +341,10 @@ void ChChainNetSrvVpn::workerStart(int a_tunSocket)
tun->workerStart(); // start loop
}
int ChChainNetSrvVpn::tunSocket() {
return tun->m_tunSocket;
}
/**
* @brief ChChainNetSrvVpn::onPktIn
* @param pkt
......
......@@ -106,15 +106,17 @@ namespace Dap {
void sigTunNativeCreate();
void sigNativeDestroy();
public:
ChChainNetSrvVpn(DapStreamer * a_streamer, DapSession * mainDapSession);
bool isTunCreated(){return tun->isCreated();}
void addNewUpstreamRoute(const QString &a_dest) {
tun->addNewUpstreamRoute(a_dest);
}
void tunCreate (const QString& a_addr, const QString& a_gw);
void workerStart(int a_tunSocket);
int tunSocket();
quint16 addForwarding(const QString remoteAddr, quint16 remotePort, quint16 localPort);
void delForwarding(int sockId);
void delForwardingAll();
......@@ -123,16 +125,13 @@ namespace Dap {
signals:
void netConfigReceived(QString,QString);
void netConfigRequested();
void netConfigReceivedSame();
void netConfigCleared();
void tunCreated();
void tunDestroyed();
void tunError(const QString&);
void androidPermissionDenied();
void tunWriteData();
void ipRequested();
void sendCmdAll(const QString&);
public slots:
void onPktIn(DapChannelPacket *pkt) override;
......@@ -143,6 +142,7 @@ namespace Dap {
void tunCreate(); // create with all predefined before values
void tunDestroy();
void tunStandby();
};
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment