datagrout-conduit 0.8.1 → 0.8.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/README.md +3 -3
- data/lib/datagrout_conduit/identity.rb +23 -5
- data/lib/datagrout_conduit/transport/base.rb +1 -7
- data/lib/datagrout_conduit/transport/ws.rb +34 -7
- data/lib/datagrout_conduit/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: ec9cfe7efc9431d776d64624de9f78a78acb96aaede8656434414be3d1fa5df2
|
|
4
|
+
data.tar.gz: d6d9b3e9b3c9cf16516b71d5b23a9ddd93ab7e8d134764d43b86d020ad331151
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5dd88750a33fd8359a45ca525e61a79f593bebb3334b17c888df7232e892965efefa6c76edb5d72445990a499dee473a2b13543ee165ea6928dd627ff146c340
|
|
7
|
+
data.tar.gz: be8e4676d63287463605dac5b278ce45b85d811373c9fdadc3a7897eb702356ba2d3eb34c047cfb124684011692333fa7edb1bffc6f35d7551d3af72be502f2f
|
data/README.md
CHANGED
|
@@ -9,13 +9,13 @@ Connect to remote MCP and JSONRPC servers, invoke tools, discover capabilities w
|
|
|
9
9
|
Add to your Gemfile:
|
|
10
10
|
|
|
11
11
|
```ruby
|
|
12
|
-
gem "datagrout-conduit", "~> 0.8.
|
|
12
|
+
gem "datagrout-conduit", "~> 0.8.3"
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
Or install directly:
|
|
16
16
|
|
|
17
17
|
```sh
|
|
18
|
-
gem install datagrout-conduit -v 0.8.
|
|
18
|
+
gem install datagrout-conduit -v 0.8.3
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
## Quick Start
|
|
@@ -310,7 +310,7 @@ Supported topics:
|
|
|
310
310
|
| `flows.<flow_id>.*` | `flow.into` progress and completion |
|
|
311
311
|
| `governor.<server_uuid>` | Governor percept events (file change, schedule, webhook) |
|
|
312
312
|
|
|
313
|
-
**Reconnection**: after a disconnect, `send_request` and `subscribe` raise `DatagroutConduit::NotInitializedError`. Call `client.connect` again and re-subscribe — subscriptions do not survive reconnects in v0.4.
|
|
313
|
+
**Reconnection**: after a disconnect, `send_request` and `subscribe` raise `DatagroutConduit::NotInitializedError`. Call `client.connect` again and re-subscribe — subscriptions do not survive reconnects in v0.4. A connection ends when the server closes it, a read fails, or a keepalive ping goes unanswered for a whole interval; in-flight calls then fail and every subscription's `each` ends.
|
|
314
314
|
|
|
315
315
|
## Standard MCP Methods
|
|
316
316
|
|
|
@@ -127,15 +127,33 @@ module DatagroutConduit
|
|
|
127
127
|
@ca_pem ? OpenSSL::X509::Certificate.new(@ca_pem) : nil
|
|
128
128
|
end
|
|
129
129
|
|
|
130
|
+
# Every certificate in the CA bundle, which may hold more than one.
|
|
131
|
+
def ca_certificates
|
|
132
|
+
return [] unless @ca_pem
|
|
133
|
+
|
|
134
|
+
@ca_pem.scan(/-----BEGIN CERTIFICATE-----.+?-----END CERTIFICATE-----/m)
|
|
135
|
+
.map { |pem| OpenSSL::X509::Certificate.new(pem) }
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
# The trust store for a connection made with this identity: the system's
|
|
139
|
+
# default roots plus this identity's CA (every certificate in the bundle).
|
|
140
|
+
#
|
|
141
|
+
# A store holding only the identity's CA rejects every publicly-issued
|
|
142
|
+
# server certificate, and a DataGrout-issued identity carries the
|
|
143
|
+
# DataGrout CA while the gateway itself presents a public certificate.
|
|
144
|
+
# Rust's `build_connector` is the reference: webpki roots plus the CA.
|
|
145
|
+
def cert_store
|
|
146
|
+
store = OpenSSL::X509::Store.new
|
|
147
|
+
store.set_default_paths
|
|
148
|
+
ca_certificates.each { |cert| store.add_cert(cert) }
|
|
149
|
+
store
|
|
150
|
+
end
|
|
151
|
+
|
|
130
152
|
# Configure Faraday SSL options with this identity's mTLS credentials.
|
|
131
153
|
def configure_ssl(ssl)
|
|
132
154
|
ssl.client_cert = openssl_cert
|
|
133
155
|
ssl.client_key = openssl_key
|
|
134
|
-
if @ca_pem
|
|
135
|
-
store = OpenSSL::X509::Store.new
|
|
136
|
-
store.add_cert(openssl_ca)
|
|
137
|
-
ssl.cert_store = store
|
|
138
|
-
end
|
|
156
|
+
ssl.cert_store = cert_store if @ca_pem
|
|
139
157
|
end
|
|
140
158
|
|
|
141
159
|
class << self
|
|
@@ -59,13 +59,7 @@ module DatagroutConduit
|
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
def configure_ssl(faraday)
|
|
62
|
-
faraday.ssl
|
|
63
|
-
faraday.ssl.client_key = @identity.openssl_key
|
|
64
|
-
if @identity.ca_pem
|
|
65
|
-
store = OpenSSL::X509::Store.new
|
|
66
|
-
store.add_cert(@identity.openssl_ca)
|
|
67
|
-
faraday.ssl.cert_store = store
|
|
68
|
-
end
|
|
62
|
+
@identity.configure_ssl(faraday.ssl)
|
|
69
63
|
end
|
|
70
64
|
|
|
71
65
|
def build_headers
|
|
@@ -321,11 +321,8 @@ module DatagroutConduit
|
|
|
321
321
|
if @identity
|
|
322
322
|
ctx.cert = @identity.openssl_cert
|
|
323
323
|
ctx.key = @identity.openssl_key
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
store.add_cert(@identity.openssl_ca)
|
|
327
|
-
ctx.cert_store = store
|
|
328
|
-
end
|
|
324
|
+
# The system roots plus the identity's CA, never the CA alone.
|
|
325
|
+
ctx.cert_store = @identity.cert_store if @identity.ca_pem
|
|
329
326
|
end
|
|
330
327
|
|
|
331
328
|
ctx
|
|
@@ -442,6 +439,19 @@ module DatagroutConduit
|
|
|
442
439
|
subs.each_value { |list| list.each(&:_close) }
|
|
443
440
|
end
|
|
444
441
|
|
|
442
|
+
# The peer stopped answering pings: release every waiter as a close
|
|
443
|
+
# does, then close the socket so the read thread stops too.
|
|
444
|
+
def peer_gone
|
|
445
|
+
was_connected = @mutex.synchronize do
|
|
446
|
+
old = @connected
|
|
447
|
+
@connected = false
|
|
448
|
+
old
|
|
449
|
+
end
|
|
450
|
+
|
|
451
|
+
fail_all_pending(:ping_timeout) if was_connected
|
|
452
|
+
@io&.close rescue nil
|
|
453
|
+
end
|
|
454
|
+
|
|
445
455
|
def cleanup_socket
|
|
446
456
|
stop_ping_thread
|
|
447
457
|
@write_mutex.synchronize do
|
|
@@ -458,11 +468,17 @@ module DatagroutConduit
|
|
|
458
468
|
# Start the background ping thread. Sends one WS ping frame every
|
|
459
469
|
# @ping_interval seconds until the connection is torn down. No-op when
|
|
460
470
|
# @ping_interval is non-positive (used by tests to disable pinging).
|
|
471
|
+
#
|
|
472
|
+
# A ping still unanswered when the next is due closes the connection: a
|
|
473
|
+
# peer that vanished without a close frame (a dropped NAT mapping, a
|
|
474
|
+
# host that went away) is otherwise invisible until the OS gives up on
|
|
475
|
+
# the TCP connection.
|
|
461
476
|
def start_ping_thread
|
|
462
477
|
return if @ping_thread
|
|
463
478
|
return if @ping_interval <= 0
|
|
464
479
|
|
|
465
480
|
interval = @ping_interval
|
|
481
|
+
@awaiting_pong = false
|
|
466
482
|
@ping_thread = Thread.new do
|
|
467
483
|
loop do
|
|
468
484
|
sleep interval
|
|
@@ -471,15 +487,26 @@ module DatagroutConduit
|
|
|
471
487
|
driver = @driver
|
|
472
488
|
break unless driver
|
|
473
489
|
|
|
490
|
+
if @awaiting_pong
|
|
491
|
+
peer_gone
|
|
492
|
+
break
|
|
493
|
+
end
|
|
494
|
+
|
|
474
495
|
begin
|
|
475
496
|
# WebSocket::Driver#ping returns false if the connection is
|
|
476
|
-
# already closing; treat that as "stop the loop" too.
|
|
477
|
-
|
|
497
|
+
# already closing; treat that as "stop the loop" too. Its block
|
|
498
|
+
# runs when the matching pong arrives.
|
|
499
|
+
@awaiting_pong = true
|
|
500
|
+
@write_mutex.synchronize { driver.ping { @awaiting_pong = false } } || break
|
|
478
501
|
@pings_sent += 1
|
|
479
502
|
rescue StandardError
|
|
480
503
|
break
|
|
481
504
|
end
|
|
482
505
|
end
|
|
506
|
+
ensure
|
|
507
|
+
# A loop that ended on its own must not stop the next connect from
|
|
508
|
+
# starting a fresh one.
|
|
509
|
+
@ping_thread = nil if @ping_thread == Thread.current
|
|
483
510
|
end
|
|
484
511
|
@ping_thread.abort_on_exception = false
|
|
485
512
|
@ping_thread.name = "conduit-ws-ping"
|