Skip to content

Commit

Permalink
Merge pull request #166 from mysteriumnetwork/update-myst-node-0.10
Browse files Browse the repository at this point in the history
Update myst node 0.10
  • Loading branch information
tadaskay authored Jul 23, 2019
2 parents b4c0be9 + f3c7caa commit 878a6b1
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 37 deletions.
6 changes: 3 additions & 3 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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')
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
19 changes: 8 additions & 11 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -40,8 +42,3 @@ allprojects {
}
}


task wrapper(type: Wrapper) {
gradleVersion = '4.4'
distributionUrl = distributionUrl.replace("bin", "all")
}
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "MysteriumVPN",
"version": "0.8.5",
"version": "0.10.0",
"license": "GPL-3.0",
"author": "Mysterium Network <[email protected]>",
"main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
Expand Down Expand Up @@ -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",
Expand Down
33 changes: 23 additions & 10 deletions src/app/adapters/proposals/tequilapi-proposals-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

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'
Expand All @@ -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<Proposal[]> {
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)
}
}
Expand Down Expand Up @@ -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
5 changes: 5 additions & 0 deletions src/app/app-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -35,6 +39,7 @@ class AppLoader {

public async load () {
await this.waitForClient()
await sleep(2500)
this.proposals.startUpdating()
this.connection.startUpdating()
try {
Expand Down
36 changes: 28 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]":
version "7.0.0-beta.47"
Expand Down Expand Up @@ -1163,6 +1163,14 @@ [email protected]:
follow-redirects "^1.2.3"
is-buffer "^1.1.5"

[email protected]:
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"
Expand Down Expand Up @@ -3244,6 +3252,13 @@ find-up@^2.0.0, find-up@^2.1.0:
dependencies:
locate-path "^2.0.0"

[email protected]:
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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 878a6b1

Please sign in to comment.