summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorEmīls <emils@mullvad.net>2020-03-25 15:05:27 +0000
committerEmīls Piņķis <emils@mullvad.net>2020-04-27 11:17:00 +0100
commit2208d40ff4e58860beb9fe3a1d8ac86f3bce6062 (patch)
tree3f5cbeeb2afd125f78c75ed0d4fb3cc7850459e1
parentec78c8b482daa80418d8ec979462628346f913c5 (diff)
downloadmullvadvpn-2208d40ff4e58860beb9fe3a1d8ac86f3bce6062.tar.xz
mullvadvpn-2208d40ff4e58860beb9fe3a1d8ac86f3bce6062.zip
Use REST endpoint for relay list in buildscript
-rw-r--r--README.md6
-rwxr-xr-xbuild.sh1
-rw-r--r--env.bat4
-rw-r--r--env.ps15
-rwxr-xr-xenv.sh4
-rw-r--r--mullvad-rpc/Cargo.toml3
-rw-r--r--mullvad-rpc/src/bin/relay_list.rs17
-rwxr-xr-xupdate-relays.sh20
8 files changed, 23 insertions, 37 deletions
diff --git a/README.md b/README.md
index 692bd8c22d..0c75b4ea1a 100644
--- a/README.md
+++ b/README.md
@@ -279,13 +279,9 @@ sections.
## Building and running mullvad-daemon on desktop
-1. Firstly, one should source `env.sh` to set the default environment variables.
- One can also source the variables on Powershell with `env.ps1`,
- however most of our scripts require bash.
+1. Firstly, on MacOS and Linux, one should source `env.sh` to set the default environment variables.
```bash
source env.sh
- # Or if you use Powershell:
- . .\env.ps1
```
1. If you are on Windows, then you have to build the C++ libraries before compiling the daemon:
diff --git a/build.sh b/build.sh
index 9d58f3eb9b..482ba2d385 100755
--- a/build.sh
+++ b/build.sh
@@ -210,6 +210,7 @@ fi
./update-relays.sh
+
pushd "$SCRIPT_DIR/gui"
echo "Installing JavaScript dependencies..."
diff --git a/env.bat b/env.bat
deleted file mode 100644
index 44483bf993..0000000000
--- a/env.bat
+++ /dev/null
@@ -1,4 +0,0 @@
-SET SCRIPT_DIR=%~dp0
-SET OPENSSL_STATIC=1
-SET OPENSSL_LIB_DIR=%SCRIPT_DIR%\dist-assets\binaries\x86_64-pc-windows-msvc
-SET OPENSSL_INCLUDE_DIR=%SCRIPT_DIR%\dist-assets\binaries\x86_64-pc-windows-msvc\include
diff --git a/env.ps1 b/env.ps1
deleted file mode 100644
index 0f8899e404..0000000000
--- a/env.ps1
+++ /dev/null
@@ -1,5 +0,0 @@
-$SCRIPT_DIR = split-path -parent $MyInvocation.MyCommand.Definition
-
-$env:OPENSSL_STATIC="1"
-$env:OPENSSL_LIB_DIR="$SCRIPT_DIR\dist-assets\binaries\x86_64-pc-windows-msvc"
-$env:OPENSSL_INCLUDE_DIR="$SCRIPT_DIR\dist-assets\binaries\x86_64-pc-windows-msvc\include"
diff --git a/env.sh b/env.sh
index 62ab1b3132..27957509b4 100755
--- a/env.sh
+++ b/env.sh
@@ -39,7 +39,3 @@ case "$TARGET" in
exit 1
;;
esac
-
-export OPENSSL_STATIC="1"
-export OPENSSL_LIB_DIR="$SCRIPT_DIR/dist-assets/binaries/$TARGET"
-export OPENSSL_INCLUDE_DIR="$SCRIPT_DIR/dist-assets/binaries/$TARGET/include"
diff --git a/mullvad-rpc/Cargo.toml b/mullvad-rpc/Cargo.toml
index 2463f78efb..a88c75aff2 100644
--- a/mullvad-rpc/Cargo.toml
+++ b/mullvad-rpc/Cargo.toml
@@ -31,3 +31,6 @@ talpid-types = { path = "../talpid-types" }
[dev-dependencies]
filetime = "0.2"
tempfile = "3.0"
+
+[[bin]]
+name = "relay_list"
diff --git a/mullvad-rpc/src/bin/relay_list.rs b/mullvad-rpc/src/bin/relay_list.rs
new file mode 100644
index 0000000000..330d53bc11
--- /dev/null
+++ b/mullvad-rpc/src/bin/relay_list.rs
@@ -0,0 +1,17 @@
+/// Intended to be used to pre-load a relay list when creating an installer for the Mullvad VPN
+/// app.
+use futures01::future::Future;
+use mullvad_rpc::{MullvadRpcRuntime, RelayListProxy};
+
+fn main() {
+ let mut runtime = MullvadRpcRuntime::new("dist-assets/api_root_ca.pem".as_ref())
+ .expect("Failed to load runtime");
+
+ let relay_list_request = RelayListProxy::new(runtime.mullvad_rest_handle()).relay_list();
+
+ let relay_list = relay_list_request
+ .wait()
+ .expect("Failed to fetch relay list");
+
+ println!("{}", serde_json::to_string_pretty(&relay_list).unwrap());
+}
diff --git a/update-relays.sh b/update-relays.sh
index 711afe342a..2a2fde13fe 100755
--- a/update-relays.sh
+++ b/update-relays.sh
@@ -1,23 +1,5 @@
#!/usr/bin/env bash
echo "Updating relay list..."
-set +e
-read -d '' JSONRPC_CODE <<-JSONRPC_CODE
-var buff = "";
-process.stdin.on('data', function (chunk) {
- buff += chunk;
-})
-process.stdin.on('end', function () {
- var obj = JSON.parse(buff);
- var output = JSON.stringify(obj.result, null, ' ');
- process.stdout.write(output);
-})
-JSONRPC_CODE
set -e
-
-JSONRPC_RESPONSE="$(curl -X POST \
- --fail \
- -H "Content-Type: application/json" \
- -d '{"jsonrpc": "2.0", "id": "0", "method": "relay_list_v3"}' \
- https://api.mullvad.net/rpc/)"
-echo $JSONRPC_RESPONSE | node -e "$JSONRPC_CODE" > dist-assets/relays.json
+cargo run -p mullvad-rpc --bin relay_list > dist-assets/relays.json