fling 0.0.6 → 0.0.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 +4 -4
- data/CHANGES.md +5 -0
- data/README.md +8 -1
- data/lib/fling/cli.rb +49 -4
- data/lib/fling/config.rb +24 -2
- data/lib/fling/{setup.rb → install.rb} +1 -1
- data/lib/fling/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42a6f202d12d757770f9fef30de7a95cee9ba807
|
4
|
+
data.tar.gz: 227651d33e67bca3f0f92c153eb238d792fe1298
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65076a7b134a4e458929d2bbda14a0ade327e40d33fcd1f63e0c32fee0f36df05101862492dba44be947b684edfdc707a69a8ce92530366db509fd98ee1b821a
|
7
|
+
data.tar.gz: 4590386fe7a699f37b1aff4a7c987ef234a238e8cd71019c1eb46a4aeeb6938a1cb995404822948552578ba18802cb282fe68ad9e6015190d7de1e2c15acada4
|
data/CHANGES.md
CHANGED
data/README.md
CHANGED
@@ -38,12 +38,19 @@ Or install it yourself as:
|
|
38
38
|
Once fling has been installed, you can use it to install a local Tahoe-LAFS
|
39
39
|
client by running the following command:
|
40
40
|
|
41
|
-
$ fling
|
41
|
+
$ fling install
|
42
42
|
|
43
43
|
(NOTE: This command is presently only supported on OS X)
|
44
44
|
|
45
45
|
This will download and install a local copy of Tahoe-LAFS.
|
46
46
|
|
47
|
+
After installing Tahoe-LAFS, you can configure your local instance from
|
48
|
+
an administrator-supplied config file with the following command:
|
49
|
+
|
50
|
+
$ fling config https://uri.to/your/orgs.fling
|
51
|
+
|
52
|
+
(NOTE: See below for first-time setup)
|
53
|
+
|
47
54
|
## Contributing
|
48
55
|
|
49
56
|
* Fork this repository on github
|
data/lib/fling/cli.rb
CHANGED
@@ -1,13 +1,16 @@
|
|
1
1
|
require "fling"
|
2
2
|
require "thor"
|
3
|
+
require "uri"
|
4
|
+
require "net/http"
|
3
5
|
|
4
6
|
module Fling
|
5
7
|
# The Fling Command Line Interface
|
6
8
|
class CLI < Thor
|
7
|
-
desc :
|
8
|
-
def
|
9
|
-
require "fling/
|
10
|
-
|
9
|
+
desc :install, "Install Tahoe-LAFS"
|
10
|
+
def install
|
11
|
+
require "fling/install"
|
12
|
+
Install.run
|
13
|
+
say "Now run 'fling config [file or url]' to configure Tahoe-LAFS"
|
11
14
|
end
|
12
15
|
|
13
16
|
desc "provision FILE", "Create encrypted Fling configuration"
|
@@ -31,5 +34,47 @@ module Fling
|
|
31
34
|
File.open(config_file, "w") { |file| file << config }
|
32
35
|
say "Created #{config_file}"
|
33
36
|
end
|
37
|
+
|
38
|
+
desc "config FILE_OR_URL", "Configure Fling from an encrypted configuration file"
|
39
|
+
def config(file_or_uri)
|
40
|
+
require "fling/install"
|
41
|
+
|
42
|
+
if file_or_uri[/\Ahttps:\/\//]
|
43
|
+
uri = URI(file_or_uri)
|
44
|
+
ciphertext = Net::HTTP.get(uri)
|
45
|
+
elsif file_or_uri[/\Ahttp:\/\//] # ಠ_ಠ
|
46
|
+
say "Friends don't let friends use http://"
|
47
|
+
exit 1
|
48
|
+
else # Perhaps it's a file?
|
49
|
+
unless File.exist?(file_or_uri)
|
50
|
+
say "No such file: #{file_or_uri}"
|
51
|
+
exit 1
|
52
|
+
end
|
53
|
+
|
54
|
+
ciphertext = File.read(file_or_uri)
|
55
|
+
end
|
56
|
+
|
57
|
+
say "Loaded #{file_or_uri}"
|
58
|
+
password = ask "Please enter the password to decrypt the config:", echo: false
|
59
|
+
say # newline
|
60
|
+
|
61
|
+
begin
|
62
|
+
config = Config.decrypt(password, ciphertext)
|
63
|
+
rescue Fling::ConfigError => ex
|
64
|
+
say "Error: Couldn't decrypt config: #{ex}"
|
65
|
+
exit 1
|
66
|
+
end
|
67
|
+
|
68
|
+
config_dir = File.expand_path("~/.tahoe")
|
69
|
+
if File.exist?(config_dir)
|
70
|
+
say "Error: #{config_dir} already exists"
|
71
|
+
exit 1
|
72
|
+
end
|
73
|
+
|
74
|
+
config.render(config_dir)
|
75
|
+
|
76
|
+
say "Created #{config_dir}!"
|
77
|
+
say "Start Tahoe by running 'tahoe start'"
|
78
|
+
end
|
34
79
|
end
|
35
80
|
end
|
data/lib/fling/config.rb
CHANGED
@@ -2,12 +2,14 @@ require "json"
|
|
2
2
|
require "uri"
|
3
3
|
require "base64"
|
4
4
|
require "rbnacl"
|
5
|
+
require "fileutils"
|
6
|
+
require "erb"
|
5
7
|
|
6
8
|
module Fling
|
7
9
|
# Configuration for the local Tahoe cluster
|
8
10
|
class Config
|
9
11
|
BEGIN_MARKER = "-----BEGIN ENCRYPTED FLING CONFIGURATION-----\n"
|
10
|
-
END_MARKER = "------END ENCRYPTED FLING CONFIGURATION
|
12
|
+
END_MARKER = "------END ENCRYPTED FLING CONFIGURATION------"
|
11
13
|
|
12
14
|
CONFIG_KEYS = %w(introducer convergence salt dropcap)
|
13
15
|
attr_reader(*CONFIG_KEYS)
|
@@ -31,9 +33,11 @@ module Fling
|
|
31
33
|
# Decrypt an encrypted configuration
|
32
34
|
def self.decrypt(password, ciphertext)
|
33
35
|
matches = ciphertext.match(/#{BEGIN_MARKER}(.*)#{END_MARKER}/m)
|
34
|
-
fail ConfigError, "couldn't find fling configuration" unless matches
|
36
|
+
fail ConfigError, "couldn't find fling configuration (corrupted file?)" unless matches
|
35
37
|
|
36
38
|
new(Box.decrypt(password, Base64.decode64(matches[1])))
|
39
|
+
rescue RbNaCl::CryptoError # bad password
|
40
|
+
fail ConfigError, "couldn't decrypt configuration (corrupted file or bad password?)"
|
37
41
|
end
|
38
42
|
|
39
43
|
# Generate a JSON configuration
|
@@ -63,6 +67,24 @@ module Fling
|
|
63
67
|
end
|
64
68
|
end
|
65
69
|
|
70
|
+
# Render the configuration to the given path
|
71
|
+
def render(path)
|
72
|
+
tahoe_bin = File.expand_path("~/#{Fling::Install::TAHOE_DIR}/bin/tahoe")
|
73
|
+
system "#{tahoe_bin} create-node > /dev/null"
|
74
|
+
|
75
|
+
@nickname = `whoami`
|
76
|
+
@introducer_furl = introducer
|
77
|
+
|
78
|
+
config_template = File.expand_path("../../../templates/tahoe.cfg.erb", __FILE__)
|
79
|
+
tahoe_config = ERB.new(File.read(config_template)).result(binding)
|
80
|
+
|
81
|
+
File.open(File.join(path, "tahoe.cfg"), "w", 0600) { |file| file << tahoe_config }
|
82
|
+
|
83
|
+
secrets = File.join(path, "private")
|
84
|
+
File.open(File.join(secrets, "convergence"), "w", 0600) { |file| file << convergence }
|
85
|
+
File.open(File.join(secrets, "aliases"), "w", 0600) { |file| file << "dropcap: #{dropcap}" }
|
86
|
+
end
|
87
|
+
|
66
88
|
def as_json
|
67
89
|
{
|
68
90
|
introducer: introducer,
|
data/lib/fling/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fling
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tony Arcieri
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -137,7 +137,7 @@ files:
|
|
137
137
|
- lib/fling/cli.rb
|
138
138
|
- lib/fling/config.rb
|
139
139
|
- lib/fling/encoding.rb
|
140
|
-
- lib/fling/
|
140
|
+
- lib/fling/install.rb
|
141
141
|
- lib/fling/version.rb
|
142
142
|
- spec/fixtures/fling.json
|
143
143
|
- spec/fling/box_spec.rb
|