Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
cli.rb: parse multiple space or comma-separated hostnames
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Hall committed Oct 14, 2015
1 parent c359b2c commit e4ce5bd
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions lib/fakes3/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,18 @@ def server
abort "You must specify a root to use a file store (the current default)"
end

hostname = 's3.amazonaws.com'
if options[:hostname]
hostname = options[:hostname]
# Allow single or multiple hostnames
raw_hostnames = options[:hostname] || 's3.amazonaws.com'
raw_hostnames = raw_hostnames.split(/[\s,]/)
hostnames = []
raw_hostnames.each do |h|
# In case the user has put a port on the hostname
if hostname =~ /:(\d+)/
hostname = hostname.split(":")[0]
if h =~ /:(\d+)/
h = h.split(":")[0]
end
h.strip!
if not (/\A[[:space:]]*\z/ === h)
hostnames << h
end
end

Expand All @@ -52,8 +58,8 @@ def server
abort "If you specify an SSL certificate you must also specify an SSL certificate key"
end

puts "Loading FakeS3 with #{root} on port #{options[:port]} with hostname #{hostname}"
server = FakeS3::Server.new(address,options[:port],store,hostname,ssl_cert_path,ssl_key_path)
puts "Loading FakeS3 with #{root} on port #{options[:port]} with hostnames #{hostnames}"
server = FakeS3::Server.new(address,options[:port],store,hostnames,ssl_cert_path,ssl_key_path)
server.serve
end

Expand Down

0 comments on commit e4ce5bd

Please sign in to comment.