wsio 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +1 -0
- data/Manifest +5 -0
- data/README +29 -0
- data/Rakefile +12 -0
- data/bin/wsio +11 -0
- data/lib/wsio.rb +62 -0
- data/wsio.gemspec +34 -0
- metadata +88 -0
- metadata.gz.sig +3 -0
data.tar.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
�
|
data/Manifest
ADDED
data/README
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
wsio -- web stream input/output tool
|
2
|
+
|
3
|
+
Usage: wsio [options] [user[:pass]@][hostname][path]
|
4
|
+
-l Listen to stream and print to STDOUT
|
5
|
+
-s Use HTTPS
|
6
|
+
-k Ignore SSL verification (like curl)
|
7
|
+
|
8
|
+
By default, wsio listens to STDIN and does an HTTP POST for each line.
|
9
|
+
|
10
|
+
This tool is similar to netcat in that it's intended to be used with STDIN and
|
11
|
+
STDOUT, making it perfect for command pipelining. However, instead of direct
|
12
|
+
point to point TCP/UDP connections, it uses HTTP. Coupled with a server that
|
13
|
+
provides realtime pubsub over HTTP and you have one of the most magical tools
|
14
|
+
ever. Example:
|
15
|
+
|
16
|
+
Log Aggregation
|
17
|
+
===============
|
18
|
+
|
19
|
+
Run this on one or several machines:
|
20
|
+
|
21
|
+
tail -f /var/log/something | wsio somehost/log
|
22
|
+
|
23
|
+
Run this on your central aggregator:
|
24
|
+
|
25
|
+
wsio -l somehost/log > /var/log/aggregate
|
26
|
+
|
27
|
+
Run this on your *laptop* behind a NAT to watch the logs:
|
28
|
+
|
29
|
+
wsio -l somehost/log
|
data/Rakefile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'echoe'
|
4
|
+
|
5
|
+
Echoe.new('wsio', '0.0.1') do |p|
|
6
|
+
p.description = "Web stream input/output tool"
|
7
|
+
p.url = "http://github.com/progrium/wsio"
|
8
|
+
p.author = "Jeff Lindsay"
|
9
|
+
p.email = "jeff.lindsay@twilio.com"
|
10
|
+
p.ignore_pattern = ["tmp/*", "script/*"]
|
11
|
+
p.development_dependencies = []
|
12
|
+
end
|
data/bin/wsio
ADDED
data/lib/wsio.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'httpclient'
|
3
|
+
require 'highline/import'
|
4
|
+
require 'json'
|
5
|
+
require 'base64'
|
6
|
+
|
7
|
+
def start(args)
|
8
|
+
host_and_path = args.pop
|
9
|
+
if host_and_path.include? '@'
|
10
|
+
auth, host_and_path = host_and_path.split('@')
|
11
|
+
user, pass = (auth.split(':')<<nil)[0,2]
|
12
|
+
#unless pass
|
13
|
+
# pass = ask("Password for #{user}: ") {|q| q.echo = false}
|
14
|
+
#end
|
15
|
+
end
|
16
|
+
raise "No host specified" unless host_and_path
|
17
|
+
args = args.join.gsub('-', '')
|
18
|
+
scheme = (args.include? 's') ? 'https' : 'http'
|
19
|
+
url = "#{scheme}://#{host_and_path}"
|
20
|
+
if args.include? 'l'
|
21
|
+
c = HTTPClient.new
|
22
|
+
c.get_content(url) do |chunk|
|
23
|
+
obj = JSON.parse(chunk)
|
24
|
+
if obj.is_a? Array
|
25
|
+
puts obj.first
|
26
|
+
else
|
27
|
+
puts chunk
|
28
|
+
end
|
29
|
+
end
|
30
|
+
else
|
31
|
+
STDIN.each_line do |line|
|
32
|
+
begin
|
33
|
+
obj = JSON.parse(line)
|
34
|
+
if obj.is_a? Hash
|
35
|
+
body = line
|
36
|
+
headers = {"Content-Type" => "application/json"}
|
37
|
+
elsif obj.is_a? Array
|
38
|
+
body = obj.first.to_s
|
39
|
+
headers = {"Content-Type" => "text/plain"}
|
40
|
+
else
|
41
|
+
body = obj.to_s
|
42
|
+
headers = {"Content-Type" => "text/plain"}
|
43
|
+
end
|
44
|
+
rescue JSON::ParserError
|
45
|
+
body = line.strip
|
46
|
+
if body.split('&').collect{|m| /^[^&^=]+=[^&^=]+$/.match(m) }.all?
|
47
|
+
headers = {}
|
48
|
+
else
|
49
|
+
headers = {"Content-Type" => "text/plain"}
|
50
|
+
end
|
51
|
+
end
|
52
|
+
c = HTTPClient.new
|
53
|
+
#c.set_auth(url, 'user', 'pass') if user ## This doesn't work?
|
54
|
+
headers['Authorization'] = "Basic #{Base64.encode64([user,pass].join(':')).gsub("\n",'')}" if user # Fix set_auth
|
55
|
+
c.ssl_config.verify_mode = nil if args.include? 'k'
|
56
|
+
resp = c.post(url, body, headers)
|
57
|
+
if resp.status != 200
|
58
|
+
puts resp.content
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/wsio.gemspec
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{wsio}
|
5
|
+
s.version = "0.0.1"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Jeff Lindsay"]
|
9
|
+
s.cert_chain = ["/Users/progrium/.gem/gem-public_cert.pem"]
|
10
|
+
s.date = %q{2010-05-04}
|
11
|
+
s.default_executable = %q{wsio}
|
12
|
+
s.description = %q{Web stream input/output tool}
|
13
|
+
s.email = %q{jeff.lindsay@twilio.com}
|
14
|
+
s.executables = ["wsio"]
|
15
|
+
s.extra_rdoc_files = ["README", "bin/wsio", "lib/wsio.rb"]
|
16
|
+
s.files = ["README", "Rakefile", "bin/wsio", "lib/wsio.rb", "Manifest", "wsio.gemspec"]
|
17
|
+
s.homepage = %q{http://github.com/progrium/wsio}
|
18
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Wsio", "--main", "README"]
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
s.rubyforge_project = %q{wsio}
|
21
|
+
s.rubygems_version = %q{1.3.5}
|
22
|
+
s.signing_key = %q{/Users/progrium/.gem/gem-private_key.pem}
|
23
|
+
s.summary = %q{Web stream input/output tool}
|
24
|
+
|
25
|
+
if s.respond_to? :specification_version then
|
26
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
27
|
+
s.specification_version = 3
|
28
|
+
|
29
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
30
|
+
else
|
31
|
+
end
|
32
|
+
else
|
33
|
+
end
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: wsio
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jeff Lindsay
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDPDCCAiSgAwIBAgIBADANBgkqhkiG9w0BAQUFADBEMRUwEwYDVQQDDAxqZWZm
|
14
|
+
LmxpbmRzYXkxFjAUBgoJkiaJk/IsZAEZFgZ0d2lsaW8xEzARBgoJkiaJk/IsZAEZ
|
15
|
+
FgNjb20wHhcNMTAwNTA0MjE0NzE3WhcNMTEwNTA0MjE0NzE3WjBEMRUwEwYDVQQD
|
16
|
+
DAxqZWZmLmxpbmRzYXkxFjAUBgoJkiaJk/IsZAEZFgZ0d2lsaW8xEzARBgoJkiaJ
|
17
|
+
k/IsZAEZFgNjb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDb1P6c
|
18
|
+
/CN4l2pYBO0d5y7YHW3XJbj5d+5c1E9m2PcvUJ4Vjr7ISQM1SYpwixnWMBXBpzc1
|
19
|
+
En9YB+PYBEOOaIRh2G23aKdu7PnYQhze91qOBcHnf6LOckq25NbWQO8eaiXD3w5W
|
20
|
+
HRXOcmzigyTYRIhXBa93eMSihWAXThcfGFKNbtKerVhytT/UVHZU3pr9gCvt9vD0
|
21
|
+
aBmwMwvDlpO72eXPr5ow3Z+VzCc51iBNC07uvR/wFQ6/lS8ULBpHI9wcdo67wdv5
|
22
|
+
SaSZSGZCmG1pXov0Ahji7yqFMQ9oot5RDPZavZN3Fh3n6e2hdcSMlLgGkEGYaBVx
|
23
|
+
gdQFudko7rc5cWTdAgMBAAGjOTA3MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0G
|
24
|
+
A1UdDgQWBBRXFNQ8j0GGeMiiPWhAlHB356JPGDANBgkqhkiG9w0BAQUFAAOCAQEA
|
25
|
+
VzMJe10HfJtglbDah9h9lxv8uzK2uV7bXRcIbMCGEdx8cByM+cfKOnoWVDQBVPWA
|
26
|
+
VznqXdPsrVC70PAMMTk66ro2ciyudilVEuxEl7rhaz0tj9FzNyJUHBKCD4KpGwkC
|
27
|
+
K435qpJsHMi9k0KxY17grmsE2Hq60lFLK8ZrqgDblEAKTeaGAykMxp9KJOwAKnY2
|
28
|
+
4lUY/SVtRuTk0YXsIPNFLYUhYt7arkJtkwWV41GWhj7PbcM5uk5sGoh0aueMzY7f
|
29
|
+
TvklqXtUw3g3PcoJ8CZw68WaB2/MuJXUehRCZThhkBwi8bDKZzh4rtI/WEb1EgDs
|
30
|
+
WZqts+sMhUpDxxL+p6p6bQ==
|
31
|
+
-----END CERTIFICATE-----
|
32
|
+
|
33
|
+
date: 2010-05-04 00:00:00 -07:00
|
34
|
+
default_executable:
|
35
|
+
dependencies: []
|
36
|
+
|
37
|
+
description: Web stream input/output tool
|
38
|
+
email: jeff.lindsay@twilio.com
|
39
|
+
executables:
|
40
|
+
- wsio
|
41
|
+
extensions: []
|
42
|
+
|
43
|
+
extra_rdoc_files:
|
44
|
+
- README
|
45
|
+
- bin/wsio
|
46
|
+
- lib/wsio.rb
|
47
|
+
files:
|
48
|
+
- README
|
49
|
+
- Rakefile
|
50
|
+
- bin/wsio
|
51
|
+
- lib/wsio.rb
|
52
|
+
- Manifest
|
53
|
+
- wsio.gemspec
|
54
|
+
has_rdoc: true
|
55
|
+
homepage: http://github.com/progrium/wsio
|
56
|
+
licenses: []
|
57
|
+
|
58
|
+
post_install_message:
|
59
|
+
rdoc_options:
|
60
|
+
- --line-numbers
|
61
|
+
- --inline-source
|
62
|
+
- --title
|
63
|
+
- Wsio
|
64
|
+
- --main
|
65
|
+
- README
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: "0"
|
73
|
+
version:
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: "1.2"
|
79
|
+
version:
|
80
|
+
requirements: []
|
81
|
+
|
82
|
+
rubyforge_project: wsio
|
83
|
+
rubygems_version: 1.3.5
|
84
|
+
signing_key:
|
85
|
+
specification_version: 3
|
86
|
+
summary: Web stream input/output tool
|
87
|
+
test_files: []
|
88
|
+
|
metadata.gz.sig
ADDED