distribustream 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +18 -0
- data/README +5 -41
- data/bin/dsclient +23 -10
- data/bin/dstream +70 -7
- data/distribustream.gemspec +6 -6
- data/lib/pdtp/client.rb +35 -19
- data/lib/pdtp/client/callbacks.rb +18 -7
- data/lib/pdtp/client/connection.rb +31 -25
- data/lib/pdtp/client/file_buffer.rb +14 -2
- data/lib/pdtp/client/file_service.rb +17 -11
- data/lib/pdtp/client/http_client.rb +18 -19
- data/lib/pdtp/client/http_handler.rb +21 -11
- data/lib/pdtp/client/transfer.rb +29 -29
- data/lib/pdtp/common.rb +19 -4
- data/lib/pdtp/common/file_service.rb +14 -2
- data/lib/pdtp/common/http_server.rb +217 -0
- data/lib/pdtp/common/length_prefix_protocol.rb +14 -2
- data/lib/pdtp/common/protocol.rb +23 -16
- data/lib/pdtp/server.rb +101 -26
- data/lib/pdtp/server/client_info.rb +14 -2
- data/lib/pdtp/server/connection.rb +31 -9
- data/lib/pdtp/server/dispatcher.rb +37 -87
- data/lib/pdtp/server/file_service.rb +17 -2
- data/lib/pdtp/server/file_service_protocol.rb +23 -38
- data/lib/pdtp/server/status_handler.rb +103 -0
- data/lib/pdtp/server/transfer.rb +21 -9
- data/lib/pdtp/server/trust.rb +14 -2
- data/pdtp-specification.xml +831 -0
- metadata +8 -8
- data/bin/dsseed +0 -32
- data/lib/pdtp/common/common_init.rb +0 -122
- data/lib/pdtp/server/stats_handler.rb +0 -23
metadata
CHANGED
@@ -3,13 +3,13 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: distribustream
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2008-
|
6
|
+
version: 0.3.0
|
7
|
+
date: 2008-11-09 00:00:00 -07:00
|
8
8
|
summary: DistribuStream is a fully open peercasting system allowing on-demand or live streaming media to be delivered at a fraction of the normal cost
|
9
9
|
require_paths:
|
10
10
|
- lib
|
11
11
|
email: tony@clickcaster.com
|
12
|
-
homepage: http://distribustream.
|
12
|
+
homepage: http://distribustream.org
|
13
13
|
rubyforge_project: distribustream
|
14
14
|
description:
|
15
15
|
autorequire:
|
@@ -34,7 +34,6 @@ authors:
|
|
34
34
|
- Tom Stapleton
|
35
35
|
files:
|
36
36
|
- bin/dsclient
|
37
|
-
- bin/dsseed
|
38
37
|
- bin/dstream
|
39
38
|
- lib/pdtp
|
40
39
|
- lib/pdtp/client
|
@@ -47,8 +46,8 @@ files:
|
|
47
46
|
- lib/pdtp/client/transfer.rb
|
48
47
|
- lib/pdtp/client.rb
|
49
48
|
- lib/pdtp/common
|
50
|
-
- lib/pdtp/common/common_init.rb
|
51
49
|
- lib/pdtp/common/file_service.rb
|
50
|
+
- lib/pdtp/common/http_server.rb
|
52
51
|
- lib/pdtp/common/length_prefix_protocol.rb
|
53
52
|
- lib/pdtp/common/protocol.rb
|
54
53
|
- lib/pdtp/common.rb
|
@@ -58,7 +57,7 @@ files:
|
|
58
57
|
- lib/pdtp/server/dispatcher.rb
|
59
58
|
- lib/pdtp/server/file_service.rb
|
60
59
|
- lib/pdtp/server/file_service_protocol.rb
|
61
|
-
- lib/pdtp/server/
|
60
|
+
- lib/pdtp/server/status_handler.rb
|
62
61
|
- lib/pdtp/server/transfer.rb
|
63
62
|
- lib/pdtp/server/trust.rb
|
64
63
|
- lib/pdtp/server.rb
|
@@ -70,6 +69,7 @@ files:
|
|
70
69
|
- COPYING
|
71
70
|
- README
|
72
71
|
- CHANGES
|
72
|
+
- pdtp-specification.xml
|
73
73
|
test_files: []
|
74
74
|
|
75
75
|
rdoc_options:
|
@@ -81,9 +81,9 @@ extra_rdoc_files:
|
|
81
81
|
- COPYING
|
82
82
|
- README
|
83
83
|
- CHANGES
|
84
|
+
- pdtp-specification.xml
|
84
85
|
executables:
|
85
86
|
- dstream
|
86
|
-
- dsseed
|
87
87
|
- dsclient
|
88
88
|
extensions: []
|
89
89
|
|
@@ -106,7 +106,7 @@ dependencies:
|
|
106
106
|
requirements:
|
107
107
|
- - ">="
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version: 1.0.
|
109
|
+
version: 1.0.2
|
110
110
|
version:
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: json
|
data/bin/dsseed
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#--
|
3
|
-
# Copyright (C) 2006-07 ClickCaster, Inc. (info@clickcaster.com)
|
4
|
-
# All rights reserved. See COPYING for permissions.
|
5
|
-
#
|
6
|
-
# This source file is distributed as part of the
|
7
|
-
# DistribuStream file transfer system.
|
8
|
-
#
|
9
|
-
# See http://distribustream.rubyforge.org/
|
10
|
-
#++
|
11
|
-
|
12
|
-
require 'optparse'
|
13
|
-
require 'rubygems'
|
14
|
-
require 'eventmachine'
|
15
|
-
require 'mongrel'
|
16
|
-
|
17
|
-
require File.dirname(__FILE__) + '/../lib/pdtp/common/common_init'
|
18
|
-
require File.dirname(__FILE__) + '/../lib/pdtp/server/file_service_protocol'
|
19
|
-
|
20
|
-
common_init File.basename($0)
|
21
|
-
|
22
|
-
# Run the EventMachine reactor loop
|
23
|
-
EventMachine::run do
|
24
|
-
host, port, listen_port = @@config[:host], @@config[:port], @@config[:listen_port]
|
25
|
-
|
26
|
-
connection = EventMachine::connect(host, port, PDTP::Server::FileService::Protocol) do |c|
|
27
|
-
c.instance_eval { @base_path = @@config[:file_root] }
|
28
|
-
end
|
29
|
-
|
30
|
-
@@log.info "connecting with ev=#{EventMachine::VERSION}"
|
31
|
-
@@log.info "host= #{host} port=#{port}"
|
32
|
-
end
|
@@ -1,122 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright (C) 2006-07 ClickCaster, Inc. (info@clickcaster.com)
|
3
|
-
# All rights reserved. See COPYING for permissions.
|
4
|
-
#
|
5
|
-
# This source file is distributed as part of the
|
6
|
-
# DistribuStream file transfer system.
|
7
|
-
#
|
8
|
-
# See http://distribustream.rubyforge.org/
|
9
|
-
#++
|
10
|
-
|
11
|
-
#Provides functions used for initialization by both the client and server
|
12
|
-
|
13
|
-
require 'optparse'
|
14
|
-
require 'logger'
|
15
|
-
|
16
|
-
require File.dirname(__FILE__) + '/protocol'
|
17
|
-
|
18
|
-
STDOUT.sync=true
|
19
|
-
STDERR.sync=true
|
20
|
-
|
21
|
-
@@log=Logger.new(STDOUT)
|
22
|
-
@@log.datetime_format=""
|
23
|
-
|
24
|
-
CONFIG_TYPES = {
|
25
|
-
:host => :string,
|
26
|
-
:vhost => :string,
|
27
|
-
:port => :int,
|
28
|
-
:listen_port => :int,
|
29
|
-
:file_root => :string,
|
30
|
-
:quiet => :bool,
|
31
|
-
:chunk_size => :int,
|
32
|
-
:request_url => :string
|
33
|
-
} unless defined? CONFIG_TYPES
|
34
|
-
|
35
|
-
#prints banner and loads config file
|
36
|
-
def common_init(program_name, config = nil)
|
37
|
-
@@config = config || {
|
38
|
-
:host => '0.0.0.0',
|
39
|
-
:port => 6086, #server port
|
40
|
-
:listen_port => 8000, #client listen port
|
41
|
-
:file_root => '.',
|
42
|
-
:chunk_size => 5000,
|
43
|
-
:quiet => true
|
44
|
-
}
|
45
|
-
|
46
|
-
config_filename=nil
|
47
|
-
|
48
|
-
unless config
|
49
|
-
OptionParser.new do |opts|
|
50
|
-
opts.banner = "Usage: #{program_name} [options]"
|
51
|
-
opts.on("--config CONFIGFILE", "Load specified config file.") do |c|
|
52
|
-
config_filename=c
|
53
|
-
end
|
54
|
-
opts.on("--help", "Prints this usage info.") do
|
55
|
-
puts opts
|
56
|
-
exit
|
57
|
-
end
|
58
|
-
end.parse!
|
59
|
-
end
|
60
|
-
|
61
|
-
puts "#{program_name} starting. Run '#{program_name} --help' for more info."
|
62
|
-
|
63
|
-
load_config_file(config_filename) unless config
|
64
|
-
|
65
|
-
begin
|
66
|
-
@@config[:file_root]=File.expand_path(@@config[:file_root])
|
67
|
-
rescue
|
68
|
-
puts "Invalid path specified for file_root"
|
69
|
-
return
|
70
|
-
end
|
71
|
-
|
72
|
-
puts "@@config=#{@@config.inspect}"
|
73
|
-
validate_config_options
|
74
|
-
handle_config_options
|
75
|
-
end
|
76
|
-
|
77
|
-
#loads a config file specified by config_filename
|
78
|
-
def load_config_file(config_filename)
|
79
|
-
if config_filename.nil?
|
80
|
-
puts "No config file specified. Using defaults."
|
81
|
-
return
|
82
|
-
end
|
83
|
-
|
84
|
-
confstr=File.read(config_filename) rescue nil
|
85
|
-
if confstr.nil?
|
86
|
-
puts "Unable to open config file: #{config_filename}"
|
87
|
-
exit
|
88
|
-
end
|
89
|
-
|
90
|
-
begin
|
91
|
-
new_config = YAML.load confstr
|
92
|
-
@@config.merge!(new_config)
|
93
|
-
@@config[:vhost] ||= @@config[:host] # Use host as vhost unless specified
|
94
|
-
rescue Exception => e
|
95
|
-
puts "Error parsing config file: #{config_filename}"
|
96
|
-
puts e
|
97
|
-
exit
|
98
|
-
end
|
99
|
-
|
100
|
-
puts "Loaded config file: #{config_filename}"
|
101
|
-
end
|
102
|
-
|
103
|
-
#make sure all the config options are of the right type
|
104
|
-
def validate_config_options
|
105
|
-
@@config.each do |key,val|
|
106
|
-
type=CONFIG_TYPES[key]
|
107
|
-
if type.nil?
|
108
|
-
puts "Unknown parameter: #{key}"
|
109
|
-
exit
|
110
|
-
end
|
111
|
-
|
112
|
-
unless PDTP::Protocol.obj_matches_type?(val,type)
|
113
|
-
puts "Parameter: #{key} is not of type: #{type}"
|
114
|
-
exit
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
#responds to config options that are used by both client and server
|
120
|
-
def handle_config_options
|
121
|
-
@@log.level=Logger::INFO if @@config[:quiet]
|
122
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'mongrel'
|
3
|
-
|
4
|
-
module PDTP
|
5
|
-
class Server
|
6
|
-
#set up the mongrel server for serving the stats page
|
7
|
-
class StatsHandler < Mongrel::HttpHandler
|
8
|
-
def initialize(server)
|
9
|
-
@server = server
|
10
|
-
end
|
11
|
-
|
12
|
-
def process(request,response)
|
13
|
-
response.start(200) do |head, out|
|
14
|
-
out.write begin
|
15
|
-
outstr = @server.generate_html_stats
|
16
|
-
rescue Exception=>e
|
17
|
-
outstr = "Exception: #{e}\n#{e.backtrace.join("\n")}"
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|