rubygems-localproxy 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 327fa6e1730804ddaab7cb5eec7b32b5e5d80c8a
4
+ data.tar.gz: b4ef0c8ebdcd6655fefe067d0b89e7e370e9d6a6
5
+ SHA512:
6
+ metadata.gz: 98397090671ff8b3bacf8a23ada992229adf9542eaed358b17ab7f6dc821dd8c921e8ac8a0c0329165f12581b8c3e7f69caf044b12644fcbc3ff1fe94fe6f2ee
7
+ data.tar.gz: 5a3b9d186a89193b25c1b439d53262f9af00ec91f5bd713ed535f6b3c3d17ed5eaa691a8dab5472fcc062ef7483ecc3ec34a06453b92bf71320abbb8a7bee602
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rubygems-localproxy.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Artur Roszczyk
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,35 @@
1
+ # Rubygems::Localproxy
2
+
3
+ This gem is for setting up squid proxy in order to speed up
4
+ resolving rubygems dependencies.
5
+
6
+ ## Installation
7
+
8
+ install it yourself as:
9
+
10
+ $ gem install rubygems-localproxy
11
+ $ rubygems-localproxy init
12
+
13
+ ## Usage
14
+
15
+ $ rubygems-localproxy start
16
+ $ eval $(rubygems-localproxy use)
17
+ $ cd project/dir
18
+ $ bundle
19
+
20
+ ## Caveats
21
+
22
+ Currently cachces only non-SSL requests, so bundler will be faster
23
+ only if you have following line in your Gemfile:
24
+
25
+ source 'http://rubygems.org/'
26
+
27
+ Please be warned: this is not secure production setting!
28
+
29
+ ## Contributing
30
+
31
+ 1. Fork it
32
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
33
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
34
+ 4. Push to the branch (`git push origin my-new-feature`)
35
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env ruby
2
+ require 'fileutils'
3
+ require 'erb'
4
+
5
+ config_dir = File.expand_path('~/.gems-proxy')
6
+
7
+ class SquidConfig
8
+ def initialize working_dir
9
+ @working_dir = working_dir
10
+ end
11
+
12
+ def render
13
+ ERB.new(template).result(binding)
14
+ end
15
+
16
+ private
17
+
18
+ attr_reader :working_dir
19
+
20
+ def template
21
+ File.read(File.expand_path('../../config/squid.conf.erb', __FILE__))
22
+ end
23
+ end
24
+
25
+ def generate_config config_dir
26
+ config = SquidConfig.new(config_dir)
27
+
28
+ File.open(File.join(config_dir, "squid.conf"), "w") do |config_file|
29
+ config_file.write config.render
30
+ end
31
+ end
32
+
33
+ def initialize_disk_cache config_dir
34
+ system "/usr/local/sbin/squid -f '#{config_dir}/squid.conf' -z"
35
+ end
36
+
37
+ case ARGV[0]
38
+ when "init"
39
+ unless Dir.exists? config_dir
40
+ Dir.mkdir(config_dir)
41
+ FileUtils.cp File.expand_path("../../config/rewrite.rb", __FILE__),
42
+ File.join(config_dir, "rewrite.rb")
43
+ generate_config config_dir
44
+ initialize_disk_cache config_dir
45
+ end
46
+ when "start"
47
+ system "/usr/local/sbin/squid -f '#{config_dir}/squid.conf'"
48
+ when "stop"
49
+ system "/usr/local/sbin/squid -f '#{config_dir}/squid.conf' -k shutdown"
50
+ when "use"
51
+ puts "alias bundle='http_proxy=http://localhost:2894/ \\bundle'"
52
+ end
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env ruby
2
+ # url rewriter for rubygems squid proxy
3
+
4
+ STDOUT.sync = true
5
+
6
+ while line = gets
7
+ url = line.split(' ')[0]
8
+
9
+ # Cargo-culted this conditional, not sure if it is necessary
10
+ response = if url
11
+ # Need to find a better way to cache this redirect, rather than hard-coding
12
+ # it.
13
+ if url.include?("//rubygems.org/quick/")
14
+ "302:" + url.gsub(
15
+ "//rubygems.org/",
16
+ "//production.cf.rubygems.org/"
17
+ )
18
+ else
19
+ ""
20
+ end
21
+ else
22
+ ""
23
+ end
24
+
25
+ puts response
26
+ end
@@ -0,0 +1,87 @@
1
+ #
2
+ # Recommended minimum configuration:
3
+ #
4
+
5
+ # Example rule allowing access from your local networks.
6
+ # Adapt to list your (internal) IP networks from where browsing
7
+ # should be allowed
8
+ acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
9
+ acl localnet src 172.16.0.0/12 # RFC1918 possible internal network
10
+ acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
11
+ acl localnet src fc00::/7 # RFC 4193 local private network range
12
+ acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines
13
+
14
+ acl SSL_ports port 443
15
+ acl Safe_ports port 80 # http
16
+ acl Safe_ports port 21 # ftp
17
+ acl Safe_ports port 443 # https
18
+ acl Safe_ports port 70 # gopher
19
+ acl Safe_ports port 210 # wais
20
+ acl Safe_ports port 1025-65535 # unregistered ports
21
+ acl Safe_ports port 280 # http-mgmt
22
+ acl Safe_ports port 488 # gss-http
23
+ acl Safe_ports port 591 # filemaker
24
+ acl Safe_ports port 777 # multiling http
25
+ acl CONNECT method CONNECT
26
+
27
+ #
28
+ # Recommended minimum Access Permission configuration:
29
+ #
30
+ # Only allow cachemgr access from localhost
31
+ http_access allow localhost manager
32
+ http_access deny manager
33
+
34
+ # Deny requests to certain unsafe ports
35
+ http_access deny !Safe_ports
36
+
37
+ # Deny CONNECT to other than secure SSL ports
38
+ http_access deny CONNECT !SSL_ports
39
+
40
+ # We strongly recommend the following be uncommented to protect innocent
41
+ # web applications running on the proxy server who think the only
42
+ # one who can access services on "localhost" is a local user
43
+ #http_access deny to_localhost
44
+
45
+ #
46
+ # INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
47
+ #
48
+
49
+ # Example rule allowing access from your local networks.
50
+ # Adapt localnet in the ACL section to list your (internal) IP networks
51
+ # from where browsing should be allowed
52
+ http_access allow localnet
53
+ http_access allow localhost
54
+
55
+ # And finally deny all other access to this proxy
56
+ http_access deny all
57
+
58
+
59
+ # Squid normally listens to port 3128
60
+ http_port 2894
61
+
62
+ # Uncomment and adjust the following to add a disk cache directory.
63
+ cache_dir ufs <%= working_dir %>/cache 100 16 256
64
+
65
+ # Leave coredumps in the first cache dir
66
+ coredump_dir <%= working_dir %>/cache
67
+
68
+ always_direct allow all
69
+ ssl_bump allow all
70
+ sslproxy_cert_error allow all
71
+ sslproxy_flags DONT_VERIFY_PEER NO_DEFAULT_CA
72
+
73
+ # Add any of your own refresh_pattern entries above these.
74
+ # refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
75
+ # refresh_pattern . 0 20% 4320
76
+ refresh_pattern -i /api/v1/dependencies 900 100% 86400
77
+ refresh_pattern .rz 2592000 100% 2592000 ignore-no-cache ignore-reload override-expire override-lastmod
78
+ refresh_pattern .gem 2592000 100% 2592000
79
+ url_rewrite_program <%= working_dir %>/rewrite.rb
80
+
81
+
82
+
83
+ # sslcrtd_program /usr/local/squid/libexec/ssl_crtd -s /usr/local/squid/var/lib/ssl_db -M 4MB
84
+ # sslcrtd_children 5
85
+
86
+ access_log <%= working_dir %>/access.log
87
+ cache_log <%= working_dir %>/cache.log
@@ -0,0 +1,7 @@
1
+ require "rubygems/localproxy/version"
2
+
3
+ module Rubygems
4
+ module Localproxy
5
+ # Your code goes here...
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ module Rubygems
2
+ module Localproxy
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rubygems/localproxy/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rubygems-localproxy"
8
+ spec.version = Rubygems::Localproxy::VERSION
9
+ spec.authors = ["Artur Roszczyk"]
10
+ spec.email = ["artur.roszczyk@gmail.com"]
11
+ spec.description = %q{Keep local cache of rubygems to speed up resolving dependencies}
12
+ spec.summary = %q{Uses squid}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ end
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rubygems-localproxy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Artur Roszczyk
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-04-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Keep local cache of rubygems to speed up resolving dependencies
42
+ email:
43
+ - artur.roszczyk@gmail.com
44
+ executables:
45
+ - gem-localproxy
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - .gitignore
50
+ - Gemfile
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - bin/gem-localproxy
55
+ - config/rewrite.rb
56
+ - config/squid.conf.erb
57
+ - lib/rubygems/localproxy.rb
58
+ - lib/rubygems/localproxy/version.rb
59
+ - rubygems-localproxy.gemspec
60
+ homepage: ''
61
+ licenses:
62
+ - MIT
63
+ metadata: {}
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubyforge_project:
80
+ rubygems_version: 2.0.3
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: Uses squid
84
+ test_files: []
85
+ has_rdoc: