fiverr_copy 1.0.1 → 1.0.2
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/lib/fiverr_copy/client.rb +3 -12
- data/lib/fiverr_copy/server.rb +8 -3
- data/lib/fiverr_copy/version.rb +1 -1
- metadata +3 -3
data/lib/fiverr_copy/client.rb
CHANGED
@@ -33,30 +33,21 @@ class FiverrCopy::Client
|
|
33
33
|
|
34
34
|
client_session = nil
|
35
35
|
if !(next_client.nil?)
|
36
|
-
puts "Connecting to next hop at #{next_client}:#{port}"
|
37
36
|
client_session = TCPSocket.new(next_client, port)
|
38
|
-
else
|
39
|
-
puts "Last hop mode"
|
40
37
|
end
|
41
38
|
|
42
39
|
File.open(filename, "w+") do |f|
|
43
40
|
# Thread.start do
|
44
|
-
while (stream = session.read(chunk.to_i)) do
|
41
|
+
while (stream = session.read(chunk.to_i)) do
|
45
42
|
|
46
|
-
puts "Connection from #{session.peeraddr[2]} at #{session.peeraddr[3]}"
|
47
|
-
|
48
|
-
|
49
|
-
puts "Got #{stream.size} bytes"
|
50
43
|
f.write stream
|
51
|
-
|
44
|
+
|
52
45
|
if !(next_client.nil?)
|
53
|
-
puts "Forwarding to #{next_client}"
|
54
46
|
client_session.write(stream)
|
55
47
|
end
|
56
48
|
session.puts "OK:#{stream.size}"
|
57
49
|
end
|
58
|
-
# end #end thread conversation
|
59
50
|
end
|
60
|
-
|
51
|
+
|
61
52
|
end
|
62
53
|
end
|
data/lib/fiverr_copy/server.rb
CHANGED
@@ -29,7 +29,9 @@ class FiverrCopy::Server
|
|
29
29
|
end
|
30
30
|
next_client = "--nexthop #{current_client.next_client}" if current_client.next_client
|
31
31
|
puts "#{current_client.client_ip}: fiverr_copy --client --port #{self.recipe.port} --filename #{compressed_file_name} --chunk #{self.recipe.chunk_size} #{next_client} \&"
|
32
|
-
|
32
|
+
silence_stream(STDOUT) do
|
33
|
+
ssh.exec("fiverr_copy --client --port #{self.recipe.port} --filename #{compressed_file_name} --chunk #{self.recipe.chunk_size} #{next_client} \&")
|
34
|
+
end
|
33
35
|
end
|
34
36
|
end
|
35
37
|
end
|
@@ -65,12 +67,15 @@ class FiverrCopy::Server
|
|
65
67
|
end
|
66
68
|
|
67
69
|
puts "Transmitting..."
|
70
|
+
file_size = File.size(compressed_file_name)
|
68
71
|
|
69
72
|
File.open("#{compressed_file_name}") do |transmitted_file|
|
70
|
-
puts "Transmitting #{transmitted_file.path.to_s} (#{
|
73
|
+
puts "Transmitting #{transmitted_file.path.to_s} (#{file_size.to_f / 1024})"
|
74
|
+
sent = 0
|
71
75
|
while !(client_session.closed?) && (buffer = transmitted_file.read(self.recipe.chunk_size)) do
|
72
|
-
puts "Sending #{buffer.size}B"
|
73
76
|
client_session.write buffer
|
77
|
+
sent += self.recipe.chunk_size
|
78
|
+
print "\r#{"%.2f" % (sent.to_f / file_size.to_f * 100)}% "
|
74
79
|
end
|
75
80
|
puts "Done!"
|
76
81
|
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: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 2
|
10
|
+
version: 1.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Elad Meidar
|