fiverr_copy 0.0.10 → 0.0.11
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.
- data/bin/fiverr_copy +1 -0
- data/elad.sql +1 -0
- data/fiverr_copy_compressed_1333352437.tgz +0 -0
- data/lib/fiverr_copy/client.rb +2 -2
- data/lib/fiverr_copy/recipe.rb +14 -1
- data/lib/fiverr_copy/server.rb +27 -11
- data/lib/fiverr_copy/version.rb +1 -1
- metadata +5 -3
data/bin/fiverr_copy
CHANGED
data/elad.sql
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
elad is trying
|
Binary file
|
data/lib/fiverr_copy/client.rb
CHANGED
@@ -52,7 +52,7 @@ class FiverrCopy::Client
|
|
52
52
|
end
|
53
53
|
|
54
54
|
@real_file_name = ""
|
55
|
-
temp_file = "fiverr_copy_#{Time.now.to_i}"
|
55
|
+
temp_file = "fiverr_copy_#{Time.now.to_i}.tgz"
|
56
56
|
Tempfile.open(temp_file) do |f|
|
57
57
|
while (session = server.accept)
|
58
58
|
Thread.start do
|
@@ -74,6 +74,6 @@ class FiverrCopy::Client
|
|
74
74
|
end #end thread conversation
|
75
75
|
end #end loop
|
76
76
|
end
|
77
|
-
FileUtils.mv(temp_file, "
|
77
|
+
FileUtils.mv(temp_file, "#{Dir.pwd}/#{@real_file_name}")
|
78
78
|
end
|
79
79
|
end
|
data/lib/fiverr_copy/recipe.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
class FiverrCopy::Recipe
|
2
|
-
attr_accessor :name, :description, :filter, :clients, :username, :port
|
2
|
+
attr_accessor :name, :description, :filter, :clients, :username, :port, :chunk_size
|
3
3
|
|
4
4
|
attr_reader :initialized_clients
|
5
5
|
|
@@ -8,6 +8,7 @@ class FiverrCopy::Recipe
|
|
8
8
|
self.name = name
|
9
9
|
self.description = description
|
10
10
|
self.port = 1234
|
11
|
+
self.chunk_size = 1024
|
11
12
|
@initialized_clients = []
|
12
13
|
yield(self)
|
13
14
|
self
|
@@ -25,4 +26,16 @@ class FiverrCopy::Recipe
|
|
25
26
|
next_hop = client
|
26
27
|
end
|
27
28
|
end
|
29
|
+
|
30
|
+
def info
|
31
|
+
puts "Recipe: #{self.name}"
|
32
|
+
puts "---------------------"
|
33
|
+
puts self.description
|
34
|
+
puts
|
35
|
+
puts "Filter : #{self.filter}"
|
36
|
+
puts "Clients : #{self.initialized_clients.size}"
|
37
|
+
puts "Port : #{self.port}"
|
38
|
+
puts "Chunk : #{self.chunk_size}"
|
39
|
+
puts "---------------------"
|
40
|
+
end
|
28
41
|
end
|
data/lib/fiverr_copy/server.rb
CHANGED
@@ -13,33 +13,49 @@ class FiverrCopy::Server
|
|
13
13
|
def self.run!
|
14
14
|
threads = []
|
15
15
|
files_to_sync = Dir[self.recipe.filter]
|
16
|
-
puts "Total Clients: #{self.recipe.initialized_clients.size}"
|
17
16
|
self.recipe.initialized_clients.each do |client|
|
18
17
|
threads << Thread.new(client) do |current_client|
|
19
18
|
current_client.setup!
|
20
|
-
puts "Connecting to #{current_client.client_ip}"
|
19
|
+
puts "Connecting to #{current_client.client_ip}:#{self.recipe.port}"
|
21
20
|
Net::SSH.start(current_client.client_ip, current_client.username) do |ssh|
|
21
|
+
ssh.exec("killall fiverr_copy")
|
22
22
|
next_client = "--nexthop #{current_client.next_client}" if current_client.next_client
|
23
|
-
puts "Running: fiverr_copy --client --port #{
|
24
|
-
ssh.exec("fiverr_copy --client --port #{
|
23
|
+
puts "Running: fiverr_copy --client --port #{self.recipe.port} #{next_client} @ #{current_client.client_ip}"
|
24
|
+
ssh.exec("fiverr_copy --client --port #{self.recipe.port} #{next_client} \&")
|
25
25
|
end
|
26
|
-
end
|
26
|
+
end
|
27
|
+
sleep 10
|
27
28
|
end
|
28
29
|
|
29
30
|
compressed_file_name = "fiverr_copy_compressed_#{Time.now.to_i}"
|
30
31
|
|
31
32
|
begin
|
33
|
+
puts "Attempting Connection to #{self.recipe.initialized_clients.first.client_ip}:#{self.recipe.port}"
|
32
34
|
client_session = TCPSocket.new(self.recipe.initialized_clients.first.client_ip, self.recipe.port)
|
33
|
-
puts "Compressing: #{
|
34
|
-
`tar
|
35
|
+
puts "Compressing: tar cvzf #{compressed_file_name}.tgz #{self.recipe.filter}"
|
36
|
+
`tar cvzf #{compressed_file_name}.tgz #{self.recipe.filter}`
|
35
37
|
rescue Errno::ECONNREFUSED => e
|
36
38
|
puts "ERROR: unable to connect to #{self.recipe.initialized_clients.first.client_ip} => #{e.to_s}"
|
37
39
|
end
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
40
|
+
|
41
|
+
puts "Validating Compressed file"
|
42
|
+
if !(FileTest.exists?("#{compressed_file_name}.tgz"))
|
43
|
+
puts "Could not find the compressed file to transfer:"
|
44
|
+
puts `ls *.tgz`
|
45
|
+
puts "exiting"
|
46
|
+
exit 0
|
47
|
+
end
|
48
|
+
|
49
|
+
puts "Transmitting..."
|
50
|
+
|
51
|
+
File.open("#{compressed_file_name}.tgz") do |transmitted_file|
|
52
|
+
client_session.write "FILENAME:#{"#{compressed_file_name}.tgz"}"
|
53
|
+
puts "Transmitting #{transmitted_file.basename} (#{transmitted_file.size})"
|
54
|
+
while (buffer = transmitted_file.read(self.recipe.chunk_size)) do
|
55
|
+
puts "Sending #{buffer.size}B"
|
56
|
+
client_session.write buffer
|
42
57
|
end
|
43
58
|
end
|
59
|
+
|
44
60
|
end
|
45
61
|
end
|
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: 9
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 11
|
10
|
+
version: 0.0.11
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Elad Meidar
|
@@ -62,7 +62,9 @@ files:
|
|
62
62
|
- README.md
|
63
63
|
- Rakefile
|
64
64
|
- bin/fiverr_copy
|
65
|
+
- elad.sql
|
65
66
|
- fiverr_copy.gemspec
|
67
|
+
- fiverr_copy_compressed_1333352437.tgz
|
66
68
|
- lib/fiverr_copy.rb
|
67
69
|
- lib/fiverr_copy/client.rb
|
68
70
|
- lib/fiverr_copy/recipe.rb
|