pacproxy 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: 3640640110abb9f0a611723777390e1047433198
4
- data.tar.gz: 98acc0fd1efc7786b7976d1dfea84207c5752fe8
3
+ metadata.gz: eda757cf693b406eb8f4502a3e85b2b0e326b95d
4
+ data.tar.gz: d8ed42f024dfebcccf979f4e05e5c2df8eb0d8ea
5
5
  SHA512:
6
- metadata.gz: dec5acf4e26b12e0e7c9a0c8e4ad9e6a4993469af55a6c20d099f8995aa0cb09520e8aa9eadc68f86fa0ab23434f4fa72a146f99c819887892e7b28b213bdeac
7
- data.tar.gz: 0e4579441de1e8399910eba31c323385600270048e1a3de4c3eebe6b2d09eb01d708b8b906a53f452033959b874d73e235cfa038f9156114c3ec48a7acaca581
6
+ metadata.gz: fb5e9a2dcfdbea5c337df0142e049081a9f718bdefe59ef3c62979aca90cf38c19ff9dd1c944858eb193c52a53818043046de28be0e8fa740297b2d13818e979
7
+ data.tar.gz: 706eb4bebce43f55c59572d1afb6f55c6292305adbafe3a3660bdee0cfe11546040805188c90ae25ce6784be925bbe0c72f52a2eff2c9b1f95b1a204e67ed14a
@@ -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
- proxy = /PROXY (.*)/.match(primary_proxy)[1]
41
- URI.parse("http://#{proxy}")
60
+ /PROXY (.*)/.match(primary_proxy)[1]
42
61
  end
43
62
  end
44
63
 
@@ -1,4 +1,4 @@
1
1
  # Pacproxy provides http/https proxy routed with proxy.pac.
2
2
  module Pacproxy
3
- VERSION = '0.0.4'
3
+ VERSION = '0.0.5'
4
4
  end
@@ -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")
@@ -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
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 00:00:00.000000000 Z
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: {}