Skip to content

Commit

Permalink
Merge branch 'main' into jmwample/amnezia-poc
Browse files Browse the repository at this point in the history
  • Loading branch information
jmwample authored Nov 6, 2024
2 parents 04c9f42 + 131aa36 commit 8ec3cb1
Show file tree
Hide file tree
Showing 141 changed files with 5,957 additions and 2,897 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/build-nym-vpn-app-linux.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: build-nym-vpn-app-linux
on:
workflow_dispatch:
inputs:
dev_mode:
description: "dev build"
required: true
type: boolean
default: false
workflow_call:
inputs:
# set to true when it is a 'dev' build
Expand Down
42 changes: 32 additions & 10 deletions .github/workflows/build-nym-vpn-app-windows.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: build-nym-vpn-app-windows
on:
workflow_dispatch:
inputs:
dev_mode:
description: "dev build"
required: true
type: boolean
default: false
workflow_call:
inputs:
# set to true when it is a 'dev' build
Expand Down Expand Up @@ -117,20 +123,36 @@ jobs:
# mv '${{ env.LIBS_PATH }}/libwg.dll' '${{ env.TAURI_SRC }}'
# mv '${{ env.LIBS_PATH }}/libwg.lib' '${{ env.TAURI_SRC }}'

- name: Get nym-vpn-core release info
id: get_release
- name: Install yq
run: |
winget list MikeFarah.yq || winget install --disable-interactivity --id MikeFarah.yq
- name: Get nym-vpn-core release tag
if: inputs.dev_mode == false
run: |
$release_tag = curl -sSL -H "Accept: application/vnd.github+json" `
https://api.github.com/repos/nymtech/nym-vpn-client/releases |
yq '[.[] | select(.tag_name | test("nym-vpn-core-v\d+\.\d+\.\d+$")) | .tag_name] | sort | reverse | .[0]'
echo "core_release_tag: $release_tag"
"core_release_tag=$release_tag" >> $env:GITHUB_ENV
- name: Get nym-vpn-core release tag (dev)
if: inputs.dev_mode == true
run: |
echo "core_release_tag: nym-vpn-core-nightly"
"core_release_tag=nym-vpn-core-nightly" >> $env:GITHUB_ENV
- name: Get nym-vpn-core asset url
run: |
$releases = Invoke-RestMethod -Uri https://api.github.com/repos/nymtech/nym-vpn-client/releases
$release = $releases | Where-Object { $_.tag_name -match '^nym-vpn-core-v[0-9]+\.[0-9]+\.[0-9]+$' } | Sort-Object { [version]($_.tag_name -replace 'nym-vpn-core-v', '0.') } | Select-Object -Last 1
$asset = $release.assets | Where-Object { $_.name -match 'windows_x86_64.zip$' }
Write-Output "Release Tag: $($release.tag_name)"
Write-Output "Asset URL: $($asset.browser_download_url)"
echo "::set-output name=release_tag::$($release.tag_name)"
echo "::set-output name=asset_url::$($asset.browser_download_url)"
$asset_url = curl -sSL -H "Accept: application/vnd.github+json" `
https://api.github.com/repos/nymtech/nym-vpn-client/releases/tags/${{ env.core_release_tag }} |
yq '.assets.[] | select(.name | test("^nym-vpn-core-v.+_windows_x86_64\.zip$")) | .browser_download_url'
echo "core_asset_url: $asset_url"
"core_asset_url=$asset_url" >> $env:GITHUB_ENV
- name: Download nym-vpn-core artifact
run: |
$url = '${{ steps.get_release.outputs.asset_url }}'
$url = '${{ env.core_asset_url }}'
$output = 'nym-vpn-core.zip'
Invoke-WebRequest -Uri $url -OutFile $output
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/publish-aur-nym-vpn-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ jobs:
if: matrix.pkgtype == 'bin'
run: |
curl -LfsSo $LINUX_BIN "https://github.com/$REPOSITORY/releases/download/$RELEASE_TAG/nym-vpn_${{ steps.app-version.outputs.metadata }}_linux_x64"
- name: Prepare for PKGBUILD update
working-directory: nym-vpn-app/.pkg
run: |
cp -v app.desktop aur/nym-vpn.desktop
cp -v icon.svg aur/nym-vpn.svg
ls -la aur
- name: Update PKGBUILD
env:
PKGBUILD: ${{ env.PKGBUILD }}
Expand All @@ -74,7 +80,6 @@ jobs:
# the sources array declared in PKGBUILD
SOURCES: |
${{ matrix.pkgtype == 'bfs' && env.TARBALL || env.LINUX_BIN }}
nym-vpn-app/.pkg/aur/nym-vpn-wrapper.sh
nym-vpn-app/.pkg/aur/nym-vpn.desktop
nym-vpn-app/.pkg/aur/nym-vpn.svg
run: ./.pkg/aur_update.sh
Expand All @@ -97,6 +102,5 @@ jobs:
ssh_private_key: ${{ secrets.AUR_SSH_KEY }}
commit_message: ${{ inputs.commit_msg || format('v{0}', steps.app-version.outputs.metadata) }}
assets: |
nym-vpn-app/.pkg/aur/nym-vpn-wrapper.sh
nym-vpn-app/.pkg/aur/nym-vpn.desktop
nym-vpn-app/.pkg/aur/nym-vpn.svg
9 changes: 7 additions & 2 deletions .github/workflows/publish-nym-vpn-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ on:
description: "Tag name for release"
required: false
default: nym-vpn-app-nightly
dev_mode:
description: "dev build"
required: true
type: boolean
default: false
push:
tags:
- nym-vpn-app-v[0-9]+.[0-9]+.[0-9]+*
Expand All @@ -16,12 +21,12 @@ jobs:
build-nym-vpn-app-linux:
uses: ./.github/workflows/build-nym-vpn-app-linux.yml
with:
dev_mode: ${{ github.event_name == 'schedule' || contains(github.ref_name, 'dev') || contains(github.ref_name, 'nightly') || contains(inputs.tag_name, 'dev') || contains(inputs.tag_name, 'nightly') }}
dev_mode: ${{ github.event_name == 'schedule' || contains(github.ref_name, 'dev') || contains(github.ref_name, 'nightly') || inputs.dev_mode == true }}
secrets: inherit
build-nym-vpn-app-windows:
uses: ./.github/workflows/build-nym-vpn-app-windows.yml
with:
dev_mode: ${{ github.event_name == 'schedule' || contains(github.ref_name, 'dev') || contains(github.ref_name, 'nightly') || contains(inputs.tag_name, 'dev') || contains(inputs.tag_name, 'nightly') }}
dev_mode: ${{ github.event_name == 'schedule' || contains(github.ref_name, 'dev') || contains(github.ref_name, 'nightly') || inputs.dev_mode == true }}
secrets: inherit

