c3d 0.5.6 → 0.5.7

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: b89df29d2eb9708a3bc8bfd6328619f09e65da3a
4
- data.tar.gz: 5a8305b77f94b65aacf5bbe43ea2038fd527c535
3
+ metadata.gz: a643edac24f6736a334862867e8f2068be43dd2e
4
+ data.tar.gz: 9da1d9ae7f3327201a5c05ad7b20b9ec11270ae6
5
5
  SHA512:
6
- metadata.gz: 6a1bb4aeb6f2e899c246df60d17b9c378f8b9c9d4733e96d9bcd5a191e3c4ebc8945420e7ae2a78dcd291e5fae1f105b8f7b3025bf1ab998d91faf9eb2c27fb6
7
- data.tar.gz: 619b5b056688678c1110168d889f7948142c9a4bf3923b889a00e93fa7050b56824d828a00194a5211ac626f350f51048a329d606c58efa9bcc58631a49f5865
6
+ metadata.gz: d686d7973f19720a5f4ab4a9740192c022880359a64ec8d11b7f7d0261ca08ca0c61ccd416502db3109946d9c2dfa02f14c476832a684b73fb0eb8d1b998b896
7
+ data.tar.gz: ad0ba837624f36a9fc58295120d15c5f1a21522751b05becd8516ee563bc1acb230288cacbe7bd65097ebad6921582df2806a49acf1dfc069088cce9ebd356e0
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- c3d (0.5.2)
4
+ c3d (0.5.6)
5
5
  bencode (~> 0.8)
6
6
  celluloid (~> 0.15)
7
7
  commander (~> 4.1)
@@ -17,7 +17,7 @@ GEM
17
17
  commander (4.1.6)
18
18
  highline (~> 1.6.11)
19
19
  diff-lcs (1.2.5)
20
- epm (0.3.8)
20
+ epm (0.3.14)
21
21
  commander (~> 4.1.6)
22
22
  highline (1.6.21)
23
23
  httparty (0.13.1)
@@ -29,14 +29,14 @@ GEM
29
29
  rspec-core (~> 3.0.0)
30
30
  rspec-expectations (~> 3.0.0)
31
31
  rspec-mocks (~> 3.0.0)
32
- rspec-core (3.0.1)
32
+ rspec-core (3.0.2)
33
33
  rspec-support (~> 3.0.0)
34
- rspec-expectations (3.0.1)
34
+ rspec-expectations (3.0.2)
35
35
  diff-lcs (>= 1.2.0, < 2.0)
36
36
  rspec-support (~> 3.0.0)
37
- rspec-mocks (3.0.1)
37
+ rspec-mocks (3.0.2)
38
38
  rspec-support (~> 3.0.0)
39
- rspec-support (3.0.0)
39
+ rspec-support (3.0.2)
40
40
  timers (1.1.0)
41
41
 
42
42
  PLATFORMS
data/LICENSE.md CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) [2014] [Watershed Legal Services, PLLC]
1
+ Copyright (c) [2014] Project Douglas Limited
2
2
 
3
3
  Any person who (1) obtains a copy of this software and associated documentation
4
4
  files (the "Software") and (2) agrees to the terms of this license agreement may
@@ -120,8 +120,12 @@ module C3D
120
120
  private
121
121
 
122
122
  def guard_addresses address
123
- unless address[0..1] == "0x"
124
- address = "0x" + address
123
+ if address.class == String
124
+ unless address[0..1] == "0x"
125
+ address = "0x" + address
126
+ end
127
+ else
128
+ address = '0x'
125
129
  end
126
130
  address
127
131
  end
@@ -148,7 +152,17 @@ module C3D
148
152
  def send_command request
149
153
  @request.body = request.to_json
150
154
  puts "[C3D::#{Time.now.strftime( "%F %T" )}] Sending Question >>\t#{@request.body}"
