emptyd 0.0.9 → 0.0.10
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/bin/emptyd +21 -1
- data/lib/emptyd.rb +26 -18
- data/lib/emptyd/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 267809f0db88a7bef5c0513fbea5773dff218021
|
4
|
+
data.tar.gz: b4a6ab60c689d4b518b8bd581caf76ed53c446bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73e97ab10082578c057241cd43d82f0e16dccdf7d5391af096b08ee3f69329a4bd76953347cca89ba17be070b7395823620f1b7e44f6c2f45ef44952c6fee1df
|
7
|
+
data.tar.gz: a4e40672b2fdcbd65f96b2a7ffa96008ee8d8f7ad36017469798ffc1acec4eff1c2d5093a033ba5d86035a4a4ecbe9cd9a054d7f9d43bdbc58f14e2082e14503
|
data/bin/emptyd
CHANGED
@@ -11,6 +11,24 @@ require "emptyd"
|
|
11
11
|
require 'evma_httpserver'
|
12
12
|
require 'getoptlong'
|
13
13
|
|
14
|
+
# Monkey patch for evma_httpserver 0.2.1
|
15
|
+
class EventMachine::HttpResponse
|
16
|
+
def fixup_headers
|
17
|
+
if @content
|
18
|
+
@headers["Content-length"] = @content.bytesize
|
19
|
+
elsif @chunks
|
20
|
+
@headers["Transfer-encoding"] = "chunked"
|
21
|
+
# Might be nice to ENSURE there is no content-length header,
|
22
|
+
# but how to detect all the possible permutations of upper/lower case?
|
23
|
+
elsif @multiparts
|
24
|
+
@multipart_boundary = self.class.concoct_multipart_boundary
|
25
|
+
@headers["Content-type"] = "multipart/x-mixed-replace; boundary=\"#{@multipart_boundary}\""
|
26
|
+
else
|
27
|
+
@headers["Content-length"] = 0
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
14
32
|
class MyHttpServer < EM::Connection
|
15
33
|
include EM::HttpServer
|
16
34
|
|
@@ -100,7 +118,8 @@ end
|
|
100
118
|
|
101
119
|
CONFIG = {
|
102
120
|
:server => "::1",
|
103
|
-
:server_port => 53353
|
121
|
+
:server_port => 53353,
|
122
|
+
:log_level => "error"
|
104
123
|
}
|
105
124
|
|
106
125
|
%w{.emptyd.conf .empty.conf}.map{|name| File.expand_path("~/#{name}")}.each do |name|
|
@@ -123,6 +142,7 @@ opts = GetoptLong.new(
|
|
123
142
|
)
|
124
143
|
|
125
144
|
logger = Logger.new(STDOUT)
|
145
|
+
logger.level = Logger.const_get(CONFIG[:log_level].upcase.to_sym)
|
126
146
|
options = { :logger => logger }
|
127
147
|
options[:cookie] = CONFIG[:cookie]
|
128
148
|
options[:port] = CONFIG[:server_port]
|
data/lib/emptyd.rb
CHANGED
@@ -12,7 +12,7 @@ module Emptyd
|
|
12
12
|
class Connection
|
13
13
|
attr_reader :key, :updated_at, :failed_at, :error
|
14
14
|
EXPIRE_INTERVAL = 600 # 10min
|
15
|
-
MAX_CONNECTIONS =
|
15
|
+
MAX_CONNECTIONS = 500
|
16
16
|
HAPPY_RATIO = 0.5
|
17
17
|
@@connections = {}
|
18
18
|
@@count = {}
|
@@ -91,7 +91,7 @@ module Emptyd
|
|
91
91
|
else
|
92
92
|
@@count[self.key] = self
|
93
93
|
@logger.debug "Created new conn: #{key}, quota = #{@@count.size}"
|
94
|
-
options = { :user_known_hosts_file => [] }
|
94
|
+
options = { :user_known_hosts_file => [], :number_of_password_prompts => 0 }
|
95
95
|
options[:password] = $PASSWORD if $PASSWORD
|
96
96
|
options[:forward_agent] = true if $FORWARD_AGENT
|
97
97
|
EM::Ssh.start(@ip, @user, options) do |conn|
|
@@ -142,22 +142,30 @@ module Emptyd
|
|
142
142
|
end
|
143
143
|
end
|
144
144
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
@ip =
|
145
|
+
if @host =~ /^[0-9a-f:.]+$/i
|
146
|
+
p @host
|
147
|
+
resolver = proc do
|
148
|
+
@ip = @host
|
149
149
|
starter[]
|
150
150
|
end
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
151
|
+
else
|
152
|
+
resolver = proc do
|
153
|
+
query = @@dns.submit_AAAA @host
|
154
|
+
query.callback do |result|
|
155
|
+
@ip = result.sample
|
156
|
+
starter[]
|
157
|
+
end
|
158
|
+
query.errback do |err|
|
159
|
+
if err == :dns_error_nodata
|
160
|
+
query = @@dns.submit_A @host
|
161
|
+
query.callback do |result|
|
162
|
+
@ip = result.sample
|
163
|
+
starter[]
|
164
|
+
end
|
165
|
+
query.errback { |err| resfail[err] }
|
166
|
+
else
|
167
|
+
resfail[err]
|
157
168
|
end
|
158
|
-
query.errback { |err| resfail[err] }
|
159
|
-
else
|
160
|
-
resfail[err]
|
161
169
|
end
|
162
170
|
end
|
163
171
|
end
|
@@ -169,7 +177,7 @@ module Emptyd
|
|
169
177
|
@@count.delete self.key
|
170
178
|
had_valid_conn = !!@conn
|
171
179
|
@conn = nil
|
172
|
-
|
180
|
+
@logger.warn "Connection to #{@key} is broken: #{err}"
|
173
181
|
@error = err
|
174
182
|
@failed_at = Time.now
|
175
183
|
@connecting = false
|
@@ -242,13 +250,13 @@ module Emptyd
|
|
242
250
|
if session.interactive?
|
243
251
|
ch.request_pty do |ch, success|
|
244
252
|
ch.exec cmd do |ch, success|
|
245
|
-
|
253
|
+
@logger.warn "exec failed: #{cmd}" unless success
|
246
254
|
setup[ch]
|
247
255
|
end
|
248
256
|
end
|
249
257
|
else
|
250
258
|
ch.exec cmd do |ch, success|
|
251
|
-
|
259
|
+
@logger.warn "exec failed: #{cmd}" unless success
|
252
260
|
setup[ch]
|
253
261
|
end
|
254
262
|
end
|
data/lib/emptyd/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: emptyd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kmeaw
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|