13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/uwa/proxy.rb', line 13
def process(req,res)
query = CGI::parse(req.params['QUERY_STRING'].to_s)
url = query['url'].to_a.first
if url.nil?
UWA::Server.log :ignore, req.params['REQUEST_URI']
else
url = URI.parse(query['url'].to_a.first.to_s.strip)
if @@ALLOWED_IP.include? req.params['REMOTE_ADDR']
res.start(200) do |head, out|
head["Content-Type"] = "text/xml"
unless url.nil?
UWA::Server.log :proxy, url
res = Net::HTTP.start(url.host, url.port) do |http|
http.get(url.request_uri)
end
out.write(res.body)
end
end
else
UWA::Server.log :denied, "#{url} from #{req.params['REMOTE_ADDR']}"
end
end
end
|