151
- handle_response JSON.parse(@question_socket.request(@request).body)
155
+ begin
156
+ handle_response JSON.parse(@question_socket.request(@request).body)
157
+ rescue
158
+ sleep 2
159
+ begin
160
+ handle_response JSON.parse(@question_socket.request(@request).body)
161
+ rescue
162
+ response = {}
163
+ handle_response response['error'] = 'Cannot Connect to Ethereum Client.'
164
+ end
165
+ end
152
166
  end
153
167
 
154
168
  def handle_response response
@@ -156,7 +170,7 @@ module C3D
156
170
  puts "[C3D::#{Time.now.strftime( "%F %T" )}] Received Answer >>\tanswer:#{response['result']}"
157
171
  return response["result"]
158
172
  else
159
- puts "[C3D::#{Time.now.strftime( "%F %T" )}] Received Answer >>\tERROR!"
173
+ puts "[C3D::#{Time.now.strftime( "%F %T" )}] Received Answer >>\tERROR!: #{response['error']}"
160
174
  return nil
161
175
  end
162
176
  end
@@ -3,10 +3,22 @@
3
3
  # and work by @Burgestrand here: https://gist.github.com/Burgestrand/1733611
4
4
 
5
5
  module C3D
6
+
7
+ ## The Blobber class takes reads from either an input buffer or from a raw file.
8
+ # It first takes the SHA1 checksum of the contents of the file and truncates
9
+ # those down to 24 characters. Then it calculates the information necessary
10
+ # to formulate a torrent file without trackers. That torrent file is then
11
+ # saved into the publisher's torrent file directory as stated in the c3d
12
+ # settings. Lastly, the determined torrent file is submitted to the transmission
13
+ # client for seeding.
6
14
  class Blobber
7
15
  include Celluloid
8
- attr_accessor :tor_file, :blob_file, :sha1_trun, :btih, :mag_link
16
+ attr_reader :tor_file, :blob_file, :sha1_trun, :btih, :mag_link
9
17
 
18
+ # Blobber.new accepts one argument: the blob which is to be torrented and
19
+ # submitted to transmission for seeding. After ensuring that the blob is sent
20
+ # the function will run that blob through the torrenting process by the sequence
21
+ # of function calls to the private functions of the class.
10
22
  def initialize blob
11
23
  @piecelength = 32 * 1024
12
24
  if blob
@@ -19,6 +31,14 @@ module C3D
19
31
 
20
32
  private
21
33
 
34
+ # prepare accepts a blob as its only argument. First the function checks if the
35
+ # blob is a file which currently exists. If it is a file, it will read the contents
36
+ # of the file into memory for the remainder of the functionality. If the blob is
37
+ # a raw piece of content it will already be in memory and need not be read.
38
+ # After the blob is in memory, the function will take the SHA1 checksum of the blob
39
+ # and then will establish the display name (dn) of the blob as well as its torrent
40
+ # file as instance variables of the class. Finally, it will write the contents of the
41
+ # blob into the @blob_file in the blob directory (which is taken from the c3d settings)
22
42
  def prepare blob
23
43
  if File.exists? blob
24
44
  blob = File.read blob
@@ -28,10 +48,14 @@ module C3D
28
48
  @tor_file = File.join(ENV['TORRENTS_DIR'], "#{sha1_trun}.torrent")
29
49
  @blob_file = File.join(ENV['BLOBS_DIR'], sha1_trun)
30
50
  File.open(@blob_file, 'w'){|f| f.write(blob)}
31
- @files = [{ path: @blob_file.split('/'), length: File::open(@blob_file).size }]
32
51
  end
33
52
 
53
+ # the build command builds the information required to forumlate the torrent file.
54
+ # first it adds the files to the file instance variable, then it adds the various
55
+ # information pieces needed. Finally, it runs the read_pieces function to develop
56
+ # the hash that the torrent file needs to ensure it has all the pieces of a torrent.
34
57
  def build
