c3d 0.3.5 → 0.4.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.
@@ -1,67 +1,67 @@
1
1
  {
2
- "alt-speed-down": 50,
3
- "alt-speed-enabled": false,
4
- "alt-speed-time-begin": 540,
5
- "alt-speed-time-day": 127,
6
- "alt-speed-time-enabled": false,
7
- "alt-speed-time-end": 1020,
8
- "alt-speed-up": 50,
9
- "bind-address-ipv4": "0.0.0.0",
10
- "bind-address-ipv6": "::",
11
- "blocklist-enabled": false,
12
- "blocklist-url": "http://www.example.com/blocklist",
13
- "cache-size-mb": 4,
14
- "dht-enabled": true,
15
- "download-dir": "/home/coda/.cache/c3d/blobs",
16
- "download-queue-enabled": true,
17
- "download-queue-size": 50,
18
- "encryption": 2,
19
- "idle-seeding-limit": 30,
20
- "idle-seeding-limit-enabled": false,
21
- "incomplete-dir": "/home/coda/.cache/c3d/downloading",
22
- "incomplete-dir-enabled": false,
23
- "lpd-enabled": false,
24
- "message-level": 2,
25
- "peer-congestion-algorithm": "",
26
- "peer-id-ttl-hours": 6,
27
- "peer-limit-global": 200,
28
- "peer-limit-per-torrent": 50,
29
- "peer-port": 51413,
30
- "peer-port-random-high": 65535,
31
- "peer-port-random-low": 49152,
32
- "peer-port-random-on-start": false,
33
- "peer-socket-tos": "default",
34
- "pex-enabled": true,
35
- "port-forwarding-enabled": true,
36
- "preallocation": 1,
37
- "prefetch-enabled": 1,
38
- "queue-stalled-enabled": true,
39
- "queue-stalled-minutes": 98,
40
- "ratio-limit": 2,
41
- "ratio-limit-enabled": false,
42
- "rename-partial-files": true,
43
- "rpc-authentication-required": false,
44
- "rpc-bind-address": "0.0.0.0",
45
- "rpc-enabled": true,
46
- "rpc-password": "{e2f58ad4b908bfce4bc698c730b5b49e2cceea26.21gDuIy",
47
- "rpc-port": 9091,
48
- "rpc-url": "/transmission/",
49
- "rpc-username": "",
50
- "rpc-whitelist": "127.0.0.1",
51
- "rpc-whitelist-enabled": true,
52
- "scrape-paused-torrents-enabled": true,
53
- "script-torrent-done-enabled": false,
54
- "script-torrent-done-filename": "",
55
- "seed-queue-enabled": false,
56
- "seed-queue-size": 0,
57
- "speed-limit-down": 100,
58
- "speed-limit-down-enabled": false,
59
- "speed-limit-up": 100,
60
- "speed-limit-up-enabled": false,
61
- "start-added-torrents": true,
62
- "trash-original-torrent-files": false,
63
- "umask": 18,
64
- "upload-slots-per-torrent": 14,
65
- "utp-enabled": true,
2
+ "alt-speed-down": 50,
3
+ "alt-speed-enabled": false,
4
+ "alt-speed-time-begin": 540,
5
+ "alt-speed-time-day": 127,
6
+ "alt-speed-time-enabled": false,
7
+ "alt-speed-time-end": 1020,
8
+ "alt-speed-up": 50,
9
+ "bind-address-ipv4": "0.0.0.0",
10
+ "bind-address-ipv6": "::",
11
+ "blocklist-enabled": false,
12
+ "blocklist-url": "http://www.example.com/blocklist",
13
+ "cache-size-mb": 4,
14
+ "dht-enabled": true,
15
+ "download-dir": "~/.cache/c3d/blobs",
16
+ "download-queue-enabled": true,
17
+ "download-queue-size": 50,
18
+ "encryption": 2,
19
+ "idle-seeding-limit": 30,
20
+ "idle-seeding-limit-enabled": false,
21
+ "incomplete-dir": "~/.cache/c3d/downloading",
22
+ "incomplete-dir-enabled": false,
23
+ "lpd-enabled": false,
24
+ "message-level": 2,
25
+ "peer-congestion-algorithm": "",
26
+ "peer-id-ttl-hours": 6,
27
+ "peer-limit-global": 200,
28
+ "peer-limit-per-torrent": 100,
29
+ "peer-port": 51413,
30
+ "peer-port-random-high": 65535,
31
+ "peer-port-random-low": 49152,
32
+ "peer-port-random-on-start": false,
33
+ "peer-socket-tos": "default",
34
+ "pex-enabled": true,
35
+ "port-forwarding-enabled": true,
36
+ "preallocation": 1,
37
+ "prefetch-enabled": 1,
38
+ "queue-stalled-enabled": false,
39
+ "queue-stalled-minutes": 98,
40
+ "ratio-limit": 10,
41
+ "ratio-limit-enabled": true,
42
+ "rename-partial-files": true,
43
+ "rpc-authentication-required": false,
44
+ "rpc-bind-address": "0.0.0.0",
45
+ "rpc-enabled": true,
46
+ "rpc-password": "{e2f58ad4b908bfce4bc698c730b5b49e2cceea26.21gDuIy",
47
+ "rpc-port": 9091,
48
+ "rpc-url": "/transmission/",
49
+ "rpc-username": "",
50
+ "rpc-whitelist": "127.0.0.1",
51
+ "rpc-whitelist-enabled": true,
52
+ "scrape-paused-torrents-enabled": true,
53
+ "script-torrent-done-enabled": false,
54
+ "script-torrent-done-filename": "",
55
+ "seed-queue-enabled": false,
56
+ "seed-queue-size": 0,
57
+ "speed-limit-down": 100,
58
+ "speed-limit-down-enabled": false,
59
+ "speed-limit-up": 100,
60
+ "speed-limit-up-enabled": false,
61
+ "start-added-torrents": true,
62
+ "trash-original-torrent-files": false,
63
+ "umask": 63,
64
+ "upload-slots-per-torrent": 14,
65
+ "utp-enabled": true,
66
66
  "watch-dir-enabled": false
67
67
  }
