vagrant-proxy 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +5 -0
- data/etc/polipo.config +7 -0
- data/lib/vagrant-proxy.rb +2 -0
- data/lib/vagrant-proxy/action.rb +27 -0
- data/lib/vagrant-proxy/action/config_guest_iptables_for_proxy.rb +50 -0
- data/lib/vagrant-proxy/action/is_running_or_active.rb +47 -0
- data/lib/vagrant-proxy/command.rb +6 -0
- data/lib/vagrant-proxy/config.rb +16 -0
- data/lib/vagrant-proxy/plugin.rb +47 -0
- data/lib/vagrant-proxy/version.rb +5 -0
- data/vagrant-proxy.gemspec +19 -0
- metadata +60 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NWZjYzU1MzMyYzZkYjg5N2ZjNDdlN2UyNTAxOTg5NTgzY2QxMTNjYw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NzQ3MmZkYWMyODkwYjQzNTBhNjU2NjViOTRkNTQwOGJlZjI5NjkyMA==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YTA0MWFkODFjMGFkMzkwYjFlM2UzNjgzZGU4M2FiMzNiNmE2ZDAyYjE3NWY3
|
10
|
+
MGQzNmJiYzViZGRmMTAzYTViYzNmYzBlMGQ3NTk3YmY1NjQ0YjcxNWQ1YzFm
|
11
|
+
YzgyZjZjY2EyYjA3YjdkNDdhNzIwMzlhNDI4NDIwMTI5OTkxMWQ=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
OGE5ZjkxZTllMzk2ZDUyZjNlYWRiNjA1MWJmMDFhZGQ1ZGU0MTgzMGU1OTJh
|
14
|
+
NjhlM2M2ZTg0Mzg1MmRlMjJjODkyZGE1OGNjNDMzYWRkZWYxNGRlY2E5NTkw
|
15
|
+
NTc5MmI3M2I5ZjkzZGM2MDcxMGJjZjJiNWRmMTQ2YTIwMjYxOWQ=
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Clinton Wolfe
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Vagrant::Proxy
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'vagrant-proxy'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install vagrant-proxy
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/etc/polipo.config
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require "vagrant/action/builder"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module Proxy
|
5
|
+
module Action
|
6
|
+
include Vagrant::Action::Builtin
|
7
|
+
|
8
|
+
# autoload :SetupProxyOnHost, File.expand_path("../action/setup_proxy_on_host", __FILE__)
|
9
|
+
autoload :ConfigGuestIpTablesForProxy, File.expand_path("../action/config_guest_iptables_for_proxy", __FILE__)
|
10
|
+
autoload :IsRunningOrActive, File.expand_path("../action/is_running_or_active", __FILE__)
|
11
|
+
|
12
|
+
def self.setup_proxying
|
13
|
+
@setup_proxying ||= ::Vagrant::Action::Builder.new.tap do |b|
|
14
|
+
b.use ConfigValidate
|
15
|
+
b.use Call, IsRunningOrActive do |env1, b2|
|
16
|
+
if env1[:result]
|
17
|
+
# b2.use SetupProxyOnHost
|
18
|
+
b2.use ConfigGuestIpTablesForProxy
|
19
|
+
b2.use SSHRun
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module Proxy
|
3
|
+
module Action
|
4
|
+
class ConfigGuestIpTablesForProxy
|
5
|
+
|
6
|
+
def initialize(app, env)
|
7
|
+
@app = app
|
8
|
+
# Config#finalize! SHOULD be called automatically
|
9
|
+
env[:global_config].omnibus.finalize!
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
# (2013-04-27 16:35:42) newgoliath: http://pastebin.com/D0McquR1
|
14
|
+
# (2013-04-27 17:05:08) hanskreuger: sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to 3128
|
15
|
+
# (2013-04-27 17:06:12) juliancdunn: s/3128/8123
|
16
|
+
# (2013-04-27 17:19:59) juliancdunn: hanskreuger: is this helpful? http://www.tldp.org/HOWTO/TransparentProxy-6.html
|
17
|
+
# (2013-04-27 17:28:54) hanskreuger: sudo iptables -t nat -I OUTPUT --src 0/0 -p tcp --dport 80 -j DNAT --to 10.0.2.2:8123
|
18
|
+
|
19
|
+
def call(env)
|
20
|
+
# foo = env[:global_config].proxy.foo
|
21
|
+
|
22
|
+
env[:ui].info("Setting up iptables in guest for proxying... ")
|
23
|
+
env[:ssh_run_command] = make_iptables_command(env[:global_config].proxy)
|
24
|
+
|
25
|
+
@app.call(env)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
def make_iptables_command(conf)
|
30
|
+
# lalalala idempodency lalalala
|
31
|
+
cmd = ""
|
32
|
+
cmd << "sudo iptables -t nat -L -n | grep vagrant-proxy > /dev/null "
|
33
|
+
cmd << " || "
|
34
|
+
cmd << "sudo "
|
35
|
+
cmd << "iptables "
|
36
|
+
cmd << "-t nat "
|
37
|
+
cmd << "-I OUTPUT "
|
38
|
+
cmd << "--src 0/0 "
|
39
|
+
cmd << "-p tcp "
|
40
|
+
cmd << "--dport 80 "
|
41
|
+
cmd << "-j DNAT "
|
42
|
+
cmd << "-m comment --comment vagrant-proxy " # We use this to detect the rule
|
43
|
+
cmd << "--to 10.0.2.2:8123" # TODO - parameterize from conf
|
44
|
+
cmd << ""
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2013, Seth Chisamore
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
module VagrantPlugins
|
18
|
+
module Proxy
|
19
|
+
module Action
|
20
|
+
# @author Seth Chisamore <schisamo@opscode.com>
|
21
|
+
#
|
22
|
+
# This action checks if the machine is running (virtualbox) or active
|
23
|
+
# (aws, rackspace).
|
24
|
+
#
|
25
|
+
class IsRunningOrActive
|
26
|
+
def initialize(app, env)
|
27
|
+
@app = app
|
28
|
+
end
|
29
|
+
|
30
|
+
def call(env)
|
31
|
+
# Set the result to be true if the machine is :running or :active.
|
32
|
+
if (env[:machine].state.id == :running) ||
|
33
|
+
(env[:machine].state.id == :active)
|
34
|
+
|
35
|
+
env[:result] = true
|
36
|
+
else
|
37
|
+
env[:result] = false
|
38
|
+
end
|
39
|
+
|
40
|
+
# Call the next if we have one (but we shouldn't, since this
|
41
|
+
# middleware is built to run with the Call-type middlewares)
|
42
|
+
@app.call(env)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module Proxy
|
3
|
+
|
4
|
+
autoload :Action, 'vagrant-proxy/action'
|
5
|
+
|
6
|
+
class Plugin < Vagrant.plugin("2")
|
7
|
+
name "vagrant-proxy"
|
8
|
+
description "Vagrant Proxy plugin - proxy guest HTTP requests"
|
9
|
+
|
10
|
+
config "proxy" do
|
11
|
+
require_relative "config"
|
12
|
+
Config
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.provision(hook)
|
16
|
+
hook.before(Vagrant::Action::Builtin::Provision, Action.setup_proxying)
|
17
|
+
|
18
|
+
# BEGIN workaround
|
19
|
+
#
|
20
|
+
# Currently hooks attached to {Vagrant::Action::Builtin::Provision} are
|
21
|
+
# not wired into the middleware return path. My current workaround is to
|
22
|
+
# fire after anything boot related which wedges in right before the
|
23
|
+
# actual real run of the provisioner.
|
24
|
+
|
25
|
+
hook.after(VagrantPlugins::ProviderVirtualBox::Action::Boot, Action.setup_proxying)
|
26
|
+
|
27
|
+
# END workaround
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
action_hook(:setup_proxying, :machine_action_up, &method(:provision))
|
32
|
+
action_hook(:setup_proxying, :machine_action_provision, &method(:provision))
|
33
|
+
|
34
|
+
#command "proxy" do
|
35
|
+
# require_relative "command"
|
36
|
+
# Command
|
37
|
+
#end
|
38
|
+
|
39
|
+
#action "proxy" do
|
40
|
+
# require_relative "action"
|
41
|
+
# Action
|
42
|
+
#end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*-ruby-*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'vagrant-proxy/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "vagrant-proxy"
|
8
|
+
gem.version = VagrantPlugins::Proxy::VERSION
|
9
|
+
gem.authors = ["Clinton Wolfe"]
|
10
|
+
gem.email = ["clinton@omniti.com"]
|
11
|
+
gem.description = %q{A plugin to proxy HTTP requests made by the Vagrant provisioner, using the TBD proxy kit.}
|
12
|
+
gem.summary = %q{A plugin to proxy HTTP requests made by the Vagrant provisioner.}
|
13
|
+
gem.homepage = "https://github.com/clintoncwolfe/vagrant-proxy"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vagrant-proxy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Clinton Wolfe
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-06-06 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A plugin to proxy HTTP requests made by the Vagrant provisioner, using
|
14
|
+
the TBD proxy kit.
|
15
|
+
email:
|
16
|
+
- clinton@omniti.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- .gitignore
|
22
|
+
- Gemfile
|
23
|
+
- LICENSE.txt
|
24
|
+
- README.md
|
25
|
+
- Rakefile
|
26
|
+
- etc/polipo.config
|
27
|
+
- lib/vagrant-proxy.rb
|
28
|
+
- lib/vagrant-proxy/action.rb
|
29
|
+
- lib/vagrant-proxy/action/config_guest_iptables_for_proxy.rb
|
30
|
+
- lib/vagrant-proxy/action/is_running_or_active.rb
|
31
|
+
- lib/vagrant-proxy/command.rb
|
32
|
+
- lib/vagrant-proxy/config.rb
|
33
|
+
- lib/vagrant-proxy/plugin.rb
|
34
|
+
- lib/vagrant-proxy/version.rb
|
35
|
+
- vagrant-proxy.gemspec
|
36
|
+
homepage: https://github.com/clintoncwolfe/vagrant-proxy
|
37
|
+
licenses: []
|
38
|
+
metadata: {}
|
39
|
+
post_install_message:
|
40
|
+
rdoc_options: []
|
41
|
+
require_paths:
|
42
|
+
- lib
|
43
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ! '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
requirements: []
|
54
|
+
rubyforge_project:
|
55
|
+
rubygems_version: 2.0.3
|
56
|
+
signing_key:
|
57
|
+
specification_version: 4
|
58
|
+
summary: A plugin to proxy HTTP requests made by the Vagrant provisioner.
|
59
|
+
test_files: []
|
60
|
+
has_rdoc:
|