vagrant-proxyconf 2.0.8 → 2.0.10

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
  SHA256:
3
- metadata.gz: 4d721ed3ca409df6422674ace6fe21eb4d061f2803ab1e3d3297f2a6443ca06b
4
- data.tar.gz: ba5327b55dbda01b797803002c990b96a9905897ec9fa933f38dac8c9fd00341
3
+ metadata.gz: 6d2ed9c11cdc9cd9649a6dab1f4916430deffd34d7beef9f60ec1d997d8248ba
4
+ data.tar.gz: 44b631d6aee2ad96dcb2acceb25ac5eb11ec948830d8003f24be2182f047ea83
5
5
  SHA512:
6
- metadata.gz: d4be0de47b43ad064279e9820e22de28a3ac55436635eb655dea3e407df08c71900569a565df930d090e4ebe8a887542feeeb4f1018881aae6e0166179882bb1
7
- data.tar.gz: e259b6a96d86aca4fdebca70a029c918c574801569aee4acee0299908d7f2f34633627561e4b35d13f5b4af16e3d45c34025683523808dedcc09988bd827d881
6
+ metadata.gz: 76a5f3c7cd26ea510166d5757f3aa30f09befda31820fd0f1af02ff339964148314fcd8d686bf11cb8ee99b7ab4a49b2b7f7e1adde062766b9006e655f0130f0
7
+ data.tar.gz: c9e333a2a6f9306e71d0e7d2f5e2ef196cb4d8adde2864cb4d5bc8da54df348fddc21899291d176a7e28bb184094453da6759f4252e672b412dd9c7eac659a21
@@ -1,4 +1,24 @@
1
- # 2.0.9 / not yet released
1
+ # 2.0.10 / 2020-07-03
2
+
3
+ This is a bug fix release when provisioning docker hosts inside of
4
+ vagrant. This version removes the hard coded DOCKER_CONFIG environment
5
+ variable in /etc/environment and hard codes the client config to
6
+ /home/vagrant/.docker/config.json. This is a temporary work around until
7
+ the this can be refactored.
8
+
9
+ Existing values in /home/vagrant/.docker/config.json should be preserved
10
+ and merged when the vagrant-proxy conf is being provisioned.
11
+
12
+ #### Closed Issues
13
+
14
+ - [Respect Existing Docker Config Location #218](https://github.com/tmatilai/vagrant-proxyconf/issues/218)
15
+
16
+
17
+ # 2.0.9 / Not released
18
+
19
+ A release tagging error caused this release to become a draft release
20
+ and this will be re-released as 2.0.10.
21
+
2
22
 
3
23
  # 2.0.8 / 2020-06-10
4
24
 
@@ -6,6 +26,8 @@ This is a bug fix release for windows users which fixes a bug with the
6
26
  tempfile creation when uploading and downloading files from the vagrant
7
27
  machine.
8
28
 
29
+
30
+
9
31
  #### Closed Issues
10
32
 
11
33
  - [tempfile implementation on windows doesn't always seem to work
@@ -46,11 +46,11 @@ module VagrantPlugins
46
46
  @docker_client_config = tempfile(Hash.new)
47
47
 
48
48
  @machine.communicate.tap do |comm|
49
- if comm.test("[ -f /etc/docker/config.json ]")
50
- logger.info('Downloading file /etc/docker/config.json')
51
- comm.sudo("chmod 0644 /etc/docker/config.json")
52
- comm.download("/etc/docker/config.json", @docker_client_config.path)
53
- logger.info("Downloaded /etc/docker/config.json to #{@docker_client_config.path}")
49
+ if comm.test("[ -f /home/vagrant/.docker/config.json ]")
50
+ logger.info('Downloading file /home/vagrant/.docker/config.json')
51
+ comm.sudo("chmod 0644 /home/vagrant/.docker/config.json")
52
+ comm.download("/home/vagrant/.docker/config.json", @docker_client_config.path)
53
+ logger.info("Downloaded /home/vagrant/.docker/config.json to #{@docker_client_config.path}")
54
54
  end
55
55
  end
56
56
 
@@ -96,11 +96,10 @@ module VagrantPlugins
96
96
 
97
97
  @machine.communicate.tap do |comm|
98
98
  comm.upload(@docker_client_config.path, "/tmp/vagrant-proxyconf-docker-config.json")
99
- comm.sudo("mkdir -p /etc/docker")
100
- comm.sudo("chown root:docker /etc/docker")
101
- comm.sudo("mv /tmp/vagrant-proxyconf-docker-config.json /etc/docker/config.json")
102
- comm.sudo("chown root:docker /etc/docker/config.json")
103
- comm.sudo("chmod 0644 /etc/docker/config.json")
99
+ comm.sudo("mkdir -p /home/vagrant/.docker")
100
+ comm.sudo("mv /tmp/vagrant-proxyconf-docker-config.json /home/vagrant/.docker/config.json")
101
+ comm.sudo("chown -R vagrant:docker /home/vagrant/.docker")
102
+ comm.sudo("chmod 0644 /home/vagrant/.docker/config.json")
104
103
  comm.sudo("rm -f /tmp/vagrant-proxyconf-docker-config.json")
105
104
 
106
105
  comm.sudo("sed -i.bak -e '/^DOCKER_CONFIG/d' /etc/environment")
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module ProxyConf
3
- VERSION = '2.0.8'
3
+ VERSION = '2.0.10'
4
4
  end
5
5
  end
@@ -18,14 +18,13 @@ end
18
18
 
19
19
  def mock_update_docker_client_config(machine)
20
20
  allow(machine).to receive_message_chain(:communicate, :upload)
21
- allow(machine).to receive_message_chain(:communicate, :sudo).with("mv /tmp/vagrant-proxyconf-docker-config.json /etc/docker/config.json")
22
- allow(machine).to receive_message_chain(:communicate, :sudo).with("chown root:docker /etc/docker/config.json")
23
- allow(machine).to receive_message_chain(:communicate, :sudo).with("chmod 0644 /etc/docker/config.json")
21
+ allow(machine).to receive_message_chain(:communicate, :sudo).with("mkdir -p /home/vagrant/.docker")
22
+ allow(machine).to receive_message_chain(:communicate, :sudo).with("mv /tmp/vagrant-proxyconf-docker-config.json /home/vagrant/.docker/config.json")
23
+ allow(machine).to receive_message_chain(:communicate, :sudo).with("chown -R vagrant:docker /home/vagrant/.docker")
24
+ allow(machine).to receive_message_chain(:communicate, :sudo).with("chmod 0644 /home/vagrant/.docker/config.json")
24
25
  allow(machine).to receive_message_chain(:communicate, :sudo).with("rm -f /tmp/vagrant-proxyconf-docker-config.json")
25
26
  allow(machine).to receive_message_chain(:communicate, :sudo).with("sed -i.bak -e '/^DOCKER_CONFIG/d' /etc/environment")
26
27
  allow(machine).to receive_message_chain(:communicate, :sudo).with("echo DOCKER_CONFIG=/etc/docker >> /etc/environment")
27
- allow(machine).to receive_message_chain(:communicate, :sudo).with("mkdir -p /etc/docker")
28
- allow(machine).to receive_message_chain(:communicate, :sudo).with("chown root:docker /etc/docker")
29
28
  end
30
29
 
31
30
  def mock_update_docker_systemd_config(machine)
@@ -73,8 +72,8 @@ describe VagrantPlugins::ProxyConf::Action::ConfigureDockerProxy do
73
72
  docker_proxy.instance_variable_set(:@machine, machine)
74
73
 
75
74
  # #docker_client_config mock
76
- fixture = docker_proxy.send(:tempfile, load_fixture(fixture)).path
77
- docker_proxy.instance_variable_set(:@docker_client_config, fixture)
75
+ fixture = fixture = docker_proxy.send(:tempfile, load_fixture(fixture))
76
+ docker_proxy.instance_variable_set(:@docker_client_config, fixture.path)
78
77
 
79
78
  # #supported? mock
80
79
  allow(machine).to receive_message_chain(:guest, :capability?).with(:docker_proxy_conf).and_return(true)
@@ -101,7 +100,7 @@ describe VagrantPlugins::ProxyConf::Action::ConfigureDockerProxy do
101
100
  @docker_proxy = docker_proxy
102
101
  end
103
102
 
104
- context 'and when /etc/docker/config.json has proxy configuration' do
103
+ context 'and when /home/vagrant/.docker/config.json has proxy configuration' do
105
104
  before :each do
106
105
  fixture = fixture_file("docker_client_config_json_enabled_proxy")
107
106
  configure_docker_proxy(fixture)
@@ -110,7 +109,7 @@ describe VagrantPlugins::ProxyConf::Action::ConfigureDockerProxy do
110
109
  )
111
110
  end
112
111
 
113
- it 'update /etc/docker/config.json' do
112
+ it 'update /home/vagrant/.docker/config.json' do
114
113
  expect(@docker_proxy.send(:configure_machine)).to eq true
115
114
  end
116
115
  end
@@ -125,8 +124,8 @@ describe VagrantPlugins::ProxyConf::Action::ConfigureDockerProxy do
125
124
  docker_proxy.instance_variable_set(:@machine, machine)
126
125
 
127
126
  # #docker_client_config mock
128
- fixture = docker_proxy.send(:tempfile, load_fixture(fixture)).path
129
- docker_proxy.instance_variable_set(:@docker_client_config, fixture)
127
+ fixture = docker_proxy.send(:tempfile, load_fixture(fixture))
128
+ docker_proxy.instance_variable_set(:@docker_client_config, fixture.path)
130
129
 
131
130
  # #supported? mock
132
131
  allow(machine).to receive_message_chain(:guest, :capability?).with(:docker_proxy_conf).and_return(true)
@@ -204,7 +203,7 @@ describe VagrantPlugins::ProxyConf::Action::ConfigureDockerProxy do
204
203
  end
205
204
 
206
205
  context "when supported" do
207
- context "when /etc/docker/config.json exists" do
206
+ context "when /home/vagrant/.docker/config.json exists" do
208
207
  subject do
209
208
  docker_proxy = described_class.new(nil, nil)
210
209
  docker_proxy.instance_variable_set(:@machine, machine)
@@ -212,8 +211,8 @@ describe VagrantPlugins::ProxyConf::Action::ConfigureDockerProxy do
212
211
 
213
212
  allow(docker_proxy).to receive(:supports_config_json?).and_return(true)
214
213
 
215
- allow(machine).to receive_message_chain(:communicate, :test).with("[ -f /etc/docker/config.json ]").and_return(true)
216
- allow(machine).to receive_message_chain(:communicate, :sudo).with("chmod 0644 /etc/docker/config.json")
214
+ allow(machine).to receive_message_chain(:communicate, :test).with("[ -f /home/vagrant/.docker/config.json ]").and_return(true)
215
+ allow(machine).to receive_message_chain(:communicate, :sudo).with("chmod 0644 /home/vagrant/.docker/config.json")
217
216
  allow(machine).to receive_message_chain(:communicate, :download)
218
217
 
219
218
  docker_proxy.send(:docker_client_config)
@@ -222,7 +221,7 @@ describe VagrantPlugins::ProxyConf::Action::ConfigureDockerProxy do
222
221
  it { expect(File.exists?(subject.path)).to eq true }
223
222
  end
224
223
 
225
- context "when /etc/docker/config.json does not exist" do
224
+ context "when /home/vagrant/.docker/config.json does not exist" do
226
225
  subject do
227
226
  docker_proxy = described_class.new(nil, nil)
228
227
  docker_proxy.instance_variable_set(:@machine, machine)
@@ -230,7 +229,7 @@ describe VagrantPlugins::ProxyConf::Action::ConfigureDockerProxy do
230
229
 
231
230
  allow(docker_proxy).to receive(:supports_config_json?).and_return(true)
232
231
 
233
- allow(machine).to receive_message_chain(:communicate, :test).with("[ -f /etc/docker/config.json ]").and_return(false)
232
+ allow(machine).to receive_message_chain(:communicate, :test).with("[ -f /home/vagrant/.docker/config.json ]").and_return(false)
234
233
 
235
234
  docker_proxy.send(:docker_client_config)
236
235
  end
@@ -282,7 +281,7 @@ describe VagrantPlugins::ProxyConf::Action::ConfigureDockerProxy do
282
281
  end
283
282
  end
284
283
 
285
- context "when /etc/docker/config.json is supported" do
284
+ context "when /home/vagrant/.docker/config.json is supported" do
286
285
 
287
286
  context "when configuration is disabled" do
288
287
  it do
@@ -292,7 +291,9 @@ describe VagrantPlugins::ProxyConf::Action::ConfigureDockerProxy do
292
291
  # mock a result that looks like proxy is configured for the config.json
293
292
  fixture = fixture_file("docker_client_config_json_enabled_proxy")
294
293
  fixture_content = load_fixture(fixture)
295
- config_path = docker_proxy.send(:tempfile, fixture_content).path
294
+
295
+ temp_filename = config_path = docker_proxy.send(:tempfile, fixture_content)
296
+ config_path = temp_filename.path
296
297
 
297
298
  docker_proxy.instance_variable_set(:@docker_client_config, config_path)
298
299
 
@@ -331,7 +332,8 @@ describe VagrantPlugins::ProxyConf::Action::ConfigureDockerProxy do
331
332
  # mock a result that looks like no proxy is configured for the config.json
332
333
  fixture = fixture_file("docker_client_config_json_no_proxy")
333
334
  fixture_content = load_fixture(fixture)
334
- config_path = docker_proxy.send(:tempfile, fixture_content).path
335
+ temp_filename = config_path = docker_proxy.send(:tempfile, fixture_content)
336
+ config_path = temp_filename.path
335
337
 
336
338
  docker_proxy.instance_variable_set(:@docker_client_config, config_path)
337
339
 
@@ -391,7 +393,9 @@ describe VagrantPlugins::ProxyConf::Action::ConfigureDockerProxy do
391
393
  docker_proxy.instance_variable_set(:@version, [18, 9, 0])
392
394
 
393
395
  fixture = fixture_file("docker_client_config_json_enabled_proxy")
394
- config_path = docker_proxy.send(:tempfile, load_fixture(fixture)).path
396
+ temp_filename = config_path = docker_proxy.send(:tempfile, load_fixture(fixture))
397
+ config_path = temp_filename.path
398
+
395
399
  docker_proxy.instance_variable_set(:@docker_client_config, config_path)
396
400
 
397
401
  # to isolate this test, we turn of support for systemd
@@ -440,7 +444,8 @@ describe VagrantPlugins::ProxyConf::Action::ConfigureDockerProxy do
440
444
  allow(docker_proxy).to receive(:supports_systemd?).and_return(false)
441
445
 
442
446
  fixture = fixture_file("docker_client_config_json_enabled_proxy")
443
- config_path = docker_proxy.send(:tempfile, load_fixture(fixture)).path
447
+ temp_filename = docker_proxy.send(:tempfile, load_fixture(fixture))
448
+ config_path = temp_filename.path
444
449
  docker_proxy.instance_variable_set(:@docker_client_config, config_path)
445
450
 
446
451
  allow(machine).to receive_message_chain(:guest, :capability?).with(:docker_proxy_conf).and_return(true)
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
@@ -0,0 +1,47 @@
1
+ FROM centos:7
2
+
3
+ ENV CI_USERNAME vagrant
4
+ ENV CI_PASSWORD vagrant
5
+ ENV CI_HOMEDIR /home/vagrant
6
+ ENV CI_SHELL /bin/bash
7
+
8
+ EXPOSE 8888
9
+
10
+ RUN yum clean all && \
11
+ yum makecache fast && \
12
+ yum -y install epel-release && \
13
+ yum clean expire-cache && \
14
+ yum -y install \
15
+ curl \
16
+ initscripts \
17
+ openssh-clients \
18
+ openssh-server \
19
+ sudo \
20
+ tinyproxy
21
+
22
+ RUN /usr/sbin/sshd-keygen && \
23
+ mkdir -p /var/run/sshd && \
24
+ rm -f /usr/lib/tmpfiles.d/systemd-nologin.conf
25
+
26
+ RUN if ! getent passwd $CI_USERNAME; then \
27
+ useradd -m -d ${CI_HOMEDIR} -s ${CI_SHELL} $CI_USERNAME; \
28
+ fi && \
29
+ echo "${CI_USERNAME}:${CI_PASSWORD}" | chpasswd && \
30
+ echo "${CI_USERNAME} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers && \
31
+ mkdir -p /etc/sudoers.d && \
32
+ echo "${CI_USERNAME} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/${CI_USERNAME} && \
33
+ chmod 0440 /etc/sudoers.d/${CI_USERNAME} && \
34
+ mkdir -p ${CI_HOMEDIR}/.ssh && \
35
+ chown -R ${CI_USERNAME}:${CI_USERNAME} ${CI_HOMEDIR}/.ssh && \
36
+ chmod 0700 ${CI_HOMEDIR}/.ssh && \
37
+ curl -L https://raw.githubusercontent.com/hashicorp/vagrant/master/keys/vagrant.pub > ${CI_HOMEDIR}/.ssh/vagrant.pub && \
38
+ touch ${CI_HOMEDIR}/.ssh/authorized_keys && \
39
+ grep -q "$(cat ${CI_HOMEDIR}/.ssh/vagrant.pub | awk '{print $2}')" ${CI_HOMEDIR}/.ssh/authorized_keys || cat ${CI_HOMEDIR}/.ssh/vagrant.pub >> ${CI_HOMEDIR}/.ssh/authorized_keys && \
40
+ chown ${CI_USERNAME}:${CI_USERNAME} ${CI_HOMEDIR}/.ssh/authorized_keys && \
41
+ chmod 0600 ${CI_HOMEDIR}/.ssh/authorized_keys
42
+
43
+ COPY tinyproxy.conf /etc/tinyproxy/tinyproxy.conf
44
+ COPY entrypoint.sh /entrypoint.sh
45
+
46
+ ENTRYPOINT ["/entrypoint.sh"]
47
+ CMD [ "start" ]
@@ -0,0 +1,35 @@
1
+ Tests
2
+ -----
3
+
4
+
5
+ Lined to github issue [#218](https://github.com/tmatilai/vagrant-proxyconf/issues/218)
6
+
7
+
8
+ If you are testing the current release of this plugin via bundler
9
+
10
+ ```
11
+ bundle exec vagrant up default
12
+ ```
13
+
14
+ ## Expect
15
+
16
+
17
+ ### Box `default``
18
+
19
+ - The box `default` is a docker container that will be a reverse
20
+ proxy. It should provision itself and work without errors.
21
+
22
+ - You can check that the proxy is working by
23
+ `tail -f /var/log/tinyproxy/tinyproxy.log` inside the container
24
+
25
+ - **NOTE**: You'll need to use `docker exec <hash> -it bash` to get into the container
26
+
27
+
28
+ ### Box `docker-host`
29
+
30
+ - Vagrant should automatically instally docker-ce.
31
+ - The box should come up and provision itself with the proxy settings
32
+ configured in your Vagrantfile.
33
+
34
+
35
+ - **NOTE**: You can use `ssh` to connect to this container.
@@ -0,0 +1,27 @@
1
+ require 'rake'
2
+ require 'rspec/core/rake_task'
3
+
4
+ task :spec => 'spec:all'
5
+ task :default => :spec
6
+
7
+ namespace :spec do
8
+ targets = []
9
+ Dir.glob('./spec/*').each do |dir|
10
+ next unless File.directory?(dir)
11
+ target = File.basename(dir)
12
+ target = "_#{target}" if target == "default"
13
+ targets << target
14
+ end
15
+
16
+ task :all => targets
17
+ task :default => :all
18
+
19
+ targets.each do |target|
20
+ original_target = target == "_default" ? target[1..-1] : target
21
+ desc "Run serverspec tests to #{original_target}"
22
+ RSpec::Core::RakeTask.new(target.to_sym) do |t|
23
+ ENV['TARGET_HOST'] = original_target
24
+ t.pattern = "spec/#{original_target}/*_spec.rb"
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,62 @@
1
+ # this should be the IP address of the :default box
2
+ $PROXY_HOST ="10.0.2.2"
3
+ $PROXY_PORT="8888"
4
+ $PROXY_NO_PROXY=[
5
+ 'localhost',
6
+ ]
7
+
8
+ ENV['HTTP_PROXY'] = ENV.fetch('HTTP_PROXY', "http://#{$PROXY_HOST}:#{$PROXY_PORT}")
9
+ ENV['HTTPS_PROXY'] = ENV.fetch('HTTPS_PROXY', "http://#{$PROXY_HOST}:#{$PROXY_PORT}")
10
+ ENV['NO_PROXY'] = ENV.fetch('NO_PROXY', $PROXY_NO_PROXY.join(","))
11
+
12
+ puts "HTTP_PROXY = '#{ENV["HTTP_PROXY"]}'"
13
+ puts "HTTPS_PROXY = '#{ENV["HTTPS_PROXY"]}'"
14
+ puts "NO_PROXY = '#{ENV["NO_PROXY"]}'"
15
+
16
+ puts "is vagrant-proxyconf installed? #{Vagrant.has_plugin?('vagrant-proxyconf')}"
17
+
18
+ Vagrant.configure("2") do |config|
19
+
20
+ config.vm.define 'default' do |c|
21
+ c.vm.box = nil
22
+
23
+ if Vagrant.has_plugin?('vagrant-proxyconf')
24
+ c.proxy.enabled = false
25
+ end
26
+
27
+ c.vm.provider "docker" do |d|
28
+ d.build_dir = "."
29
+ d.expose = ['8888']
30
+ d.has_ssh = true
31
+ d.ports = ['8888:8888']
32
+ end
33
+ end
34
+
35
+ config.vm.define 'docker_host' do |c|
36
+ c.vm.box = "centos/7"
37
+ c.vm.box_check_update = false
38
+
39
+ if Vagrant.has_plugin?('vagrant-proxyconf')
40
+ c.proxy.http = ENV['HTTP_PROXY']
41
+ c.proxy.https = ENV['HTTPS_PROXY']
42
+ c.proxy.no_proxy = ENV['NO_PROXY']
43
+ end
44
+
45
+ c.vm.provision "shell", path: "force-all-outbound-traffic-through-proxy.iptables"
46
+
47
+ if Vagrant.has_plugin?('vagrant-vbguest')
48
+ c.vbguest.auto_update = false
49
+ c.vbguest.auto_reboot = true
50
+ end
51
+
52
+ c.vm.provision "docker"
53
+
54
+ c.vm.synced_folder ".", "/vagrant",
55
+ disabled: false,
56
+ type: "sshfs",
57
+ ssh_opts_append: "-o Compression=yes -o ControlPersist=60s -o ControlMaster=auto",
58
+ sshfs_opts_append: "-o cache=no -o nonempty"
59
+
60
+ end
61
+
62
+ end
@@ -0,0 +1,50 @@
1
+ #!/bin/bash
2
+ set -ex
3
+
4
+ export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
5
+
6
+ start() {
7
+ # start ssh if sshd is installed
8
+ if [ -f /usr/sbin/sshd ]; then
9
+
10
+ /usr/sbin/sshd-keygen
11
+ /usr/sbin/sshd -t
12
+ /usr/sbin/sshd
13
+
14
+ else
15
+
16
+ true
17
+
18
+ fi
19
+
20
+ # start tinyproxy
21
+ /usr/sbin/tinyproxy \
22
+ -d \
23
+ -c "/etc/tinyproxy/tinyproxy.conf"
24
+ }
25
+
26
+ stop() {
27
+
28
+ pgrep -f 'sshd' | while read _pid
29
+ do
30
+ kill -9 $_pid
31
+ done
32
+
33
+ pgrep -f 'tinyproxy' | while read _pid
34
+ do
35
+ kill -9 $_pid
36
+ done
37
+
38
+ }
39
+
40
+ case "${1}" in
41
+
42
+ start)
43
+ start
44
+ ;;
45
+
46
+ stop)
47
+ stop
48
+ ;;
49
+
50
+ esac
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env bash
2
+ set -ex
3
+
4
+ # OUTPUT:IN= OUT=eth0 SRC=10.0.2.15 DST=10.0.2.2 LEN=40 TOS=0x00 PREC=0x00 TTL=64 ID=61920 DF PROTO=TCP SPT=59780 DPT=8888 WINDOW=65535 RES=0x00 ACK URGP=0
5
+ # OUTPUT:IN= OUT=eth0 SRC=10.0.2.15 DST=10.0.2.2 LEN=84 TOS=0x10 PREC=0x00 TTL=64 ID=22073 DF PROTO=TCP SPT=22 DPT=55694 WINDOW=47600 RES=0x00 ACK PSH URGP=0
6
+ # OUTPUT:IN= OUT=eth0 SRC=10.0.2.15 DST=10.0.2.3 LEN=60 TOS=0x00 PREC=0x00 TTL=64 ID=30731 PROTO=UDP SPT=45910 DPT=53 LEN=40
7
+
8
+ iptables -F OUTPUT
9
+ iptables -Z OUTPUT
10
+
11
+ iptables -A OUTPUT -d 10.0.2.2 -p tcp -m tcp --dport 8888 -j ACCEPT
12
+ iptables -A OUTPUT -p tcp -m tcp --sport 22 -j ACCEPT
13
+ iptables -A OUTPUT -p udp -m udp --dport 53 -j ACCEPT
14
+ iptables -A OUTPUT -p udp -m udp --dport 123 -j ACCEPT
15
+
16
+ iptables -A OUTPUT -j LOG --log-prefix 'OUTPUT:DROPPED '
17
+
18
+ iptables -P OUTPUT DROP
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe package('tinyproxy') do
4
+ it { should be_installed }
5
+ end
6
+
7
+ describe service('tinyproxy') do
8
+ it { should be_enabled }
9
+ it { should be_running }
10
+ end
11
+
12
+
13
+ describe port(8888) do
14
+ it { should be_listening }
15
+ it { should be_listening.on('0.0.0.0').with('tcp') }
16
+ end
@@ -0,0 +1,171 @@
1
+ require 'spec_helper'
2
+
3
+ PROXY_HOST = "10.0.2.2"
4
+
5
+ describe service('docker') do
6
+ it { should be_running }
7
+ it { should be_enabled }
8
+ end
9
+
10
+
11
+ describe file('/etc/docker/config.json') do
12
+ it { should_not be_file }
13
+ it { should_not exist }
14
+ end
15
+
16
+
17
+ describe file('/home/vagrant/.docker/config.json') do
18
+ it { should be_file }
19
+ it { should exist }
20
+ it { should be_mode 644 }
21
+ it { should be_owned_by "vagrant" }
22
+ it { should be_grouped_into "docker" }
23
+ end
24
+
25
+ context 'when proxy is enabled' do
26
+ before(:context) do
27
+ ENV['HTTP_PROXY'] = "http://#{PROXY_HOST}:8888"
28
+ ENV['HTTPS_PROXY'] = "http://#{PROXY_HOST}:8888"
29
+ ENV['NO_PROXY'] = "*.example.com"
30
+
31
+ `vagrant provision #{ENV['TARGET_HOST']}`
32
+ `sleep 3`
33
+ end
34
+
35
+ describe file('/home/vagrant/.docker/config.json') do
36
+ let(:expected_content) do
37
+ {
38
+ "proxies" => {
39
+ "default" => {
40
+ "httpProxy" => "http://10.0.2.2:8888",
41
+ "httpsProxy" => "http://10.0.2.2:8888",
42
+ "noProxy" => "*.example.com",
43
+ }
44
+ }
45
+ }
46
+ end
47
+
48
+ its(:content_as_json) do
49
+ should include(expected_content)
50
+ end
51
+ end
52
+
53
+ end
54
+
55
+ context 'when HTTP_PROXY=""' do
56
+
57
+ before(:context) do
58
+ ENV['HTTP_PROXY'] = ""
59
+ ENV['HTTPS_PROXY'] = "https://#{PROXY_HOST}:8888"
60
+ ENV['NO_PROXY'] = "*.example.com"
61
+
62
+ `vagrant provision #{ENV['TARGET_HOST']}`
63
+ `sleep 3`
64
+ end
65
+
66
+ describe file('/home/vagrant/.docker/config.json') do
67
+ let(:expected_content) do
68
+ {
69
+ "proxies" => {
70
+ "default" => {
71
+ "httpsProxy" => "https://#{PROXY_HOST}:8888",
72
+ "noProxy" => "*.example.com",
73
+ }
74
+ }
75
+ }
76
+ end
77
+
78
+ its(:content_as_json) do
79
+ should include(expected_content)
80
+ end
81
+ end
82
+
83
+ end
84
+
85
+ context 'when HTTPS_PROXY=""' do
86
+
87
+ before(:context) do
88
+ ENV['HTTP_PROXY'] = "http://#{PROXY_HOST}:8888"
89
+ ENV['HTTPS_PROXY'] = ""
90
+ ENV['NO_PROXY'] = "*.example.com"
91
+
92
+ `vagrant provision #{ENV['TARGET_HOST']}`
93
+ end
94
+
95
+ describe file('/home/vagrant/.docker/config.json') do
96
+ let(:expected_content) do
97
+ {
98
+ "proxies" => {
99
+ "default" => {
100
+ "httpProxy" => "http://#{PROXY_HOST}:8888",
101
+ "noProxy" => "*.example.com",
102
+ }
103
+ }
104
+ }
105
+ end
106
+
107
+ its(:content_as_json) do
108
+ should include(expected_content)
109
+ end
110
+ end
111
+
112
+ end
113
+
114
+ context 'when HTTPS_PROXY="" and HTTP_PROXY=""' do
115
+
116
+ before(:context) do
117
+ ENV['HTTP_PROXY'] = ""
118
+ ENV['HTTPS_PROXY'] = ""
119
+ ENV['NO_PROXY'] = "*.example.com"
120
+
121
+ `vagrant provision #{ENV['TARGET_HOST']}`
122
+ `sleep 3`
123
+ end
124
+
125
+ describe file('/home/vagrant/.docker/config.json') do
126
+ let(:expected_content) do
127
+ {
128
+ "proxies" => {
129
+ "default" => {
130
+ "noProxy" => "*.example.com",
131
+ }
132
+ }
133
+ }
134
+ end
135
+
136
+ its(:content_as_json) do
137
+ should include(expected_content)
138
+ end
139
+ end
140
+
141
+ end
142
+
143
+ context 'when NO_PROXY=""' do
144
+
145
+ before(:context) do
146
+ ENV['HTTP_PROXY'] = "http://#{PROXY_HOST}:8888"
147
+ ENV['HTTPS_PROXY'] = "https://#{PROXY_HOST}:8888"
148
+ ENV['NO_PROXY'] = ""
149
+
150
+ `vagrant provision #{ENV['TARGET_HOST']}`
151
+ `sleep 3`
152
+ end
153
+
154
+ describe file('/home/vagrant/.docker/config.json') do
155
+ let(:expected_content) do
156
+ {
157
+ "proxies" => {
158
+ "default" => {
159
+ "httpProxy" => "http://#{PROXY_HOST}:8888",
160
+ "httpsProxy" => "https://#{PROXY_HOST}:8888",
161
+ }
162
+ }
163
+ }
164
+ end
165
+
166
+ its(:content_as_json) do
167
+ should include(expected_content)
168
+ end
169
+ end
170
+
171
+ end
@@ -0,0 +1,43 @@
1
+ require 'serverspec'
2
+ require 'net/ssh'
3
+ require 'tempfile'
4
+
5
+ set :backend, :ssh
6
+
7
+ if ENV['ASK_SUDO_PASSWORD']
8
+ begin
9
+ require 'highline/import'
10
+ rescue LoadError
11
+ fail "highline is not available. Try installing it."
12
+ end
13
+ set :sudo_password, ask("Enter sudo password: ") { |q| q.echo = false }
14
+ else
15
+ set :sudo_password, ENV['SUDO_PASSWORD'] || "vagrant"
16
+ end
17
+
18
+ host = ENV['TARGET_HOST']
19
+
20
+ `vagrant up #{host}`
21
+
22
+ config = Tempfile.new('', Dir.tmpdir)
23
+ config.write(`vagrant ssh-config #{host}`)
24
+ config.close
25
+
26
+ options = Net::SSH::Config.for(host, [config.path])
27
+
28
+ options[:user] ||= Etc.getlogin
29
+
30
+ set :host, options[:host_name] || host
31
+ set :ssh_options, options
32
+
33
+ # Disable sudo
34
+ # set :disable_sudo, true
35
+
36
+
37
+ # Set environment variables
38
+ set :env,
39
+ :LANG => 'C',
40
+ :LC_MESSAGES => 'C'
41
+
42
+ # Set PATH
43
+ # set :path, '/sbin:/usr/local/sbin:$PATH'
@@ -0,0 +1,333 @@
1
+ ##
2
+ ## tinyproxy.conf -- tinyproxy daemon configuration file
3
+ ##
4
+ ## This example tinyproxy.conf file contains example settings
5
+ ## with explanations in comments. For decriptions of all
6
+ ## parameters, see the tinproxy.conf(5) manual page.
7
+ ##
8
+
9
+ #
10
+ # User/Group: This allows you to set the user and group that will be
11
+ # used for tinyproxy after the initial binding to the port has been done
12
+ # as the root user. Either the user or group name or the UID or GID
13
+ # number may be used.
14
+ #
15
+ User tinyproxy
16
+ Group tinyproxy
17
+
18
+ #
19
+ # Port: Specify the port which tinyproxy will listen on. Please note
20
+ # that should you choose to run on a port lower than 1024 you will need
21
+ # to start tinyproxy using root.
22
+ #
23
+ Port 8888
24
+
25
+ #
26
+ # Listen: If you have multiple interfaces this allows you to bind to
27
+ # only one. If this is commented out, tinyproxy will bind to all
28
+ # interfaces present.
29
+ #
30
+ #Listen 192.168.0.1
31
+
32
+ #
33
+ # Bind: This allows you to specify which interface will be used for
34
+ # outgoing connections. This is useful for multi-home'd machines where
35
+ # you want all traffic to appear outgoing from one particular interface.
36
+ #
37
+ #Bind 192.168.0.1
38
+
39
+ #
40
+ # BindSame: If enabled, tinyproxy will bind the outgoing connection to the
41
+ # ip address of the incoming connection.
42
+ #
43
+ #BindSame yes
44
+
45
+ #
46
+ # Timeout: The maximum number of seconds of inactivity a connection is
47
+ # allowed to have before it is closed by tinyproxy.
48
+ #
49
+ Timeout 600
50
+
51
+ #
52
+ # ErrorFile: Defines the HTML file to send when a given HTTP error
53
+ # occurs. You will probably need to customize the location to your
54
+ # particular install. The usual locations to check are:
55
+ # /usr/local/share/tinyproxy
56
+ # /usr/share/tinyproxy
57
+ # /etc/tinyproxy
58
+ #
59
+ #ErrorFile 404 "/usr/share/tinyproxy/404.html"
60
+ #ErrorFile 400 "/usr/share/tinyproxy/400.html"
61
+ #ErrorFile 503 "/usr/share/tinyproxy/503.html"
62
+ #ErrorFile 403 "/usr/share/tinyproxy/403.html"
63
+ #ErrorFile 408 "/usr/share/tinyproxy/408.html"
64
+
65
+ #
66
+ # DefaultErrorFile: The HTML file that gets sent if there is no
67
+ # HTML file defined with an ErrorFile keyword for the HTTP error
68
+ # that has occured.
69
+ #
70
+ DefaultErrorFile "/usr/share/tinyproxy/default.html"
71
+
72
+ #
73
+ # StatHost: This configures the host name or IP address that is treated
74
+ # as the stat host: Whenever a request for this host is received,
75
+ # Tinyproxy will return an internal statistics page instead of
76
+ # forwarding the request to that host. The default value of StatHost is
77
+ # tinyproxy.stats.
78
+ #
79
+ #StatHost "tinyproxy.stats"
80
+ #
81
+
82
+ #
83
+ # StatFile: The HTML file that gets sent when a request is made
84
+ # for the stathost. If this file doesn't exist a basic page is
85
+ # hardcoded in tinyproxy.
86
+ #
87
+ StatFile "/usr/share/tinyproxy/stats.html"
88
+
89
+ #
90
+ # LogFile: Allows you to specify the location where information should
91
+ # be logged to. If you would prefer to log to syslog, then disable this
92
+ # and enable the Syslog directive. These directives are mutually
93
+ # exclusive.
94
+ #
95
+ LogFile "/var/log/tinyproxy/tinyproxy.log"
96
+
97
+ #
98
+ # Syslog: Tell tinyproxy to use syslog instead of a logfile. This
99
+ # option must not be enabled if the Logfile directive is being used.
100
+ # These two directives are mutually exclusive.
101
+ #
102
+ #Syslog On
103
+
104
+ #
105
+ # LogLevel:
106
+ #
107
+ # Set the logging level. Allowed settings are:
108
+ # Critical (least verbose)
109
+ # Error
110
+ # Warning
111
+ # Notice
112
+ # Connect (to log connections without Info's noise)
113
+ # Info (most verbose)
114
+ #
115
+ # The LogLevel logs from the set level and above. For example, if the
116
+ # LogLevel was set to Warning, then all log messages from Warning to
117
+ # Critical would be output, but Notice and below would be suppressed.
118
+ #
119
+ LogLevel Info
120
+
121
+ #
122
+ # PidFile: Write the PID of the main tinyproxy thread to this file so it
123
+ # can be used for signalling purposes.
124
+ #
125
+ PidFile "/var/run/tinyproxy/tinyproxy.pid"
126
+
127
+ #
128
+ # XTinyproxy: Tell Tinyproxy to include the X-Tinyproxy header, which
129
+ # contains the client's IP address.
130
+ #
131
+ #XTinyproxy Yes
132
+
133
+ #
134
+ # Upstream:
135
+ #
136
+ # Turns on upstream proxy support.
137
+ #
138
+ # The upstream rules allow you to selectively route upstream connections
139
+ # based on the host/domain of the site being accessed.
140
+ #
141
+ # For example:
142
+ # # connection to test domain goes through testproxy
143
+ # upstream testproxy:8008 ".test.domain.invalid"
144
+ # upstream testproxy:8008 ".our_testbed.example.com"
145
+ # upstream testproxy:8008 "192.168.128.0/255.255.254.0"
146
+ #
147
+ # # no upstream proxy for internal websites and unqualified hosts
148
+ # no upstream ".internal.example.com"
149
+ # no upstream "www.example.com"
150
+ # no upstream "10.0.0.0/8"
151
+ # no upstream "192.168.0.0/255.255.254.0"
152
+ # no upstream "."
153
+ #
154
+ # # connection to these boxes go through their DMZ firewalls
155
+ # upstream cust1_firewall:8008 "testbed_for_cust1"
156
+ # upstream cust2_firewall:8008 "testbed_for_cust2"
157
+ #
158
+ # # default upstream is internet firewall
159
+ # upstream firewall.internal.example.com:80
160
+ #
161
+ # The LAST matching rule wins the route decision. As you can see, you
162
+ # can use a host, or a domain:
163
+ # name matches host exactly
164
+ # .name matches any host in domain "name"
165
+ # . matches any host with no domain (in 'empty' domain)
166
+ # IP/bits matches network/mask
167
+ # IP/mask matches network/mask
168
+ #
169
+ #Upstream some.remote.proxy:port
170
+
171
+ #
172
+ # MaxClients: This is the absolute highest number of threads which will
173
+ # be created. In other words, only MaxClients number of clients can be
174
+ # connected at the same time.
175
+ #
176
+ MaxClients 100
177
+
178
+ #
179
+ # MinSpareServers/MaxSpareServers: These settings set the upper and
180
+ # lower limit for the number of spare servers which should be available.
181
+ #
182
+ # If the number of spare servers falls below MinSpareServers then new
183
+ # server processes will be spawned. If the number of servers exceeds
184
+ # MaxSpareServers then the extras will be killed off.
185
+ #
186
+ MinSpareServers 5
187
+ MaxSpareServers 20
188
+
189
+ #
190
+ # StartServers: The number of servers to start initially.
191
+ #
192
+ StartServers 10
193
+
194
+ #
195
+ # MaxRequestsPerChild: The number of connections a thread will handle
196
+ # before it is killed. In practise this should be set to 0, which
197
+ # disables thread reaping. If you do notice problems with memory
198
+ # leakage, then set this to something like 10000.
199
+ #
200
+ MaxRequestsPerChild 0
201
+
202
+ #
203
+ # Allow: Customization of authorization controls. If there are any
204
+ # access control keywords then the default action is to DENY. Otherwise,
205
+ # the default action is ALLOW.
206
+ #
207
+ # The order of the controls are important. All incoming connections are
208
+ # tested against the controls based on order.
209
+ #
210
+ Allow 127.0.0.1
211
+ Allow 0.0.0.0/0
212
+
213
+ #
214
+ # AddHeader: Adds the specified headers to outgoing HTTP requests that
215
+ # Tinyproxy makes. Note that this option will not work for HTTPS
216
+ # traffic, as Tinyproxy has no control over what headers are exchanged.
217
+ #
218
+ #AddHeader "X-My-Header" "Powered by Tinyproxy"
219
+
220
+ #
221
+ # ViaProxyName: The "Via" header is required by the HTTP RFC, but using
222
+ # the real host name is a security concern. If the following directive
223
+ # is enabled, the string supplied will be used as the host name in the
224
+ # Via header; otherwise, the server's host name will be used.
225
+ #
226
+ ViaProxyName "tinyproxy"
227
+
228
+ #
229
+ # DisableViaHeader: When this is set to yes, Tinyproxy does NOT add
230
+ # the Via header to the requests. This virtually puts Tinyproxy into
231
+ # stealth mode. Note that RFC 2616 requires proxies to set the Via
232
+ # header, so by enabling this option, you break compliance.
233
+ # Don't disable the Via header unless you know what you are doing...
234
+ #
235
+ #DisableViaHeader Yes
236
+
237
+ #
238
+ # Filter: This allows you to specify the location of the filter file.
239
+ #
240
+ #Filter "/etc/tinyproxy/filter"
241
+
242
+ #
243
+ # FilterURLs: Filter based on URLs rather than domains.
244
+ #
245
+ #FilterURLs On
246
+
247
+ #
248
+ # FilterExtended: Use POSIX Extended regular expressions rather than
249
+ # basic.
250
+ #
251
+ #FilterExtended On
252
+
253
+ #
254
+ # FilterCaseSensitive: Use case sensitive regular expressions.
255
+ #
256
+ #FilterCaseSensitive On
257
+
258
+ #
259
+ # FilterDefaultDeny: Change the default policy of the filtering system.
260
+ # If this directive is commented out, or is set to "No" then the default
261
+ # policy is to allow everything which is not specifically denied by the
262
+ # filter file.
263
+ #
264
+ # However, by setting this directive to "Yes" the default policy becomes
265
+ # to deny everything which is _not_ specifically allowed by the filter
266
+ # file.
267
+ #
268
+ #FilterDefaultDeny Yes
269
+
270
+ #
271
+ # Anonymous: If an Anonymous keyword is present, then anonymous proxying
272
+ # is enabled. The headers listed are allowed through, while all others
273
+ # are denied. If no Anonymous keyword is present, then all headers are
274
+ # allowed through. You must include quotes around the headers.
275
+ #
276
+ # Most sites require cookies to be enabled for them to work correctly, so
277
+ # you will need to allow Cookies through if you access those sites.
278
+ #
279
+ #Anonymous "Host"
280
+ #Anonymous "Authorization"
281
+ #Anonymous "Cookie"
282
+
283
+ #
284
+ # ConnectPort: This is a list of ports allowed by tinyproxy when the
285
+ # CONNECT method is used. To disable the CONNECT method altogether, set
286
+ # the value to 0. If no ConnectPort line is found, all ports are
287
+ # allowed (which is not very secure.)
288
+ #
289
+ # The following two ports are used by SSL.
290
+ #
291
+ ConnectPort 443
292
+ ConnectPort 563
293
+
294
+ #
295
+ # Configure one or more ReversePath directives to enable reverse proxy
296
+ # support. With reverse proxying it's possible to make a number of
297
+ # sites appear as if they were part of a single site.
298
+ #
299
+ # If you uncomment the following two directives and run tinyproxy
300
+ # on your own computer at port 8888, you can access Google using
301
+ # http://localhost:8888/google/ and Wired News using
302
+ # http://localhost:8888/wired/news/. Neither will actually work
303
+ # until you uncomment ReverseMagic as they use absolute linking.
304
+ #
305
+ #ReversePath "/google/" "http://www.google.com/"
306
+ #ReversePath "/wired/" "http://www.wired.com/"
307
+
308
+ #
309
+ # When using tinyproxy as a reverse proxy, it is STRONGLY recommended
310
+ # that the normal proxy is turned off by uncommenting the next directive.
311
+ #
312
+ #ReverseOnly Yes
313
+
314
+ #
315
+ # Use a cookie to track reverse proxy mappings. If you need to reverse
316
+ # proxy sites which have absolute links you must uncomment this.
317
+ #
318
+ #ReverseMagic Yes
319
+
320
+ #
321
+ # The URL that's used to access this reverse proxy. The URL is used to
322
+ # rewrite HTTP redirects so that they won't escape the proxy. If you
323
+ # have a chain of reverse proxies, you'll need to put the outermost
324
+ # URL here (the address which the end user types into his/her browser).
325
+ #
326
+ # If not set then no rewriting occurs.
327
+ #
328
+ #ReverseBaseURL "http://localhost:8888/"
329
+
330
+
331
+
332
+
333
+ ### foo
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-proxyconf
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.8
4
+ version: 2.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Teemu Matilainen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-12 00:00:00.000000000 Z
11
+ date: 2020-07-03 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A Vagrant plugin that configures the virtual machine to use proxy servers
14
14
  email:
