Merge pull request #8840 from chrisroberts/rsync/ipv6

Format host address for rsync when IPv6
This commit is contained in:
Chris Roberts 2017-08-21 13:49:58 -07:00 committed by GitHub
commit f32f85595e
2 changed files with 32 additions and 0 deletions

View File

@ -1,3 +1,4 @@
require "ipaddr"
require "shellwords"
require "vagrant/util/platform"
@ -147,6 +148,15 @@ module VagrantPlugins
args << "--rsync-path"<< rsync_path
end
# If the remote host is an IPv6 address reformat
begin
if IPAddr.new(host).ipv6?
host = "[#{host}]"
end
rescue IPAddr::Error
# Ignore
end
# Build up the actual command to execute
command = [
"rsync",

View File

@ -233,6 +233,28 @@ describe VagrantPlugins::SyncedFolderRSync::RsyncHelper do
allow(guest).to receive(:capability?){ false }
end
context "with an IPv6 address" do
before { ssh_info[:host] = "fe00::0" }
it "formats the address correctly" do
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
expect(args[13]).to include("@[#{ssh_info[:host]}]")
}
subject.rsync_single(machine, ssh_info, opts)
end
end
context "with an IPv4 address" do
before { ssh_info[:host] = "127.0.0.1" }
it "formats the address correctly" do
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
expect(args[13]).to include("@#{ssh_info[:host]}")
}
subject.rsync_single(machine, ssh_info, opts)
end
end
it "includes IdentitiesOnly, StrictHostKeyChecking, and UserKnownHostsFile with defaults" do
expect(Vagrant::Util::Subprocess).to receive(:execute).with(any_args) { |*args|