generate-build-info-nym-vpn-app:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import net.nymtech.vpn.backend.Backend
import net.nymtech.vpn.backend.Tunnel
import net.nymtech.vpn.model.BackendMessage
import net.nymtech.vpn.model.Statistics
import nym_vpn_lib.AccountStateSummary
import nym_vpn_lib.BandwidthEvent
import nym_vpn_lib.BandwidthStatus.NoBandwidth
import timber.log.Timber
Expand Down Expand Up @@ -97,6 +98,10 @@ class NymTunnelManager @Inject constructor(
emitMnemonicStored(false)
}

override suspend fun getAccountSummary(): AccountStateSummary {
return backend.get().getAccountSummary()
}

private fun emitMnemonicStored(stored: Boolean) {
_state.update {
it.copy(isMnemonicStored = stored)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ package net.nymtech.nymvpn.service.tunnel

import kotlinx.coroutines.flow.Flow
import net.nymtech.vpn.backend.Tunnel
import nym_vpn_lib.AccountStateSummary

interface TunnelManager {
suspend fun stop()
suspend fun start(fromBackground: Boolean = true)
suspend fun storeMnemonic(credential: String)
suspend fun isMnemonicStored(): Boolean
suspend fun removeMnemonic()
suspend fun getAccountSummary(): AccountStateSummary
val stateFlow: Flow<TunnelState>
fun getState(): Tunnel.State
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package net.nymtech.vpn.backend

import nym_vpn_lib.AccountStateSummary

interface Backend {

suspend fun getAccountSummary(): AccountStateSummary

suspend fun storeMnemonic(credential: String)

suspend fun isMnemonicStored(): Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import net.nymtech.vpn.util.LifecycleVpnService
import net.nymtech.vpn.util.NotificationManager
import net.nymtech.vpn.util.SingletonHolder
import net.nymtech.vpn.util.addRoutes
import nym_vpn_lib.AccountStateSummary
import nym_vpn_lib.AndroidTunProvider
import nym_vpn_lib.BandwidthEvent
import nym_vpn_lib.MixnetEvent
Expand All @@ -34,7 +35,9 @@ import nym_vpn_lib.VpnException
import nym_vpn_lib.initLogger
import nym_vpn_lib.isAccountMnemonicStored
import nym_vpn_lib.removeAccountMnemonic
import nym_vpn_lib.startAccountController
import nym_vpn_lib.startVpn
import nym_vpn_lib.stopAccountController
import nym_vpn_lib.stopVpn
import nym_vpn_lib.storeAccountMnemonic
import timber.log.Timber
Expand Down Expand Up @@ -77,6 +80,16 @@ class NymBackend private constructor(val context: Context) : Backend, TunnelStat
@get:Synchronized @set:Synchronized
private var state: Tunnel.State = Tunnel.State.Down

@Throws(VpnException::class)
override suspend fun getAccountSummary(): AccountStateSummary {
startAccountController(storagePath)
return try {
nym_vpn_lib.getAccountSummary()
} finally {
stopAccountController()
}
}

@Throws(VpnException::class)
override suspend fun storeMnemonic(mnemonic: String) {
return storeAccountMnemonic(mnemonic, storagePath)
Expand Down
Loading

0 comments on commit 8ec3cb1

Please sign in to comment.