rb-portless 0.3.0.dev.20260630.03ed07d → 0.3.0.dev.20260630.8a76e8f
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.md +0 -15
- data/lib/portless/config.rb +0 -11
- data/lib/portless/health.rb +2 -4
- data/lib/portless/proxy.rb +7 -10
- data/lib/portless/runner.rb +0 -1
- data/lib/portless/version.rb +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: dda2037a7c7e36ac84158c7c47c2a49de2006452255f552d87547e513a17f8f9
|
|
4
|
+
data.tar.gz: cf0b838ff151ed00b72ec48579719de79b0e6f37e46368cd3358595dff9482c2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 382f71a9be4a4a9b7b71b36e4d23d98d69831e3f17174c534cab283371357cdcb7586ee55435b5c723a6a74b6382a7a79a68fe7e56b28a26a5f2e64d5ffba8e2
|
|
7
|
+
data.tar.gz: 425b0f7286a54d778b0cfedae39e74fb4bc07415f1c93ba1243153fa4ecf55614fd4e5d09e22cd99419185db7c70f034036554df871655cf611608e2e8e236d1
|
data/CHANGELOG.md
CHANGED
|
@@ -6,23 +6,8 @@ All notable changes to this project are documented here. The format follows
|
|
|
6
6
|
|
|
7
7
|
## [0.3.0]
|
|
8
8
|
|
|
9
|
-
### Fixed / hardened
|
|
10
|
-
|
|
11
|
-
- **Health probes can't hang.** Added a read timeout to the TLS and plain probes
|
|
12
|
-
so a port that accepts but never answers no longer blocks `discover_port`.
|
|
13
|
-
|
|
14
9
|
### Added
|
|
15
10
|
|
|
16
|
-
- **Risky-TLD warning.** Warn when the configured `tld` ends in a real/reserved
|
|
17
|
-
TLD (`dev`, `app`, `local`, …) that could intercept live traffic.
|
|
18
|
-
- **More tests** — `Proxy#call` is now public, so the proxy's routing + error
|
|
19
|
-
logic is unit-tested (404 / 508 loop guard / 502 dead-backend, all stamped with
|
|
20
|
-
the health header) plus health probes and privilege logic (42 tests). The
|
|
21
|
-
successful byte-forward + **WebSocket upgrade relay** (ActionCable) need a live
|
|
22
|
-
reactor and are verified end-to-end manually — async-http servers can't be torn
|
|
23
|
-
down in-process without deadlock.
|
|
24
|
-
|
|
25
|
-
|
|
26
11
|
- **Startup banner.** Running a dev server through rb-portless now prints a clear
|
|
27
12
|
banner with the named URL(s) it's reachable at — not just `127.0.0.1:port`.
|
|
28
13
|
- **Monorepo / multi-app.** A `portless.json` `apps` map runs several apps under
|
data/lib/portless/config.rb
CHANGED
|
@@ -32,17 +32,6 @@ module Portless
|
|
|
32
32
|
tld.split(".").include?(name) ? tld : "#{name}.#{tld}"
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
-
# Real/reserved TLDs that can intercept live traffic or clash with mDNS.
|
|
36
|
-
RISKY_TLDS = %w[dev app page zip mov local].freeze
|
|
37
|
-
|
|
38
|
-
# A warning string if the tld looks risky, else nil. (.localhost / .test are safe.)
|
|
39
|
-
def tld_warning
|
|
40
|
-
last = tld.split(".").last
|
|
41
|
-
return unless RISKY_TLDS.include?(last)
|
|
42
|
-
|
|
43
|
-
"tld \".#{last}\" is a real/reserved TLD — prefer \".localhost\" so you don't intercept real traffic"
|
|
44
|
-
end
|
|
45
|
-
|
|
46
35
|
def self.read_file(dir)
|
|
47
36
|
json = File.join(dir, "portless.json")
|
|
48
37
|
return JSON.parse(File.read(json)) if File.exist?(json)
|
data/lib/portless/health.rb
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
require "socket"
|
|
4
4
|
require "openssl"
|
|
5
|
-
require "timeout"
|
|
6
5
|
|
|
7
6
|
module Portless
|
|
8
7
|
# "Is *our* proxy on this port?" — every proxied response carries the
|
|
@@ -27,8 +26,7 @@ module Portless
|
|
|
27
26
|
ssl.sync_close = true
|
|
28
27
|
ssl.connect
|
|
29
28
|
ssl.write(REQUEST)
|
|
30
|
-
|
|
31
|
-
marker?(Timeout.timeout(timeout) { ssl.read(4096) })
|
|
29
|
+
marker?(ssl.read(4096))
|
|
32
30
|
rescue StandardError
|
|
33
31
|
false
|
|
34
32
|
ensure
|
|
@@ -40,7 +38,7 @@ module Portless
|
|
|
40
38
|
Socket.tcp("127.0.0.1", port, connect_timeout: timeout) do |sock|
|
|
41
39
|
sock.write(REQUEST)
|
|
42
40
|
sock.close_write
|
|
43
|
-
marker?(
|
|
41
|
+
marker?(sock.read(4096))
|
|
44
42
|
end
|
|
45
43
|
rescue StandardError
|
|
46
44
|
false
|
data/lib/portless/proxy.rb
CHANGED
|
@@ -51,10 +51,13 @@ module Portless
|
|
|
51
51
|
routes.find { |r| host.end_with?(".#{r.hostname}") }
|
|
52
52
|
end
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
private
|
|
55
|
+
|
|
56
|
+
def make_server(endpoint)
|
|
57
|
+
Async::HTTP::Server.for(endpoint) { |request| handle(request) }
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def handle(request)
|
|
58
61
|
host = request_host(request)
|
|
59
62
|
route = route_for(host)
|
|
60
63
|
return error(404, "No app is registered for #{host}.") unless route
|
|
@@ -69,12 +72,6 @@ module Portless
|
|
|
69
72
|
error(502, "Backend for #{host} is not responding (#{e.class}).")
|
|
70
73
|
end
|
|
71
74
|
|
|
72
|
-
private
|
|
73
|
-
|
|
74
|
-
def make_server(endpoint)
|
|
75
|
-
Async::HTTP::Server.for(endpoint) { |request| call(request) }
|
|
76
|
-
end
|
|
77
|
-
|
|
78
75
|
def build_forward(request, host, hops)
|
|
79
76
|
headers = Protocol::HTTP::Headers.new
|
|
80
77
|
request.headers.each do |key, value|
|
data/lib/portless/runner.rb
CHANGED
|
@@ -21,7 +21,6 @@ module Portless
|
|
|
21
21
|
command = Frameworks.inject(command, port) # --port/--host for vite/astro/etc.
|
|
22
22
|
hostname = @config.hostname
|
|
23
23
|
|
|
24
|
-
warn "rb-portless: #{@config.tld_warning}" if @config.tld_warning
|
|
25
24
|
ensure_trusted if @config.tls
|
|
26
25
|
proxy_port = Daemon.ensure_running(tls: @config.tls)
|
|
27
26
|
@route_store.add(hostname: hostname, port: port, pid: Process.pid, force: true)
|
data/lib/portless/version.rb
CHANGED