Format host address for rsync when IPv6
This commit is contained in:
parent
a7b228eb69
commit
139a65e555
|
@ -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",
|
||||
|
|
|
@ -233,6 +233,28 @@ describe VagrantPlugins::SyncedFolderRSync::RsyncHelper do
|
|||
guest.stub(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 { |*args|
|
||||
|
|
Loading…
Reference in New Issue