vagrant-foodshow 1.0.3 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +12 -0
- data/Rakefile +1 -1
- data/lib/vagrant-foodshow.rb +2 -2
- data/lib/vagrant-foodshow/action/start.rb +13 -13
- data/lib/vagrant-foodshow/action/stop.rb +4 -4
- data/lib/vagrant-foodshow/config.rb +70 -42
- data/lib/vagrant-foodshow/plugin.rb +6 -6
- data/lib/vagrant-foodshow/util/ngrok.rb +62 -30
- data/lib/vagrant-foodshow/util/ngrok_config.rb +59 -17
- data/lib/vagrant-foodshow/version.rb +1 -1
- data/vagrant-foodshow.gemspec +8 -8
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 366d9a432ef47400bf996eb100457e6d9564d872
|
4
|
+
data.tar.gz: 2baa056556112ec5671495ede167e787b04df2e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c70c7750701cbe445a8208a427a246efbb2be1110f0ae4c7770d19cacf61a40d1d99865d61e8f6b751420bd32e4523f289768b33064f40c0e11a780af37651d
|
7
|
+
data.tar.gz: 0a6b52cb46b411a8e84e2cd5d4f0682c21a8a16d424aae75fd950948ba0c7eb7bc416feb522b0865ff75735339b591f80e64a327f446800d480be5aae7cd2b07
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -133,6 +133,8 @@ Read this document if you want to start self-hosted server https://github.com/in
|
|
133
133
|
- Scope *config+tunnel* means that this option can be set via `foodshow.<options>` and can be can be passed to the `foodshow.tunnel` method as options hash.
|
134
134
|
- Scope *tunnel* means that this option can be passed to the `foodshow.tunnel` method
|
135
135
|
|
136
|
+
Configuration options for **ngrok v1.x**
|
137
|
+
|
136
138
|
Option | Default | Scope | Purpose
|
137
139
|
-------|---------|---------|--------
|
138
140
|
`enabled` | `false` | config | Enable foodshow plugin
|
@@ -149,6 +151,16 @@ Option | Default | Scope | Purpose
|
|
149
151
|
`server_addr` | `nil` | config+tunnel | Server address for self-hosted ngrokd, see [Self-hosted tunnels example](#self-hosted-tunnel-example)
|
150
152
|
`trust_host_root_certs` | `nil` | config+tunnel | Allow ngrok accept root server certificate. Must be `true` if you using self-hosted ngrokd
|
151
153
|
|
154
|
+
Changes in config options for **ngrok v2.x**
|
155
|
+
|
156
|
+
v1.x option | | v2.x option
|
157
|
+
------------|-|------------
|
158
|
+
httpauth | => | auth
|
159
|
+
inspect_addr | => | web_addr
|
160
|
+
inspect_pbase | => | web_pbase
|
161
|
+
|
162
|
+
> If you are using ngrok v2.x authtoken option could be automatically filled from ngrok configuration
|
163
|
+
|
152
164
|
# Authors
|
153
165
|
|
154
166
|
* Nikita Borzykh (<sample.n@gmail.com>)
|
data/Rakefile
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
data/lib/vagrant-foodshow.rb
CHANGED
@@ -2,7 +2,7 @@ module VagrantPlugins
|
|
2
2
|
module Foodshow
|
3
3
|
module Action
|
4
4
|
class Start
|
5
|
-
def initialize(app,env)
|
5
|
+
def initialize(app, env)
|
6
6
|
@app = app
|
7
7
|
end
|
8
8
|
|
@@ -13,10 +13,10 @@ module VagrantPlugins
|
|
13
13
|
|
14
14
|
if env[:machine].config.foodshow.forward_ssh?
|
15
15
|
env[:machine].config.foodshow.tunnel(
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
env[:machine].ssh_info[:port],
|
17
|
+
'tcp',
|
18
|
+
:host => env[:machine].ssh_info[:host]
|
19
|
+
)
|
20
20
|
end
|
21
21
|
|
22
22
|
env[:machine].config.vm.networks.each do |network|
|
@@ -24,16 +24,16 @@ module VagrantPlugins
|
|
24
24
|
if network[0] == :forwarded_port
|
25
25
|
if network[1][:ngrok_proto]
|
26
26
|
|
27
|
-
if network[1][:protocol] !=
|
27
|
+
if network[1][:protocol] != 'tcp'
|
28
28
|
env[:ui].error "Can't tunnel port #{network[1][:host]}, only tcp protocol supported. Skipping."
|
29
29
|
next
|
30
30
|
end
|
31
31
|
|
32
32
|
env[:machine].config.foodshow.tunnel(
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
network[1][:host],
|
34
|
+
network[1][:ngrok_proto],
|
35
|
+
:host => network[1][:host_ip] || '127.0.0.1',
|
36
|
+
)
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
@@ -41,12 +41,12 @@ module VagrantPlugins
|
|
41
41
|
status, message, debug_output = VagrantPlugins::Foodshow::Util::Ngrok.start(env, tunnel)
|
42
42
|
|
43
43
|
if status == 0
|
44
|
-
env[:ui].success
|
44
|
+
env[:ui].success 'Tunnel from ' + message + ' to ' + tunnel[:host] + ':' + tunnel[:port].to_s
|
45
45
|
elsif status == 1
|
46
|
-
env[:ui].error
|
46
|
+
env[:ui].error 'Ngrok failed: ' + message
|
47
47
|
elsif status == -1
|
48
48
|
env[:ui].error message
|
49
|
-
env[:ui].error
|
49
|
+
env[:ui].error 'Ngrok output: ' + debug_output.join
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
@@ -2,7 +2,7 @@ module VagrantPlugins
|
|
2
2
|
module Foodshow
|
3
3
|
module Action
|
4
4
|
class Stop
|
5
|
-
def initialize(app,env)
|
5
|
+
def initialize(app, env)
|
6
6
|
@app = app
|
7
7
|
end
|
8
8
|
|
@@ -10,15 +10,15 @@ module VagrantPlugins
|
|
10
10
|
|
11
11
|
machine_id = VagrantPlugins::Foodshow::Util::NgrokConfig.get_machine_id(env)
|
12
12
|
Dir.glob("#{env[:tmp_path] || '/tmp'}/ngrok-#{machine_id}-*.pid") do |pid_file|
|
13
|
-
::File.open(pid_file,
|
13
|
+
::File.open(pid_file, 'r') do |f|
|
14
14
|
begin
|
15
15
|
pid = f.readline().to_i
|
16
|
-
::Process.kill(
|
16
|
+
::Process.kill('TERM', pid)
|
17
17
|
::File.delete(pid_file)
|
18
18
|
rescue Errno::ESRCH
|
19
19
|
::File.delete(pid_file)
|
20
20
|
ensure
|
21
|
-
env[:ui].info(
|
21
|
+
env[:ui].info('ngrok terminated')
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -9,39 +9,59 @@ module VagrantPlugins
|
|
9
9
|
attr_accessor :enabled
|
10
10
|
attr_accessor :forward_ssh
|
11
11
|
|
12
|
+
# ngrok common options
|
12
13
|
attr_accessor :authtoken
|
13
14
|
attr_accessor :hostname
|
14
|
-
attr_accessor :httpauth
|
15
15
|
attr_accessor :subdomain
|
16
|
+
|
17
|
+
# ngrok v1.x options
|
18
|
+
attr_accessor :httpauth
|
16
19
|
attr_accessor :inspect_addr
|
17
20
|
attr_accessor :inspect_pbase
|
18
21
|
|
19
|
-
|
20
|
-
|
22
|
+
# ngrok v2.x options
|
23
|
+
attr_accessor :auth
|
24
|
+
attr_accessor :web_addr
|
25
|
+
attr_accessor :web_pbase
|
26
|
+
|
27
|
+
attr_reader :tunnels
|
28
|
+
attr_reader :ngrok_bin
|
21
29
|
|
22
30
|
def initialize
|
23
|
-
@forward_ssh
|
24
|
-
@enabled
|
25
|
-
@timeout
|
26
|
-
@ngrok_bin
|
31
|
+
@forward_ssh = UNSET_VALUE
|
32
|
+
@enabled = UNSET_VALUE
|
33
|
+
@timeout = UNSET_VALUE
|
34
|
+
@ngrok_bin = UNSET_VALUE
|
35
|
+
@tunnels = []
|
36
|
+
|
37
|
+
# ngrok common params
|
38
|
+
@authtoken = UNSET_VALUE
|
39
|
+
@hostname = UNSET_VALUE
|
40
|
+
@subdomain = UNSET_VALUE
|
41
|
+
|
42
|
+
# ngrok v1.x params
|
43
|
+
@httpauth = UNSET_VALUE
|
27
44
|
@inspect_addr = UNSET_VALUE
|
28
45
|
@inspect_port = UNSET_VALUE
|
29
|
-
@tunnels = []
|
30
46
|
|
31
|
-
#ngrok params
|
32
|
-
@
|
33
|
-
@
|
34
|
-
@
|
35
|
-
@subdomain = UNSET_VALUE
|
47
|
+
# ngrok v2.x params
|
48
|
+
@auth = UNSET_VALUE
|
49
|
+
@web_addr = UNSET_VALUE
|
50
|
+
@web_port = UNSET_VALUE
|
36
51
|
|
37
52
|
# Options for self-hosted ngrokd
|
38
|
-
@server_addr
|
53
|
+
@server_addr = UNSET_VALUE
|
39
54
|
@trust_host_root_certs = UNSET_VALUE
|
55
|
+
|
56
|
+
file = ENV['HOME'] + '/.ngrok2/ngrok.yml'
|
57
|
+
if File.exist?(file)
|
58
|
+
@authtoken = YAML.load_file(file)['authtoken']
|
59
|
+
end
|
40
60
|
end
|
41
61
|
|
42
|
-
def tunnel(port, proto =
|
43
|
-
host_hash = {:host => options[:host] ||
|
44
|
-
@tunnels << options.merge(:port => port).merge(
|
62
|
+
def tunnel(port, proto = 'http+https', options={})
|
63
|
+
host_hash = {:host => options[:host] || '127.0.0.1'}
|
64
|
+
@tunnels << options.merge(:port => port).merge(:proto => proto).merge(host_hash)
|
45
65
|
end
|
46
66
|
|
47
67
|
def forward_ssh?
|
@@ -59,49 +79,57 @@ module VagrantPlugins
|
|
59
79
|
def validate(machine)
|
60
80
|
errors = _detected_errors
|
61
81
|
if @ngrok_bin == UNSET_VALUE
|
62
|
-
errors <<
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
82
|
+
errors << <<MSG
|
83
|
+
Ngrok binary not found!
|
84
|
+
Make sure you have downloaded ngrok binary from http://ngrok.com
|
85
|
+
You can do this:
|
86
|
+
1) Add directory with ngrok binary your PATH
|
87
|
+
2) Add ngrok binary in ~/bin/ngrok
|
88
|
+
3) Set ngrok binary location with option foodshow.ngrok_bin in your vagrant file
|
89
|
+
|
90
|
+
You can read docs at http://github.com/express42/vagrant-foodshow
|
91
|
+
MSG
|
69
92
|
end
|
70
93
|
|
71
94
|
unless @authtoken || @server_addr
|
72
95
|
if @subdomain || @forward_ssh || @hostname
|
73
|
-
errors <<
|
96
|
+
errors << 'You should set authtoken if you use subdomain/forward_ssh/hostname options'
|
74
97
|
end
|
75
|
-
|
76
|
-
@tunnels.each do |tunnel|
|
77
98
|
|
99
|
+
@tunnels.each do |tunnel|
|
78
100
|
unless tunnel[:authtoken]
|
79
|
-
if tunnel[:hostname] || tunnel[:subdomain] || tunnel[:proto] ==
|
80
|
-
errors <<
|
101
|
+
if tunnel[:hostname] || tunnel[:subdomain] || tunnel[:proto] == 'tcp'
|
102
|
+
errors << 'You should set authtoken if you call foodshow.tunnel with subdomain/hostname/proto=tcp options'
|
81
103
|
end
|
82
104
|
end
|
83
105
|
end
|
84
106
|
|
85
107
|
end
|
86
|
-
|
87
|
-
{
|
108
|
+
|
109
|
+
{foodshow: errors}
|
88
110
|
end
|
89
111
|
|
90
112
|
def finalize!
|
91
113
|
@ngrok_bin = VagrantPlugins::Foodshow::Util::NgrokConfig.where_ngrok if @ngrok_bin == UNSET_VALUE
|
92
114
|
|
93
115
|
@trust_host_root_certs = nil if @trust_host_root_certs == UNSET_VALUE
|
94
|
-
@server_addr
|
95
|
-
|
96
|
-
@enabled
|
97
|
-
@forward_ssh
|
98
|
-
@timeout
|
99
|
-
|
100
|
-
@
|
101
|
-
@
|
102
|
-
@
|
103
|
-
|
104
|
-
@
|
116
|
+
@server_addr = nil if @server_addr == UNSET_VALUE
|
117
|
+
|
118
|
+
@enabled = false if @enabled == UNSET_VALUE
|
119
|
+
@forward_ssh = false if @forward_ssh == UNSET_VALUE
|
120
|
+
@timeout = 10 if @timeout == UNSET_VALUE
|
121
|
+
|
122
|
+
@authtoken = nil if @authtoken == UNSET_VALUE
|
123
|
+
@hostname = nil if @hostname == UNSET_VALUE
|
124
|
+
@httpauth = nil if @httpauth == UNSET_VALUE
|
125
|
+
|
126
|
+
@subdomain = nil if @subdomain == UNSET_VALUE
|
127
|
+
@inspect_addr = '127.0.0.1' if @inspect_addr == UNSET_VALUE
|
128
|
+
@inspect_pbase = 4040 if @inspect_port == UNSET_VALUE
|
129
|
+
|
130
|
+
@auth = nil if @auth == UNSET_VALUE
|
131
|
+
@web_addr = '127.0.0.1' if @web_addr == UNSET_VALUE
|
132
|
+
@web_pbase = 4040 if @web_port == UNSET_VALUE
|
105
133
|
end
|
106
134
|
end
|
107
135
|
end
|
@@ -1,13 +1,13 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require 'vagrant-foodshow/action/start.rb'
|
2
|
+
require 'vagrant-foodshow/action/stop.rb'
|
3
|
+
require 'vagrant-foodshow/util/ngrok.rb'
|
4
4
|
|
5
5
|
module VagrantPlugins
|
6
6
|
module Foodshow
|
7
|
-
class Plugin < Vagrant.plugin(
|
8
|
-
name
|
7
|
+
class Plugin < Vagrant.plugin('2')
|
8
|
+
name 'foodshow'
|
9
9
|
config 'foodshow' do
|
10
|
-
require_relative
|
10
|
+
require_relative 'config'
|
11
11
|
Config
|
12
12
|
end
|
13
13
|
action_hook :ngrok_start_handler, :machine_action_up do |hook|
|
@@ -1,12 +1,18 @@
|
|
1
|
+
require 'json'
|
1
2
|
require 'open3'
|
2
3
|
require 'timeout'
|
3
|
-
require
|
4
|
+
require 'vagrant-foodshow/util/ngrok_config.rb'
|
4
5
|
|
5
6
|
module VagrantPlugins
|
6
7
|
module Foodshow
|
7
8
|
module Util
|
8
9
|
class Ngrok
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
end
|
13
|
+
|
9
14
|
def self.start(env, tunnel)
|
15
|
+
@ngrok_version_deprecated = VagrantPlugins::Foodshow::Util::NgrokConfig.ngrok_version_deprecated?
|
10
16
|
if defined?(@@counter)
|
11
17
|
@@counter += 1
|
12
18
|
else
|
@@ -16,57 +22,72 @@ module VagrantPlugins
|
|
16
22
|
config = VagrantPlugins::Foodshow::Util::NgrokConfig.merge_config(env, tunnel)
|
17
23
|
|
18
24
|
trust_host_root_certs = config.delete(:trust_host_root_certs)
|
19
|
-
server_addr
|
25
|
+
server_addr = config.delete(:server_addr)
|
26
|
+
|
27
|
+
timeout = config.delete(:timeout)
|
28
|
+
log_file = config.delete(:log_file)
|
29
|
+
pid_file = config.delete(:pid_file)
|
30
|
+
authtoken = config.delete(:authtoken)
|
20
31
|
|
21
|
-
|
22
|
-
log_file = config.delete(:log_file)
|
23
|
-
pid_file = config.delete(:pid_file)
|
24
|
-
inspect_addr = config.delete(:inspect_addr)
|
25
|
-
authtoken = config.delete(:authtoken)
|
32
|
+
inspect_addr = config.delete(:inspect_addr)
|
26
33
|
inspect_pbase = config.delete(:inspect_pbase)
|
27
|
-
|
28
|
-
|
29
|
-
|
34
|
+
|
35
|
+
web_addr = config.delete(:web_addr)
|
36
|
+
web_pbase = config.delete(:web_pbase)
|
37
|
+
|
38
|
+
config_file = config[:config]
|
39
|
+
|
40
|
+
cmd = VagrantPlugins::Foodshow::Util::NgrokConfig.build_cmd(config)
|
30
41
|
|
31
42
|
begin
|
32
|
-
current_pid
|
43
|
+
current_pid = -1
|
33
44
|
::File.open(pid_file) { |pid| current_pid = pid.readline(); }
|
34
45
|
Process.getpgid(current_pid.to_i)
|
35
|
-
return 0, "Ngrok already running at pid #{current_pid}. Skipping tunnel",
|
46
|
+
return 0, "Ngrok already running at pid #{current_pid}. Skipping tunnel", ''
|
36
47
|
rescue
|
48
|
+
# ignored
|
37
49
|
end
|
38
50
|
|
39
|
-
::File.open(config_file,
|
51
|
+
::File.open(config_file, 'w') do |conf_h|
|
40
52
|
|
41
|
-
|
53
|
+
if @ngrok_version_deprecated
|
54
|
+
conf_h.write("inspect_addr: #{inspect_addr.to_s}:#{inspect_pbase.to_i + @@counter}\n")
|
55
|
+
else
|
56
|
+
conf_h.write("web_addr: #{web_addr.to_s}:#{web_pbase.to_i + @@counter}\n")
|
57
|
+
end
|
42
58
|
|
43
59
|
if server_addr
|
44
60
|
conf_h.write("server_addr: #{server_addr}\n")
|
45
61
|
end
|
46
62
|
|
47
|
-
if trust_host_root_certs
|
63
|
+
if trust_host_root_certs
|
48
64
|
conf_h.write("trust_host_root_certs: true\n")
|
49
65
|
end
|
50
66
|
|
51
67
|
if authtoken
|
52
|
-
|
68
|
+
if @ngrok_version_deprecated
|
69
|
+
conf_h.write("auth_token: #{authtoken}\n")
|
70
|
+
else
|
71
|
+
conf_h.write("authtoken: #{authtoken}\n")
|
72
|
+
end
|
53
73
|
end
|
54
74
|
|
55
75
|
end
|
56
76
|
|
57
77
|
pid = spawn(cmd, :out => log_file.to_s)
|
58
78
|
|
59
|
-
::File.open(pid_file,
|
79
|
+
::File.open(pid_file, 'w') { |pid_h| pid_h.write(pid) }
|
60
80
|
|
61
|
-
log_h = ::File.open(log_file,
|
81
|
+
log_h = ::File.open(log_file, 'r')
|
62
82
|
status, message, debug_output = parse_log(log_h, timeout)
|
63
83
|
log_h.close
|
64
84
|
|
65
85
|
unless status == 0
|
66
86
|
begin
|
67
87
|
::File.delete(pid_file)
|
68
|
-
::Process.kill(
|
88
|
+
::Process.kill('TERM', pid)
|
69
89
|
rescue
|
90
|
+
# ignored
|
70
91
|
end
|
71
92
|
end
|
72
93
|
|
@@ -76,6 +97,7 @@ module VagrantPlugins
|
|
76
97
|
private
|
77
98
|
|
78
99
|
def self.parse_log(log_h, timeout)
|
100
|
+
@ngrok_version_deprecated = VagrantPlugins::Foodshow::Util::NgrokConfig.ngrok_version_deprecated?
|
79
101
|
debug_output = []
|
80
102
|
begin
|
81
103
|
timeout(timeout.to_i) do
|
@@ -86,22 +108,32 @@ module VagrantPlugins
|
|
86
108
|
next
|
87
109
|
end
|
88
110
|
debug_output << stdout_str
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
111
|
+
if @ngrok_version_deprecated
|
112
|
+
if stdout_str.include? '[INFO] [client] Tunnel established at'
|
113
|
+
return 0, stdout_str[/(http\:\/\/|https\:\/\/|tcp\:\/\/).+/], debug_output
|
114
|
+
end
|
115
|
+
if stdout_str.include? '[EROR]'
|
116
|
+
if stdout_str.include? 'Error while checking for update'
|
117
|
+
next
|
118
|
+
else
|
119
|
+
return 1, stdout_str, debug_output
|
120
|
+
end
|
121
|
+
end
|
122
|
+
else
|
123
|
+
stdout_json = JSON.parse(stdout_str)
|
124
|
+
if stdout_json.include?('err') && stdout_json['err'] != '<nil>'
|
125
|
+
return 1, stdout_json['err'], debug_output
|
126
|
+
end
|
127
|
+
if stdout_json.include?('msg') && stdout_json['msg'] == 'decoded response'
|
128
|
+
if stdout_json['resp'].match(/URL:/)
|
129
|
+
return 0, stdout_json['resp'][/\sURL:(.+?)\s/, 1], debug_output
|
130
|
+
end
|
99
131
|
end
|
100
132
|
end
|
101
133
|
end
|
102
134
|
end
|
103
135
|
rescue ::Timeout::Error
|
104
|
-
return -1,
|
136
|
+
return -1, 'Ngrok wait timeout. See ngrok output:', debug_output
|
105
137
|
end
|
106
138
|
end
|
107
139
|
end
|
@@ -1,8 +1,10 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
1
3
|
module VagrantPlugins
|
2
4
|
module Foodshow
|
3
5
|
module Util
|
4
6
|
class NgrokConfig
|
5
|
-
NGROK_ALLOWED_OPTIONS = %w(authtoken hostname httpauth proto subdomain host port server_addr trust_host_root_certs)
|
7
|
+
NGROK_ALLOWED_OPTIONS = %w(authtoken hostname httpauth auth proto subdomain host port server_addr trust_host_root_certs)
|
6
8
|
|
7
9
|
def self.where_ngrok
|
8
10
|
cmd = 'ngrok'
|
@@ -17,20 +19,49 @@ module VagrantPlugins
|
|
17
19
|
return VagrantPlugins::Foodshow::Config::UNSET_VALUE
|
18
20
|
end
|
19
21
|
|
22
|
+
def self.ngrok_version
|
23
|
+
return @ngrok_version unless @ngrok_version.nil?
|
24
|
+
cmd = where_ngrok
|
25
|
+
@ngrok_version = `#{cmd} version`.gsub!(/[^\d\.]/, '')
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.ngrok_version_deprecated?
|
29
|
+
ngrok_version < '2.'
|
30
|
+
end
|
31
|
+
|
20
32
|
def self.build_cmd(config)
|
21
|
-
cmd
|
33
|
+
cmd = config.delete(:ngrok_bin)
|
22
34
|
host = config.delete(:host)
|
23
35
|
port = config.delete(:port)
|
24
36
|
|
37
|
+
if ngrok_version_deprecated?
|
38
|
+
cmd += ' -log=stdout'
|
39
|
+
else
|
40
|
+
proto = config.delete(:proto)
|
41
|
+
case proto
|
42
|
+
when 'http'
|
43
|
+
config['bind-tls'] = 'false'
|
44
|
+
when 'https'
|
45
|
+
config['bind-tls'] = 'true'
|
46
|
+
proto = 'http'
|
47
|
+
when 'http+https', 'https+http'
|
48
|
+
config['bind-tls'] = 'both'
|
49
|
+
proto = 'http'
|
50
|
+
else
|
51
|
+
# ignored
|
52
|
+
end
|
53
|
+
cmd += ' ' + proto + ' -log=stdout -log-level=debug -log-format=json'
|
54
|
+
end
|
55
|
+
|
25
56
|
config.each_pair do |opt, val|
|
26
|
-
cmd
|
57
|
+
cmd += ' -' + opt.to_s + '=' + val.to_s
|
27
58
|
end
|
28
59
|
|
29
|
-
cmd
|
60
|
+
cmd += ' ' + host + ':' + port.to_s
|
30
61
|
end
|
31
62
|
|
32
63
|
def self.get_machine_id(env)
|
33
|
-
if env[:machine].provider_name.to_s
|
64
|
+
if env[:machine].provider_name.to_s.start_with?('vmware')
|
34
65
|
machine_id = env[:machine].id.match(/\h+\-\h+\-\h+\-\h+\-\h+/)[0]
|
35
66
|
else
|
36
67
|
machine_id = env[:machine].id
|
@@ -42,17 +73,28 @@ module VagrantPlugins
|
|
42
73
|
foodshow_config = env[:machine].config.foodshow
|
43
74
|
|
44
75
|
config[:trust_host_root_certs] = foodshow_config.trust_host_root_certs if foodshow_config.trust_host_root_certs
|
45
|
-
config[:server_addr]
|
76
|
+
config[:server_addr] = foodshow_config.server_addr if foodshow_config.server_addr
|
77
|
+
|
78
|
+
config[:ngrok_bin] = foodshow_config.ngrok_bin if foodshow_config.ngrok_bin
|
79
|
+
config[:timeout] = foodshow_config.timeout if foodshow_config.timeout
|
46
80
|
|
47
|
-
config[:
|
48
|
-
config[:
|
81
|
+
config[:authtoken] = foodshow_config.authtoken if foodshow_config.authtoken
|
82
|
+
config[:hostname] = foodshow_config.hostname if foodshow_config.hostname
|
83
|
+
config[:subdomain] = foodshow_config.subdomain if foodshow_config.subdomain
|
49
84
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
85
|
+
auth = foodshow_config.auth || foodshow_config.httpauth
|
86
|
+
web_addr = foodshow_config.web_addr || foodshow_config.inspect_addr
|
87
|
+
web_pbase = foodshow_config.web_pbase || foodshow_config.inspect_pbase
|
88
|
+
|
89
|
+
if ngrok_version_deprecated?
|
90
|
+
config[:httpauth] = auth
|
91
|
+
config[:inspect_addr] = web_addr
|
92
|
+
config[:inspect_pbase] = web_pbase
|
93
|
+
else
|
94
|
+
config[:auth] = auth
|
95
|
+
config[:web_addr] = web_addr
|
96
|
+
config[:web_pbase] = web_pbase
|
97
|
+
end
|
56
98
|
|
57
99
|
tunnel.keys.each do |key|
|
58
100
|
raise unless NGROK_ALLOWED_OPTIONS.include? key.to_s
|
@@ -61,9 +103,9 @@ module VagrantPlugins
|
|
61
103
|
|
62
104
|
machine_id = get_machine_id(env)
|
63
105
|
|
64
|
-
config[:config]
|
65
|
-
config[:log_file] = (env[:tmp_path] ||
|
66
|
-
config[:pid_file] = (env[:tmp_path] ||
|
106
|
+
config[:config] = (env[:tmp_path] || '/tmp') + ('ngrok-' + machine_id + '-' + config[:port].to_s + '.cfg')
|
107
|
+
config[:log_file] = (env[:tmp_path] || '/tmp') + ('ngrok-' + machine_id + '-' + config[:port].to_s + '.log')
|
108
|
+
config[:pid_file] = (env[:tmp_path] || '/tmp') + ('ngrok-' + machine_id + '-' + config[:port].to_s + '.pid')
|
67
109
|
config
|
68
110
|
end
|
69
111
|
end
|
data/vagrant-foodshow.gemspec
CHANGED
@@ -4,21 +4,21 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'vagrant-foodshow/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'vagrant-foodshow'
|
8
8
|
spec.version = Vagrant::Foodshow::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
9
|
+
spec.authors = ['Nikita Borzykh']
|
10
|
+
spec.email = ['sample.n@gmail.com']
|
11
11
|
spec.summary = %q{You can share your vagrant vm with your colleagues easily by using vagrant-foodshow}
|
12
12
|
spec.description = spec.summary
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
13
|
+
spec.homepage = 'https://github.com/express42/vagrant-foodshow'
|
14
|
+
spec.license = 'MIT'
|
15
15
|
|
16
|
-
spec.rubyforge_project =
|
16
|
+
spec.rubyforge_project = 'vagrant-foodshow'
|
17
17
|
|
18
18
|
spec.files = `git ls-files -z`.split("\x0")
|
19
19
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
20
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
|
-
spec.require_paths = [
|
21
|
+
spec.require_paths = ['lib']
|
22
22
|
|
23
|
-
spec.add_development_dependency
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.5'
|
24
24
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-foodshow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nikita Borzykh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -65,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
65
65
|
version: '0'
|
66
66
|
requirements: []
|
67
67
|
rubyforge_project: vagrant-foodshow
|
68
|
-
rubygems_version: 2.
|
68
|
+
rubygems_version: 2.4.4
|
69
69
|
signing_key:
|
70
70
|
specification_version: 4
|
71
71
|
summary: You can share your vagrant vm with your colleagues easily by using vagrant-foodshow
|