tn_s3_file_uploader 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZjFiMTNlOTlmYjQzODc3M2FjMjE1ZGYzMjM3MDM3ZmM0NmFmM2VjYg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MjQ2YzdkMGMwMWI1YjA4MGRlNDI2YmVjYzFlMzE3N2IyYzJiZDQ5Zg==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NGE0OTExNjIwNmIwOWEyNzI2OWM5NmU2MGUzMTUxNzZkZDY1MjlhZjM3ZGEz
|
10
|
+
ZjQ1ZWJlMGE0MGMxOGRlZTA1OTMyMWNhMjViNTAwMWFhOGM5NmU4MDI1YTUy
|
11
|
+
NzJiZTlmN2EyYzRiNGJiZmRjZTU4Yzg3NzI2MDA5YjJlMGZjYzg=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
YzFiMGQ1Mjc3NWQ2MjUyMGZmYjg0MDIxOGFiNjc4N2E1MjY1OTdmN2YwYzll
|
14
|
+
NDEyMWExM2ZlZjdkNTdmOWQ0MjNjZjNmNmExNjA2N2VhMmU1MzBkZTUzMWVl
|
15
|
+
OTlhYTIzNmQ2MGM1ZmU5ZjNmYjYzMDQ2MTJiMDI5MjUyY2IwMWE=
|
@@ -44,6 +44,14 @@ module TnS3FileUploader
|
|
44
44
|
opts.on("--aws-secret-access-key AWS-SECRET-ACCESS-KEY", "Provide the AWS secret access key") do |aws_secret_access_key|
|
45
45
|
options[:aws_secret_access_key] = aws_secret_access_key
|
46
46
|
end
|
47
|
+
|
48
|
+
# Default: Google's static IP
|
49
|
+
options[:udp_resolve_ip] = '64.233.187.99'
|
50
|
+
opts.on("--udp_resolve_ip RESOLVE-IP", "Lookup IP to determine active network interface local IP.") do |resolve_ip|
|
51
|
+
if resolve_ip =~ /\d+\.\d+\.\d+\.\d+/
|
52
|
+
options[:udp_resolve_ip] = resolve_ip
|
53
|
+
end
|
54
|
+
end
|
47
55
|
|
48
56
|
opts.on("-v", "--verbose", "Display verbose output") do |v|
|
49
57
|
options[:verbose] = !v.nil?
|
@@ -63,6 +63,54 @@ module TnS3FileUploader
|
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
+
# First tries to find local IP using UDPSocket technique.
|
67
|
+
# In the event of a failure, we will revert to using the old
|
68
|
+
# method of local ip retrieval. In the event that both techniques
|
69
|
+
# fail, we return a default value
|
70
|
+
def local_ip
|
71
|
+
resolve_ip = @options[:udp_resolve_ip]
|
72
|
+
ip_address = nil
|
73
|
+
|
74
|
+
unless resolve_ip.nil?
|
75
|
+
ip_address = udp_resolve_ip(resolve_ip)
|
76
|
+
end
|
77
|
+
|
78
|
+
unless ip_address.nil? or valid_ip?(ip_address)
|
79
|
+
ip_address = hostname_resolve_ip
|
80
|
+
end
|
81
|
+
|
82
|
+
unless valid_ip?(ip_address)
|
83
|
+
ip_address = '0.0.0.0'
|
84
|
+
end
|
85
|
+
|
86
|
+
ip_address
|
87
|
+
end
|
88
|
+
|
89
|
+
# Finds public local IP by tracing a UDP route.
|
90
|
+
# Note: This code does NOT make a connection or send any packets to the listed resolve_ip
|
91
|
+
# UDP is a stateless protocol, the connect method makes
|
92
|
+
# a system call to determine packet routing based on address and what interface it
|
93
|
+
# should bind to. addr returns an array containing the family, local port and local address
|
94
|
+
# The local address is the last element in the addr array.
|
95
|
+
def udp_resolve_ip(resolve_ip)
|
96
|
+
orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true
|
97
|
+
|
98
|
+
UDPSocket.open do |s|
|
99
|
+
s.connect resolve_ip, 1
|
100
|
+
s.addr.last
|
101
|
+
end
|
102
|
+
ensure
|
103
|
+
Socket.do_not_reverse_lookup = orig
|
104
|
+
end
|
105
|
+
|
106
|
+
def hostname_resolve_ip
|
107
|
+
IPSocket.getaddress(Socket.gethostname)
|
108
|
+
end
|
109
|
+
|
110
|
+
def valid_ip?(resolve_ip)
|
111
|
+
resolve_ip =~ /\d+\.\d+\.\d+\.\d+/
|
112
|
+
end
|
113
|
+
|
66
114
|
def build_substitutions(file)
|
67
115
|
file_components = file.split('/').last.split('.')
|
68
116
|
|
@@ -73,8 +121,9 @@ module TnS3FileUploader
|
|
73
121
|
file_name = file_components[0..-2].join('.')
|
74
122
|
file_extension = file_components.last
|
75
123
|
end
|
76
|
-
|
77
|
-
ip_address =
|
124
|
+
|
125
|
+
ip_address = local_ip.gsub('.', '-')
|
126
|
+
|
78
127
|
file_timestamp = generate_file_timestamp
|
79
128
|
|
80
129
|
{
|
metadata
CHANGED
@@ -1,48 +1,47 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tn_s3_file_uploader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.5
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Thinknear.com
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2015-02-05 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: honeybadger
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
19
|
+
version: !binary |-
|
20
|
+
MS4xNQ==
|
22
21
|
type: :runtime
|
23
22
|
prerelease: false
|
24
23
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
24
|
requirements:
|
27
25
|
- - ~>
|
28
26
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
27
|
+
version: !binary |-
|
28
|
+
MS4xNQ==
|
30
29
|
- !ruby/object:Gem::Dependency
|
31
30
|
name: aws-sdk
|
32
31
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
32
|
requirements:
|
35
33
|
- - ~>
|
36
34
|
- !ruby/object:Gem::Version
|
37
|
-
version:
|
35
|
+
version: !binary |-
|
36
|
+
MS4zNQ==
|
38
37
|
type: :runtime
|
39
38
|
prerelease: false
|
40
39
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
40
|
requirements:
|
43
41
|
- - ~>
|
44
42
|
- !ruby/object:Gem::Version
|
45
|
-
version:
|
43
|
+
version: !binary |-
|
44
|
+
MS4zNQ==
|
46
45
|
description: Amazon S3 file uploader that can build folder structures based on timestamp.
|
47
46
|
Typically used in conjunction with Unix's logrotate.
|
48
47
|
email: opensource@thinknear.com
|
@@ -51,7 +50,10 @@ executables:
|
|
51
50
|
extensions: []
|
52
51
|
extra_rdoc_files: []
|
53
52
|
files:
|
53
|
+
- LICENSE.txt
|
54
|
+
- README.md
|
54
55
|
- bin/tn_s3_file_uploader
|
56
|
+
- lib/tn_s3_file_uploader.rb
|
55
57
|
- lib/tn_s3_file_uploader/cli_parser.rb
|
56
58
|
- lib/tn_s3_file_uploader/error_reporting/error_report_manager.rb
|
57
59
|
- lib/tn_s3_file_uploader/error_reporting/honeybadger_error_reporter.rb
|
@@ -61,32 +63,28 @@ files:
|
|
61
63
|
- lib/tn_s3_file_uploader/runner.rb
|
62
64
|
- lib/tn_s3_file_uploader/s3.rb
|
63
65
|
- lib/tn_s3_file_uploader/version.rb
|
64
|
-
- lib/tn_s3_file_uploader.rb
|
65
|
-
- README.md
|
66
|
-
- LICENSE.txt
|
67
66
|
homepage: http://www.thinknear.com
|
68
67
|
licenses:
|
69
68
|
- Copyright (c) ThinkNear 2014, Licensed under APLv2.0
|
69
|
+
metadata: {}
|
70
70
|
post_install_message:
|
71
71
|
rdoc_options: []
|
72
72
|
require_paths:
|
73
73
|
- lib
|
74
74
|
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
-
none: false
|
76
75
|
requirements:
|
77
76
|
- - ! '>='
|
78
77
|
- !ruby/object:Gem::Version
|
79
78
|
version: '0'
|
80
79
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
80
|
requirements:
|
83
81
|
- - ! '>='
|
84
82
|
- !ruby/object:Gem::Version
|
85
83
|
version: '0'
|
86
84
|
requirements: []
|
87
85
|
rubyforge_project:
|
88
|
-
rubygems_version:
|
86
|
+
rubygems_version: 2.4.5
|
89
87
|
signing_key:
|
90
|
-
specification_version:
|
88
|
+
specification_version: 4
|
91
89
|
summary: Amazon S3 file uploader
|
92
90
|
test_files: []
|