-
Notifications
You must be signed in to change notification settings - Fork 35
Description
When I discovered I could put "aws_s3_host: 192.168.56.101" in my .s3conf/s3config.yml and point s3cmd and s3sync at my Openstack Swift[1] dev machine (which is running swift3[2]) - I was pretty excited! Cause it worked!
But I had to bounce the port over to 80 because everything relies on that handy PORTS_BY_SECURITY map and also the fact that s3try doesn't pass in a port when creating it's AWSAuthConnection. So I didn't see an easy override.
Moving my proxy servers over to 80 works... but then I have to start services with sudo so they can bind to a privileged port (i know, wah wah wah).
Still, I think a aws_s3_port option could get bubbled up out to the conf the way i want without too much trouble. So I'd love to try and send a PR, but I didn't see any tests, and I don't use s3 that much, and I'm not really up to speed on idiomatic ruby...
But basically I just want to add $AWS_S3_PORT to S3sync and always pass it in (even if its nil) to AWSAuthConnection (and QueryStringAuthGenerator?).
What do you think:
diff --git a/S3.rb b/S3.rb
index 3021b97..557991d 100644
--- a/S3.rb
+++ b/S3.rb
@@ -137,14 +137,14 @@ module S3
attr_accessor :calling_format
def initialize(aws_access_key_id, aws_secret_access_key, is_secure=true,
- server=DEFAULT_HOST, port=PORTS_BY_SECURITY[is_secure],
+ server=DEFAULT_HOST, port=nil,
calling_format=CallingFormat::REGULAR)
@aws_access_key_id = aws_access_key_id
@aws_secret_access_key = aws_secret_access_key
@server = server
@is_secure = is_secure
@calling_format = calling_format
- @port = port
+ @port = (port or PORTS_BY_SECURITY[is_secure])
end
def create_bucket(bucket, headers={})
@@ -325,13 +325,13 @@ end
DEFAULT_EXPIRES_IN = 60
def initialize(aws_access_key_id, aws_secret_access_key, is_secure=true,
- server=DEFAULT_HOST, port=PORTS_BY_SECURITY[is_secure],
+ server=DEFAULT_HOST, port=nil,
format=CallingFormat::REGULAR)
@aws_access_key_id = aws_access_key_id
@aws_secret_access_key = aws_secret_access_key
@protocol = is_secure ? 'https' : 'http'
@server = server
- @port = port
+ @port = (port or PORTS_BY_SECURITY[is_secure])
@calling_format = format
# by default expire
@expires_in = DEFAULT_EXPIRES_IN
diff --git a/s3try.rb b/s3try.rb
index e236dcc..ab73f26 100644
--- a/s3try.rb
+++ b/s3try.rb
@@ -12,6 +12,7 @@ module S3sync
$AWS_ACCESS_KEY_ID = ENV["AWS_ACCESS_KEY_ID"]
$AWS_SECRET_ACCESS_KEY = ENV["AWS_SECRET_ACCESS_KEY"]
$AWS_S3_HOST = (ENV["AWS_S3_HOST"] or "s3.amazonaws.com")
+ $AWS_S3_PORT = ENV["AWS_S3_PORT"]
$HTTP_PROXY_HOST = ENV["HTTP_PROXY_HOST"]
$HTTP_PROXY_PORT = ENV["HTTP_PROXY_PORT"]
$HTTP_PROXY_USER = ENV["HTTP_PROXY_USER"]
@@ -40,7 +41,7 @@ module S3sync
# ---------- CONNECT ---------- #
- $S3syncConnection = S3::AWSAuthConnection.new($AWS_ACCESS_KEY_ID, $AWS_SECRET_ACCESS_KEY, $S3syncOptions['--ssl'], $AWS_S3_HOST)
+ $S3syncConnection = S3::AWSAuthConnection.new($AWS_ACCESS_KEY_ID, $AWS_SECRET_ACCESS_KEY, $S3syncOptions['--ssl'], $AWS_S3_HOST, $AWS_S3_PORT)
$S3syncConnection.calling_format = S3::CallingFormat::string_to_format($AWS_CALLING_FORMAT)
if $S3syncOptions['--ssl']
if $SSL_CERT_DIR
@@ -53,7 +54,7 @@ module S3sync
end
end
def S3sync.s3urlSetup
- $S3syncGenerator = S3::QueryStringAuthGenerator.new($AWS_ACCESS_KEY_ID, $AWS_SECRET_ACCESS_KEY, $S3syncOptions['--ssl'], $AWS_S3_HOST)
+ $S3syncGenerator = S3::QueryStringAuthGenerator.new($AWS_ACCESS_KEY_ID, $AWS_SECRET_ACCESS_KEY, $S3syncOptions['--ssl'], $AWS_S3_HOST, $AWS_S3_PORT)
$S3syncGenerator.calling_format = S3::CallingFormat::string_to_format($AWS_CALLING_FORMAT)
$S3syncGenerator.expires_in = $S3syncOptions['--expires-in']
end
^ WOMM! 🙏
1 - https://launchpad.net/swift
2 - https://github.com/fujita/swift3