fargo 0.1.1 → 0.2.0
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/ext/fargo/base32.c +61 -0
- data/ext/fargo/base32.h +16 -0
- data/ext/fargo/extconf.rb +8 -0
- data/ext/fargo/fargo_tth.c +34 -0
- data/ext/fargo/sboxes.c +515 -0
- data/ext/fargo/tiger.c +245 -0
- data/ext/fargo/tiger.h +41 -0
- data/ext/fargo/tigertree.c +184 -0
- data/ext/fargo/tigertree.h +48 -0
- data/ext/fargo/tth.c +100 -0
- data/ext/fargo/tth.h +18 -0
- data/lib/fargo/client.rb +47 -118
- data/lib/fargo/protocol/dc.rb +52 -0
- data/lib/fargo/{connection → protocol}/download.rb +56 -88
- data/lib/fargo/protocol/hub.rb +81 -0
- data/lib/fargo/search.rb +21 -16
- data/lib/fargo/search_result.rb +6 -6
- data/lib/fargo/supports/chat.rb +10 -7
- data/lib/fargo/supports/downloads.rb +73 -117
- data/lib/fargo/supports/file_list.rb +21 -10
- data/lib/fargo/supports/nick_list.rb +23 -14
- data/lib/fargo/supports/persistence.rb +28 -23
- data/lib/fargo/supports/searches.rb +30 -9
- data/lib/fargo/supports/timeout.rb +8 -5
- data/lib/fargo/supports/uploads.rb +5 -5
- data/lib/fargo/utils.rb +5 -4
- data/lib/fargo/version.rb +1 -1
- data/lib/fargo.rb +8 -10
- metadata +41 -19
- data/lib/fargo/connection/base.rb +0 -126
- data/lib/fargo/connection/hub.rb +0 -120
- data/lib/fargo/connection/search.rb +0 -19
- data/lib/fargo/connection/upload.rb +0 -85
- data/lib/fargo/publisher.rb +0 -42
- data/lib/fargo/server.rb +0 -52
data/lib/fargo/server.rb
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
module Fargo
|
2
|
-
class Server
|
3
|
-
|
4
|
-
include Fargo::Publisher
|
5
|
-
|
6
|
-
def initialize options = {}
|
7
|
-
@options = options
|
8
|
-
@options[:address] = '0.0.0.0'
|
9
|
-
@peers = []
|
10
|
-
end
|
11
|
-
|
12
|
-
def connected?
|
13
|
-
!@server.nil?
|
14
|
-
end
|
15
|
-
|
16
|
-
def connect
|
17
|
-
return if connected?
|
18
|
-
|
19
|
-
Fargo.logger.info "#{self}: Starting server on #{@options[:address]}:#{@options[:port]}"
|
20
|
-
|
21
|
-
@server = TCPServer.new @options[:address], @options[:port]
|
22
|
-
|
23
|
-
@active_thread = Thread.start { loop {
|
24
|
-
|
25
|
-
connection = @options[:connection].new @options.merge(:first => false)
|
26
|
-
|
27
|
-
connection_type = self.class.name.split("::").last.downcase
|
28
|
-
disconnect_symbol = :"#{connection_type}_disconnected"
|
29
|
-
|
30
|
-
connection.subscribe{ |type, hash|
|
31
|
-
@peers.delete connection if type == disconnect_symbol
|
32
|
-
}
|
33
|
-
|
34
|
-
connection.socket = @server.accept
|
35
|
-
connection.listen
|
36
|
-
@peers << connection
|
37
|
-
} }
|
38
|
-
end
|
39
|
-
|
40
|
-
def disconnect
|
41
|
-
Fargo.logger.info "#{self}: disconnecting..."
|
42
|
-
@active_thread.exit if @active_thread
|
43
|
-
|
44
|
-
@server.close if @server rescue nil
|
45
|
-
@server = nil
|
46
|
-
|
47
|
-
@peers.each{ |p| p.disconnect }
|
48
|
-
@peers.clear
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
52
|
-
end
|