diff --git a/android/app/build.gradle b/android/app/build.gradle index b67f9d569..1cfecedc7 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" @@ -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') } 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") 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 diff --git a/package.json b/package.json index e67c17d08..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", @@ -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/src/app/adapters/proposals/tequilapi-proposals-adapter.ts b/src/app/adapters/proposals/tequilapi-proposals-adapter.ts index 052d006ec..33ebfa34a 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) } } @@ -75,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 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 { 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"