hosty 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4a5d97a155e2b26377c36d975ee721233cc22b4d
4
- data.tar.gz: 07e333c168cf0ccb4d1e9f30884b50752d13bc4d
3
+ metadata.gz: 8a0b03e26f73d0a8a5812179b5243007e8fba96d
4
+ data.tar.gz: d445d547e01932c793cc11f2d15c8fac4d7fdc96
5
5
  SHA512:
6
- metadata.gz: 54fab775c050f2e6477c748efba8a7e2dd82125ad487adbc1cc1e29e20cb9a100b2152945aba3d9b5ab41ee65b20c77ec6f467868a4fe58f29b26b4517484d2c
7
- data.tar.gz: b64946a209185702cd9d711246103dd6b6806dd7bacdd43248c1b4141b5f7fb85fcc755bd1fcc75faead87f526dbf8be59bbb6aa7fb5b7051d3dedca38e70025
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)
@@ -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 = '0.0.4'
8
+ spec.version = Hosty::VERSION
8
9
  spec.authors = ["Shintaro Kojima"]
9
10
  spec.email = ["goodies@codeout.net"]
10
11
 
@@ -0,0 +1,3 @@
1
+ module Hosty
2
+ VERSION = '0.0.5'
3
+ end
@@ -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
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: 2017-10-26 00:00:00.000000000 Z
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