@mytmpvpn/mytmpvpn-cli 1.5.0 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mytmpvpn/mytmpvpn-cli",
3
- "version": "1.5.0",
3
+ "version": "1.6.1",
4
4
  "description": "MyTmpVpn CLI",
5
5
  "main": "./dist/mytmpvpn.js",
6
6
  "bin": {
@@ -27,7 +27,7 @@
27
27
  "dependencies": {
28
28
  "commander": "^9.4.1",
29
29
  "loglevel": "^1.8.1",
30
- "@mytmpvpn/mytmpvpn-client": "^1.6.2",
30
+ "@mytmpvpn/mytmpvpn-client": "^1.7.1",
31
31
  "@mytmpvpn/mytmpvpn-common": "^1.4.0"
32
32
  },
33
33
  "devDependencies": {
@@ -0,0 +1,79 @@
1
+ #!/bin/bash
2
+
3
+ if test $# -ne 1; then
4
+ 1>&2 echo "Usage: $(basename $0) <region ID>"
5
+ exit 1
6
+ fi
7
+
8
+ mytmpvpn="npx @mytmpvpn/mytmpvpn-cli@latest"
9
+
10
+ region=$1
11
+
12
+ # Create VPN and get VPN ID
13
+ vpnId=$(${mytmpvpn} create ${region} --sync | grep vpnId | cut -d \' -f 2)
14
+
15
+ err=$?
16
+ if test $err -ne 0; then
17
+ exit 1
18
+ fi
19
+
20
+ # Get config file
21
+ path_config_file=$(${mytmpvpn} download-config ${vpnId})
22
+
23
+ err=$?
24
+ if test $err -ne 0; then
25
+ exit 1
26
+ fi
27
+
28
+ # De-tar config file
29
+ tar xvf ${path_config_file} --directory $(dirname ${path_config_file})
30
+
31
+ err=$?
32
+ if test $err -ne 0; then
33
+ exit 1
34
+ fi
35
+
36
+ # Get IP address
37
+ old_ip_addr=$(curl ifconfig.me)
38
+
39
+ # Connect to VPN
40
+ sudo wg-quick up ~/.config/mytmpvpn/${vpnId}/mytmpvpn-wg.conf
41
+
42
+ err=$?
43
+ if test $err -ne 0; then
44
+ exit 1
45
+ fi
46
+
47
+ # Test connection
48
+ ping 8.8.8.8 -c 4
49
+
50
+ err=$?
51
+ if test $err -ne 0; then
52
+ exit 1
53
+ fi
54
+
55
+ # Test different IP address
56
+ new_ip_addr=$(curl ifconfig.me)
57
+
58
+ if test "${old_ip_addr}" == "${new_ip_addr}"; then
59
+ 1>$2 echo "external IP address has not changed: old IP ${old_ip_addr} new ${new_ip_addr}"
60
+ exit 1
61
+ fi
62
+ # Test region
63
+
64
+ # disconnect from VPN
65
+ sudo wg-quick down mytmpvpn-wg
66
+ sudo ip link delete mytmpvpn-wg
67
+
68
+ err=$?
69
+ if test $err -ne 0; then
70
+ exit 1
71
+ fi
72
+
73
+ # delete VPN
74
+ ${mytmpvpn} delete ${vpnId}
75
+
76
+ err=$?
77
+ if test $err -ne 0; then
78
+ exit 1
79
+ fi