netpump 1.0.2 → 1.0.3
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 +4 -0
- data/bin/netpump +1 -1
- data/lib/eventmachine/websocket/client.rb +1 -1
- data/lib/eventmachine/websocket/server.rb +4 -4
- data/lib/netpump/client.rb +4 -3
- data/lib/netpump/server.rb +2 -2
- data/public/netpump.html +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f5b100cc632515db3f10a3f896cc9693868779f1b46ba669e733f94ef2a947ae
|
|
4
|
+
data.tar.gz: a121111da173f5315a621678e987f2ff5bd22699c4b062a13f280741fb6eac21
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a6cf3afbf87b63067b8c5ec0728ebd8546ec9fa74ebe3ceaa8a8dd9df4e6dffaeb612a9fa3aab92f4e973ef86f06a3a8da01f79dc5cc653cca1d364ba485f7e7
|
|
7
|
+
data.tar.gz: f0570c7cbe13d4709368f9f82dd620649de65ab6d7266113b8201b72def271c9a421bfb17100ebf7344e4f4cc07d1ad18936e1a46d3987d50ca3efff2fd19771
|
data/CHANGELOG
CHANGED
data/bin/netpump
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
module EventMachine::WebSocket::Server
|
|
2
|
-
def self.start(host, port, &block)
|
|
3
|
-
EventMachine::WebSocket.run(host: host, port: port, block: block) do |ws|
|
|
2
|
+
def self.start(host, port, log, &block)
|
|
3
|
+
EventMachine::WebSocket.run(host: host, port: port, block: block, log: log) do |ws|
|
|
4
4
|
ws.onerror do |e|
|
|
5
5
|
if EventMachine::WebSocket::WebSocketError === e
|
|
6
|
-
log "[!] websocket error.", error: e
|
|
6
|
+
log.call "[!] websocket error.", error: e
|
|
7
7
|
else
|
|
8
8
|
fail e
|
|
9
9
|
end
|
|
@@ -20,7 +20,7 @@ module EventMachine::WebSocket::Server
|
|
|
20
20
|
send_error = lambda do |status|
|
|
21
21
|
send_data("HTTP/1.1 #{status}\r\n\r\n#{status}")
|
|
22
22
|
close_connection_after_writing
|
|
23
|
-
log "[!] http client error.", method: method, path: path, status: status
|
|
23
|
+
@options[:log].call "[!] http client error.", method: method, path: path, status: status
|
|
24
24
|
end
|
|
25
25
|
if method != "GET"
|
|
26
26
|
send_error.call(405)
|
data/lib/netpump/client.rb
CHANGED
|
@@ -61,7 +61,7 @@ module Netpump
|
|
|
61
61
|
private_constant :PUBLIC_DIR
|
|
62
62
|
|
|
63
63
|
def start_websocket_server
|
|
64
|
-
EventMachine::WebSocket::Server.start(@host, @port) do |path, ws|
|
|
64
|
+
EventMachine::WebSocket::Server.start(@host, @port, @log) do |path, ws|
|
|
65
65
|
case path
|
|
66
66
|
when "/"
|
|
67
67
|
ws.serve_file(PUBLIC_DIR.join("netpump.html"))
|
|
@@ -98,7 +98,7 @@ module Netpump
|
|
|
98
98
|
end
|
|
99
99
|
|
|
100
100
|
def print_open_url
|
|
101
|
-
ip = Socket.getifaddrs.
|
|
101
|
+
ip = Socket.getifaddrs.select { |ifa| ifa.addr&.ipv4? }.last or raise(
|
|
102
102
|
"could not find an interface to listen on; " \
|
|
103
103
|
"make sure that you are connected to your device."
|
|
104
104
|
)
|
|
@@ -119,7 +119,8 @@ module Netpump
|
|
|
119
119
|
case @mode
|
|
120
120
|
when "direct"
|
|
121
121
|
host = @server_url.host
|
|
122
|
-
port
|
|
122
|
+
# Fallback to port 443 on older rubies.
|
|
123
|
+
port = @server_url.port || 443
|
|
123
124
|
begin
|
|
124
125
|
EventMachine.connect(host, port, EventMachine::WebSocket::Client, url: @server_url) do |ws|
|
|
125
126
|
ws.onopen do
|
data/lib/netpump/server.rb
CHANGED
|
@@ -28,10 +28,10 @@ module Netpump
|
|
|
28
28
|
private
|
|
29
29
|
|
|
30
30
|
def start_websocket_server
|
|
31
|
-
EventMachine::WebSocket::Server.start(@host, @port) do |path, ws|
|
|
31
|
+
EventMachine::WebSocket::Server.start(@host, @port, @log) do |path, ws|
|
|
32
32
|
case path
|
|
33
33
|
when "/", "/healthcheck"
|
|
34
|
-
@log.call "[~] http request.", method: "GET", path: path,
|
|
34
|
+
@log.call "[~] http request.", ip: ws.remote_ip, method: "GET", path: path, status: 200
|
|
35
35
|
ws.send_healthcheck_response
|
|
36
36
|
when "/ws/rem/relay"
|
|
37
37
|
ws.onopen do |handshake|
|
data/public/netpump.html
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<html>
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="utf-8" />
|
|
5
|
-
<meta name="viewport" content="width=device-width
|
|
5
|
+
<meta name="viewport" content="width=device-width" />
|
|
6
6
|
<title>netpump</title>
|
|
7
7
|
<link rel="icon" href="favicon.svg" type="image/svg+xml" />
|
|
8
8
|
<style>
|