synapse-easy 0.1.9 → 0.1.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7c8961a6aaaf5f5a1097995faad093746e0c8296
4
- data.tar.gz: 72a1da2617782d24d3a55e2e13a6111a8f9fd7b3
3
+ metadata.gz: a19980fe2271a379f2a63484db6e16aa2ea350ba
4
+ data.tar.gz: 1fe87c961e77a8adaa66b98864270f2a7d47e323
5
5
  SHA512:
6
- metadata.gz: d52cc731e18617759c1e833c8d7d7c9c12fd129fd9309543af62c2989a6c260a1c7f2bf70a225439628db843a91333914da64d9b6b319c9fca2679e8ac7167a8
7
- data.tar.gz: 5b9b03ddf7efa65b1979ef064fcb10cdb7c0ac398776a9bfbe4e37289c2349001567d1d0addadf1af6c72fa4247591c165a2dbf34e2316b240442373025bbe09
6
+ metadata.gz: de8ff95866152c578605708fa211145613b38d5fb521500a9f1ccb110a3369f328be0fe9af8e0161ee71c7bb20b13330444975269fc0cef507c07f8512154262
7
+ data.tar.gz: 641a34cd6951c34b48ab51f45637557a175aadc371130e32e6d871956767c0d11795655904a3c81954788d2df7b0666ac24e3692f32451555c8627c548981771
data/lib/synapse/easy.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  require "synapse/easy/version"
2
2
  require "synapse/easy/service"
3
3
  require "synapse/easy/haproxy"
4
- require "synapse/easy/stats_section"
5
- require "synapse/easy/frontend_section"
4
+ require "synapse/easy/section"
@@ -84,17 +84,14 @@ module Synapse
84
84
  ]
85
85
  end
86
86
  def defaults
87
- defaults = @default_options
87
+ defaults = default_options
88
88
  defaults << "log #{default_log}"
89
89
  defaults << "maxconn #{default_maxconn}"
90
90
  defaults << "retries #{default_retries}"
91
91
  defaults << "balance #{default_balance}"
92
- defaults += @default_timeouts.collect{|l,t| "timeout #{l} #{t}"}
92
+ defaults += default_timeouts.collect{|l,t| "timeout #{l} #{t}"}
93
93
  defaults
94
94
  end
95
- def extra_sections
96
- @extra_sections
97
- end
98
95
  def to_synapse
99
96
  FileUtils.mkdir_p workdir.to_s unless Dir.exists? workdir.to_s
