pacproxy 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/lib/pacproxy/pacproxy.rb +22 -3
- data/lib/pacproxy/version.rb +1 -1
- data/pacproxy.gemspec +1 -1
- data/spec/pacproxy_spec.rb +20 -0
- 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: eda757cf693b406eb8f4502a3e85b2b0e326b95d
|
4
|
+
data.tar.gz: d8ed42f024dfebcccf979f4e05e5c2df8eb0d8ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb5e9a2dcfdbea5c337df0142e049081a9f718bdefe59ef3c62979aca90cf38c19ff9dd1c944858eb193c52a53818043046de28be0e8fa740297b2d13818e979
|
7
|
+
data.tar.gz: 706eb4bebce43f55c59572d1afb6f55c6292305adbafe3a3660bdee0cfe11546040805188c90ae25ce6784be925bbe0c72f52a2eff2c9b1f95b1a204e67ed14a
|
data/lib/pacproxy/pacproxy.rb
CHANGED
@@ -18,7 +18,27 @@ module Pacproxy
|
|
18
18
|
return unless @pac
|
19
19
|
|
20
20
|
proxy_line = @pac.find(request_uri(req))
|
21
|
-
lookup_proxy_uri(proxy_line)
|
21
|
+
proxy = lookup_proxy_uri(proxy_line)
|
22
|
+
create_proxy_uri(proxy, req.header)
|
23
|
+
end
|
24
|
+
|
25
|
+
def create_proxy_uri(proxy, header)
|
26
|
+
return nil unless proxy
|
27
|
+
return URI.parse("http://#{proxy}") unless
|
28
|
+
header.key?('proxy-authorization')
|
29
|
+
|
30
|
+
auth = header['proxy-authorization'][0]
|
31
|
+
pattern = /basic (\S+)/i
|
32
|
+
basic_auth = pattern.match(auth)[1]
|
33
|
+
header.delete('proxy-authorization')
|
34
|
+
|
35
|
+
return URI.parse("http://#{proxy}") unless basic_auth
|
36
|
+
|
37
|
+
URI.parse("http://#{basic_auth.unpack('m').first}@#{proxy}")
|
38
|
+
end
|
39
|
+
|
40
|
+
def proxy_auth(req, res)
|
41
|
+
@config[:ProxyAuthProc].call(req, res) if @config[:ProxyAuthProc]
|
22
42
|
end
|
23
43
|
|
24
44
|
private
|
@@ -37,8 +57,7 @@ module Pacproxy
|
|
37
57
|
nil
|
38
58
|
when /PROXY/
|
39
59
|
primary_proxy = proxy_line.split(';')[0]
|
40
|
-
|
41
|
-
URI.parse("http://#{proxy}")
|
60
|
+
/PROXY (.*)/.match(primary_proxy)[1]
|
42
61
|
end
|
43
62
|
end
|
44
63
|
|
data/lib/pacproxy/version.rb
CHANGED
data/pacproxy.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["ota_h@nifty.com"]
|
11
11
|
spec.summary = %q{A proxy server works with proxy.pac}
|
12
12
|
spec.description = %q{A proxy server works with proxy.pac}
|
13
|
-
spec.homepage = ""
|
13
|
+
spec.homepage = "https://github.com/otahi/pacproxy"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
data/spec/pacproxy_spec.rb
CHANGED
@@ -126,5 +126,25 @@ describe Pacproxy do
|
|
126
126
|
res = c.get('http://127.0.0.1:13080/noproxy/')
|
127
127
|
expect(res.status).to eq(200)
|
128
128
|
end
|
129
|
+
|
130
|
+
it 'transfer request with auth to server via parent proxy' do
|
131
|
+
@pacproxy_server =
|
132
|
+
Pacproxy::Pacproxy.new(Port: 13_128,
|
133
|
+
Proxypac: 'spec/all_proxy.pac')
|
134
|
+
|
135
|
+
Thread.new { @pacproxy_server.start }
|
136
|
+
wait_server_status(@pacproxy_server, :Running)
|
137
|
+
|
138
|
+
c = HTTPClient.new('http://127.0.0.1:13128')
|
139
|
+
header = { header: { 'proxy-authorization' =>
|
140
|
+
%Q(Basic #{['user01:pass01'].pack('m').delete("\n")})
|
141
|
+
}
|
142
|
+
}
|
143
|
+
p header: header
|
144
|
+
res = c.get('http://127.0.0.1:13080/', header)
|
145
|
+
expect(res.status).to eq(200)
|
146
|
+
res = c.get('http://127.0.0.1:13080/noproxy/', header)
|
147
|
+
expect(res.status).to eq(200)
|
148
|
+
end
|
129
149
|
end
|
130
150
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pacproxy
|
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
|
- OTA Hiroshi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pac
|
@@ -155,7 +155,7 @@ files:
|
|
155
155
|
- spec/pacproxy_spec.rb
|
156
156
|
- spec/partial_proxy.pac
|
157
157
|
- spec/spec_helper.rb
|
158
|
-
homepage:
|
158
|
+
homepage: https://github.com/otahi/pacproxy
|
159
159
|
licenses:
|
160
160
|
- MIT
|
161
161
|
metadata: {}
|