mullvadrb 0.0.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/Gemfile +3 -1
- data/README.md +29 -4
- data/lib/mullvadrb/command_manager.rb +54 -0
- data/lib/mullvadrb/connection.rb +20 -1
- data/lib/mullvadrb/servers.rb +87 -85
- data/lib/mullvadrb/wg_manager.rb +96 -0
- data/lib/mullvadrb.rb +95 -51
- data/mullvadrb.gemspec +3 -1
- metadata +34 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15b1705d449260a54db9087125b5e4a9e0a6db3d548eb5d21dbeac3fb0031a83
|
4
|
+
data.tar.gz: ef45c9ffec12967471be56c4ca096e4af2bd1e4fde8011744bab1333bf17ea7b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c78f22e514750210bab56f43fb18d06fa214c25832782ba6593ea915cdcc077235c25daf695ba6ea3aac10badc01e85b9a77d854073dcfaf35079ba6ddc33d85
|
7
|
+
data.tar.gz: 8234009792fa8e18dc7efef9a6e78e5441a5448086c0b7e5d42ab0f11fec3a618a1a8a305dfe0f8ac39cd3ba90d386cbc160ef32ea6204e5ae97e714a9f84447
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# 0.0.3
|
2
|
+
|
3
|
+
Minor cleanup in the code and updates the way status is displayed.
|
4
|
+
|
5
|
+
# 0.0.2
|
6
|
+
|
7
|
+
I added back the support for WireGuard, in cases you don't want to or can't install the `mullvad` cli app, which was the initial reason I built this. The first time you run the app, it's going to ask you which one you want to use, and save your preference in `~/.local/share/mullvadrb/backend.conf`. You can switch backends from the Main Menu on the app at any time.
|
8
|
+
|
9
|
+
- Added extra options on the Main Menu.
|
10
|
+
- Refactored the whole code.
|
11
|
+
|
12
|
+
# 0.0.1
|
13
|
+
|
14
|
+
Initial release. Allows you to use the TUI as an interface for mullvad, the Mullvad VPN CLI.
|
15
|
+
|
16
|
+
I started this script as a test to build a TUI for Mullvad using WireGuard. Then I switched it to use the `mullvad` CLI. It called the command via a menu on the Terminal, allowing to access most (for now) of the CLI app's features.
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,13 +1,39 @@
|
|
1
1
|
# Ruby TUI for Mullvad VPN
|
2
2
|
|
3
|
-
This is a Terminal App I wrote for myself to use with Mullvad VPN on Linux. It
|
3
|
+
This is a Terminal App I wrote for myself to use with Mullvad VPN on Linux. It makes it easier for me to choose servers when using Mullvad from the command line.
|
4
4
|
|
5
|
-
|
5
|
+
![mullvad](https://github.com/user-attachments/assets/1c628381-9a7c-40f4-9376-2f65496b2bc8)
|
6
6
|
|
7
|
+
The app has two "backends", [Mullvad CLI](https://mullvad.net/en/help/how-use-mullvad-cli) or [WireGuard](https://mullvad.net/en/help/wireguard-and-mullvad-vpn).
|
8
|
+
|
9
|
+
Most of the basic functionality is available for either backend: Select a server (random, by country, specific server), connect, disconnect and show the current status. You can use either backend. The first time you run the app, it's going to ask you which one you want to use, and save your preference in `~/.local/share/mullvadrb/backend.conf`. You can switch backends from the Main Menu on the app at any time.
|
7
10
|
|
8
11
|
## Requirements
|
9
12
|
|
10
|
-
You need to have a [Mullvad VPN](https://mullvad.net) account
|
13
|
+
You need to have a [Mullvad VPN](https://mullvad.net) account to use the app.
|
14
|
+
|
15
|
+
> [!WARNING]
|
16
|
+
> `mullvad` uses WireGuard, so if you change backends while connected to an OpenVPN server with `wg`, `mullvad` won't be able to disconnect from the OpenVPN connection.
|
17
|
+
> In general, it's a good idea to stick to one backend, and disconnect from the VPN before switching backends.
|
18
|
+
> This might potentially be fixed in the future.
|
19
|
+
|
20
|
+
### For the WireGuard backend
|
21
|
+
|
22
|
+
You need to [install WireGuard](https://www.wireguard.com/install/) and follow the instructions on [Mullvad: WireGuard on Linux terminal](https://mullvad.net/en/help/wireguard-and-mullvad-vpn). The configuration script you are asked to run in this last link will download the WireGuard configuration files needed to `/etc/wireguard`.
|
23
|
+
|
24
|
+
The app is basically a layer on top of `wg-quick`. The scripts it runs are:
|
25
|
+
```
|
26
|
+
$ wg-quick up <connected server (e.g. uy-mma-wg-001)> # Connect with WireGuard
|
27
|
+
$ curl https://am.i.mullvad.net/connected # Check if you're connected to Mullvad
|
28
|
+
$ wg-quick down <connected server> # Disconnect
|
29
|
+
```
|
30
|
+
It uses `sudo` to read the files on `/etc/wireguard` and execute `wg-quick` for connecting and disconnecting.
|
31
|
+
|
32
|
+
### For the Mullvad CLI backend
|
33
|
+
|
34
|
+
You need to install [the Mullvad CLI](https://mullvad.net/en/download/vpn/linux) to use this backend.
|
35
|
+
|
36
|
+
On first run, you need to log in (unless you've already run `mullvad account login` on your terminal before). The servers list will be updated and will be saved to `~/.local/share/mullvadrb.dump`.
|
11
37
|
|
12
38
|
## Development
|
13
39
|
|
@@ -16,4 +42,3 @@ Run gem from the source:
|
|
16
42
|
```bash
|
17
43
|
$ irb -Ilib -rmullvadrb
|
18
44
|
```
|
19
|
-
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Mullvadrb
|
2
|
+
module CommandManager
|
3
|
+
def connect
|
4
|
+
if @wg
|
5
|
+
Mullvadrb::WgManager.connect
|
6
|
+
else
|
7
|
+
Mullvadrb::Connection.connect
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def disconnect
|
12
|
+
if @wg
|
13
|
+
Mullvadrb::WgManager.disconnect
|
14
|
+
else
|
15
|
+
Mullvadrb::Connection.disconnect
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def status
|
20
|
+
if @wg
|
21
|
+
puts Mullvadrb::WgManager.status
|
22
|
+
else
|
23
|
+
puts Mullvadrb::Connection.status
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def random
|
28
|
+
if @wg
|
29
|
+
Mullvadrb::WgManager.random
|
30
|
+
else
|
31
|
+
Mullvadrb::Servers.random
|
32
|
+
Mullvadrb::Connection.connect
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def country
|
37
|
+
if @wg
|
38
|
+
Mullvadrb::WgManager.country
|
39
|
+
else
|
40
|
+
Mullvadrb::Servers.select_country
|
41
|
+
Mullvadrb::Connection.connect
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def specific
|
46
|
+
if @wg
|
47
|
+
Mullvadrb::WgManager.specific
|
48
|
+
else
|
49
|
+
Mullvadrb::Servers.select_specific
|
50
|
+
Mullvadrb::Connection.connect
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/lib/mullvadrb/connection.rb
CHANGED
@@ -26,7 +26,26 @@ module Mullvadrb
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def status
|
29
|
-
|
29
|
+
status = `mullvad status -v`
|
30
|
+
if status.start_with?('Disconnected')
|
31
|
+
status.gsub!('Disconnected', "\n⚠ 🚨 DISCONNECTED 🚨 c⚠")
|
32
|
+
.gsub!(/$/, "\n")
|
33
|
+
elsif status.start_with?('Connected')
|
34
|
+
status = status.split("\n")
|
35
|
+
.sort
|
36
|
+
.reject { |a| a == 'Connected' }
|
37
|
+
.prepend("📡 Connected ✅ \n")
|
38
|
+
.push("\n")
|
39
|
+
.join("\n")
|
40
|
+
elsif status.start_with?('Connecting')
|
41
|
+
status = status.split("\n")
|
42
|
+
.sort
|
43
|
+
.reject { |a| a == 'Connecting' }
|
44
|
+
.prepend("📞 Connecting ☎ \n")
|
45
|
+
.push("\n")
|
46
|
+
.join("\n")
|
47
|
+
end
|
48
|
+
status
|
30
49
|
end
|
31
50
|
end
|
32
51
|
end
|
data/lib/mullvadrb/servers.rb
CHANGED
@@ -1,106 +1,108 @@
|
|
1
1
|
module Mullvadrb
|
2
2
|
module Servers
|
3
|
-
|
3
|
+
class << self
|
4
|
+
SERVERS_FILE = File.expand_path('~/.local/share/mullvadrb/servers.dump').freeze
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
def update
|
7
|
+
`mullvad relay update`
|
8
|
+
data = `mullvad relay list`
|
9
|
+
country, city, info, flag = nil
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
11
|
+
# Each line is either a country, a city or a server
|
12
|
+
servers = data.split("\n").compact.reject(&:empty?).map do |s|
|
13
|
+
if s.start_with?("\t\t")
|
14
|
+
info = s.gsub("\t\t", '')
|
15
|
+
{ country: country, city: city, info: info, flag: flag, value: info.split(' ').first }
|
16
|
+
elsif s.start_with?("\t")
|
17
|
+
city = s.gsub("\t", '').split("(").first.strip
|
18
|
+
next
|
19
|
+
else
|
20
|
+
regexp = /\(([a-z]{2})\)/ # Country (xx) - Country name + code and group code
|
21
|
+
flag = s.match(regexp)[1]
|
22
|
+
.upcase
|
23
|
+
.codepoints
|
24
|
+
.map { |c| (c + 127397).chr('utf-8') }.join
|
25
|
+
country = s.gsub(regexp, '').strip
|
26
|
+
next
|
27
|
+
end
|
28
|
+
end.compact
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
save_servers(servers)
|
31
|
+
puts '🗃 Server list updated'
|
32
|
+
puts
|
33
|
+
end
|
33
34
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
35
|
+
def select_country
|
36
|
+
servers = @servers
|
37
|
+
country = TTY::Prompt.new.select('Select country', countries(servers), cycle: true, per_page: 10, filter: true, symbols: { marker: '🛫' })
|
38
|
+
connection = servers.select do |s|
|
39
|
+
s[:country] == country
|
40
|
+
end.sample
|
41
|
+
puts `mullvad relay set location #{connection[:value]}`
|
42
|
+
end
|
42
43
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
44
|
+
def random
|
45
|
+
server = all_connections.sample
|
46
|
+
puts "Connecting to #{server[:name]}"
|
47
|
+
puts `mullvad relay set location #{server[:value]}`
|
48
|
+
end
|
48
49
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
50
|
+
def select_specific
|
51
|
+
connections = all_connections
|
52
|
+
server = TTY::Prompt.new.select(
|
53
|
+
'Select server',
|
54
|
+
connections,
|
55
|
+
cycle: true,
|
56
|
+
per_page: 10,
|
57
|
+
filter: true,
|
58
|
+
symbols: { marker: '🛫' }
|
59
|
+
)
|
60
|
+
puts `mullvad relay set location #{server}`
|
61
|
+
end
|
61
62
|
|
62
|
-
|
63
|
-
|
64
|
-
|
63
|
+
def servers
|
64
|
+
@servers ||= load_servers
|
65
|
+
end
|
65
66
|
|
66
|
-
|
67
|
+
private
|
67
68
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
69
|
+
def countries(servers)
|
70
|
+
servers.uniq { |s| s[:country] }.map do |server|
|
71
|
+
{
|
72
|
+
name: "#{server[:flag]} #{server[:country]}",
|
73
|
+
value: server[:country]
|
74
|
+
}
|
75
|
+
end
|
74
76
|
end
|
75
|
-
end
|
76
77
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
78
|
+
def all_connections
|
79
|
+
servers.map do |server|
|
80
|
+
{
|
81
|
+
name: "#{server[:flag]} #{server[:country]} - #{server[:city]}: #{server[:info]}",
|
82
|
+
value: server[:value]
|
83
|
+
}
|
84
|
+
end
|
83
85
|
end
|
84
|
-
end
|
85
86
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
87
|
+
def emoji_from_code(code)
|
88
|
+
code.upcase
|
89
|
+
.codepoints
|
90
|
+
.map { |c| (c + 127_397).chr('utf-8') }.join
|
91
|
+
end
|
91
92
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
93
|
+
def load_servers
|
94
|
+
servers = File.expand_path(SERVERS_FILE)
|
95
|
+
if File.file?(servers)
|
96
|
+
Marshal.load(File.read(servers))
|
97
|
+
else
|
98
|
+
update
|
99
|
+
end
|
98
100
|
end
|
99
|
-
end
|
100
101
|
|
101
|
-
|
102
|
-
|
103
|
-
|
102
|
+
def save_servers(servers)
|
103
|
+
File.open(SERVERS_FILE, 'w+') do |f|
|
104
|
+
f.write(Marshal.dump(servers))
|
105
|
+
end
|
104
106
|
end
|
105
107
|
end
|
106
108
|
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'countries'
|
2
|
+
|
3
|
+
module Mullvadrb
|
4
|
+
module WgManager
|
5
|
+
# Default path, copy the files here from /etc/wireguard (in general)
|
6
|
+
PATH = '/etc/wireguard'
|
7
|
+
FILES = `sudo find /etc/wireguard/ -name *.conf`.split
|
8
|
+
CONFIG = File.expand_path('~/.local/share/mullvadrb/connection.dump').freeze
|
9
|
+
|
10
|
+
CONNECTIONS = FILES.map { |f| f.split('/').last }.uniq.map do |file|
|
11
|
+
country = ISO3166::Country.find_country_by_alpha2(file[0..1].upcase)
|
12
|
+
name = "#{country.common_name} #{country.emoji_flag}"
|
13
|
+
{ value: file, name: name }
|
14
|
+
end.sort_by { |c| c[:name] }
|
15
|
+
|
16
|
+
class << self
|
17
|
+
# Select a random VPN connection
|
18
|
+
def random
|
19
|
+
connect(FILES.sample)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Choose by country
|
23
|
+
def country
|
24
|
+
countries = CONNECTIONS.map { |c| { value: c[:value][0..1], name: c[:name] } }.uniq
|
25
|
+
country = TTY::Prompt.new.select('Select country', countries, cycle: true, per_page: 30, filter: true)
|
26
|
+
connect FILES.select { |a| a.split('/').last.start_with?(country) }.sample
|
27
|
+
end
|
28
|
+
|
29
|
+
# Select a specific connection
|
30
|
+
def specific
|
31
|
+
connections = CONNECTIONS.map { |c| { name: "#{c[:value]} #{c[:name]}", value: c[:value] } }
|
32
|
+
connect(
|
33
|
+
TTY::Prompt.new.select('Select configuration file', connections, cycle: true, per_page: 30, filter: true)
|
34
|
+
)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Check status
|
38
|
+
def status
|
39
|
+
status = `curl -s https://am.i.mullvad.net/connected`
|
40
|
+
regexp = /\(server ([a-z]{2})[a-z\-0-9]+\)/
|
41
|
+
# Add country name to the server if we are connected
|
42
|
+
if (match = status.match(regexp))
|
43
|
+
country = CONNECTIONS.find { |c| c[:value][0..1] == match[1] }[:name]
|
44
|
+
status = status.gsub(regexp, "in #{country} \\0")
|
45
|
+
end
|
46
|
+
status
|
47
|
+
end
|
48
|
+
|
49
|
+
def connected?
|
50
|
+
status.match?('You are connected')
|
51
|
+
end
|
52
|
+
|
53
|
+
def load_connection
|
54
|
+
Marshal.load(File.read(CONFIG))
|
55
|
+
end
|
56
|
+
|
57
|
+
def save_connection
|
58
|
+
File.open(CONFIG, 'wb') do |f|
|
59
|
+
f.write(Marshal.dump(@connection))
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def connect(selection)
|
64
|
+
connection_file = selection.split('/').last
|
65
|
+
current = status
|
66
|
+
if current.match?('You are connected')
|
67
|
+
server = current.match(/\(server (.*)\)/)[1]
|
68
|
+
puts "Disconnecting from #{server}"
|
69
|
+
disconnect
|
70
|
+
end
|
71
|
+
@connection = connection_file
|
72
|
+
puts "Attempting to connect to #{@connection}"
|
73
|
+
puts system("wg-quick up #{PATH}/#{@connection}")
|
74
|
+
save_connection
|
75
|
+
end
|
76
|
+
|
77
|
+
def disconnect
|
78
|
+
@connection = load_connection
|
79
|
+
if @connection
|
80
|
+
wg_disconnect
|
81
|
+
else
|
82
|
+
puts 'No active connection available'
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def wg_disconnect
|
87
|
+
if system("wg-quick down #{PATH}/#{@connection}")
|
88
|
+
puts "🔌 Successfully pulled the plug from #{@connection}"
|
89
|
+
else
|
90
|
+
puts 'Error disconnecting'
|
91
|
+
puts 'Maybe the connection wasn\'t active? 🤨'
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
data/lib/mullvadrb.rb
CHANGED
@@ -2,60 +2,104 @@
|
|
2
2
|
|
3
3
|
require 'tty-prompt'
|
4
4
|
require 'mullvadrb/account'
|
5
|
+
require 'mullvadrb/command_manager'
|
5
6
|
require 'mullvadrb/connection'
|
6
7
|
require 'mullvadrb/servers'
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
9
|
+
module Mullvadrb
|
10
|
+
class Main
|
11
|
+
include Mullvadrb::CommandManager
|
12
|
+
CONFIG_FILE = File.expand_path('~/.local/share/mullvadrb/backend.conf').freeze
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
# To determine if we're using WireGuard or mullvad cli, attempt to load a pre-saved
|
16
|
+
# configuration or prompt the user which one to use:
|
17
|
+
backend = load_config || ask_backend_and_save
|
18
|
+
puts "Using #{backend} backend"
|
19
|
+
puts Mullvadrb::Connection.status
|
20
|
+
end
|
21
|
+
|
22
|
+
def ask_backend_and_save
|
23
|
+
backend = TTY::Prompt.new.select('Which cli backend would you like to use?', cycle: true) do |menu|
|
24
|
+
menu.choice name: 'WireGuard - wg (needs sudo powers)', value: 'wg'
|
25
|
+
menu.choice name: 'Mullvad - mullvad', value: 'mullvad'
|
26
|
+
end
|
27
|
+
@wg = (backend == 'wg')
|
28
|
+
require 'mullvadrb/wg_manager' if @wg
|
29
|
+
dir = File.expand_path('~/.local/share/mullvadrb/')
|
30
|
+
system 'mkdir', '-p', dir unless File.exist?(dir)
|
31
|
+
File.open(CONFIG_FILE, 'w+') { |f| f.write(backend) }
|
32
|
+
end
|
33
|
+
|
34
|
+
def load_config
|
35
|
+
return unless File.exist?(CONFIG_FILE)
|
36
|
+
|
37
|
+
backend = File.read(CONFIG_FILE)
|
38
|
+
@wg = (backend == 'wg')
|
39
|
+
load_servers unless @wg
|
40
|
+
require 'mullvadrb/wg_manager' if @wg
|
41
|
+
backend
|
42
|
+
end
|
25
43
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
44
|
+
def load_servers
|
45
|
+
@servers = Mullvadrb::Servers.servers
|
46
|
+
end
|
47
|
+
|
48
|
+
def main_menu
|
49
|
+
choices = common_menu_choices
|
50
|
+
choices.merge!(mullvad_cli_choices) unless @wg
|
51
|
+
choices.merge!({ '❌ Exit' => 'exit' })
|
52
|
+
TTY::Prompt.new.select('Main Menu', choices, cycle: true, per_page: 12)
|
53
|
+
end
|
54
|
+
|
55
|
+
def common_menu_choices
|
56
|
+
{
|
57
|
+
'📡 Status' => 'status',
|
58
|
+
'🎰 Random' => 'random',
|
59
|
+
"#{['🌏', '🌎', '🌍'].sample} Choose country" => 'country',
|
60
|
+
'🗺 Choose specific' => 'specific',
|
61
|
+
'🔌 Disconnect' => 'disconnect',
|
62
|
+
'⚙ Change backend' => 'backend'
|
63
|
+
}
|
64
|
+
end
|
65
|
+
|
66
|
+
def mullvad_cli_choices
|
67
|
+
{
|
68
|
+
'🗃 Update Servers' => 'update_servers',
|
69
|
+
'🔑 Log in' => 'account_login',
|
70
|
+
'📁 Account info' => 'account_info',
|
71
|
+
'🖥 Devices' => 'account_devices'
|
72
|
+
}
|
73
|
+
end
|
74
|
+
|
75
|
+
def run
|
76
|
+
loop do
|
77
|
+
selection = main_menu
|
78
|
+
puts "\e[H\e[2J"
|
79
|
+
case selection
|
80
|
+
when 'status', 'disconnect', 'country', 'specific', 'random'
|
81
|
+
send(selection)
|
82
|
+
when 'exit'
|
83
|
+
abort('Tioraidh!')
|
84
|
+
when 'backend'
|
85
|
+
ask_backend_and_save
|
86
|
+
# Only when using mullvad cli and not wg:
|
87
|
+
when 'update_servers'
|
88
|
+
Mullvadrb::Servers.update
|
89
|
+
when 'account_login'
|
90
|
+
Mullvadrb::Account.login(
|
91
|
+
TTY::Prompt.new.ask('Please enter your account number:')
|
92
|
+
)
|
93
|
+
when 'account_info'
|
94
|
+
Mullvadrb::Account.info
|
95
|
+
when 'account_devices'
|
96
|
+
Mullvadrb::Account.devices
|
97
|
+
end
|
98
|
+
rescue SystemExit, Interrupt
|
99
|
+
abort("\n\nTioraidh!\n")
|
100
|
+
end
|
101
|
+
end
|
57
102
|
end
|
58
|
-
rescue SystemExit, Interrupt
|
59
|
-
puts
|
60
|
-
exit
|
61
103
|
end
|
104
|
+
|
105
|
+
Mullvadrb::Main.new.run
|
data/mullvadrb.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'mullvadrb'
|
3
|
-
s.version = '0.0.
|
3
|
+
s.version = '0.0.3'
|
4
4
|
s.summary = 'A TUI to use with Mullvad VPN'
|
5
5
|
s.description = 'A Terminal User Interface to use with Mullvad VPN'
|
6
6
|
s.authors = ['Fernando Briano']
|
@@ -11,4 +11,6 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.license = 'GPL-3.0-or-later'
|
12
12
|
s.required_ruby_version = '>= 3.0'
|
13
13
|
s.executables << 'mullvadrb'
|
14
|
+
s.add_dependency 'countries'
|
15
|
+
s.add_dependency 'tty-prompt'
|
14
16
|
end
|
metadata
CHANGED
@@ -1,15 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mullvadrb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fernando Briano
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
12
|
-
dependencies:
|
11
|
+
date: 2024-11-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: countries
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: tty-prompt
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
13
41
|
description: A Terminal User Interface to use with Mullvad VPN
|
14
42
|
email: fernando@picandocodigo.net
|
15
43
|
executables:
|
@@ -18,13 +46,16 @@ extensions: []
|
|
18
46
|
extra_rdoc_files: []
|
19
47
|
files:
|
20
48
|
- ".gitignore"
|
49
|
+
- CHANGELOG.md
|
21
50
|
- Gemfile
|
22
51
|
- README.md
|
23
52
|
- bin/mullvadrb
|
24
53
|
- lib/mullvadrb.rb
|
25
54
|
- lib/mullvadrb/account.rb
|
55
|
+
- lib/mullvadrb/command_manager.rb
|
26
56
|
- lib/mullvadrb/connection.rb
|
27
57
|
- lib/mullvadrb/servers.rb
|
58
|
+
- lib/mullvadrb/wg_manager.rb
|
28
59
|
- mullvadrb.gemspec
|
29
60
|
homepage: https://github.com/picandocodigo/mullvad-ruby
|
30
61
|
licenses:
|