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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7430efcc1364552ff11c18a40fb81497f6adb231e9b70de8dac525209baa0140
4
- data.tar.gz: a7e8a061d587ae4df39feb5c419cdc4ded1f56e25c371d65e04daf39c88bc0ab
3
+ metadata.gz: dda2037a7c7e36ac84158c7c47c2a49de2006452255f552d87547e513a17f8f9
4
+ data.tar.gz: cf0b838ff151ed00b72ec48579719de79b0e6f37e46368cd3358595dff9482c2
5
5
  SHA512:
6
- metadata.gz: 479a942f43878da3fd6c9fc3ef51f45de6548aef51d69ec66442e87ae235378544b7165d070aeef22b19a4c5a57d9d60e1b1bca17d1324a2a50ddbf38e6bcd67
7
- data.tar.gz: ebf5b7ba3081de166182d8548235f27b7af0cd462008f458e82b786dc87db352b4cb5e82b3f1b60c350d4ba7c2748d6494ad482a5a3217d8fb0dce65ebed8e42
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
@@ -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)
@@ -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
- # Read timeout too — a port that accepts but never answers must not hang us.
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?(Timeout.timeout(timeout) { sock.read(4096) })
41
+ marker?(sock.read(4096))
44
42
  end
45
43
  rescue StandardError
46
44
  false
@@ -51,10 +51,13 @@ module Portless
51
51
  routes.find { |r| host.end_with?(".#{r.hostname}") }
52
52
  end
53
53
 
54
- # The reverse-proxy app: resolve the request's host to a backend, forward it,
55
- # stamp the health header. Public so it can be mounted in a test reactor
56
- # (Async::HTTP::Server.for(endpoint, &proxy.method(:call))).
57
- def call(request)
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|
@@ -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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Portless
4
- VERSION = "0.3.0.dev.20260630.03ed07d"
4
+ VERSION = "0.3.0.dev.20260630.8a76e8f"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rb-portless
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0.dev.20260630.03ed07d
4
+ version: 0.3.0.dev.20260630.8a76e8f
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Afonso