hosty 0.0.1 → 0.0.2
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/README.md +20 -6
- data/config.ru +6 -1
- data/exe/hosty +1 -3
- data/hosty.gemspec +1 -1
- data/lib/hosty.rb +0 -2
- data/lib/hosty/hosts.rb +28 -11
- data/lib/portable_string.rb +0 -8
- metadata +2 -4
- data/lib/hosty/scheme_detectable.rb +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa4c812980a81da36b3932c3d701f91890b01a9a
|
4
|
+
data.tar.gz: c5d0e7696dc1b6b551cfffa8d2800f0aea1aa9bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a1bfd75a8406de3be137551db8169522457eac4efee1019852cc7ad88c64babb0202a8b46e1b432e26b89a4457c9631a0e8c47db7ffdc0dfbb7b3f7c41ede91
|
7
|
+
data.tar.gz: ecb768e70845bc7c87a7356cb53fff1f108b305c49fec3cf77c1020ab3abf61bff5f80cb729d7916a2d18bc26ef878916dc8c14d973fa8933c14499b4dc37a09
|
data/README.md
CHANGED
@@ -31,14 +31,28 @@ If you have lines below in your ```/etc/hosts```:
|
|
31
31
|
127.0.0.1 rails # :3000
|
32
32
|
```
|
33
33
|
|
34
|
-
Hosty accepts ```http
|
35
|
-
into ```http
|
34
|
+
Hosty accepts ```http://internal.example.com/foo``` locally and proxies it
|
35
|
+
into ```http://internal.example.com:8080/foo``` for example.
|
36
36
|
|
37
|
-
Shortly,
|
38
37
|
|
39
|
-
|
40
|
-
|
41
|
-
|
38
|
+
### Use https
|
39
|
+
|
40
|
+
You can specify ```tls``` option at the end of each line:
|
41
|
+
|
42
|
+
```
|
43
|
+
127.0.0.1 internal.example.com internal # :8080 tls
|
44
|
+
```
|
45
|
+
|
46
|
+
Hosty accepts ```http://internal.example.com/foo``` and proxies into ```https://internal.example.com:8080/foo```. Also, you can spacify 'verify_none' to skip server cert verification.
|
47
|
+
|
48
|
+
```
|
49
|
+
127.0.0.1 internal.example.com internal # :8080 tls verify_none
|
50
|
+
```
|
51
|
+
|
52
|
+
**Note**
|
53
|
+
|
54
|
+
The URL scheme in your browser is always 'http'.
|
55
|
+
|
42
56
|
|
43
57
|
|
44
58
|
## Copyright and License
|
data/config.ru
CHANGED
@@ -3,9 +3,14 @@ require 'hosty'
|
|
3
3
|
use Rack::ReverseProxy do
|
4
4
|
Hosty::Hosts.mapping do |map|
|
5
5
|
port = map[:port]
|
6
|
+
scheme = map[:options].include?('tls') ? 'https' : 'http'
|
7
|
+
|
8
|
+
proxy_options = {}
|
9
|
+
proxy_options[:verify_mode] = OpenSSL::SSL::VERIFY_NONE if map[:options].include?('verify_none')
|
10
|
+
|
6
11
|
|
7
12
|
map[:servers].each do |server|
|
8
|
-
reverse_proxy /(.*)/, "
|
13
|
+
reverse_proxy /(.*)/, "#{scheme}://#{server}:#{port}/$1", {vhost: server}.merge(proxy_options)
|
9
14
|
end
|
10
15
|
end
|
11
16
|
end
|
data/exe/hosty
CHANGED
@@ -4,6 +4,4 @@ require 'rack'
|
|
4
4
|
|
5
5
|
config = File.expand_path('../../config.ru', __FILE__)
|
6
6
|
|
7
|
-
|
8
|
-
Thread.start { Rack::Server.start(config: config, Port: 443) }.join # single ^C to kill all
|
9
|
-
|
7
|
+
Rack::Server.start(config: config, Port: 80)
|
data/hosty.gemspec
CHANGED
data/lib/hosty.rb
CHANGED
data/lib/hosty/hosts.rb
CHANGED
@@ -13,19 +13,36 @@ module Hosty
|
|
13
13
|
private
|
14
14
|
|
15
15
|
def parse(str, &block)
|
16
|
-
|
17
|
-
columns = l.split
|
18
|
-
next unless columns[0].local_address?
|
19
|
-
|
20
|
-
if columns.last.port_number?
|
21
|
-
yield servers: columns[1..-2], port: columns.last.port_number
|
22
|
-
end
|
23
|
-
end
|
16
|
+
str.each_line {|l| new(l).parse &block }
|
24
17
|
end
|
18
|
+
end
|
25
19
|
|
26
|
-
|
27
|
-
|
28
|
-
|
20
|
+
|
21
|
+
def initialize(line)
|
22
|
+
@line = line
|
23
|
+
end
|
24
|
+
|
25
|
+
def parse(&block)
|
26
|
+
return unless content
|
27
|
+
yield content
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def content
|
34
|
+
return @content if @content
|
35
|
+
|
36
|
+
columns = @line.split
|
37
|
+
return unless columns[0].local_address?
|
38
|
+
|
39
|
+
mark_index = columns.index('#')
|
40
|
+
return unless mark_index
|
41
|
+
return unless columns[mark_index+1] && columns[mark_index+1].port_number?
|
42
|
+
|
43
|
+
@content = {servers: columns[1..mark_index-1],
|
44
|
+
port: columns[mark_index+1].port_number,
|
45
|
+
options: columns[mark_index+2..-1]}
|
29
46
|
end
|
30
47
|
end
|
31
48
|
end
|
data/lib/portable_string.rb
CHANGED
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shintaro Kojima
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack-reverse-proxy
|
@@ -93,7 +93,6 @@ files:
|
|
93
93
|
- hosty.gemspec
|
94
94
|
- lib/hosty.rb
|
95
95
|
- lib/hosty/hosts.rb
|
96
|
-
- lib/hosty/scheme_detectable.rb
|
97
96
|
- lib/hosty/virtual_hostable.rb
|
98
97
|
- lib/portable_string.rb
|
99
98
|
homepage: https://github.com/codeout/hosty
|
@@ -120,4 +119,3 @@ signing_key:
|
|
120
119
|
specification_version: 4
|
121
120
|
summary: "/etc/hosts based tiny reverse proxy."
|
122
121
|
test_files: []
|
123
|
-
has_rdoc:
|