From 5a42808fb9b79ba2f69b77a5e761e05d0a3e9ed1 Mon Sep 17 00:00:00 2001 From: Tadas Krivickas Date: Thu, 18 Jul 2019 15:23:59 +0300 Subject: [PATCH 1/8] Fix android build errors Due to wildcard versions and conflicts with the new androidx --- android/app/build.gradle | 4 ++-- android/build.gradle | 19 ++++++++----------- .../gradle/wrapper/gradle-wrapper.properties | 2 +- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index b67f9d569..3d5c37b21 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -83,11 +83,11 @@ apply from: "../../node_modules/react-native/react.gradle" /** * Get the version code from command line param * - * @return int If the param -PversionCode is present then return int value or -1 + * @return int If the param -PversionCode is present then return int value or 1 */ def getVersionCode = { -> - def code = project.hasProperty('versionCode') ? versionCode.toInteger() : -1 + def code = project.hasProperty('versionCode') ? versionCode.toInteger() : 1 println "VersionCode is set to $code" diff --git a/android/build.gradle b/android/build.gradle index 4495a6101..cac0b4cb4 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,21 +1,23 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.2.71' + ext.kotlin_version = '1.3.41' ext { - buildToolsVersion = "28.0.2" + buildToolsVersion = "28.0.3" minSdkVersion = 16 - compileSdkVersion = 27 + compileSdkVersion = 28 targetSdkVersion = 26 supportLibVersion = "27.1.1" + firebaseVersion = "18.0.0" + googlePlayServicesVersion = "16.1.0" } repositories { - maven { url 'https://maven.fabric.io/public' } - jcenter() google() + jcenter() + maven { url 'https://maven.fabric.io/public' } } dependencies { - classpath 'com.android.tools.build:gradle:3.2.0' + classpath 'com.android.tools.build:gradle:3.4.2' classpath 'io.fabric.tools:gradle:1.+' classpath 'com.google.gms:google-services:4.0.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" @@ -40,8 +42,3 @@ allprojects { } } - -task wrapper(type: Wrapper) { - gradleVersion = '4.4' - distributionUrl = distributionUrl.replace("bin", "all") -} diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index aebb2b5ed..a9f694c06 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip From 3c9b99b84aed27fda9f001cb683aa6df0fc185a9 Mon Sep 17 00:00:00 2001 From: Tadas Krivickas Date: Fri, 19 Jul 2019 16:44:07 +0300 Subject: [PATCH 2/8] Upgrade axios --- package.json | 2 +- yarn.lock | 36 ++++++++++++++++++++++++++++-------- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index e67c17d08..43059b908 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@types/react-native-htmlview": "^0.12.2", "@types/react-native-push-notification": "^3.0.3", - "axios": "^0.18.0", + "axios": "0.19.0", "computed-async-mobx": "^4.1.0", "mobx": "^4.3.1", "mobx-react": "^5.1.0", diff --git a/yarn.lock b/yarn.lock index 263cc317e..982bc0483 100644 --- a/yarn.lock +++ b/yarn.lock @@ -505,11 +505,11 @@ source-map-support "^0.4.2" "@babel/runtime@^7.1.5": - version "7.1.5" - resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.1.5.tgz#4170907641cf1f61508f563ece3725150cc6fe39" - integrity sha512-xKnPpXG/pvK1B90JkwwxSGii90rQGKtzcMt2gI5G6+M0REXaq6rOHsGC2ay6/d0Uje7zzvSzjEzfR3ENhFlrfA== + version "7.5.5" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.5.5.tgz#74fba56d35efbeca444091c7850ccd494fd2f132" + integrity sha512-28QvEGyQyNkB0/m2B4FU7IEZGK2NUrcMtT6BZEFALTguLk+AUT6ofsHtPk5QyjAdUkpMJ+/Em+quwz4HOt30AQ== dependencies: - regenerator-runtime "^0.12.0" + regenerator-runtime "^0.13.2" "@babel/template@7.0.0-beta.47": version "7.0.0-beta.47" @@ -1163,6 +1163,14 @@ axios@0.16.2: follow-redirects "^1.2.3" is-buffer "^1.1.5" +axios@0.19.0: + version "0.19.0" + resolved "https://registry.yarnpkg.com/axios/-/axios-0.19.0.tgz#8e09bff3d9122e133f7b8101c8fbdd00ed3d2ab8" + integrity sha512-1uvKqKQta3KBxIz14F2v06AEHZ/dIoeKfbTRkK1E5oqjDnuEerLmYTgJB5AiQZHJcljpg1TuRzdjDR06qNk0DQ== + dependencies: + follow-redirects "1.5.10" + is-buffer "^2.0.2" + axios@^0.18.0: version "0.18.0" resolved "https://registry.yarnpkg.com/axios/-/axios-0.18.0.tgz#32d53e4851efdc0a11993b6cd000789d70c05102" @@ -3244,6 +3252,13 @@ find-up@^2.0.0, find-up@^2.1.0: dependencies: locate-path "^2.0.0" +follow-redirects@1.5.10: + version "1.5.10" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.5.10.tgz#7b7a9f9aea2fdff36786a94ff643ed07f4ff5e2a" + integrity sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ== + dependencies: + debug "=3.1.0" + follow-redirects@^1.2.3, follow-redirects@^1.3.0: version "1.5.9" resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.5.9.tgz#c9ed9d748b814a39535716e531b9196a845d89c6" @@ -3937,6 +3952,11 @@ is-buffer@^1.1.5, is-buffer@~1.1.1: resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be" integrity sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w== +is-buffer@^2.0.2: + version "2.0.3" + resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-2.0.3.tgz#4ecf3fcf749cbd1e472689e109ac66261a25e725" + integrity sha512-U15Q7MXTuZlrbymiz95PJpZxu8IlipAp4dtS3wOdgPXx3mqBnslrWU14kxfHB+Py/+2PVKSr37dMAgM2A4uArw== + is-builtin-module@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-builtin-module/-/is-builtin-module-1.0.0.tgz#540572d34f7ac3119f8f76c30cbc1b1e037affbe" @@ -6894,10 +6914,10 @@ regenerator-runtime@^0.11.0: resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9" integrity sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg== -regenerator-runtime@^0.12.0: - version "0.12.1" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.12.1.tgz#fa1a71544764c036f8c49b13a08b2594c9f8a0de" - integrity sha512-odxIc1/vDlo4iZcfXqRYFj0vpXFNoGdKMAUieAlFYO6m/nl5e9KR/beGf41z4a1FI+aQgtjhuaSlDxQ0hmkrHg== +regenerator-runtime@^0.13.2: + version "0.13.2" + resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.2.tgz#32e59c9a6fb9b1a4aff09b4930ca2d4477343447" + integrity sha512-S/TQAZJO+D3m9xeN1WTI8dLKBBiRgXBlTJvbWjCThHWZj9EvHK70Ff50/tYj2J/fvBY6JtFVwRuazHN2E7M9BA== regenerator-transform@^0.12.3: version "0.12.4" From 77d0d041909335498939200e4d89d2f979781fc0 Mon Sep 17 00:00:00 2001 From: Tadas Krivickas Date: Fri, 19 Jul 2019 16:50:04 +0300 Subject: [PATCH 3/8] Remove options customization as NAT punching enabled by default in node --- .../mysterium/service/core/MysteriumAndroidCoreService.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/android/app/src/main/java/network/mysterium/service/core/MysteriumAndroidCoreService.kt b/android/app/src/main/java/network/mysterium/service/core/MysteriumAndroidCoreService.kt index e9947d151..5c0024459 100644 --- a/android/app/src/main/java/network/mysterium/service/core/MysteriumAndroidCoreService.kt +++ b/android/app/src/main/java/network/mysterium/service/core/MysteriumAndroidCoreService.kt @@ -31,10 +31,11 @@ class MysteriumAndroidCoreService : VpnService() { fun startMobileNode(filesPath: String) { val openvpnBridge = Openvpn3AndroidTunnelSetupBridge(this) val wireguardBridge = WireguardAndroidTunnelSetup(this) + + val logOptions = Mysterium.defaultLogOptions() val options = Mysterium.defaultNetworkOptions() - options.experimentNATPunching = true - mobileNode = Mysterium.newNode(filesPath, options) + mobileNode = Mysterium.newNode(filesPath, logOptions, options) mobileNode?.overrideOpenvpnConnection(openvpnBridge) mobileNode?.overrideWireguardConnection(wireguardBridge) Log.i(TAG, "started") From 93fc5466dfc121bcf301147755b343734f4b2750 Mon Sep 17 00:00:00 2001 From: Tadas Krivickas Date: Mon, 22 Jul 2019 17:24:34 +0300 Subject: [PATCH 4/8] Return non-whitelist proposals only --- .../proposals/tequilapi-proposals-adapter.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/app/adapters/proposals/tequilapi-proposals-adapter.ts b/src/app/adapters/proposals/tequilapi-proposals-adapter.ts index 052d006ec..2f7bade3e 100644 --- a/src/app/adapters/proposals/tequilapi-proposals-adapter.ts +++ b/src/app/adapters/proposals/tequilapi-proposals-adapter.ts @@ -15,6 +15,7 @@ * along with this program. If not, see . */ +import axios from 'axios' import { TequilapiClient } from 'mysterium-tequilapi/lib/client' import { MetricsDTO } from 'mysterium-tequilapi/lib/dto/metrics-dto' import { ProposalDTO } from 'mysterium-tequilapi/lib/dto/proposal' @@ -26,14 +27,21 @@ import { stringToServiceType } from '../../models/service-type' import { ProposalsAdapter } from './proposals-adapter' class TequilapiProposalsAdapter implements ProposalsAdapter { - private readonly SERVICE_TYPE = 'all' + // @ts-ignore constructor (private tequilapiClient: TequilapiClient) {} public async findProposals (): Promise { - const options: ProposalQueryOptions = { fetchConnectCounts: true, serviceType: this.SERVICE_TYPE } - const proposalDtos: ProposalDTO[] = await this.tequilapiClient.findProposals(options) - + const options: ProposalQueryOptions = { + fetchConnectCounts: true + } + const proposalDtos = await axios.get('http://127.0.0.1:4050/proposals', { params: options }) + .then(res => res.data.proposals) + .then(proposals => proposals.filter((p: any) => { + const applicableServiceType = p.serviceType === 'openvpn' || p.serviceType === 'wireguard' + const withoutWhitelistPolicy = !p.accessPolicies + return applicableServiceType && withoutWhitelistPolicy + })) return proposalDtosToModels(proposalDtos) } } From 4fb116448a4a5d86b37ff3d8c74440d16dbdea73 Mon Sep 17 00:00:00 2001 From: Tadas Krivickas Date: Mon, 22 Jul 2019 17:25:07 +0300 Subject: [PATCH 5/8] Delay proposal fetch (expect node to have fetched proposals by that time) --- src/app/app-loader.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/app/app-loader.ts b/src/app/app-loader.ts index 54631f4e6..5fbe5efca 100644 --- a/src/app/app-loader.ts +++ b/src/app/app-loader.ts @@ -22,6 +22,10 @@ import Connection from './domain/connection' import { IdentityManager } from './domain/identity-manager' import ProposalsStore from './stores/proposals-store' +function sleep (ms: number) { + return new Promise(resolve => setTimeout(resolve, ms)) +} + /** * Prepares app: refreshes connection state, ip and unlocks identity. * Starts periodic state refreshing. @@ -35,6 +39,7 @@ class AppLoader { public async load () { await this.waitForClient() + await sleep(2500) this.proposals.startUpdating() this.connection.startUpdating() try { From e469b7d1c39917b4e8e27321bd26a49269a512b9 Mon Sep 17 00:00:00 2001 From: Tadas Krivickas Date: Mon, 22 Jul 2019 17:25:39 +0300 Subject: [PATCH 6/8] Patch up invalid connect metric numbers --- .../proposals/tequilapi-proposals-adapter.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/app/adapters/proposals/tequilapi-proposals-adapter.ts b/src/app/adapters/proposals/tequilapi-proposals-adapter.ts index 2f7bade3e..33ebfa34a 100644 --- a/src/app/adapters/proposals/tequilapi-proposals-adapter.ts +++ b/src/app/adapters/proposals/tequilapi-proposals-adapter.ts @@ -83,14 +83,19 @@ function getCountryName (countryCode: string | null) { } function metricsDtoToModel (metrics?: MetricsDTO): Metrics { - const nullMetrics: Metrics = { connectCount: { success: 0, fail: 0, timeout: 0 } } - if (metrics === undefined) { - return nullMetrics + const emptyMetrics: Metrics = { connectCount: { success: 0, fail: 0, timeout: 0 } } + if (metrics === undefined || metrics.connectCount === undefined) { + return emptyMetrics } - if (metrics.connectCount === undefined) { - return nullMetrics + + // FIXME quality oracle sometimes returns negative values, patching those to 0 + return { + connectCount: { + success: Math.max(0, metrics.connectCount.success), + fail: Math.max(0, metrics.connectCount.fail), + timeout: Math.max(0, metrics.connectCount.timeout) + } } - return { connectCount: metrics.connectCount } } export default TequilapiProposalsAdapter From ca15a4d932bcc2b328c35a12f951aa543360ec4e Mon Sep 17 00:00:00 2001 From: Tadas Krivickas Date: Tue, 23 Jul 2019 14:42:06 +0300 Subject: [PATCH 7/8] Upgrade to the latest node --- android/app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 3d5c37b21..1cfecedc7 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -185,7 +185,7 @@ dependencies { implementation 'com.google.firebase:firebase-core:16.0.1' implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation 'network.mysterium:mobile-node:0.9.0' + implementation 'network.mysterium:mobile-node:0.10.1' // implementation files('libs/Mysterium.aar') } From f3c7caa137b737458a4f5401ee5e56bba24d2f5d Mon Sep 17 00:00:00 2001 From: Tadas Krivickas Date: Tue, 23 Jul 2019 14:44:36 +0300 Subject: [PATCH 8/8] Bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 43059b908..84018f486 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "MysteriumVPN", - "version": "0.8.5", + "version": "0.10.0", "license": "GPL-3.0", "author": "Mysterium Network ", "main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",