* s3cmd, S3/Config.py, S3/S3.py: HTTPS support
git-svn-id: https://s3tools.svn.sourceforge.net/svnroot/s3tools/s3cmd/trunk@132 830e0280-6d2a-0410-9c65-932aecc39d9d
... | ... |
@@ -20,12 +20,13 @@ class Config(object): |
20 | 20 |
force = False |
21 | 21 |
acl_public = False |
22 | 22 |
proxy_host = "" |
23 |
- proxy_port = 8080 |
|
23 |
+ proxy_port = 3128 |
|
24 | 24 |
encrypt = False |
25 | 25 |
gpg_passphrase = "" |
26 | 26 |
gpg_command = "" |
27 | 27 |
gpg_encrypt = "%(gpg_command)s -c --verbose --no-use-agent --batch --yes --passphrase-fd %(passphrase_fd)s -o %(output_file)s %(input_file)s" |
28 | 28 |
gpg_decrypt = "%(gpg_command)s -d --verbose --no-use-agent --batch --yes --passphrase-fd %(passphrase_fd)s -o %(output_file)s %(input_file)s" |
29 |
+ use_https = False |
|
29 | 30 |
|
30 | 31 |
## Creating a singleton |
31 | 32 |
def __new__(self, configfile = None): |
... | ... |
@@ -84,6 +84,8 @@ class S3(object): |
84 | 84 |
self.config = config |
85 | 85 |
|
86 | 86 |
def get_connection(self): |
87 |
+ if self.config.use_https: |
|
88 |
+ return httplib.HTTPSConnection(self.config.host) |
|
87 | 89 |
if self.config.proxy_host != "": |
88 | 90 |
return httplib.HTTPConnection(self.config.proxy_host, self.config.proxy_port) |
89 | 91 |
else: |
... | ... |
@@ -278,6 +278,7 @@ def run_configure(config_file): |
278 | 278 |
("secret_key", "Secret Key"), |
279 | 279 |
("gpg_passphrase", "Encryption password", "Encryption password is used to protect your files from reading\nby unauthorized persons while in transfer to S3"), |
280 | 280 |
("gpg_command", "Path to GPG program"), |
281 |
+ ("use_https", "Use HTTPS protocol", "When using secure HTTPS protocol all communication with Amazon S3\nservers is protected from 3rd party eavesdropping. This method is\nslower than plain HTTP and can't be used if you're behind a proxy"), |
|
281 | 282 |
("proxy_host", "HTTP Proxy server name", "On some networks all internet access must go through a HTTP proxy.\nTry setting it here if you can't conect to S3 directly"), |
282 | 283 |
("proxy_port", "HTTP Proxy server port"), |
283 | 284 |
] |
... | ... |
@@ -297,8 +298,18 @@ def run_configure(config_file): |
297 | 297 |
output("Refer to user manual for detailed description of all options.") |
298 | 298 |
for option in options: |
299 | 299 |
prompt = option[1] |
300 |
+ ## Option-specific handling |
|
301 |
+ if option[0] == 'proxy_host' and getattr(cfg, 'use_https') == True: |
|
302 |
+ setattr(cfg, option[0], "") |
|
303 |
+ continue |
|
304 |
+ if option[0] == 'proxy_port' and getattr(cfg, 'proxy_host') == "": |
|
305 |
+ setattr(cfg, option[0], 0) |
|
306 |
+ continue |
|
307 |
+ |
|
300 | 308 |
try: |
301 | 309 |
val = getattr(cfg, option[0]) |
310 |
+ if type(val) is bool: |
|
311 |
+ val = val and "Yes" or "No" |
|
302 | 312 |
if val not in (None, ""): |
303 | 313 |
prompt += " [%s]" % val |
304 | 314 |
except AttributeError: |
... | ... |
@@ -309,6 +320,9 @@ def run_configure(config_file): |
309 | 309 |
|
310 | 310 |
val = raw_input(prompt + ": ") |
311 | 311 |
if val != "": |
312 |
+ if type(getattr(cfg, option[0])) is bool: |
|
313 |
+ # Turn 'Yes' into True, everything else into False |
|
314 |
+ val = val.lower().startswith('y') |
|
312 | 315 |
setattr(cfg, option[0], val) |
313 | 316 |
output("\nNew settings:") |
314 | 317 |
for option in options: |