58
+ @files = [{ path: @blob_file.split('/'), length: File::open(@blob_file).size }]
35
59
  @info = { :'created by' => "OWIG3",
36
60
  :'creation date' => DateTime.now.strftime("%s").to_i,
37
61
  encoding: "UTF-8",
@@ -42,30 +66,31 @@ module C3D
42
66
  }
43
67
  }
44
68
  @info[:info][:pieces] = ""
45
- i = 0
46
- read_pieces(@files.first[:path], @piecelength) do |piece|
69
+ read_pieces do |piece|
47
70
  @info[:info][:pieces] += Digest::SHA1.digest(piece)
48
- i += 1
49
71
  end
50
72
  end
51
73
 
52
- def read_pieces file, length
74
+ # read_pieces accepts file and length arguments and it hashes the blob file to
75
+ # make sure that it has all of the pieces. it uses ruby's buffer functionality.
76
+ def read_pieces
77
+ puts "[C3D-EPM::#{Time.now.strftime( "%F %T" )}] Hashing Blob >>\t\t" + "#{@files.first[:path].join("/")}"
53
78
  buffer = ""
54
- puts "[C3D-EPM::#{Time.now.strftime( "%F %T" )}] Hashing Blob >>\t\t" + "#{file.join("/")}"
55
- File.open(file.join("/")) do |fh|
79
+ File.open(@files.first[:path].join("/")) do |file|
56
80
  begin
57
- read = fh.read(length - buffer.length)
58
- if (buffer.length + read.length) == length
81
+ read = file.read(@piecelength - buffer.length)
82
+ if (buffer.length + read.length) == @piecelength
59
83
  yield(buffer + read)
60
84
  buffer = ""
61
85
  else
62
86
  buffer += read
63
87
  end
64
- end until fh.eof?
88
+ end until file.eof?
65
89
  end
66
90
  yield buffer
67
91
  end
68
92
 
93
+ # write torrent byteencodes the torrent information hash into the torrent file.
69
94
  def write_torrent
70
95
  File.open(@tor_file, 'w') do |torrentfile|
71
96
  torrentfile.write @info.bencode
@@ -73,6 +98,12 @@ module C3D
73
98
  puts "[C3D-EPM::#{Time.now.strftime( "%F %T" )}] Torrent Link >>\t\t" + "#{@tor_file}"
74
99
  end
75
100
 
101
+ # publish torrent uses the torrent connector object from the Celluloid actor registry
102
+ # and sends that to the torrent client via RPC. After it sends that it queries the
103
+ # return to understand the btih of the torrent file, which together with the truncated
104
+ # SHA1 checksum of the contents (the display name, or dn) formulates the magnet link
105
+ # and also these pieces are then sent to the ethereum layer for submission to the blockchain
106
+ # via a different class.
76
107
  def publish_torrent
77
108
  torrent = Celluloid::Actor[:puller].create @tor_file
78
109
  begin