File without changes
@@ -0,0 +1,52 @@
1
+ require 'json'
2
+ require 'securerandom'
3
+ require 'fileutils'
4
+ require 'c3d'
5
+ require 'epm'
6
+
7
+ SWARUM_REPO = 'https://github.com/project-douglas/swarum.git'
8
+
9
+ RSpec.configure do |config|
10
+ config.mock_with :rspec
11
+ config.before(:suite) do
12
+ get_set_up
13
+ end
14
+ config.after(:all) do
15
+ end
16
+ end
17
+
18
+ def get_set_up
19
+ C3D::SetupC3D.new
20
+
21
+ C3D::ConnectTorrent.supervise_as :puller, {
22
+ username: ENV['TORRENT_USER'],
23
+ password: ENV['TORRENT_PASS'],
24
+ url: ENV['TORRENT_RPC'] }
25
+ $puller = Celluloid::Actor[:puller]
26
+
27
+ C3D::ConnectEth.supervise_as :eth, :cpp
28
+ $eth = Celluloid::Actor[:eth]
29
+
30
+ unless check_for_doug
31
+ print "\nThere is No DOUG. Please Fix That."
32
+ exit 0
33
+ end
34
+ end
35
+
36
+ def check_for_doug
37
+ log_file = File.join(ENV['HOME'], '.epm', 'deployed-log.csv')
38
+ begin
39
+ log = File.read log_file
40
+ doug = log.split("\n").map{|l| l.split(',')}.select{|l| l[0] == ("Doug" || "DOUG" || "doug")}[-1][-1]
41
+ rescue
42
+ EPM::Deploy.new(SWARUM_REPO).deploy_package
43
+ log = File.read log_file
44
+ doug = log.split("\n").map{|l| l.split(',')}.select{|l| l[0] == ("Doug" || "DOUG" || "doug")}[-1][-1]
45
+ end
46
+ doug_check = $eth.get_storage_at doug, '0x10'
47
+ if doug_check != '0x'
48
+ return true
49
+ else
50
+ return false
51
+ end
52
+ end
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env ruby
2
+ require 'spec_helper'
3
+
4
+ describe "Setting Up c3D" do
5
+
6
+ describe C3D::SetupC3D, "running Setup Sequence" do
7
+ it "should set the environment variables." do
8
+ expect(ENV['SWARM_DIR']).to be
9
+ expect(ENV['TORRENTS_DIR']).to be
10
+ expect(ENV['BLOBS_DIR']).to be
11
+ expect(ENV['WATCH_FILE']).to be
12
+ expect(ENV['IGNORE_FILE']).to be
13
+ expect(ENV['TORRENT_RPC']).to be
14
+ expect(ENV['TORRENT_USER']).to be
15
+ expect(ENV['TORRENT_PASS']).to be
16
+ expect(ENV['UI_RESPOND']).to be
17
+ expect(ENV['UI_ANNOUNCE']).to be
18
+ expect(ENV['ETH_CONNECTOR']).to be
19
+ expect(ENV['ETH_HOST']).to be
20
+ expect(ENV['ETH_PORT']).to be
21
+ expect(ENV['ETH_KEY']).to be
22
+ end
23
+
24
+ it "should build the default files and directories." do
25
+ expect(File.directory? ENV['SWARM_DIR']).to be_truthy
26
+ expect(File.directory? ENV['TORRENTS_DIR']).to be_truthy
27
+ expect(File.directory? ENV['BLOBS_DIR']).to be_truthy
28
+ expect(File.exists? ENV['WATCH_FILE']).to be_truthy
29
+ expect(File.exists? ENV['IGNORE_FILE']).to be_truthy
30
+ end
31
+ end
32
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: c3d
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Casey Kuhlman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-03 00:00:00.000000000 Z
11
+ date: 2014-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -25,51 +25,80 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.13'
27
27
  - !ruby/object:Gem::Dependency
