spitfire 0.1.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/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +12 -0
- data/Rakefile +1 -0
- data/bin/spitfire +5 -0
- data/lib/spitfire/version.rb +3 -0
- data/lib/spitfire.rb +86 -0
- data/spitfire.gemspec +23 -0
- metadata +103 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Wiktor Macura
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# Spitfire
|
2
|
+
|
3
|
+
Extremely low overhead file and directory transfer, mainly by not bothering with encryption.
|
4
|
+
|
5
|
+
spitfire transfer --source-host host1 \
|
6
|
+
--source-dir /var/run/kafka/logs \
|
7
|
+
--destination-host host2 \
|
8
|
+
--destination-dir /tmp/spitfirelogs2
|
9
|
+
|
10
|
+
Internally spitfire works by opening a socket on both hosts through `nc` and using `tar` to transfer contents.
|
11
|
+
|
12
|
+
You'll have no problem saturating dual gigabit uplinks with in-datacenter transfers.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/spitfire
ADDED
data/lib/spitfire.rb
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
require "spitfire/version"
|
2
|
+
require 'thor'
|
3
|
+
|
4
|
+
require 'net/ssh'
|
5
|
+
|
6
|
+
def channel_execute(session, command, prefix = '')
|
7
|
+
$stdout.sync
|
8
|
+
return session.open_channel do |ch|
|
9
|
+
$stdout.print "#{prefix} !! #{command}"
|
10
|
+
ch.exec command do |ch|
|
11
|
+
ch.on_data do |c,data|
|
12
|
+
$stdout.print "#{prefix}> #{data}"
|
13
|
+
end
|
14
|
+
|
15
|
+
ch.on_extended_data do |ch, type, data|
|
16
|
+
$stderr.print "#{prefix}:ERR> #{data}"
|
17
|
+
end
|
18
|
+
|
19
|
+
ch.on_eof do |ch|
|
20
|
+
$stdout.print "#{prefix} [eof]"
|
21
|
+
end
|
22
|
+
|
23
|
+
ch.on_close do |ch|
|
24
|
+
$stdout.print "#{prefix} [closed]"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
ch.wait
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
module Spitfire
|
33
|
+
class CLI < Thor
|
34
|
+
desc 'transfer', 'transfer files'
|
35
|
+
method_option :source_host, default: '127.0.0.1'
|
36
|
+
method_option :source_user
|
37
|
+
method_option :source_dir, default: '.'
|
38
|
+
|
39
|
+
method_option :port_number, default: '56789'
|
40
|
+
method_option :destination_host, required: true
|
41
|
+
method_option :destination_user
|
42
|
+
method_option :destination_dir, required: true
|
43
|
+
|
44
|
+
def transfer
|
45
|
+
source_user = options['source_user']
|
46
|
+
source_user ||= %x[whoami].strip
|
47
|
+
|
48
|
+
destination_user = options['destination_user']
|
49
|
+
destination_user ||= source_user
|
50
|
+
|
51
|
+
puts "Connecting to destination: #{options.destination_host} as #{destination_user}"
|
52
|
+
destThread = Thread.new {
|
53
|
+
destination = Net::SSH.start(options.destination_host, destination_user)
|
54
|
+
destChannel = channel_execute(
|
55
|
+
destination,
|
56
|
+
"echo 'ok'; mkdir -p #{options.destination_dir}; cd #{options.destination_dir}; nc -vl #{options.port_number} | tar xvvf -",
|
57
|
+
'DEST'
|
58
|
+
)
|
59
|
+
destination.loop{true}
|
60
|
+
}
|
61
|
+
|
62
|
+
|
63
|
+
sleep(2)
|
64
|
+
puts "Connecting to source: #{options.source_host} as #{source_user}"
|
65
|
+
srcThread = Thread.new {
|
66
|
+
source = Net::SSH.start(options.source_host, source_user)
|
67
|
+
command = "echo 'ok'; cd #{options.source_dir}; tar vvc . | nc -v #{options.destination_host} #{options.port_number}"
|
68
|
+
|
69
|
+
srcChannel = channel_execute(
|
70
|
+
source,
|
71
|
+
command,
|
72
|
+
' SRC'
|
73
|
+
)
|
74
|
+
source.close()
|
75
|
+
}
|
76
|
+
|
77
|
+
|
78
|
+
# wait for the source to finish
|
79
|
+
srcThread.join
|
80
|
+
|
81
|
+
# okay, now pause and kill the destination
|
82
|
+
sleep(2)
|
83
|
+
destThread.kill
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
data/spitfire.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'spitfire/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "spitfire"
|
8
|
+
gem.version = Spitfire::VERSION
|
9
|
+
gem.authors = ["Wiktor Macura"]
|
10
|
+
gem.email = ["wiktor@tumblr.com"]
|
11
|
+
gem.description = %q{ultra lightweight, encryption free directory transfer}
|
12
|
+
gem.summary = %q{ultra lightweight, encryption free directory transfer}
|
13
|
+
gem.homepage = "http://github.com/wkm/spitfire"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_dependency 'net-ssh'
|
21
|
+
gem.add_dependency 'highline'
|
22
|
+
gem.add_dependency 'thor'
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: spitfire
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Wiktor Macura
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-03-05 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: net-ssh
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: highline
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: thor
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
description: ultra lightweight, encryption free directory transfer
|
63
|
+
email:
|
64
|
+
- wiktor@tumblr.com
|
65
|
+
executables:
|
66
|
+
- spitfire
|
67
|
+
extensions: []
|
68
|
+
extra_rdoc_files: []
|
69
|
+
files:
|
70
|
+
- .gitignore
|
71
|
+
- Gemfile
|
72
|
+
- LICENSE.txt
|
73
|
+
- README.md
|
74
|
+
- Rakefile
|
75
|
+
- bin/spitfire
|
76
|
+
- lib/spitfire.rb
|
77
|
+
- lib/spitfire/version.rb
|
78
|
+
- spitfire.gemspec
|
79
|
+
homepage: http://github.com/wkm/spitfire
|
80
|
+
licenses: []
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options: []
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ! '>='
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
+
none: false
|
93
|
+
requirements:
|
94
|
+
- - ! '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
requirements: []
|
98
|
+
rubyforge_project:
|
99
|
+
rubygems_version: 1.8.25
|
100
|
+
signing_key:
|
101
|
+
specification_version: 3
|
102
|
+
summary: ultra lightweight, encryption free directory transfer
|
103
|
+
test_files: []
|