tunnelblick 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b66f4735c7dfe937fc36c330ab403cc67c080aef
4
+ data.tar.gz: 4f8955327de66bcc3d9bf846c5b2feeecfef8664
5
+ SHA512:
6
+ metadata.gz: 0c4061147ecf0e5b51a0de51166399ebf59727f0be81779d734ff97e22668e50d5bcab86f4fa6b917823082138015190f909f733a9a988bb746791fea927e500
7
+ data.tar.gz: c3da8c77a288113d08514f2e89091dae6d6e9ea8632ac2fc9ef88b04fe9575b2dc0d2dea35d5d41070a595c1b23a5b3240610fc14c2e881812b91d3c486d63fe
@@ -0,0 +1,66 @@
1
+ require 'facets/hash/op_push'
2
+ require 'facets/string/titlecase'
3
+
4
+ module TunnelBlick
5
+
6
+ module ExpressVPN
7
+
8
+ class << self
9
+
10
+ def parse_config (string)
11
+ details = {}
12
+
13
+ string = string.sub('my_expressvpn_', '')
14
+ string.sub!(/_\D{3}\z/, '')
15
+
16
+ if string.split('_').size == 2
17
+ details << {:country => string.sub('_', ' ').titlecase}
18
+ details << {:label => details[:country]}
19
+ return details
20
+ end
21
+
22
+ country = string.split('-')[0]
23
+ string.sub!(country, '')
24
+ country.gsub!('_', ' ').strip!
25
+
26
+ country =
27
+ if %w"usa".include?(country)
28
+ country.upcase
29
+ else
30
+ country.titlecase
31
+ end
32
+
33
+ city =
34
+ if ['Hong Kong'].include?(country)
35
+ country
36
+ else
37
+ string.split('-_')[1]
38
+ end
39
+
40
+ string.gsub!(city, '')
41
+ city = city.gsub('_', ' ').strip.titlecase.sub('Dc', 'DC')
42
+
43
+ label =
44
+ if country == city
45
+ country
46
+ else
47
+ "#{country} - #{city}"
48
+ end
49
+ number = string.scan(/\d/)
50
+
51
+ unless number.empty?
52
+ label = label + " - #{number[0]}"
53
+ end
54
+
55
+ details = {
56
+ :country => country,
57
+ :city => city,
58
+ :label => label
59
+ }
60
+
61
+ end
62
+
63
+ end
64
+
65
+ end
66
+ end
@@ -0,0 +1,88 @@
1
+ require 'rb-scpt'
2
+ require 'tunnel_blick/express_vpn'
3
+
4
+ include Appscript
5
+
6
+ module TunnelBlick
7
+
8
+ class << self
9
+ attr_accessor :tunnel, :module, :d_id
10
+
11
+ def config_match (file_name)
12
+ case file_name
13
+ when /\Amy_expressvpn.+/
14
+ puts 'Express VPN'
15
+ else
16
+ puts 'VPN not recognized.'
17
+ end
18
+ end
19
+
20
+ def connected?
21
+ vpn_states.include?('CONNECTED')
22
+ end
23
+
24
+ def connect_rand (extra_waits = 2)
25
+
26
+ unless TunnelBlick.connected?
27
+
28
+ TunnelBlick.connect(vpn_configs.sample)
29
+
30
+ count = 0
31
+ while count <= extra_waits && !TunnelBlick.connected?
32
+ sleep(5)
33
+ count += 1
34
+ end
35
+
36
+ unless TunnelBlick.connected?
37
+ puts 'VPN did not connect in time'
38
+ return
39
+ end
40
+
41
+ end
42
+
43
+ config_file_name = vpn_configs[vpn_states.index('CONNECTED')]
44
+ loaded_module = TunnelBlick::TunnelBlick.module
45
+
46
+ loaded_module.parse_config(config_file_name)
47
+ end
48
+
49
+ def method_missing (method, *args, &block)
50
+ @tunnel.send(method, *args, &block)
51
+ end
52
+
53
+ end
54
+
55
+ def self.included(base)
56
+ TunnelBlick.tunnel = Appscript.app('Tunnelblick.app')
57
+ TunnelBlick.tunnel.extend(TunnelBlick)
58
+ end
59
+
60
+ def connected_vpn
61
+ p vpn_states
62
+ if vpn_state == 'CONNECTED'
63
+ vpn_configs[0]
64
+ else
65
+ nil
66
+ end
67
+ end
68
+
69
+ def disconnect
70
+ TunnelBlick.disconnect_all
71
+ end
72
+
73
+ def vpn_state
74
+ vpn_states[0]
75
+ end
76
+
77
+ def vpn_configs
78
+ TunnelBlick.configurations.name.get
79
+ end
80
+
81
+ def vpn_states
82
+ TunnelBlick.configurations.state.get
83
+ end
84
+
85
+ end
86
+
87
+
88
+
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tunnelblick
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Eugene Lai
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-03-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: facets
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: rb-scpt
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'
41
+ description: To do
42
+ email: ejt.lai@gmail.com
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - lib/tunnel_blick.rb
48
+ - lib/tunnel_blick/express_vpn.rb
49
+ homepage:
50
+ licenses: []
51
+ metadata: {}
52
+ post_install_message:
53
+ rdoc_options: []
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ requirements: []
67
+ rubyforge_project:
68
+ rubygems_version: 2.5.2
69
+ signing_key:
70
+ specification_version: 4
71
+ summary: A controller for Tunnelblick
72
+ test_files: []