tunnelblick_ruby 0.3.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 372e8bc8fcf59cbbdfea73ec9ecae1cca3672322c0d1c98a198298d9dd32917b
4
+ data.tar.gz: 6d7014f74102c4873b6680c031f3a0b3f6afc6b40bf11d03b4e5c42c9769352d
5
+ SHA512:
6
+ metadata.gz: 0257a430427730d1475071834491ec5187f5a0287ed8309228ebb3dc8568c51519ce094d4d356bc1eb212ad1cf1a524819d51bac211bb996baaa530fafd212ed
7
+ data.tar.gz: 47c27aa0fe4f65e33dac2cd158c4262966ff723f21624b1df3184f16de0c3a1a6ce6b02c551c6d1b1c0040fbf4f21d5189f8492a737bd5c1a7fd01471a3a7a83
@@ -0,0 +1,19 @@
1
+ require_relative 'vpn_service'
2
+
3
+ class TunnelblickRb
4
+ def self.connected?
5
+ VpnService.connected?
6
+ end
7
+
8
+ def self.start(address)
9
+ VpnService.connect(address)
10
+ end
11
+
12
+ def self.switch_ip(address)
13
+ VpnService.switch(address)
14
+ end
15
+
16
+ def self.stop(address)
17
+ VpnService.disconnect(address)
18
+ end
19
+ end
@@ -0,0 +1,53 @@
1
+ class VpnService
2
+ def self.connect(address)
3
+ system(
4
+ %x{
5
+ osascript <<APPLESCRIPT
6
+ tell application "Tunnelblick"
7
+ connect "#{address}"
8
+ get state of first configuration where name = "#{address}"
9
+ repeat until result = "CONNECTED"
10
+ delay 1
11
+ get state of first configuration where name = "#{address}"
12
+ end repeat
13
+ end tell
14
+ APPLESCRIPT}
15
+ )
16
+
17
+ return "Connected to #{address}"
18
+ end
19
+
20
+ def self.disconnect(address)
21
+ raise 'No connection exists' unless connected?
22
+ system(
23
+ %x{
24
+ osascript <<APPLESCRIPT
25
+ tell application "Tunnelblick"
26
+ disconnect "#{address}"
27
+ end tell
28
+ APPLESCRIPT}
29
+ )
30
+ return 'Disconnected'
31
+ end
32
+
33
+ def self.switch(address)
34
+ raise 'No connection exists' unless connected?
35
+ self.disconnect
36
+ self.connect(address)
37
+ return "Connected to #{address}"
38
+ end
39
+
40
+ def self.connected?
41
+
42
+ output = `
43
+ osascript <<APPLESCRIPT
44
+ tell application "Tunnelblick"
45
+ get state of first configuration
46
+ return result
47
+ end tell
48
+ APPLESCRIPT
49
+ `
50
+
51
+ return output == "CONNECTED\n"
52
+ end
53
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tunnelblick_ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0
5
+ platform: ruby
6
+ authors:
7
+ - Matt Simon
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-08-10 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Provides tools for interacting with Tunnelblick using ruby
14
+ email: dev.msimon@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/tunnelblick_ruby.rb
20
+ - lib/vpn_service.rb
21
+ homepage: ''
22
+ licenses:
23
+ - NGPL
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubygems_version: 3.0.8
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: Provides tools for interacting with Tunnelblick using ruby
44
+ test_files: []