vpn-cli 0.1.0

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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/vpn.rb +81 -0
  3. metadata +40 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4022e1192fdbdb48d47a011e697dc092ea12a9336d5bec0bacec6688143a0906
4
+ data.tar.gz: 698f7eb0b75a82d40b00dea3db1e56e613e72689a8aceffc17574813f89c2e06
5
+ SHA512:
6
+ metadata.gz: eb657b37fc3a5e76991d49c3822b5d00a9cbb9a62fd3f67d232675f9715f4880093cf7845d520fa71302429ad7559465176e59f2f54e28c1d1138268c115e906
7
+ data.tar.gz: 3ff37b1f7780f2d498350c43fb6108d5ccae412a928afda7ee7bd313ae5c386f72d70006255531159e1ade2e5f36a58be6d4be64287fa1dee48007edebf5e056
data/lib/vpn.rb ADDED
@@ -0,0 +1,81 @@
1
+ require "net/http"
2
+ require "json"
3
+ require "uri"
4
+
5
+ module VPN
6
+ BASE = "https://vpn-gateway--jdjdjdjdjdh8288.replit.app"
7
+
8
+ def self.start(country)
9
+ if country.nil?
10
+ puts "Usage: vpn start <COUNTRY_CODE>"
11
+ return
12
+ end
13
+
14
+ uri = URI("#{BASE}/api/vpn/connect")
15
+
16
+ http = Net::HTTP.new(uri.host, uri.port)
17
+ http.use_ssl = true
18
+
19
+ req = Net::HTTP::Post.new(uri)
20
+ req["Content-Type"] = "application/json"
21
+ req.body = { countryCode: country.upcase }.to_json
22
+
23
+ res = http.request(req)
24
+ puts res.body
25
+ end
26
+
27
+ def self.disconnect
28
+ uri = URI("#{BASE}/api/vpn/disconnect")
29
+
30
+ http = Net::HTTP.new(uri.host, uri.port)
31
+ http.use_ssl = true
32
+
33
+ req = Net::HTTP::Post.new(uri)
34
+ req["Content-Type"] = "application/json"
35
+ req.body = {}.to_json
36
+
37
+ res = http.request(req)
38
+ puts res.body
39
+ end
40
+
41
+ def self.list
42
+ uri = URI("#{BASE}/api/vpn/countries")
43
+
44
+ res = Net::HTTP.get_response(uri)
45
+
46
+ if res.is_a?(Net::HTTPSuccess)
47
+ JSON.parse(res.body).each do |c|
48
+ puts "#{c["code"]} #{c["flagEmoji"]} #{c["name"]}"
49
+ end
50
+ else
51
+ puts "Error: #{res.code}"
52
+ end
53
+ end
54
+
55
+ def self.help
56
+ puts <<~TXT
57
+ VPN CLI
58
+
59
+ Commands:
60
+ vpn list
61
+ vpn start US
62
+ vpn disconnect
63
+ vpn help
64
+ TXT
65
+ end
66
+
67
+ def self.run(args)
68
+ case args[0]
69
+ when "start"
70
+ start(args[1])
71
+ when "disconnect"
72
+ disconnect
73
+ when "list"
74
+ list
75
+ else
76
+ help
77
+ end
78
+ end
79
+ end
80
+
81
+ VPN.run(ARGV)
metadata ADDED
@@ -0,0 +1,40 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vpn-cli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - YourName
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 2026-07-03 00:00:00.000000000 Z
11
+ dependencies: []
12
+ description: Start, stop and list VPN servers
13
+ email:
14
+ - you@example.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/vpn.rb
20
+ licenses:
21
+ - MIT
22
+ metadata: {}
23
+ rdoc_options: []
24
+ require_paths:
25
+ - lib
26
+ required_ruby_version: !ruby/object:Gem::Requirement
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ version: '0'
31
+ required_rubygems_version: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ requirements: []
37
+ rubygems_version: 3.6.2
38
+ specification_version: 4
39
+ summary: VPN CLI tool
40
+ test_files: []