@@ -0,0 +1,177 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ module C3D
4
+
5
+ ## The Encryptor class is used to sign and encrypt file blobs using
6
+ # gpg (for now) on a user's computer. The object class is instantiated
7
+ # using any of gpg's options and the instance methods can then be used
8
+ # and will rely upon the instatiated options. The encryptor class
9
+ # will not blob files, and as such it should be called prior to and
10
+ # in conjunction with the Blobber class for users to share encrypted
11
+ # files via the torrent layer c3d utilizes.
12
+ class Encryptor
13
+ include Celluloid
14
+ attr_accessor :opts
15
+ attr_reader :opts_addendum
16
+
17
+ # Encryptor.new can be instantiated using any gpg options available to the
18
+ # user. Each of the options should be sent as the key to the hash with
19
+ # the value of the hash being the value of the option send to the gpg
20
+ # cli. The instantiated class will then use these options whenever any
21
+ # of the instance methods are called.
22
+ def initialize opts={}
23
+ @opts = '--quiet --yes '
24
+ @opts << build_opts(opts)
25
+ end
26
+
27
+ # clearsign will call gpg's clearsign function on a blob. A blob can be passed
28
+ # in the form of raw file contents already read into memory, or as a filepath
29
+ # as is the case with the Blobber class. clearsign will return the raw contents
30
+ # of the clearsigned file to the caller, by clearsigning to a tmp file and reading
31
+ # that tempfile into memory (this will avoid any gpg errors being passed back to
32
+ # the caller). the clearsign function would typically be called in conjunction with
33
+ # the verify function. typically, clearsign will utilize the default gpg keys
34
+ # for the user.
35
+ def clearsign blob
36
+ clear_addendum
37
+ blob = file_or_contents blob
38
+ outf = add_output_path_to_opts
39
+ cmd = build_command '--clearsign', blob
40
+ system "#{cmd}"
41
+ return outf
42
+ end
43
+
44
+ # verify will call gpg's verify function on a blob file. the function will only
45
+ # accept a file path and does not accept raw file contents. the function will return
46
+ # true or false depending on whether the clearsigned file was valid or not. Verify
47
+ # is not used with encrypted files (for simplicity in c3d's case) but only with
48
+ # clearsigned files. This is a design decision for convenience.
49
+ def verify blob_file
50
+ clear_addendum
51
+ cmd = build_command '--verify', blob_file
52
+ result = `#{cmd} 2>&1`
53
+ p "REAS: " + result
54
+ result = parse_gpg_output result
55
+ return result
56
+ end
57
+
58
+ # encrypt will call gpg's sign and encrypt function on a blob. by default encrypt will
59
+ # sign and encrypt via the user's default keys. this function is opinionated and
60
+ # has not been built to provide abstracted gpg encryption functionality. as such,
61
+ # it will utilized gpg's built in rsa encryption functionality rather than using
62
+ # elliptical curve functionality. over time, Project Douglas intends to expand the
63
+ # scope of blob encryption options. the blob argument passed to the encrypt function
64
+ # can be either a file path or raw file contents as with the Blobber class as well as
65
+ # the clearsign function. in addition, the function accepts an array of recipient email
66
+ # addresses or gpg keys which can be used to restrict decryption functionality to the
67
+ # intended recipients of the file blob only.
68
+ def encrypt blob, recipients=[]
69
+ clear_addendum
70
+ blob = file_or_contents blob
71
+ outf = add_output_path_to_opts
72
+ add_recipients_to_opts recipients unless recipients.empty?
73
+ cmd = build_command '--sign --encrypt', blob
74
+ system "#{cmd}"
75
+ return outf
76
+ end
77
+
78
+ # decrypt will call gpg's decrypt function on a blob. the function will only accept
79
+ # a file path and does not accept raw file contents (roughly mirroring the verify
80
+ # function). the function will return an array containing: [0] -- true or false flag
81
+ # which signals whether the signature of the file was correct and verified by gpg as
82
+ # well as [1] -- the path to the decrypted file.
83
+ def decrypt blob_file
84
+ clear_addendum
85
+ outf = add_output_path_to_opts
86
+ cmd = build_command '--decrypt', blob_file
87
+ result = `#{cmd} 2>&1`
88
+ result = parse_gpg_output result
89
+ result = [outf, result]
90
+ return result
91
+ end
92
+
93
+ private
94
+
95
+ # build_opts accepts a hash of options from the instantiating function of the class
96
+ # and builds the command line options which will be passed prior to the gpg command.
97
+ # the keys of the hash must match with gpg options exactly as the function is designed
98
+ # to be relatively dumb. it will simply loop through the keys and change those from
99
+ # symbols to strings while adding the correct cli switcher notation.
100
+ def build_opts opts
101
+ return opts.inject('') do |cmd, key, val|
102
+ cmd << '--'
103
+ cmd << key.to_s
104
+ cmd << ' '
105
+ cmd << val.to_s
106
+ cmd << ' '
107
+ cmd
108
+ end
109
+ end
110
+
111
+ # build_command syncronizes all the pieces of the command structure into a unified
112
+ # cli command which is then sent to gpg via the command line for parsing by the
113
+ # post command functions. this command does not send the command to gpg via a cli
114
+ # interface but simply builds the string.
115
+ def build_command task, blob_or_file
116
+ cmd = 'gpg '
117
+ cmd << @opts
118
+ cmd << ' '
119
+ cmd << @opts_addendum
120
+ cmd << task
121
+ cmd << ' '
122
+ cmd << blob_or_file
123
+ return cmd
124
+ end
125
+
126
+ # separates the options passed to gpg by individual commands from the global ones
127
+ # which are established in the @opts instance variable. Because the class will
128
+ # be called multiple times, we need to clear this instance variable prior to any
129
+ # of the functional commands.
130
+ def clear_addendum
131
+ @opts_addendum = ' '
132
+ end
133
+
134
+ # file_or_contents identifies whether the blob sent to the invoking command was a
135
+ # file or the raw contents of a file. if the later then it will create a temp
136
+ # file and write the raw contents of the file to that tmp file so that gpg can
137
+ # operate on the file contents. gpg does not work well in signing and encrypting
138
+ # from stdin, so we are forced to use tempfiles for this process.
139
+ def file_or_contents blob
140
+ unless File.exists? blob
141
+ blob = Tempfile.new 'c3d-encrypted'
142
+ File.open(blob.path, 'w'){|f| f.write(blob)}
143
+ return blob.path
144
+ end
145
+ return blob
146
+ end
147
+
148
+ # add_recipients_to_opts is invoked by the encrypt function which has an optional
149
+ # array of recipients that may be passed as its second argument. this command
150
+ # loops through those recipients and adds each to the @opts string.
151
+ def add_recipients_to_opts recipients
152
+ @opts_addendum << '--recipients '
153
+ recipients.each do |recip|
154
+ @opts_addendum << ( recip + ' ' )
155
+ end
156
+ end
157
+
158
+ # add_output_path_to_opts is invoked by all of the functions.
159
+ def add_output_path_to_opts
160
+ output_file = Tempfile.new 'c3d-output'
161
+ @opts_addendum << '--output '
162
+ @opts_addendum << ( output_file.path + ' ' )
163
+ return output_file.path
164
+ end
165
+
166
+ # parse_gpg_output performs a regex query on the output string from the gpg
167
+ # verify and decrypt strings to check if the signature of a particular file
168
+ # was valid
169
+ def parse_gpg_output output
170
+ output = output.split("\n")
171
+ p output
172
+ output = output.select{|line| line[/gpg: Good signature/]}
173
+ p output
174
+ return ( ! output.empty? )
175
+ end
176
+ end
177
+ end
@@ -29,6 +29,20 @@ module C3D
29
29
  end
