Various fixes

This commit is contained in:
pokamest 2022-02-09 15:23:20 +03:00
parent cb21991efa
commit 505c9c6218
5 changed files with 306 additions and 295 deletions

View file

@ -43,6 +43,7 @@ class VPNService : android.net.VpnService() {
} }
override fun onUnbind(intent: Intent?): Boolean { override fun onUnbind(intent: Intent?): Boolean {
Log.v(tag, "Got Unbind request")
if (!isUp) { if (!isUp) {
// If the Qt Client got closed while we were not connected // If the Qt Client got closed while we were not connected
// we do not need to stay as a foreground service. // we do not need to stay as a foreground service.
@ -128,6 +129,7 @@ class VPNService : android.net.VpnService() {
putOpt("deviceIpv4", mConfig?.getJSONObject("device")?.getString("ipv4Address")) putOpt("deviceIpv4", mConfig?.getJSONObject("device")?.getString("ipv4Address"))
} }
} }
/* /*
* Checks if the VPN Permission is given. * Checks if the VPN Permission is given.
* If the permission is given, returns true * If the permission is given, returns true
@ -237,6 +239,7 @@ class VPNService : android.net.VpnService() {
mOpenVPNThreadv3 = null mOpenVPNThreadv3 = null
Log.e(tag, "mOpenVPNThreadv3 stop!") Log.e(tag, "mOpenVPNThreadv3 stop!")
} }
/** /**
* Configures an Android VPN Service Tunnel * Configures an Android VPN Service Tunnel
* with a given Wireguard Config * with a given Wireguard Config
@ -296,7 +299,8 @@ class VPNService : android.net.VpnService() {
currentSection?.let { currentSection?.let {
parseData.put(it.first, it.second) parseData.put(it.first, it.second)
} }
currentSection = line.substring(1, line.indexOfLast { it == ']' }) to mutableMapOf() currentSection =
line.substring(1, line.indexOfLast { it == ']' }) to mutableMapOf()
} else { } else {
val parameter = line.split("=", limit = 2) val parameter = line.split("=", limit = 2)
currentSection!!.second.put(parameter.first().trim(), parameter.last().trim()) currentSection!!.second.put(parameter.first().trim(), parameter.last().trim())
@ -401,6 +405,7 @@ class VPNService : android.net.VpnService() {
NotificationUtil.show(this) // Go foreground NotificationUtil.show(this) // Go foreground
} }
companion object { companion object {
@JvmStatic @JvmStatic
fun startService(c: Context) { fun startService(c: Context) {
@ -412,14 +417,19 @@ class VPNService : android.net.VpnService() {
@JvmStatic @JvmStatic
private external fun wgGetConfig(handle: Int): String? private external fun wgGetConfig(handle: Int): String?
@JvmStatic @JvmStatic
private external fun wgGetSocketV4(handle: Int): Int private external fun wgGetSocketV4(handle: Int): Int
@JvmStatic @JvmStatic
private external fun wgGetSocketV6(handle: Int): Int private external fun wgGetSocketV6(handle: Int): Int
@JvmStatic @JvmStatic
private external fun wgTurnOff(handle: Int) private external fun wgTurnOff(handle: Int)
@JvmStatic @JvmStatic
private external fun wgTurnOn(ifName: String, tunFd: Int, settings: String): Int private external fun wgTurnOn(ifName: String, tunFd: Int, settings: String): Int
@JvmStatic @JvmStatic
private external fun wgVersion(): String? private external fun wgVersion(): String?
} }

View file

@ -1,4 +1,4 @@
QT += widgets core gui network xml remoteobjects quick QT += widgets core gui network xml remoteobjects quick svg
TARGET = AmneziaVPN TARGET = AmneziaVPN
TEMPLATE = app TEMPLATE = app

View file

@ -38,8 +38,6 @@ void QrDecoderLogic::onDetectedQrCode(const QString &code)
if (magic == amnezia::qrMagicCode) { if (magic == amnezia::qrMagicCode) {
qDebug() << "QrDecoderLogic::onDetectedQrCode magic code detected" << magic << ba.size();
quint8 chunksCount; s >> chunksCount; quint8 chunksCount; s >> chunksCount;
if (totalChunksCount() != chunksCount) { if (totalChunksCount() != chunksCount) {
m_chunks.clear(); m_chunks.clear();

View file

@ -12,6 +12,7 @@ BasicButtonType {
anchors.left: parent.left anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
svg.source: root.icon.source svg.source: root.icon.source
color: "#100A44"
width: 25 width: 25
height: 25 height: 25
} }

View file

@ -112,6 +112,7 @@ UiLogic::~UiLogic()
{ {
emit hide(); emit hide();
#ifdef AMNEZIA_DESKTOP
if (m_vpnConnection->connectionState() != VpnProtocol::VpnConnectionState::Disconnected) { if (m_vpnConnection->connectionState() != VpnProtocol::VpnConnectionState::Disconnected) {
m_vpnConnection->disconnectFromVpn(); m_vpnConnection->disconnectFromVpn();
for (int i = 0; i < 50; i++) { for (int i = 0; i < 50; i++) {
@ -122,6 +123,7 @@ UiLogic::~UiLogic()
} }
} }
} }
#endif
m_vpnConnection->deleteLater(); m_vpnConnection->deleteLater();
m_vpnConnectionThread.quit(); m_vpnConnectionThread.quit();