28
- name: bencode
28
+ name: celluloid
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.8'
33
+ version: '0.15'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.8'
40
+ version: '0.15'
41
41
  - !ruby/object:Gem::Dependency
42
- name: celluloid
42
+ name: commander
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0.15'
47
+ version: '4.1'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0.15'
54
+ version: '4.1'
55
55
  - !ruby/object:Gem::Dependency
56
- name: celluloid-zmq
56
+ name: bencode
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0.15'
61
+ version: '0.8'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0.15'
68
+ version: '0.8'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: epm
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
69
97
  description: |2
70
98
  This gem is designed to assist in distribution mangement of content which is controlled by an Ethereum contract.
71
99
  email: caseykuhlman@watershedlegal.com
72
- executables: []
100
+ executables:
101
+ - c3d
73
102
  extensions: []
74
103
  extra_rdoc_files: []
75
104
  files:
@@ -81,24 +110,28 @@ files:
81
110
  - LICENSE.md
82
111
  - README.md
83
112
  - Rakefile
113
+ - bin/c3d
84
114
  - c3d.gemspec
85
115
  - lib/c3d.rb
86
- - lib/c3d/connect_ethereum_rpc.rb
87
- - lib/c3d/connect_ethereum_socket.rb
88
- - lib/c3d/connect_torrent.rb
89
- - lib/c3d/connect_ui.rb
90
- - lib/c3d/get.rb
91
- - lib/c3d/processes.rb
92
- - lib/c3d/publish.rb
93
- - lib/c3d/setup.rb
94
- - lib/c3d/subscribe.rb
95
- - lib/c3d/util.rb
116
+ - lib/c3d/actors/blacklist.rb
117
+ - lib/c3d/actors/crawler.rb
118
+ - lib/c3d/actors/getter.rb
119
+ - lib/c3d/actors/subscribe.rb
120
+ - lib/c3d/connectors/connect_ethereum.rb
121
+ - lib/c3d/connectors/connect_torrent.rb
122
+ - lib/c3d/util/blobber.rb
123
+ - lib/c3d/util/processes.rb
124
+ - lib/c3d/util/purger.rb
125
+ - lib/c3d/util/setup.rb
126
+ - lib/c3d/util/trees.rb
127
+ - lib/c3d/util/util.rb
128
+ - lib/c3d/util/watch.rb
96
129
  - lib/c3d/version.rb
97
130
  - settings/c3d-config.json
98
131
  - settings/transmission.json
99
- - spec/checker.rb
100
- - spec/checker2.rb
101
- - spec/tmp
132
+ - spec/fixtures/tmp
133
+ - spec/spec_helper.rb
134
+ - spec/unit/1.setup_spec.rb
102
135
  homepage: https://github.com/ethereum-package-manager/c3d
103
136
  licenses: []
104
137
  metadata: {}
@@ -124,6 +157,6 @@ specification_version: 4
124
157
  summary: Contract Controlled Content Distribution using Ethereum Contracts to Distribute
125
158
  Content.
126
159
  test_files:
