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 CHANGED
@@ -51,6 +51,7 @@ if options[:mode] == :server
51
51
  exit 0
52
52
  else
53
53
  require options[:recipe]
54
+ FiverrCopy::Server.recipe.info
54
55
  FiverrCopy::Server.run!
55
56
  end
56
57
  else
data/elad.sql ADDED
@@ -0,0 +1 @@
1
+ elad is trying
@@ -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, "~/#{@real_file_name}")
77
+ FileUtils.mv(temp_file, "#{Dir.pwd}/#{@real_file_name}")
78
78
  end
79
79
  end
@@ -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
@@ -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 #{current_client.port} #{next_client} - #{current_client.client_ip}"
24
- ssh.exec("fiverr_copy --client --port #{current_client.port} #{next_client}")
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.join
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: #{files_to_sync.inspect}"
34
- `tar cv #{files_to_sync.join(" ")} #{compressed_file_name}.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
- File.open(compressed_file_name) do |transmitted_file|
40
- while (buffer = transmitted_file.read(size)) do
41
- client_session.puts buffer
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
@@ -1,3 +1,3 @@
1
1
  module FiverrCopy
2
- VERSION = "0.0.10"
2
+ VERSION = "0.0.11"
3
3
  end
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: 11
4
+ hash: 9
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 10
10
- version: 0.0.10
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