torrenter 0.0.1 → 0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 473fad5c40e464ed097518df8cff579077b34072
4
- data.tar.gz: 40ff8e80571d14cd92a32f2e7b1bad4658914a36
3
+ metadata.gz: 126aceaca6caddcec9814075900faa9f8e5ce0e0
4
+ data.tar.gz: 537b792fc0b1640c9e6683acc9157e2140b5390f
5
5
  SHA512:
6
- metadata.gz: e2e4ae190b34baed37fd95981f33fc4b839fbdf6fa70381a71c4fcd25d75e23ae693ab9bb715a6c5da62dffddf9e7e33d4391ae3a7281734e09ea2696f4d7a32
7
- data.tar.gz: 15d2962fb37e1b76c86f8f9cf98a6e01f421cc4c6d97ed56ece7d36077e7bea4bc970cec02ae0a39e640e2647971ee472342c5db91dc4ad7aa1e73b186a3349c
6
+ metadata.gz: 9c8dc7755108cb35a6f9c99a8ed5f415c84a12e0f5e002f9a5b58d08aa2dff43b0b89952b26be964cfad7ee34683cf532cac1e64e9704fe05c37e0132fe49311
7
+ data.tar.gz: 07eae93f45408462558f941efc24be0fd3779a1982c481f819e470fa0b1bb100c0f4133a0c6167331ffc15462ac3a6235a1452204ad4a6e5fae1171d9f14a544
@@ -44,6 +44,8 @@ module Torrenter
44
44
  end
45
45
 
46
46
  if @socket
47
+ emit_event
48
+
47
49
  @socket.write(handshake)
48
50
  @status = true
49
51
  else
@@ -51,6 +53,12 @@ module Torrenter
51
53
  end
52
54
  end
53
55
 
56
+ def emit_event
57
+ # http = Net::HTTP.new("localhost", 9000)
58
+
59
+ # http.post("/watcher", JSON.generate(peer))
60
+ end
61
+
54
62
  def handshake
55
63
  "#{PROTOCOL}#{@info_hash}#{PEER_ID}"
56
64
  end
@@ -22,6 +22,7 @@ module Torrenter
22
22
  data = IO.read($data_dump, @piece_length, n * @piece_length) || ''
23
23
  @master_index[n] = :downloaded if Digest::SHA1.digest(data) == @sha_list[n]
24
24
  end
25
+ $update = @master_index
25
26
  puts "#{@master_index.count(:downloaded)} pieces are downloaded already."
26
27
  end
27
28
 
@@ -31,6 +32,7 @@ module Torrenter
31
32
  modify_index
32
33
  if !@master_index.all? { |index| index == :downloaded }
33
34
  @peers.each { |peer| peer.connect }
35
+ puts "You are now connected to #{active_peers} peers."
34
36
  loop do
35
37
  break if @master_index.all? { |piece| piece == :downloaded }
36
38
  @peers.each do |peer|
@@ -38,6 +40,7 @@ module Torrenter
38
40
  if peer.status
39
41
  peer.state(@master_index, @blocks) # unless peer.piece_index.all? { |piece| piece == :downloaded }
40
42
  if @master_index.count(:downloaded) > piece_count
43
+ send_post
41
44
  system("clear")
42
45
  puts download_bar + "Downloading from #{active_peers} active peers"
43
46
  end
@@ -53,6 +56,12 @@ module Torrenter
53
56
  end
54
57
  end
55
58
 
59
+ def send_post
60
+ $update = @master_index
61
+ # http = Net::HTTP.new("localhost", 4567)
62
+ # http.post("/filer", JSON.generate({:index => @master_index}))
63
+ end
64
+
56
65
  def active_peers
57
66
  @peers.select { |peer| peer.status }.size
58
67
  end
@@ -1,3 +1,3 @@
1
1
  module Torrenter
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: torrenter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - wismer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-21 00:00:00.000000000 Z
11
+ date: 2014-04-23 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: BitTorrent Client written in Ruby
14
14
  email: