fluent-plugin-sstp 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/.rspec +2 -0
- data/Gemfile +3 -0
- data/README.md +36 -0
- data/Rakefile +1 -0
- data/fluent-plugin-sstp.gemspec +26 -0
- data/lib/fluent/plugin/out_sstp.rb +66 -0
- data/spec/lib/fluent/plugin/out_sstp_spec.rb +65 -0
- data/spec/spec_helper.rb +25 -0
- metadata +139 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a1d14ec6a7974609b0e5f2510a6b2fe5fe1360c1
|
4
|
+
data.tar.gz: 94a5118a25c154175d7a39bf35226ed7814a206e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a0277670f241c24899b19f203c5d3c1907a44431208fd993768d5e3fc2a9e589386346b0101efb682f25069e9a24eda6e68a2fc1c109c4187cfe0f284a8498f5
|
7
|
+
data.tar.gz: e2d39ca16926b46aee9d98c6041d43841805b9fd494c2a3192f67109857cbafd1cf08ae625d17f090e77bf77c0d17cdd2bddf3e860f464c99c5dd97eb121a4bd
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# fluent-plugin-sstp
|
2
|
+
|
3
|
+
Fluentd output plugin to send server using Sakura Script Transfer Protocol(SSTP)
|
4
|
+
|
5
|
+
## Requirement
|
6
|
+
|
7
|
+
nc(netcat) command
|
8
|
+
|
9
|
+
## config
|
10
|
+
|
11
|
+
````
|
12
|
+
type sstp
|
13
|
+
sstp_server 127.0.0.1
|
14
|
+
sstp_port 9801
|
15
|
+
request_method NOTIFY
|
16
|
+
request_version SSTP/1.1
|
17
|
+
sender カードキャプター
|
18
|
+
script_template \0汝のあるべき姿に戻れ。<%= record['craw_card'] %>\e
|
19
|
+
````
|
20
|
+
|
21
|
+
Support SSTP request method is `NOTIFY/1.1` only
|
22
|
+
http://www.ooyashima.net/db/sstp.html#notify11
|
23
|
+
|
24
|
+
I'm expecting your contribute!
|
25
|
+
|
26
|
+
## Contributing
|
27
|
+
|
28
|
+
1. Fork it
|
29
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
30
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
31
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
32
|
+
5. Create new Pull Request
|
33
|
+
|
34
|
+
## releases
|
35
|
+
|
36
|
+
- 2014/01/26 0.0.0 1st release
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "fluent-plugin-sstp"
|
7
|
+
spec.version = '0.0.0'
|
8
|
+
spec.authors = ["bash0C7"]
|
9
|
+
spec.email = ["koshiba+github@4038nullpointer.com"]
|
10
|
+
spec.description = "Fluentd output plugin to send server using Sakura Script Transfer Protocol(SSTP)"
|
11
|
+
spec.summary = "Fluentd output plugin to send server using Sakura Script Transfer Protocol(SSTP)"
|
12
|
+
spec.homepage = "https://github.com/bash0C7/fluent-plugin-sstp"
|
13
|
+
spec.license = "Ruby's"
|
14
|
+
|
15
|
+
spec.files = `git ls-files`.split($/)
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_dependency "fluentd"
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
spec.add_development_dependency "rr"
|
25
|
+
spec.add_development_dependency "pry"
|
26
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
|
2
|
+
module Fluent
|
3
|
+
class Fluent::SstpOutput < Fluent::Output
|
4
|
+
Fluent::Plugin.register_output('sstp', self)
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
super
|
8
|
+
end
|
9
|
+
|
10
|
+
config_param :sstp_server, :string
|
11
|
+
config_param :sstp_port, :integer, :default => 9801
|
12
|
+
config_param :request_method, :string
|
13
|
+
config_param :request_version, :string
|
14
|
+
config_param :sender, :string
|
15
|
+
config_param :script_template, :string
|
16
|
+
|
17
|
+
def configure(conf)
|
18
|
+
super
|
19
|
+
|
20
|
+
@script = ERB.new(@script_template)
|
21
|
+
raise "Unsupport post_type: #{@request_method}" unless @request_method == 'NOTIFY'
|
22
|
+
end
|
23
|
+
|
24
|
+
def start
|
25
|
+
super
|
26
|
+
end
|
27
|
+
|
28
|
+
def shutdown
|
29
|
+
super
|
30
|
+
end
|
31
|
+
|
32
|
+
def emit(tag, es, chain)
|
33
|
+
es.each {|time,record|
|
34
|
+
message = build_message(tag, time, record)
|
35
|
+
post message
|
36
|
+
}
|
37
|
+
|
38
|
+
chain.next
|
39
|
+
end
|
40
|
+
|
41
|
+
def build_message tag, time, record
|
42
|
+
script = @script.result(binding)
|
43
|
+
ERB.new(<<-'EOS'
|
44
|
+
<%= @request_method %> <%= @request_version %>
|
45
|
+
Sender: <%= @sender %>
|
46
|
+
Script: <%= script %>
|
47
|
+
Charset: UTF-8
|
48
|
+
EOS
|
49
|
+
).result(binding).gsub("\n", "\r\n")
|
50
|
+
end
|
51
|
+
|
52
|
+
def post(message)
|
53
|
+
begin
|
54
|
+
IO.popen("nc '#{@sstp_server}' '#{@sstp_port}'", 'w') do |io|
|
55
|
+
io.puts message
|
56
|
+
end
|
57
|
+
rescue IOError, EOFError, SystemCallError
|
58
|
+
# server didn't respond
|
59
|
+
$log.warn "raises exception: #{$!.class}, '#{$!.message}'"
|
60
|
+
end
|
61
|
+
|
62
|
+
message
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe do
|
4
|
+
let(:driver) {Fluent::Test::OutputTestDriver.new(Fluent::SstpOutput, 'test.metrics').configure(config)}
|
5
|
+
let(:instance) {driver.instance}
|
6
|
+
|
7
|
+
let(:record) {{ 'craw_card' => 'クロウカード!', 'otherfield' => 99}}
|
8
|
+
let(:time) {0}
|
9
|
+
|
10
|
+
describe 'build_message' do
|
11
|
+
let(:tag) {'TAG'}
|
12
|
+
|
13
|
+
let(:message) { s = <<-'EOS'
|
14
|
+
NOTIFY SSTP/1.1
|
15
|
+
Sender: カードキャプター
|
16
|
+
Script: \0汝のあるべき姿に戻れ。クロウカード!\e
|
17
|
+
Charset: UTF-8
|
18
|
+
EOS
|
19
|
+
s.gsub("\n", "\r\n")
|
20
|
+
}
|
21
|
+
|
22
|
+
let(:built) {instance.build_message(tag, time, record)}
|
23
|
+
context 'empty custom_determine_color_code' do
|
24
|
+
let(:script) {'\0汝のあるべき姿に戻れ。<%= record["craw_card"] %>\e'}
|
25
|
+
let(:config) {
|
26
|
+
%[
|
27
|
+
sstp_server 127.0.0.1
|
28
|
+
sstp_port 9801
|
29
|
+
request_method NOTIFY
|
30
|
+
request_version SSTP/1.1
|
31
|
+
sender カードキャプター
|
32
|
+
script_template #{script}
|
33
|
+
]
|
34
|
+
}
|
35
|
+
|
36
|
+
subject {built}
|
37
|
+
it{should == message}
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe 'emit' do
|
42
|
+
let(:posted) {
|
43
|
+
d = driver
|
44
|
+
mock(IO).popen("nc '#{d.instance.sstp_server}' '#{d.instance.sstp_port}'", 'w').times 1
|
45
|
+
d.emit(record, Time.at(time))
|
46
|
+
d.run
|
47
|
+
}
|
48
|
+
|
49
|
+
context 'empty custom_determine_color_code' do
|
50
|
+
let(:config) {
|
51
|
+
%[
|
52
|
+
sstp_server 127.0.0.1
|
53
|
+
sstp_port 9801
|
54
|
+
request_method NOTIFY
|
55
|
+
request_version SSTP/1.1
|
56
|
+
sender カードキャプター
|
57
|
+
script_template \0汝のあるべき姿に戻れ。<%= record['craw_card'] %>\e
|
58
|
+
]
|
59
|
+
}
|
60
|
+
|
61
|
+
subject {posted}
|
62
|
+
it{should_not be_nil}
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
RSpec.configure do |config|
|
8
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
9
|
+
config.run_all_when_everything_filtered = true
|
10
|
+
config.filter_run :focus
|
11
|
+
|
12
|
+
# Run specs in random order to surface order dependencies. If you find an
|
13
|
+
# order dependency and want to debug it, you can fix the order by providing
|
14
|
+
# the seed, which is printed after each run.
|
15
|
+
# --seed 1234
|
16
|
+
config.order = 'random'
|
17
|
+
|
18
|
+
require 'fluent/load'
|
19
|
+
require 'fluent/test'
|
20
|
+
|
21
|
+
require 'fluent/plugin/out_sstp'
|
22
|
+
|
23
|
+
require 'pry'
|
24
|
+
require 'rr'
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-sstp
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- bash0C7
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-01-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: fluentd
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rr
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry
|
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'
|
97
|
+
description: Fluentd output plugin to send server using Sakura Script Transfer Protocol(SSTP)
|
98
|
+
email:
|
99
|
+
- koshiba+github@4038nullpointer.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- .gitignore
|
105
|
+
- .rspec
|
106
|
+
- Gemfile
|
107
|
+
- README.md
|
108
|
+
- Rakefile
|
109
|
+
- fluent-plugin-sstp.gemspec
|
110
|
+
- lib/fluent/plugin/out_sstp.rb
|
111
|
+
- spec/lib/fluent/plugin/out_sstp_spec.rb
|
112
|
+
- spec/spec_helper.rb
|
113
|
+
homepage: https://github.com/bash0C7/fluent-plugin-sstp
|
114
|
+
licenses:
|
115
|
+
- Ruby's
|
116
|
+
metadata: {}
|
117
|
+
post_install_message:
|
118
|
+
rdoc_options: []
|
119
|
+
require_paths:
|
120
|
+
- lib
|
121
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - '>='
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
131
|
+
requirements: []
|
132
|
+
rubyforge_project:
|
133
|
+
rubygems_version: 2.0.5
|
134
|
+
signing_key:
|
135
|
+
specification_version: 4
|
136
|
+
summary: Fluentd output plugin to send server using Sakura Script Transfer Protocol(SSTP)
|
137
|
+
test_files:
|
138
|
+
- spec/lib/fluent/plugin/out_sstp_spec.rb
|
139
|
+
- spec/spec_helper.rb
|