fiverr_copy 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/fiverr_copy/client.rb +5 -18
- data/lib/fiverr_copy/recipe.rb +4 -2
- data/lib/fiverr_copy/server.rb +12 -7
- data/lib/fiverr_copy/version.rb +1 -1
- metadata +3 -3
data/lib/fiverr_copy/client.rb
CHANGED
@@ -21,23 +21,7 @@ class FiverrCopy::Client
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def setup!
|
24
|
-
|
25
|
-
Net::SSH.start(self.client_ip, self.username) do |ssh|
|
26
|
-
bundler_exists = ssh.exec!("which bundle") == "" ? false : true
|
27
|
-
if !(bundler_exists)
|
28
|
-
puts "Installing bundler on #{client_ip}."
|
29
|
-
puts ssh.exec!("gem install bundler --no-rdoc --no-ri")
|
30
|
-
end
|
31
|
-
|
32
|
-
fiverr_copy_exists = ssh.exec!("gem list | grep fiverr_copy") == "" ? false : true
|
33
|
-
|
34
|
-
if !(fiverr_copy_exists)
|
35
|
-
puts "Installing fiverr_copy."
|
36
|
-
puts ssh.exec!("gem install fiverr_copy --no-rdoc --no-ri")
|
37
|
-
end
|
38
|
-
|
39
|
-
@ready = true
|
40
|
-
end
|
24
|
+
@ready = true
|
41
25
|
end
|
42
26
|
|
43
27
|
|
@@ -65,7 +49,10 @@ class FiverrCopy::Client
|
|
65
49
|
puts "Got #{stream.size} bytes"
|
66
50
|
f.write stream
|
67
51
|
|
68
|
-
|
52
|
+
if !(next_client.nil?)
|
53
|
+
puts "Forwarding to #{next_client}"
|
54
|
+
client_session.write(stream)
|
55
|
+
end
|
69
56
|
session.puts "OK:#{stream.size}"
|
70
57
|
end
|
71
58
|
# end #end thread conversation
|
data/lib/fiverr_copy/recipe.rb
CHANGED
@@ -6,7 +6,8 @@ class FiverrCopy::Recipe
|
|
6
6
|
:username,
|
7
7
|
:port,
|
8
8
|
:chunk_size,
|
9
|
-
:manual
|
9
|
+
:manual,
|
10
|
+
:gem_installation_auth
|
10
11
|
|
11
12
|
attr_reader :initialized_clients
|
12
13
|
|
@@ -17,6 +18,7 @@ class FiverrCopy::Recipe
|
|
17
18
|
self.port = 1234
|
18
19
|
self.chunk_size = 1024
|
19
20
|
self.manual = false
|
21
|
+
self.gem_installation_auth = ""
|
20
22
|
@initialized_clients = []
|
21
23
|
yield(self)
|
22
24
|
self
|
@@ -25,7 +27,7 @@ class FiverrCopy::Recipe
|
|
25
27
|
def manual_client_activation?
|
26
28
|
self.manual == true
|
27
29
|
end
|
28
|
-
|
30
|
+
|
29
31
|
def clients=(clients_array = [])
|
30
32
|
raise "No clients specified" if clients_array.empty?
|
31
33
|
clients_array.uniq!
|
data/lib/fiverr_copy/server.rb
CHANGED
@@ -19,24 +19,29 @@ class FiverrCopy::Server
|
|
19
19
|
if !(self.recipe.manual_client_activation?)
|
20
20
|
self.recipe.initialized_clients.each do |client|
|
21
21
|
threads << Thread.new(client) do |current_client|
|
22
|
-
|
22
|
+
current_client.setup!
|
23
23
|
puts "Connecting to #{current_client.client_ip}:#{self.recipe.port}"
|
24
24
|
Net::SSH.start(current_client.client_ip, current_client.username) do |ssh|
|
25
|
-
|
25
|
+
gem_exists = ssh.exec("which fiverr_copy") == "" ? false : true
|
26
|
+
if !(gem_exists)
|
27
|
+
puts "Please install the fiverr_copy gem on all clients."
|
28
|
+
exit 0
|
29
|
+
end
|
26
30
|
next_client = "--nexthop #{current_client.next_client}" if current_client.next_client
|
27
|
-
puts "#{current_client}: fiverr_copy --client --port #{self.recipe.port} --filename #{compressed_file_name} --chunk #{self.recipe.chunk_size} #{next_client} \&"
|
31
|
+
puts "#{current_client.client_ip}: fiverr_copy --client --port #{self.recipe.port} --filename #{compressed_file_name} --chunk #{self.recipe.chunk_size} #{next_client} \&"
|
28
32
|
ssh.exec("fiverr_copy --client --port #{self.recipe.port} --filename #{compressed_file_name} --chunk #{self.recipe.chunk_size} #{next_client} \&")
|
29
33
|
end
|
30
34
|
end
|
31
35
|
end
|
32
36
|
end
|
33
37
|
|
38
|
+
#threads.collect(&:join)
|
34
39
|
puts "Booting clients"
|
35
40
|
|
36
41
|
attempts = 1
|
37
42
|
begin
|
38
|
-
puts "Attempting Connection to #{self.recipe.initialized_clients.
|
39
|
-
client_session = TCPSocket.new(self.recipe.initialized_clients.
|
43
|
+
puts "Attempting Connection to #{self.recipe.initialized_clients.last.client_ip}:#{self.recipe.port}"
|
44
|
+
client_session = TCPSocket.new(self.recipe.initialized_clients.last.client_ip, self.recipe.port)
|
40
45
|
puts "Compressing: tar cvzf #{compressed_file_name} #{self.recipe.filter}"
|
41
46
|
`tar cvzf #{compressed_file_name} #{self.recipe.filter}`
|
42
47
|
rescue Errno::ECONNREFUSED => e
|
@@ -46,7 +51,7 @@ class FiverrCopy::Server
|
|
46
51
|
print "Retry #{attempts}: "
|
47
52
|
retry
|
48
53
|
else
|
49
|
-
puts "ERROR: unable to connect to #{self.recipe.initialized_clients.
|
54
|
+
puts "ERROR: unable to connect to #{self.recipe.initialized_clients.last.client_ip} => #{e.to_s}"
|
50
55
|
exit 0
|
51
56
|
end
|
52
57
|
end
|
@@ -62,7 +67,7 @@ class FiverrCopy::Server
|
|
62
67
|
puts "Transmitting..."
|
63
68
|
|
64
69
|
File.open("#{compressed_file_name}") do |transmitted_file|
|
65
|
-
puts "Transmitting #{transmitted_file.to_s} (#{File.size(transmitted_file)})"
|
70
|
+
puts "Transmitting #{transmitted_file.path.to_s} (#{File.size(transmitted_file)})"
|
66
71
|
while !(client_session.closed?) && (buffer = transmitted_file.read(self.recipe.chunk_size)) do
|
67
72
|
puts "Sending #{buffer.size}B"
|
68
73
|
client_session.write buffer
|
data/lib/fiverr_copy/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fiverr_copy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 1
|
10
|
+
version: 1.0.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Elad Meidar
|