30
30
  return (! a.empty?)
31
31
  end
32
+
33
+ def set_trans_config config
34
+ trans_file = File.join(ENV['HOME'], '.epm', 'settings.json')
35
+ trans_example = File.join(File.dirname(__FILE__), '..', '..', '..', 'settings', 'transmission.json')
36
+ unless File.exists? trans_file
37
+ FileUtils.cp trans_example, trans_file
38
+ end
39
+ trans_config = JSON.load(File.read(trans_file))
40
+ trans_config["incomplete-dir"] = config['download_dir']
41
+ trans_config["download-queue-size"] = config['download-queue-size'].to_i
42
+ trans_config["queue-stalled-minutes"] = config['queue-stalled-minutes'].to_i
43
+ trans_config["seed-queue-size"] = config['seed-queue-size'].to_i
44
+ File.open(trans_file, 'w'){|f| f.write(JSON.pretty_generate(trans_config))}
45
+ end
32
46
  end
33
47
 
34
48
  module EthRunner
@@ -66,8 +80,17 @@ module C3D
66
80
 
67
81
 
68
82
  def is_eth_running?
69
- a = `ps ux`.split("\n").select{|e| e[/eth --json-rpc-port/]}
83
+ a = `ps ux`.split("\n").select{|e| e[/eth .*--json-rpc-port/]}
70
84
  return (! a.empty?)
