hosty 0.0.4 → 0.0.5
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 +4 -4
- data/exe/hosty +29 -0
- data/hosty.gemspec +2 -1
- data/lib/hosty/version.rb +3 -0
- data/lib/hosty/virtual_hostable.rb +23 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a0b03e26f73d0a8a5812179b5243007e8fba96d
|
4
|
+
data.tar.gz: d445d547e01932c793cc11f2d15c8fac4d7fdc96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 552789a180be2e515bdc4e39dc0d89daca23797df2ff32768dab1208b5e5ce12cbb34011b405dd9ac9c8ad837a5d79dac5e8d64d5c72ee1fb40ce964f92118f0
|
7
|
+
data.tar.gz: b3286bcaab54467a2622451548a7bda6f3d713b3905659f920e825b76195835396eddcde9240f1c5abe181fa0c3fbf7e47beae1b0fcf7197db678d6ea05bbc3d
|
data/exe/hosty
CHANGED
@@ -1,7 +1,36 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
require 'optparse'
|
4
|
+
require 'pathname'
|
3
5
|
require 'rack'
|
4
6
|
|
7
|
+
$: << File.expand_path('../../lib', Pathname.new(__FILE__).realpath)
|
8
|
+
|
9
|
+
require 'hosty'
|
10
|
+
|
11
|
+
|
5
12
|
config = File.expand_path('../../config.ru', __FILE__)
|
6
13
|
|
14
|
+
opts = OptionParser.new do |opts|
|
15
|
+
opts.banner = 'hosty: /etc/hosts based tiny reverse proxy'
|
16
|
+
opts.define_head 'Usage: hosty [options]'
|
17
|
+
opts.separator ''
|
18
|
+
opts.separator 'Options:'
|
19
|
+
|
20
|
+
opts.on '-d', '--debug', 'Turn on debug mode' do
|
21
|
+
$HOSTY_DEBUG = true
|
22
|
+
end
|
23
|
+
|
24
|
+
opts.on_tail '-h', '--help', 'Show this message' do
|
25
|
+
puts opts
|
26
|
+
exit
|
27
|
+
end
|
28
|
+
|
29
|
+
opts.on_tail '-v', '--version', 'Show version' do
|
30
|
+
puts Hosty::VERSION
|
31
|
+
exit
|
32
|
+
end
|
33
|
+
end
|
34
|
+
opts.parse!
|
35
|
+
|
7
36
|
Rack::Server.start(config: config, Host: '127.0.0.1', Port: 80)
|
data/hosty.gemspec
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
lib = File.expand_path('../lib', __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'hosty/version'
|
4
5
|
|
5
6
|
Gem::Specification.new do |spec|
|
6
7
|
spec.name = "hosty"
|
7
|
-
spec.version =
|
8
|
+
spec.version = Hosty::VERSION
|
8
9
|
spec.authors = ["Shintaro Kojima"]
|
9
10
|
spec.email = ["goodies@codeout.net"]
|
10
11
|
|
@@ -1,7 +1,30 @@
|
|
1
1
|
module Hosty
|
2
2
|
module VirtualHostable
|
3
|
+
def proxy
|
4
|
+
debug "<= #{env['REQUEST_METHOD']} #{source_request.url}"
|
5
|
+
|
6
|
+
return app.call(env) if uri.nil?
|
7
|
+
return https_redirect if need_https_redirect?
|
8
|
+
|
9
|
+
setup_request
|
10
|
+
setup_response_headers
|
11
|
+
|
12
|
+
debug " -> #{env['REQUEST_METHOD']} #{uri}"
|
13
|
+
|
14
|
+
transform_response(rack_response).tap {|t|
|
15
|
+
debug " <- #{t[0]}"
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
3
19
|
def rules
|
4
20
|
super.select {|r| r.options[:vhost] == env['SERVER_NAME'] }
|
5
21
|
end
|
22
|
+
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def debug(message)
|
27
|
+
puts "#{Time.now} #{message}" if $HOSTY_DEBUG
|
28
|
+
end
|
6
29
|
end
|
7
30
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hosty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shintaro Kojima
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack-reverse-proxy
|
@@ -93,6 +93,7 @@ files:
|
|
93
93
|
- hosty.gemspec
|
94
94
|
- lib/hosty.rb
|
95
95
|
- lib/hosty/hosts.rb
|
96
|
+
- lib/hosty/version.rb
|
96
97
|
- lib/hosty/virtual_hostable.rb
|
97
98
|
- lib/portable_string.rb
|
98
99
|
homepage: https://github.com/codeout/hosty
|