127
- - spec/checker.rb
128
- - spec/checker2.rb
129
- - spec/tmp
160
+ - spec/fixtures/tmp
161
+ - spec/spec_helper.rb
162
+ - spec/unit/1.setup_spec.rb
@@ -1,147 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- # Transactions:
4
- # * `add-blob-to-g`: add blob to group (params: blob: "BLOB_ID", contract: "CONTRACT_ADDRESS", group: "GROUP_ID") (returns success: true or error)
5
- # * `rm-blob-from-g`: remove blob from contract (params: blob: "BLOB_ID", contract: "CONTRACT_ADDRESS", group: "GROUP_ID") (returns success: true or error)
6
-
7
- require 'socket'
8
- require 'json'
9
-
10
- class ConnectEthRPC
11
- include Celluloid
12
-
13
- def initialize client, host=ENV['ETH_HOST'], port=ENV['ETH_PORT']
14
- @client = client
15
- @question_socket = TCPSocket.new host, port
16
- puts "[C3D-EPM::#{Time.now.strftime( "%F %T" )}] c3D->eth via RPC on port >>\t#{ENV['ETH_PORT']}"
17
- end
18
-
19
- def get_storage_at address, storage_location
20
- address = guard_addresses address
21
- storage_location = guard_addresses storage_location
22
-
23
- case @client
24
- when :go
25
- request = {
26
- id: 1,
27
- method: "EthereumApi.GetStorageAt",
28
- params: [{
29
- address: address,
30
- key: storage_location
31
- }]
32
- }
33
- when :cpp
34
- request = {
35
- id: 1,
36
- method: "storageAt",
37
- params: [{
38
- a: address,
39
- x: storage_location
40
- }]
41
- }
42
- end
43
-
44
- send_command request
45
- end
46
-
47
- def transact recipient, key='', data='', value=0, gas=10000, gas_price=100000
48
- recipient = guard_addresses recipient
49
-
50
- case @client
51
- when :go
52
- request = {
53
- id: 1,
54
- method: "EthereumApi.Transact",
55
- params: [{
56
- recipient: recipient,
57
- value: value,
58
- gas: gas,
59
- gasprice: gas_price
60
- }]
61
- }
62
- when :cpp
63
- request = {
64
- id: 1,
65
- method: 'transact',
66
- params: [{
67
- sec: '',#todo: key,
68
- xValue: value,
69
- aDest: recipient,
70
- bData: '',#todo: build_data data,
71
- xGas: gas,
72
- xGasPrice: gas_price
73
- }]
74
- }
75
- end
76
-
77
- send_command request
78
- end
79
-
80
- def create body_file, endowment=0, key='', gas=10000, gas_price=100000
81
- body_content = File.read(body_file)
82
-
83
- case @client
84
- when :go
85
- request = {
86
- id: 1,
87
- method: "EthereumApi.Create",
88
- params: [{
89
- init: '',
90
- body: body_content,
91
- value: endowment,
92
- gas: gas,
93
- gasprice: gas_price
94
- }]
95
- }
96
- when :cpp
97
- request = {
98
- id: 1,
99
- method: "create",
100
- params: [{
101
- sec: '',#todo: key,
102
- xEndowment: endowment,
103
- bCode: body_content,
104
- xGas: gas,
105
- xGasPrice: gas_price
106
- }]
107
- }
108
- end
109
-
110
- send_command request
111
- end
112
-
113
- private
114
-
115
- def guard_addresses address
116
- unless address[0..1] == "0x"
117
- address = "0x" + address
118
- end
119
- end
120
-
121
- def build_data data
122
- if data.class == Array
123
- slots = data[0].to_i
124
- data.each do |piece|
125
- #todo, encode the pieces...
126
- end
127
- else
128
- return data
129
- end
130
- end
131
-
132
- def send_command request
133
- puts "[C3D-EPM::#{Time.now.strftime( "%F %T" )}] Sending Question >>\t#{request}"
134
- @question_socket.puts request.to_json
135
- handle_response JSON.parse(@question_socket.gets)
136
- end
137
-
138
- def handle_response response
139
- unless response["error"]
140
- puts "[C3D-EPM::#{Time.now.strftime( "%F %T" )}] Received Answer >>\tanswer:#{response['result']}"
141
- return JSON.parse(response["result"])
142
- else
143
- puts "[C3D-EPM::#{Time.now.strftime( "%F %T" )}] Received Answer >>\tERROR!"
144
- return nil
145
- end
146
- end
147
- end
@@ -1,122 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- # Transactions:
4
- # * `add-blob-to-g`: add blob to group (params: blob: "BLOB_ID", contract: "CONTRACT_ADDRESS", group: "GROUP_ID") (returns success: true or error)
5
- # * `rm-blob-from-g`: remove blob from contract (params: blob: "BLOB_ID", contract: "CONTRACT_ADDRESS", group: "GROUP_ID") (returns success: true or error)
6
-
7
- require 'json'
8
- require 'celluloid/zmq'
9
-
10
- Celluloid::ZMQ.init
11
-
12
- class ConnectEthZMQ
13
- include Celluloid::ZMQ
14
-
15
- def initialize
16
- @question_socket = ReqSocket.new
17
- begin
18
- @question_socket.connect ENV['ETH_ZMQ_ADDR']
19
- rescue IOError
20
- @question_socket.close
21
- end
22
- puts "[C3D-EPM::#{Time.now.strftime( "%F %T" )}] c3D->eth via ZMQ and JS Socket on port >>\t#{ENV['ETH_ZMQ_ADDR'].split(':').last}"
23
- end
24
-
25
- def get_storage_at address, storage_location
26
- address = guard_addresses address
27
- storage_location = guard_addresses storage_location
28
-
29
- request = {
30
- method: 'getStorageAt',
31
- params: [
32
- address,
33
- storage_location
34
- ]
35
- }
36
-
37
- send_message request
38
- end
39
-
40
- def transact recipient, key='', data='', value=0, gas=10000
41
- recipient = guard_addresses recipient
42
- #todo -- add variable gas_price
43
-
44
- request = {
45
- method: 'transact',
46
- params: [
47
- key, #todo -- fix this -- especially in the socket listeners.
48
- value,
49
- recipient,
50
- gas,
51
- data #todo -- audit this
52
- ].flatten
53
- }
54
-
55
- send_message request
56
- end
57
-
58
- def create body_file, endowment=0, key='', gas=10000
59
- body = File.read(body_file)
60
- #todo -- add variable gas_price
61
-
62
- request = {
63
- method: 'create',
64
- params: [
65
- key, #todo -- fix this -- especially in the socket listeners.
66
- endowment,
67
- body,
68
- gas
69
- ]
70
- }
71
-
72
- send_message request
73
- end
74
-
75
- private
76
-
77
- def guard_addresses address
78
- unless address[0..1] == "0x"
79
- address = "0x" + address
80
- end
81
- end
82
-
83
- def send_message request
84
- puts "[C3D-EPM::#{Time.now.strftime( "%F %T" )}] Sending Question >>\t#{request}"
85
- @question_socket.send request.to_json
86
- handle_response JSON.load(@question_socket.read)
87
- end
88
-
89
- def handle_response response
90
- puts "[C3D-EPM::#{Time.now.strftime( "%F %T" )}] Received Answer >>\tsuccess:#{response['success']}\tanswer:#{response['answer']}"
91
- return response['answer']
92
- end
93
- end
94
-
95
- if __FILE__==$0
96
- ENV['ETH_ZMQ_ADDR'] = 'tcp://127.0.0.1:31315'
97
-
98
- message = {}
99
- message['method'] = 'transact'
100
- message['params'] = [
101
- 'a6cb63ec28c12929bee2d3567bf98f374a0b7167', #senderaddr
102
- '', #value
103
- '61363f0d19cfe71a5c130642016e37649610294b', #recipientaddr
104
- '10000', #gas
105
- '3', #dataslots
106
- 'newp', #....data
107
- '0x76A46EAB30845C1FA2C0E08243890CDFBF73D6421CFA5BF9169FFB98A3300000',
108
- '0x1d822cb2e4c60c3a8a85546304072b14fb9de94e2c0c608c4120b5d529590c9d'
109
- ]
110
- questions_for_eth = ConnectEth.new
111
- questions_for_eth.write JSON.dump message
112
-
113
- message = {}
114
- message['method'] = 'getStorageAt'
115
- message['params'] = [
116
- '61363f0d19cfe71a5c130642016e37649610294b',
117
- '0x76A46EAB30845C1FA2C0E08243890CDFBF73D6421CFA5BF9169FFB98A3300003'
118
- ]
119
-
120
- questions_for_eth.write JSON.dump message
121
- sleep
122
- end