71
85
  end
86
+
87
+ def eth_process
88
+ if is_eth_running?
89
+ a = `ps ux`.split("\n").select{|e| e[/eth .*--json-rpc-port/]}[0].split(" ")[1]
90
+ return a
91
+ else
92
+ return false
93
+ end
94
+ end
72
95
  end
73
96
  end
@@ -6,119 +6,56 @@ module C3D
6
6
 
7
7
  def initialize cli=false
8
8
  set_deps
9
- #todo - pull these from utility module rather than use here.
10
- config = get_config
11
- set_the_env config
12
- set_trans_config config
9
+ config = C3D::Utility.get_config
10
+ C3D::Utility.set_the_env config
13
11
  set_c3d_config config
14
- start_processes config, cli
12
+ C3D::TransmissionRunner.set_trans_config config
13
+ C3D::TransmissionRunner.start_transmission cli
14
+ C3D::EthRunner.start_ethereum config
15
15
  end
16
16
 
17
17
  private
18
18
 
19
- def set_deps
20
- dep_exist? 'transmission-daemon', 'sudo apt-get install transmission-daemon && sudo service transmission-daemon stop && sudo update-rc.d -f transmission-daemon remove'
21
- end
22
-
23
- def get_config
24
- dir_exist? File.join(ENV['HOME'], '.epm')
25
- config_file = File.join(ENV['HOME'], '.epm', 'c3d-config.json')
26
- config_example = File.join(File.dirname(__FILE__), '..', '..', '..', 'settings', 'c3d-config.json')
27
- unless File.exists? config_file
28
- tmp = File.read config_example
29
- until ! tmp[/(\{\{USERHOME\}\})/]
30
- tmp.gsub!("{{USERHOME}}", ENV["HOME"])
31
- end
32
- print "Before we begin, I need to ask you two personal questions:\n"
33
- print "What is your primary account which I should be using to send transactions?\n\n"
34
- account = STDIN.gets.chomp
35
- print "Thanks. #{account} is what I will use.\n"
36
- print "Thanks. Now what is the private key for that account which I should be using?\n\n"
37
- secret = STDIN.gets.chomp
38
- print "Thanks. #{secret} is what I will use.\n"
39
- account = "0x#{account}" if account[0..1] != '0x'
40
- secret = "0x#{secret}" if secret[0..1] != '0x'
41
- tmp.gsub!("{{0xACCT}}", account)
42
- tmp.gsub!("{{0xSEC}}", secret)
43
- File.open(config_file, 'w'){|f| f.write(tmp)}
19
+ def set_deps
20
+ dep_exist? 'transmission-daemon', 'sudo apt-get install transmission-daemon && sudo service transmission-daemon stop && sudo update-rc.d -f transmission-daemon remove'
44
21
  end
45
- return JSON.load(File.read(config_file))
46
- end
47
22
 
