netpump 1.0.0 → 1.0.1
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/CHANGELOG +10 -2
- data/VERSION +1 -1
- data/bin/netpump +6 -11
- data/lib/netpump/client.rb +6 -6
- data/lib/netpump/log.rb +1 -1
- data/lib/netpump/server.rb +2 -2
- data/public/favicon.png +0 -0
- data/public/netpump.html +6 -6
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f72c49ca8c96dafbb9aa62b8742af225bc1117dac402989e1f0ed5612e61f41
|
4
|
+
data.tar.gz: 48322987d7bb48bffefe9d04f752e866ece76e972cffda9b034aed26c41ca959
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: edb4d71ba4c318196880e0d6195255e3fc26c526586d82c6897ae12a43bd88dab8912d26134eb1246d540672ff40770e94dc614629bc3d9360476a1e661149f5
|
7
|
+
data.tar.gz: cbfe25169670f0dbe03813b0c5903aeb9f3644579331377f3c9f4fde3d99c3a26439fae2a3d8113f4e4db6dbbffeeeea32e492bd3b38607d846e734b66887d84
|
data/CHANGELOG
CHANGED
@@ -1,10 +1,18 @@
|
|
1
|
+
1.0.1
|
2
|
+
|
3
|
+
Simplify sequential and parallel request tests
|
4
|
+
Dump backtrace only if $VERBOSE is true
|
5
|
+
Manage $LOAD_PATH externally
|
6
|
+
Abort on unhandled exception
|
7
|
+
|
1
8
|
1.0.0
|
2
9
|
|
3
|
-
*
|
10
|
+
* Rename weblink to netpump
|
11
|
+
* Add direct client mode, where client connects to the server directly
|
12
|
+
* Add backpressure handling to keep memory usage low and bounded
|
4
13
|
* Add websocket pool timeout
|
5
14
|
* Add more unbind reasons
|
6
15
|
* Add option to set the server URL, remove the server query param
|
7
|
-
* Add direct client mode
|
8
16
|
|
9
17
|
1.3.0
|
10
18
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.1
|
data/bin/netpump
CHANGED
@@ -2,12 +2,7 @@
|
|
2
2
|
|
3
3
|
Process.setproctitle "netpump"
|
4
4
|
$stdin.close
|
5
|
-
|
6
|
-
$VERBOSE = true
|
7
|
-
$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
|
8
|
-
else
|
9
|
-
$VERBOSE = nil
|
10
|
-
end
|
5
|
+
$VERBOSE = $PROGRAM_NAME == __FILE__ || nil
|
11
6
|
|
12
7
|
require "optparse"
|
13
8
|
require "uri"
|
@@ -59,7 +54,7 @@ op = OptionParser.new do |op|
|
|
59
54
|
copts[:proxy_port] = port
|
60
55
|
end
|
61
56
|
|
62
|
-
op.on("--server-url URL", WSS, "netpump server url (example: wss://
|
57
|
+
op.on("--server-url URL", WSS, "netpump server url (example: wss://netpump.org)") do |url|
|
63
58
|
copts[:server_url] = url
|
64
59
|
end
|
65
60
|
|
@@ -97,7 +92,10 @@ else
|
|
97
92
|
end
|
98
93
|
end
|
99
94
|
|
100
|
-
EventMachine.error_handler
|
95
|
+
EventMachine.error_handler do |e|
|
96
|
+
log "[!] error: #{e.message}."
|
97
|
+
EventMachine.stop
|
98
|
+
end
|
101
99
|
EventMachine.run do
|
102
100
|
trap(:INT) { puts; EventMachine.stop }
|
103
101
|
if sopts.delete(:server)
|
@@ -108,7 +106,4 @@ EventMachine.run do
|
|
108
106
|
client = Netpump::Client.new(**copts)
|
109
107
|
client.start
|
110
108
|
end
|
111
|
-
rescue => e
|
112
|
-
log "[!] #{e.message}."
|
113
|
-
EventMachine.stop
|
114
109
|
end
|
data/lib/netpump/client.rb
CHANGED
@@ -21,8 +21,8 @@ module Netpump
|
|
21
21
|
websocket_pool_timeout: 60.0
|
22
22
|
)
|
23
23
|
@mode = mode
|
24
|
-
@host = host
|
25
|
-
@port = port
|
24
|
+
@host = host if mode == "browser"
|
25
|
+
@port = port if mode == "browser"
|
26
26
|
@proxy_host = proxy_host
|
27
27
|
@proxy_port = proxy_port
|
28
28
|
@server_url = URI(server_url)
|
@@ -31,7 +31,7 @@ module Netpump
|
|
31
31
|
@websocket_pool_size = websocket_pool_size
|
32
32
|
@websocket_pool_timeout = websocket_pool_timeout
|
33
33
|
@control_ws = nil
|
34
|
-
@log = lambda { |msg, **ctx| log(msg,
|
34
|
+
@log = lambda { |msg, **ctx| log(msg, c: true, **ctx) }
|
35
35
|
@ready = EventMachine::Completion.new
|
36
36
|
end
|
37
37
|
|
@@ -58,10 +58,10 @@ module Netpump
|
|
58
58
|
case path
|
59
59
|
when "/"
|
60
60
|
ws.serve_file(PUBLIC_DIR.join("netpump.html"))
|
61
|
-
@log.call "[~] http request.", method: "GET", path: path
|
61
|
+
@log.call "[~] http request.", ip: ws.remote_ip, method: "GET", path: path
|
62
62
|
when "/favicon.svg"
|
63
63
|
ws.serve_file(PUBLIC_DIR.join("favicon.svg"))
|
64
|
-
@log.call "[~] http request.", method: "GET", path: path
|
64
|
+
@log.call "[~] http request.", ip: ws.remote_ip, method: "GET", path: path
|
65
65
|
when "/ws/loc/control"
|
66
66
|
next false if @control_ws
|
67
67
|
ws.onopen do |_handshake|
|
@@ -100,7 +100,7 @@ module Netpump
|
|
100
100
|
end
|
101
101
|
|
102
102
|
def start_proxy_server
|
103
|
-
proxy = EventMachine.start_server(@proxy_host, @proxy_port, Relay, "
|
103
|
+
proxy = EventMachine.start_server(@proxy_host, @proxy_port, Relay, "c") do |relay|
|
104
104
|
bind(relay)
|
105
105
|
end
|
106
106
|
@log.call "[+] proxy server is ready.", type: "https", host: @proxy_host, port: @proxy_port
|
data/lib/netpump/log.rb
CHANGED
@@ -7,7 +7,7 @@ def log(msg, **context)
|
|
7
7
|
case v
|
8
8
|
when Exception
|
9
9
|
line << " #{k}=#{v.message.inspect}"
|
10
|
-
line << " backtrace=#{v.backtrace}" if
|
10
|
+
line << " backtrace=#{v.backtrace}" if $VERBOSE && v.backtrace
|
11
11
|
when true
|
12
12
|
line << " #{k}"
|
13
13
|
when false, nil, ""
|
data/lib/netpump/server.rb
CHANGED
@@ -11,7 +11,7 @@ module Netpump
|
|
11
11
|
@port = port
|
12
12
|
@proxy_host = proxy_host
|
13
13
|
@proxy_port = proxy_port
|
14
|
-
@log = lambda { |msg, **ctx| log(msg,
|
14
|
+
@log = lambda { |msg, **ctx| log(msg, s: true, **ctx) }
|
15
15
|
end
|
16
16
|
|
17
17
|
def start
|
@@ -48,7 +48,7 @@ module Netpump
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def bind(ws, ip)
|
51
|
-
EventMachine.connect(@proxy_host, @proxy_port, Relay, "
|
51
|
+
EventMachine.connect(@proxy_host, @proxy_port, Relay, "s") do |relay|
|
52
52
|
fail "inactivity timeout" unless relay.comm_inactivity_timeout.zero?
|
53
53
|
relay.bind(ws, ip).callback { bind(ws, ip) }
|
54
54
|
end
|
data/public/favicon.png
ADDED
Binary file
|
data/public/netpump.html
CHANGED
@@ -20,12 +20,6 @@
|
|
20
20
|
text-align: center;
|
21
21
|
color: white;
|
22
22
|
}
|
23
|
-
dd {
|
24
|
-
margin: 0;
|
25
|
-
}
|
26
|
-
input[type="checkbox"] {
|
27
|
-
margin-right: 0.5em;
|
28
|
-
}
|
29
23
|
header {
|
30
24
|
margin: 1em 0;
|
31
25
|
}
|
@@ -36,6 +30,12 @@
|
|
36
30
|
header svg {
|
37
31
|
width: 4em;
|
38
32
|
}
|
33
|
+
dd {
|
34
|
+
margin: 0;
|
35
|
+
}
|
36
|
+
input[type="checkbox"] {
|
37
|
+
margin-right: 0.5em;
|
38
|
+
}
|
39
39
|
</style>
|
40
40
|
</head>
|
41
41
|
<body>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: netpump
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- soylent
|
@@ -52,6 +52,7 @@ files:
|
|
52
52
|
- lib/netpump/log.rb
|
53
53
|
- lib/netpump/relay.rb
|
54
54
|
- lib/netpump/server.rb
|
55
|
+
- public/favicon.png
|
55
56
|
- public/favicon.svg
|
56
57
|
- public/netpump.html
|
57
58
|
homepage: https://netpump.org
|