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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 298b321a2b63596d5247b8d8cd807722c5062249f8f2c9e1b44b30b030a528f3
4
- data.tar.gz: c534a39e90383b0ac3896c8060d233dbd02c26c83563ed7d8c9d331b81c91370
3
+ metadata.gz: 2f72c49ca8c96dafbb9aa62b8742af225bc1117dac402989e1f0ed5612e61f41
4
+ data.tar.gz: 48322987d7bb48bffefe9d04f752e866ece76e972cffda9b034aed26c41ca959
5
5
  SHA512:
6
- metadata.gz: 95a11534001077454e72c94f94c81a2e816b613f9ab643ebaaeb06bbcf3e40f7210799130457d0af56677d2c0e5ac73ff8701426f778551c837f5b0ef9c3c711
7
- data.tar.gz: c0a4abe22639b9667cdfdf879f63a2c05e96c8ed3eac0d3376506b3d2e094724d5c18933ca9464ad099a87560545dbac91a55324ee82707f337d3eb2cf3a567c
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
- * Add backpressure mechanism to keep memory usage bounded
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.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
- if $PROGRAM_NAME.include?("/")
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://example.org)") do |url|
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 { |e| log "[!] unexpected errback.", error: e }
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
@@ -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, loc: true, **ctx) }
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, ip: ws.remote_ip
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, ip: ws.remote_ip
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, "loc") do |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 !$VERBOSE.nil? && v.backtrace
10
+ line << " backtrace=#{v.backtrace}" if $VERBOSE && v.backtrace
11
11
  when true
12
12
  line << " #{k}"
13
13
  when false, nil, ""
@@ -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, rem: true, **ctx) }
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, "rem") do |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
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.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