48
- def set_the_env config
49
- ENV['SWARM_DIR'] = config['swarm_dir']
50
- ENV['TORRENTS_DIR'] = config['torrents_dir']
51
- ENV['BLOBS_DIR'] = config['blobs_dir']
52
- ENV['WATCH_FILE'] = config['watch_file']
53
- ENV['IGNORE_FILE'] = config['ignore_file']
54
- ENV['TORRENT_RPC'] = config['torrent_rpc']
55
- ENV['TORRENT_USER'] = config['torrent_user']
56
- ENV['TORRENT_PASS'] = config['torrent_pass']
57
- ENV['UI_RESPOND'] = config['ui_respond']
58
- ENV['UI_ANNOUNCE'] = config['ui_announce']
59
- ENV['ETH_CONNECTOR'] = config['eth_connector']
60
- ENV['ETH_ZMQ_ADDR'] = config['eth_zmq_addr']
61
- ENV['ETH_HOST'] = config['eth_rpc_host']
62
- ENV['ETH_PORT'] = config['eth_rpc_port']
63
- ENV['ETH_KEY'] ||= config['primary_account_key']
64
- ENV['GAS_PRICE'] = config['gas_price'] || '100000000000000'
65
- end
66
-
67
- def set_trans_config config
68
- trans_file = File.join(ENV['HOME'], '.epm', 'settings.json')
69
- trans_example = File.join(File.dirname(__FILE__), '..', '..', '..', 'settings', 'transmission.json')
70
- unless File.exists? trans_file
71
- FileUtils.cp trans_example, trans_file
23
+ def set_c3d_config config
24
+ dir_exist? ENV['SWARM_DIR']
25
+ dir_exist? ENV['TORRENTS_DIR']
26
+ dir_exist? ENV['BLOBS_DIR']
27
+ dir_exist? ENV['TORRENT_DOWN_DIR']
28
+ file_exist? ENV['WATCH_FILE']
29
+ file_exist? ENV['IGNORE_FILE']
72
30
  end
73
- trans_config = JSON.load(File.read(trans_file))
74
- trans_config["incomplete-dir"] = config['download_dir']
75
- trans_config["download-queue-size"] = config['download-queue-size'].to_i
76
- trans_config["queue-stalled-minutes"] = config['queue-stalled-minutes'].to_i
77
- trans_config["seed-queue-size"] = config['seed-queue-size'].to_i
78
- File.open(trans_file, 'w'){|f| f.write(JSON.pretty_generate(trans_config))}
79
- end
80
31
 
81
- def set_c3d_config config
82
- dir_exist? ENV['SWARM_DIR']
83
- dir_exist? ENV['TORRENTS_DIR']
84
- dir_exist? ENV['BLOBS_DIR']
85
- dir_exist? config['download_dir']
86
- file_exist? ENV['WATCH_FILE']
87
- file_exist? ENV['IGNORE_FILE']
88
- end
89
-
90
- def start_processes config, cli
91
- C3D::TransmissionRunner.start_transmission cli
92
- C3D::EthRunner.start_ethereum config
93
- end
94
-
95
- def dir_exist? directry
96
- unless File.directory? directry
97
- FileUtils.mkdir_p directry
32
+ def dir_exist? directry
33
+ unless File.directory? directry
34
+ FileUtils.mkdir_p directry
35
+ end
98
36
  end
99
- end
100
37
 
101
- def file_exist? fil
102
- unless File.exists? fil
103
- File.open(fil, "w") {}
38
+ def file_exist? fil
39
+ unless File.exists? fil
40
+ File.open(fil, "w") {}
41
+ end
104
42
  end
105
- end
106
43
 
107
- def dep_exist? dependency, fixer
108
- unless which dependency
109
- `#{fixer}`
44
+ def dep_exist? dependency, fixer
45
+ unless which dependency
46
+ `#{fixer}`
47
+ end
110
48
  end
111
- end
112
49
 
113
- def which cmd
114
- exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
115
- ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
116
- exts.each { |ext|
117
- exe = File.join(path, "#{cmd}#{ext}")
118
- return exe if File.executable? exe
119
- }
50
+ def which cmd
51
+ exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
52
+ ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
53
+ exts.each { |ext|
54
+ exe = File.join(path, "#{cmd}#{ext}")
55
+ return exe if File.executable? exe
56
+ }
57
+ end
58
+ return nil
120
59
  end
121
- return nil
122
- end
123
60
  end