100
97
  {
@@ -0,0 +1,3 @@
1
+ require "synapse/easy/section/stats"
2
+ require "synapse/easy/section/tcp"
3
+ require "synapse/easy/section/http"
@@ -0,0 +1,42 @@
1
+ require "pathname"
2
+ require "active_support/core_ext/hash/indifferent_access"
3
+ require "fake/hash"
4
+
5
+ module Synapse
6
+ module Easy
7
+ module Section
8
+ class Base
9
+ include Fake::Hash
10
+ attr_accessor :type, :name, :options, :address, :port
11
+ def initialize params={}
12
+ @address = params[:address]
13
+ @address ||= "localhost"
14
+ @port = params[:port]
15
+ @port ||= Freeport.port
16
+ @name = params[:name]
17
+ @type = params[:type]
18
+ @type ||= "frontend"
19
+ @options = params[:options]
20
+ @options ||= []
21
+ end
22
+ def label
23
+ "#{type} #{name}"
24
+ end
25
+ def section_options
26
+ options
27
+ end
28
+ def each *args, &block
29
+ section_options.each(*args,&block)
30
+ end
31
+ def bind
32
+ [address,port].compact.join(":")
33
+ end
34
+ def to_synapse
35
+ {
36
+ label => section_options
37
+ }
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,65 @@
1
+ require "synapse/easy/section/tcp"
2
+
3
+ module Synapse
4
+ module Easy
5
+ module Section
6
+ class Http < Tcp
7
+ attr_accessor :protocol, :ssl, :default_certificate, :certificates,
8
+ :ciphers, :secure_cookies, :strict_security
9
+ def initialize params={}
10
+ super
11
+ @mode = :http
12
+ @protocol = params[:protocol]
13
+ @protocol ||= :http
14
+ @protocol = :http unless [:http, :https].include? @protocol.to_sym
15
+ @ssl = not(params[:default_certificate].nil?)
16
+ @ssl ||= false if ssl.nil?
17
+ @default_certificate = params[:default_certificate]
18
+ @default_certificate ||= "/etc/ssl/private/ssl-cert-snakeoil.key crt /etc/ssl/certs/ssl-cert-snakeoil.pem" if ssl
19
+ @certificates = params[:certificates]
20
+ @certificates ||= []
21
+ @ciphers = params[:ciphers]
22
+ @ciphers ||= %W{ECDHE-ECDSA-AES256-GCM-SHA384
23
+ ECDHE-ECDSA-AES128-GCM-SHA256
24
+ ECDHE-ECDSA-AES256-SHA384
25
+ ECDHE-ECDSA-AES256-SHA
26
+ ECDHE-RSA-AES256-SHA384
27
+ ECDHE-RSA-AES256-SHA
28
+ DHE-RSA-AES256-SHA DHE-RSA-AES128-SHA
29
+ DES-CBC3-SHA !NULL !aNULL !RC4 !RC2 !MEDIUM
30
+ !LOW !EXPORT !DES !MD5 !PSK !3DES} if ssl
31
+ @secure_cookies = params[:secure_cookies]
32
+ @secure_cookies ||= true if @secure_cookies.nil? and ssl
33
+ @strict_security = params[:strict_security]
34
+ @strict_security ||= true if @strict_security.nil? and ssl
35
+ end
36
+ def secure_cookies
37
+ "rsprep ^Set-Cookie:\\ (.*) Set-Cookie:\\ \\1;\\ Secure" if @secure_cookies
38
+ end
39
+ def strict_security
40
+ "rspadd Strict-Transport-Security:\\ max-age=31536000;\\ includeSubDomains" if @strict_security
41
+ end
42
+ def complex_bind
43
+ @complex_bind = []
44
+ @complex_bind << bind
45
+ @complex_bind << "ssl" if ssl
46
+ @complex_bind << "crt" if ssl
47
+ @complex_bind << default_certificate
48
+ certificates.each do |certificate|
49
+ @complex_bind << "crt"
50
+ @complex_bind << certificate
51
+ end
52
+ @complex_bind.compact.join(" ")
53
+ end
54
+ def section_options
55
+ @options.reject{|o| o =~ /^bind/} + [
56
+ "bind #{complex_bind}",
57
+ "reqadd X-Forwarded-Proto:\\ #{protocol}",
58
+ secure_cookies,
59
+ strict_security
60
+ ].compact
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,50 @@
1
+ require "synapse/easy/section/base"
2
+ require "socket"
3
+ require "freeport"
4
+
5
+ module Synapse
6
+ module Easy
7
+ module Section
8
+ class Stats < Base
9
+ attr_accessor :uri, :enabled, :refresh, :realm, :node, :hide_version,
10
+ :username, :password, :scope, :show_node
11
+ def initialize params={}
12
+ super
13
+ @uri = params[:uri]
14
+ @uri ||= "/"
15
+ @enabled = params[:enabled]
16
+ @enabled ||= true if @enabled.nil?
17
+ @refresh = params[:refresh]
18
+ @refresh ||= 5
19
+ @realm = params[:realm]
20
+ @realm ||= "HAProxy\\ Stats"
21
+ @hide_version = params[:hide_version]
22
+ @hide_version ||= true if @hide_version.nil?
23
+ @username = params[:username]
24
+ @password = params[:password]
25
+ @scope = params[:scope]
26
+ @show_node = params[:show_node]
27
+ @show_node ||= false if @show_node.nil?
28
+ @node = params[:node]
29
+ @node ||= Socket.gethostname
30
+ end
31
+ def section_options
32
+ @options + [
33
+ "mode http",
34
+ ( "stats enable" if enabled ),
35
+ "stats uri #{uri}",
36
+ "stats refresh #{refresh}",
37
+ "stats realm #{realm}",
38
+ ( "stats hide-version" if hide_version),
39
+ ( "stats auth #{username}:#{password}" if username and password ),
40
+ ( "stats scope #{scope}" if scope ),
41
+ ( "stats show-node #{node}" if show_node ),
42
+ ].compact
43
+ end
44
+ def label
45
+ "listen stats #{bind}"
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,24 @@
1
+ require "synapse/easy/section/base"
2
+
3
+ module Synapse
4
+ module Easy
5
+ module Section
6
+ class Tcp < Base
7
+ attr_accessor :mode, :default_backend
8
+ def initialize params={}
9
+ super
10
+ @type = "frontend"
11
+ @mode = params[:mode]
12
+ @mode ||= :tcp
13
+ @default_backend = params[:default_backend]
14
+ end
15
+ def section_options
16
+ @options + [
17
+ "mode #{mode}",
18
+ "bind #{bind}",
19
+ ].compact
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -91,6 +91,7 @@ module Synapse
91
91
  def listen
92
92
  [
93
93
  "mode #{mode}",
94
+ "option tcpka",
94
95
  ( "option httpchk GET #{uri}" if uri and mode.to_s == "http" )
95
96
  ].compact
96
97
  end
@@ -1,5 +1,5 @@
1
1
  module Synapse
2
2
  module Easy
3
- VERSION = "0.1.9"
3
+ VERSION = "0.1.10"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: synapse-easy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mathias Kaufmann
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-04-01 00:00:00.000000000 Z
11
+ date: 2015-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: resolv-consul
@@ -95,11 +95,13 @@ files:
95
95
  - bin/console
96
96
  - bin/setup
97
97
  - lib/synapse/easy.rb
98
- - lib/synapse/easy/extra_section.rb
99
- - lib/synapse/easy/frontend_section.rb
100
98
  - lib/synapse/easy/haproxy.rb
99
+ - lib/synapse/easy/section.rb
100
+ - lib/synapse/easy/section/base.rb
101
+ - lib/synapse/easy/section/http.rb
102
+ - lib/synapse/easy/section/stats.rb
103
+ - lib/synapse/easy/section/tcp.rb
101
104
  - lib/synapse/easy/service.rb
102
- - lib/synapse/easy/stats_section.rb
103
105
  - lib/synapse/easy/version.rb
104
106
  - synapse-easy.gemspec
105
107
  homepage: http://synapse.stei.gr/easy
@@ -1,32 +0,0 @@
1
- require "pathname"
2
- require "active_support/core_ext/hash/indifferent_access"
3
- require "fake/hash"
4
-
5
- module Synapse
6
- module Easy
7
- class ExtraSection
8
- include Fake::Hash
9
- attr_accessor :name, :type, :options
10
- def initialize params={}
11
- @name = params[:name]
12
- @type = params[:type]
13
- @type ||= "frontend"
14
- @options ||= []
15
- end
16
- def label
17
- "#{type} #{name}"
18
- end
19
- def section_options
20
- options
21
- end
22
- def each *args, &block
23
- section_options.each(*args,&block)
24
- end
25
- def to_synapse
26
- {
27
- label => section_options
28
- }
29
- end
30
- end
31
- end
32
- end
@@ -1,13 +0,0 @@
1
- require "synapse/easy/extra_section"
2
-
3
- module Synapse
4
- module Easy
5
- class FrontendSection < ExtraSection
6
- attr_accessor :name, :type, :options
7
- def initialize params={}
8
- super
9
- @type = "frontend"
10
- end
11
- end
12
- end
13
- end
@@ -1,56 +0,0 @@
1
- require "synapse/easy/extra_section"
2
- require "socket"
3
- require "freeport"
4
-
5
- module Synapse
6
- module Easy
7
- class StatsSection < ExtraSection
8
- attr_accessor :address, :port, :uri, :enabled, :refresh, :realm,
9
- :hide_version, :username, :password, :scope, :show_node,
10
- :node
11
- def initialize params={}
12
- super
13
- @address = params[:address]
14
- @address ||= "localhost"
15
- @port = params[:port]
16
- @port ||= Freeport.port
17
- @uri = params[:uri]
18
- @uri ||= "/"
19
- @enabled = params[:enabled]
20
- @enabled ||= true if @enabled.nil?
21
- @refresh = params[:refresh]
22
- @refresh ||= 5
23
- @realm = params[:realm]
24
- @realm ||= "HAProxy\\ Stats"
25
- @hide_version = params[:hide_version]
26
- @hide_version ||= true if @hide_version.nil?
27
- @username = params[:username]
28
- @password = params[:password]
29
- @scope = params[:scope]
30
- @show_node = params[:show_node]
31
- @show_node ||= false if @show_node.nil?
32
- @node = params[:node]
33
- @node ||= Socket.gethostname
34
- end
35
- def section_options
36
- @options + [
37
- "mode http",
38
- ( "stats enable" if enabled ),
39
- "stats uri #{uri}",
40
- "stats refresh #{refresh}",
41
- "stats realm #{realm}",
42
- ( "stats hide-version" if hide_version),
43
- ( "stats auth #{username}:#{password}" if username and password ),
44
- ( "stats scope #{scope}" if scope ),
45
- ( "stats show-node #{node}" if show_node ),
46
- ].compact
47
- end
48
- def bind
49
- [address,port].compact.join(":")
50
- end
51
- def label
52
- "listen stats #{bind}"
53
- end
54
- end
55
- end
56
- end