@@ -183,6 +183,17 @@ files:
183
183
  - test/issues/199/spec/default/redhat_spec.rb
184
184
  - test/issues/199/spec/spec_helper.rb
185
185
  - test/issues/199/tinyproxy.conf
186
+ - test/issues/218/.rspec
187
+ - test/issues/218/Dockerfile
188
+ - test/issues/218/README.md
189
+ - test/issues/218/Rakefile
190
+ - test/issues/218/Vagrantfile
191
+ - test/issues/218/entrypoint.sh
192
+ - test/issues/218/force-all-outbound-traffic-through-proxy.iptables
193
+ - test/issues/218/spec/default/redhat_spec.rb
194
+ - test/issues/218/spec/docker_host/redhat_spec.rb
195
+ - test/issues/218/spec/spec_helper.rb
196
+ - test/issues/218/tinyproxy.conf
186
197
  - travis/before_install
187
198
  - vagrant-proxyconf.gemspec
188
199
  homepage: http://tmatilai.github.io/vagrant-proxyconf/
@@ -305,3 +316,14 @@ test_files:
305
316
  - test/issues/199/spec/default/redhat_spec.rb
306
317
  - test/issues/199/spec/spec_helper.rb
307
318
  - test/issues/199/tinyproxy.conf
319
+ - test/issues/218/.rspec
320
+ - test/issues/218/Dockerfile
321
+ - test/issues/218/README.md
322
+ - test/issues/218/Rakefile
323
+ - test/issues/218/Vagrantfile
324
+ - test/issues/218/entrypoint.sh
325
+ - test/issues/218/force-all-outbound-traffic-through-proxy.iptables
326
+ - test/issues/218/spec/default/redhat_spec.rb
327
+ - test/issues/218/spec/docker_host/redhat_spec.rb
328
+ - test/issues/218/spec/spec_helper.rb
329
+ - test/issues/218/tinyproxy.conf