124
61
  end
@@ -53,22 +53,37 @@ module C3D
53
53
  end
54
54
 
55
55
  def set_the_env config
56
- ENV['SWARM_DIR'] = config['swarm_dir']
57
- ENV['TORRENTS_DIR'] = config['torrents_dir']
58
- ENV['BLOBS_DIR'] = config['blobs_dir']
59
- ENV['WATCH_FILE'] = config['watch_file']
60
- ENV['IGNORE_FILE'] = config['ignore_file']
61
- ENV['TORRENT_RPC'] = config['torrent_rpc']
62
- ENV['TORRENT_USER'] = config['torrent_user']
63
- ENV['TORRENT_PASS'] = config['torrent_pass']
64
- ENV['UI_RESPOND'] = config['ui_respond']
65
- ENV['UI_ANNOUNCE'] = config['ui_announce']
66
- ENV['ETH_CONNECTOR'] = config['eth_connector']
67
- ENV['ETH_ZMQ_ADDR'] = config['eth_zmq_addr']
68
- ENV['ETH_HOST'] = config['eth_rpc_host']
69
- ENV['ETH_PORT'] = config['eth_rpc_port']
70
- ENV['ETH_KEY'] ||= config['primary_account_key']
71
- ENV['GAS_PRICE'] = config['gas_price'] || '100000000000000'
56
+ ENV['SWARM_DIR'] = config['swarm_dir']
57
+ ENV['TORRENTS_DIR'] = config['torrents_dir']
58
+ ENV['BLOBS_DIR'] = config['blobs_dir']
59
+ ENV['WATCH_FILE'] = config['watch_file']
60
+ ENV['IGNORE_FILE'] = config['ignore_file']
61
+ ENV['TORRENT_RPC'] = config['torrent_rpc']
62
+ ENV['TORRENT_USER'] = config['torrent_user']
63
+ ENV['TORRENT_PASS'] = config['torrent_pass']
64
+ ENV['TORRENT_DOWN_DIR'] = config['download_dir']
65
+ ENV['ETH_HOST'] = config['eth_rpc_host']
66
+ ENV['ETH_PORT'] = config['eth_rpc_port']
67
+ ENV['ETH_REMOTE'] = config["eth_remote"]
68
+ ENV['ETH_KEY'] ||= config['primary_account_key']
69
+ ENV['BLOCKCHAIN_DIR'] = config["blockchain_dir"]
70
+ ENV['GAS_PRICE'] = config['gas_price'] || '100000000000000'
71
+ end
72
+
73
+ def get_latest_doug
74
+ log_file = File.join(ENV['HOME'], '.epm', 'deployed-log.csv')
75
+ begin
76
+ log = File.read log_file
77
+ doug = log.split("\n").map{|l| l.split(',')}.select{|l| l[0] == ("Doug" || "DOUG" || "doug")}[-1][-1]
78
+ rescue
79
+ doug = '0x'
80
+ end
81
+ doug_check = Celluloid::Actor[:eth].get_storage_at doug, '0x10'
82
+ if doug_check != '0x'
83
+ return doug
84
+ else
85
+ return nil
86
+ end
72
87
  end
73
88
 
74
89
  def dir_exist? directry
@@ -1 +1 @@
1
- VERSION ||= "0.5.6"
1
+ VERSION ||= "0.5.7"
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.5.6
4
+ version: 0.5.7
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-26 00:00:00.000000000 Z
11
+ date: 2014-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -135,6 +135,7 @@ files:
135
135
  - lib/c3d/connectors/connect_ethereum.rb
136
136
  - lib/c3d/connectors/connect_torrent.rb
137
137
  - lib/c3d/util/blobber.rb
138
+ - lib/c3d/util/encrypt.rb
138
139
  - lib/c3d/util/processes.rb
139
140
  - lib/c3d/util/purger.rb
140
141
  - lib/c3d/util/setup.rb