@streamr/dht 100.2.5-beta.1 → 101.0.0-beta.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.
Files changed (231) hide show
  1. package/dist/package.json +8 -8
  2. package/dist/src/connection/ConnectionLockRpcLocal.d.ts +3 -3
  3. package/dist/src/connection/ConnectionLockRpcLocal.js +8 -8
  4. package/dist/src/connection/ConnectionLockRpcLocal.js.map +1 -1
  5. package/dist/src/connection/ConnectionLockRpcRemote.js +1 -1
  6. package/dist/src/connection/ConnectionLockRpcRemote.js.map +1 -1
  7. package/dist/src/connection/ConnectionManager.d.ts +4 -6
  8. package/dist/src/connection/ConnectionManager.js +128 -103
  9. package/dist/src/connection/ConnectionManager.js.map +1 -1
  10. package/dist/src/connection/ConnectorFacade.d.ts +15 -14
  11. package/dist/src/connection/ConnectorFacade.js +70 -52
  12. package/dist/src/connection/ConnectorFacade.js.map +1 -1
  13. package/dist/src/connection/Handshaker.d.ts +9 -2
  14. package/dist/src/connection/Handshaker.js +117 -27
  15. package/dist/src/connection/Handshaker.js.map +1 -1
  16. package/dist/src/connection/ManagedConnection.d.ts +13 -38
  17. package/dist/src/connection/ManagedConnection.js +31 -252
  18. package/dist/src/connection/ManagedConnection.js.map +1 -1
  19. package/dist/src/connection/OutputBuffer.d.ts +9 -0
  20. package/dist/src/connection/OutputBuffer.js +26 -0
  21. package/dist/src/connection/OutputBuffer.js.map +1 -0
  22. package/dist/src/connection/PendingConnection.d.ts +19 -0
  23. package/dist/src/connection/PendingConnection.js +59 -0
  24. package/dist/src/connection/PendingConnection.js.map +1 -0
  25. package/dist/src/connection/connectivityChecker.js +3 -3
  26. package/dist/src/connection/connectivityChecker.js.map +1 -1
  27. package/dist/src/connection/connectivityRequestHandler.js +2 -2
  28. package/dist/src/connection/connectivityRequestHandler.js.map +1 -1
  29. package/dist/src/connection/simulator/Simulator.d.ts +1 -3
  30. package/dist/src/connection/simulator/Simulator.js +1 -4
  31. package/dist/src/connection/simulator/Simulator.js.map +1 -1
  32. package/dist/src/connection/simulator/SimulatorConnection.js +1 -2
  33. package/dist/src/connection/simulator/SimulatorConnection.js.map +1 -1
  34. package/dist/src/connection/simulator/SimulatorConnector.d.ts +3 -3
  35. package/dist/src/connection/simulator/SimulatorConnector.js +28 -21
  36. package/dist/src/connection/simulator/SimulatorConnector.js.map +1 -1
  37. package/dist/src/connection/webrtc/NodeWebrtcConnection.d.ts +1 -6
  38. package/dist/src/connection/webrtc/NodeWebrtcConnection.js +3 -20
  39. package/dist/src/connection/webrtc/NodeWebrtcConnection.js.map +1 -1
  40. package/dist/src/connection/webrtc/WebrtcConnector.d.ts +11 -6
  41. package/dist/src/connection/webrtc/WebrtcConnector.js +57 -42
  42. package/dist/src/connection/webrtc/WebrtcConnector.js.map +1 -1
  43. package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.d.ts +8 -10
  44. package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js +21 -44
  45. package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js.map +1 -1
  46. package/dist/src/connection/websocket/AbstractWebsocketClientConnection.js +8 -2
  47. package/dist/src/connection/websocket/AbstractWebsocketClientConnection.js.map +1 -1
  48. package/dist/src/connection/websocket/AutoCertifierClientFacade.d.ts +3 -3
  49. package/dist/src/connection/websocket/AutoCertifierClientFacade.js +8 -8
  50. package/dist/src/connection/websocket/AutoCertifierClientFacade.js.map +1 -1
  51. package/dist/src/connection/websocket/NodeWebsocketClientConnection.js +1 -1
  52. package/dist/src/connection/websocket/NodeWebsocketClientConnection.js.map +1 -1
  53. package/dist/src/connection/websocket/WebsocketClientConnector.d.ts +26 -0
  54. package/dist/src/connection/websocket/WebsocketClientConnector.js +86 -0
  55. package/dist/src/connection/websocket/WebsocketClientConnector.js.map +1 -0
  56. package/dist/src/connection/websocket/WebsocketClientConnectorRpcLocal.d.ts +19 -0
  57. package/dist/src/connection/websocket/WebsocketClientConnectorRpcLocal.js +23 -0
  58. package/dist/src/connection/websocket/WebsocketClientConnectorRpcLocal.js.map +1 -0
  59. package/dist/src/connection/websocket/WebsocketClientConnectorRpcRemote.d.ts +5 -0
  60. package/dist/src/connection/websocket/{WebsocketConnectorRpcRemote.js → WebsocketClientConnectorRpcRemote.js} +4 -4
  61. package/dist/src/connection/websocket/WebsocketClientConnectorRpcRemote.js.map +1 -0
  62. package/dist/src/connection/websocket/WebsocketServer.d.ts +8 -5
  63. package/dist/src/connection/websocket/WebsocketServer.js +11 -11
  64. package/dist/src/connection/websocket/WebsocketServer.js.map +1 -1
  65. package/dist/src/connection/websocket/{WebsocketConnector.d.ts → WebsocketServerConnector.d.ts} +16 -21
  66. package/dist/src/connection/websocket/{WebsocketConnector.js → WebsocketServerConnector.js} +112 -160
  67. package/dist/src/connection/websocket/WebsocketServerConnector.js.map +1 -0
  68. package/dist/src/dht/DhtNode.d.ts +4 -4
  69. package/dist/src/dht/DhtNode.js +85 -84
  70. package/dist/src/dht/DhtNode.js.map +1 -1
  71. package/dist/src/dht/DhtNodeRpcLocal.d.ts +3 -3
  72. package/dist/src/dht/DhtNodeRpcLocal.js +9 -9
  73. package/dist/src/dht/DhtNodeRpcLocal.js.map +1 -1
  74. package/dist/src/dht/ExternalApiRpcLocal.d.ts +3 -3
  75. package/dist/src/dht/ExternalApiRpcLocal.js +5 -5
  76. package/dist/src/dht/ExternalApiRpcLocal.js.map +1 -1
  77. package/dist/src/dht/ExternalApiRpcRemote.js +2 -2
  78. package/dist/src/dht/ExternalApiRpcRemote.js.map +1 -1
  79. package/dist/src/dht/PeerManager.d.ts +4 -4
  80. package/dist/src/dht/PeerManager.js +22 -22
  81. package/dist/src/dht/PeerManager.js.map +1 -1
  82. package/dist/src/dht/contact/SortedContactList.d.ts +3 -3
  83. package/dist/src/dht/contact/SortedContactList.js +9 -9
  84. package/dist/src/dht/contact/SortedContactList.js.map +1 -1
  85. package/dist/src/dht/discovery/DiscoverySession.d.ts +3 -3
  86. package/dist/src/dht/discovery/DiscoverySession.js +21 -21
  87. package/dist/src/dht/discovery/DiscoverySession.js.map +1 -1
  88. package/dist/src/dht/discovery/PeerDiscovery.d.ts +3 -3
  89. package/dist/src/dht/discovery/PeerDiscovery.js +46 -44
  90. package/dist/src/dht/discovery/PeerDiscovery.js.map +1 -1
  91. package/dist/src/dht/discovery/RingDiscoverySession.d.ts +3 -3
  92. package/dist/src/dht/discovery/RingDiscoverySession.js +19 -19
  93. package/dist/src/dht/discovery/RingDiscoverySession.js.map +1 -1
  94. package/dist/src/dht/recursive-operation/RecursiveOperationManager.d.ts +3 -3
  95. package/dist/src/dht/recursive-operation/RecursiveOperationManager.js +33 -33
  96. package/dist/src/dht/recursive-operation/RecursiveOperationManager.js.map +1 -1
  97. package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.d.ts +3 -3
  98. package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.js +8 -8
  99. package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.js.map +1 -1
  100. package/dist/src/dht/recursive-operation/RecursiveOperationSession.d.ts +4 -4
  101. package/dist/src/dht/recursive-operation/RecursiveOperationSession.js +24 -24
  102. package/dist/src/dht/recursive-operation/RecursiveOperationSession.js.map +1 -1
  103. package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.d.ts +4 -4
  104. package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.js +5 -5
  105. package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.js.map +1 -1
  106. package/dist/src/dht/routing/Router.d.ts +3 -3
  107. package/dist/src/dht/routing/Router.js +20 -20
  108. package/dist/src/dht/routing/Router.js.map +1 -1
  109. package/dist/src/dht/routing/RouterRpcLocal.d.ts +3 -3
  110. package/dist/src/dht/routing/RouterRpcLocal.js +16 -16
  111. package/dist/src/dht/routing/RouterRpcLocal.js.map +1 -1
  112. package/dist/src/dht/routing/RoutingSession.d.ts +3 -3
  113. package/dist/src/dht/routing/RoutingSession.js +24 -24
  114. package/dist/src/dht/routing/RoutingSession.js.map +1 -1
  115. package/dist/src/dht/store/StoreManager.d.ts +3 -3
  116. package/dist/src/dht/store/StoreManager.js +25 -25
  117. package/dist/src/dht/store/StoreManager.js.map +1 -1
  118. package/dist/src/dht/store/StoreRpcLocal.d.ts +3 -3
  119. package/dist/src/dht/store/StoreRpcLocal.js +12 -12
  120. package/dist/src/dht/store/StoreRpcLocal.js.map +1 -1
  121. package/dist/src/exports.d.ts +3 -0
  122. package/dist/src/exports.js +5 -1
  123. package/dist/src/exports.js.map +1 -1
  124. package/dist/src/proto/google/protobuf/any.d.ts +5 -8
  125. package/dist/src/proto/google/protobuf/any.js.map +1 -1
  126. package/dist/src/proto/google/protobuf/empty.d.ts +1 -0
  127. package/dist/src/proto/google/protobuf/empty.js.map +1 -1
  128. package/dist/src/proto/google/protobuf/timestamp.d.ts +1 -10
  129. package/dist/src/proto/google/protobuf/timestamp.js.map +1 -1
  130. package/dist/src/proto/packages/dht/protos/DhtRpc.client.d.ts +4 -4
  131. package/dist/src/proto/packages/dht/protos/DhtRpc.client.js +8 -8
  132. package/dist/src/proto/packages/dht/protos/DhtRpc.client.js.map +1 -1
  133. package/dist/src/proto/packages/dht/protos/DhtRpc.d.ts +3 -3
  134. package/dist/src/proto/packages/dht/protos/DhtRpc.js +4 -4
  135. package/dist/src/proto/packages/dht/protos/DhtRpc.js.map +1 -1
  136. package/dist/src/proto/packages/dht/protos/DhtRpc.server.d.ts +2 -2
  137. package/dist/src/proto/packages/proto-rpc/protos/ProtoRpc.js +1 -1
  138. package/dist/src/transport/ListeningRpcCommunicator.d.ts +2 -2
  139. package/dist/src/transport/ListeningRpcCommunicator.js +2 -2
  140. package/dist/src/transport/ListeningRpcCommunicator.js.map +1 -1
  141. package/dist/src/transport/RoutingRpcCommunicator.d.ts +2 -2
  142. package/dist/src/transport/RoutingRpcCommunicator.js +2 -2
  143. package/dist/src/transport/RoutingRpcCommunicator.js.map +1 -1
  144. package/package.json +8 -8
  145. package/protos/DhtRpc.proto +1 -1
  146. package/src/connection/ConnectionLockRpcLocal.ts +9 -9
  147. package/src/connection/ConnectionLockRpcRemote.ts +1 -1
  148. package/src/connection/ConnectionManager.ts +153 -111
  149. package/src/connection/ConnectorFacade.ts +84 -61
  150. package/src/connection/Handshaker.ts +131 -27
  151. package/src/connection/ManagedConnection.ts +41 -304
  152. package/src/connection/OutputBuffer.ts +28 -0
  153. package/src/connection/PendingConnection.ts +68 -0
  154. package/src/connection/connectivityChecker.ts +2 -2
  155. package/src/connection/connectivityRequestHandler.ts +1 -1
  156. package/src/connection/simulator/Simulator.ts +1 -5
  157. package/src/connection/simulator/SimulatorConnection.ts +1 -2
  158. package/src/connection/simulator/SimulatorConnector.ts +34 -33
  159. package/src/connection/webrtc/BrowserWebrtcConnection.ts +0 -6
  160. package/src/connection/webrtc/NodeWebrtcConnection.ts +3 -24
  161. package/src/connection/webrtc/WebrtcConnector.ts +73 -62
  162. package/src/connection/webrtc/WebrtcConnectorRpcLocal.ts +26 -56
  163. package/src/connection/websocket/AbstractWebsocketClientConnection.ts +8 -2
  164. package/src/connection/websocket/AutoCertifierClientFacade.ts +11 -11
  165. package/src/connection/websocket/NodeWebsocketClientConnection.ts +1 -1
  166. package/src/connection/websocket/WebsocketClientConnector.ts +119 -0
  167. package/src/connection/websocket/WebsocketClientConnectorRpcLocal.ts +39 -0
  168. package/src/connection/websocket/{WebsocketConnectorRpcRemote.ts → WebsocketClientConnectorRpcRemote.ts} +2 -2
  169. package/src/connection/websocket/WebsocketServer.ts +18 -14
  170. package/src/connection/websocket/{WebsocketConnector.ts → WebsocketServerConnector.ts} +128 -205
  171. package/src/dht/DhtNode.ts +90 -89
  172. package/src/dht/DhtNodeRpcLocal.ts +11 -11
  173. package/src/dht/ExternalApiRpcLocal.ts +6 -6
  174. package/src/dht/ExternalApiRpcRemote.ts +2 -2
  175. package/src/dht/PeerManager.ts +24 -24
  176. package/src/dht/contact/SortedContactList.ts +10 -10
  177. package/src/dht/discovery/DiscoverySession.ts +24 -24
  178. package/src/dht/discovery/PeerDiscovery.ts +47 -45
  179. package/src/dht/discovery/RingDiscoverySession.ts +23 -23
  180. package/src/dht/recursive-operation/RecursiveOperationManager.ts +36 -36
  181. package/src/dht/recursive-operation/RecursiveOperationRpcLocal.ts +9 -9
  182. package/src/dht/recursive-operation/RecursiveOperationSession.ts +25 -25
  183. package/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.ts +7 -7
  184. package/src/dht/routing/Router.ts +21 -21
  185. package/src/dht/routing/RouterRpcLocal.ts +17 -17
  186. package/src/dht/routing/RoutingSession.ts +26 -26
  187. package/src/dht/store/StoreManager.ts +27 -27
  188. package/src/dht/store/StoreRpcLocal.ts +13 -13
  189. package/src/exports.ts +3 -0
  190. package/src/proto/google/protobuf/any.ts +6 -9
  191. package/src/proto/google/protobuf/empty.ts +2 -1
  192. package/src/proto/google/protobuf/timestamp.ts +2 -11
  193. package/src/proto/packages/dht/protos/DhtRpc.client.ts +9 -9
  194. package/src/proto/packages/dht/protos/DhtRpc.server.ts +3 -3
  195. package/src/proto/packages/dht/protos/DhtRpc.ts +4 -4
  196. package/src/proto/packages/proto-rpc/protos/ProtoRpc.ts +1 -1
  197. package/src/transport/ListeningRpcCommunicator.ts +3 -3
  198. package/src/transport/RoutingRpcCommunicator.ts +3 -3
  199. package/test/end-to-end/Layer0Webrtc.test.ts +0 -10
  200. package/test/integration/ConnectionManager.test.ts +3 -2
  201. package/test/integration/GeoIpConnectivityChecking.test.ts +1 -1
  202. package/test/integration/SimultaneousConnections.test.ts +2 -2
  203. package/test/integration/WebrtcConnectionManagement.test.ts +2 -10
  204. package/test/integration/{WebsocketConnectorRpc.test.ts → WebsocketClientConnectorRpc.test.ts} +9 -9
  205. package/test/integration/WebsocketConnectionManagement.test.ts +11 -29
  206. package/test/unit/ConnectionManager.test.ts +64 -0
  207. package/test/unit/DiscoverySession.test.ts +1 -1
  208. package/test/unit/Handshaker.test.ts +169 -0
  209. package/test/unit/ManagedConnection.test.ts +58 -0
  210. package/test/unit/PendingConnection.test.ts +57 -0
  211. package/test/unit/WebrtcConnector.test.ts +56 -0
  212. package/test/unit/{WebsocketConnector.test.ts → WebsocketClientConnector.test.ts} +56 -11
  213. package/test/unit/WebsocketServerConnector.test.ts +102 -0
  214. package/test/utils/FakeConnectorFacade.ts +41 -0
  215. package/test/utils/mock/MockConnection.ts +26 -0
  216. package/test/utils/utils.ts +2 -2
  217. package/dist/src/connection/IConnectionSource.d.ts +0 -4
  218. package/dist/src/connection/IConnectionSource.js +0 -3
  219. package/dist/src/connection/IConnectionSource.js.map +0 -1
  220. package/dist/src/connection/webrtc/ManagedWebrtcConnection.d.ts +0 -7
  221. package/dist/src/connection/webrtc/ManagedWebrtcConnection.js +0 -20
  222. package/dist/src/connection/webrtc/ManagedWebrtcConnection.js.map +0 -1
  223. package/dist/src/connection/websocket/WebsocketConnector.js.map +0 -1
  224. package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.d.ts +0 -19
  225. package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.js +0 -23
  226. package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.js.map +0 -1
  227. package/dist/src/connection/websocket/WebsocketConnectorRpcRemote.d.ts +0 -5
  228. package/dist/src/connection/websocket/WebsocketConnectorRpcRemote.js.map +0 -1
  229. package/src/connection/IConnectionSource.ts +0 -6
  230. package/src/connection/webrtc/ManagedWebrtcConnection.ts +0 -27
  231. package/src/connection/websocket/WebsocketConnectorRpcLocal.ts +0 -39
@@ -13,12 +13,6 @@ enum DisconnectedRtcPeerConnectionStateEnum {
13
13
 
14
14
  const logger = new Logger(module)
15
15
 
16
- export const WEBRTC_CLEANUP = new class {
17
- // eslint-disable-next-line class-methods-use-this
18
- cleanUp(): void {
19
- }
20
- }
21
-
22
16
  type Events = WebrtcConnectionEvents & ConnectionEvents
23
17
 
24
18
  interface Params {
@@ -2,7 +2,7 @@ import { IWebrtcConnection, WebrtcConnectionEvents } from './IWebrtcConnection'
2
2
  import { ConnectionType, IConnection, ConnectionID, ConnectionEvents } from '../IConnection'
3
3
  import { PeerDescriptor } from '../../proto/packages/dht/protos/DhtRpc'
4
4
  import EventEmitter from 'eventemitter3'
5
- import { DataChannel, DescriptionType, PeerConnection, cleanup, initLogger } from 'node-datachannel'
5
+ import { DataChannel, DescriptionType, PeerConnection, initLogger } from 'node-datachannel'
6
6
  import { Logger } from '@streamr/utils'
7
7
  import { IllegalRtcPeerConnectionState } from '../../helpers/errors'
8
8
  import { iceServerAsString } from './iceServerAsString'
@@ -13,18 +13,10 @@ import { createRandomConnectionId } from '../Connection'
13
13
 
14
14
  const logger = new Logger(module)
15
15
 
16
- export const WEBRTC_CLEANUP = new class {
17
- // eslint-disable-next-line class-methods-use-this
18
- cleanUp(): void {
19
- cleanup()
20
- }
21
- }
22
-
23
16
  export interface Params {
24
17
  remotePeerDescriptor: PeerDescriptor
25
18
  bufferThresholdHigh?: number
26
19
  bufferThresholdLow?: number
27
- connectingTimeout?: number
28
20
  maxMessageSize?: number
29
21
  iceServers?: IceServer[] // TODO make this parameter required (empty array is a good fallback which can be set by the caller if needed)
30
22
  portRange?: PortRange
@@ -55,16 +47,15 @@ export class NodeWebrtcConnection extends EventEmitter<Events> implements IConne
55
47
  private dataChannel?: DataChannel
56
48
  private lastState: RtcPeerConnectionState = 'connecting'
57
49
  private remoteDescriptionSet = false
58
- private connectingTimeoutRef?: NodeJS.Timeout
59
50
  public readonly connectionType: ConnectionType = ConnectionType.WEBRTC
60
51
  private readonly iceServers: IceServer[]
61
52
  private readonly _bufferThresholdHigh: number // TODO: buffer handling must be implemented before production use (NET-938)
62
53
  private readonly bufferThresholdLow: number
63
- private readonly connectingTimeout: number
64
54
  private readonly remotePeerDescriptor: PeerDescriptor
65
55
  private readonly portRange?: PortRange
66
56
  private readonly maxMessageSize?: number
67
57
  private closed = false
58
+ private offering?: boolean
68
59
 
69
60
  constructor(params: Params) {
70
61
  super()
@@ -73,7 +64,6 @@ export class NodeWebrtcConnection extends EventEmitter<Events> implements IConne
73
64
  // eslint-disable-next-line no-underscore-dangle
74
65
  this._bufferThresholdHigh = params.bufferThresholdHigh ?? 2 ** 17
75
66
  this.bufferThresholdLow = params.bufferThresholdLow ?? 2 ** 15
76
- this.connectingTimeout = params.connectingTimeout ?? 20000
77
67
  this.remotePeerDescriptor = params.remotePeerDescriptor
78
68
  this.maxMessageSize = params.maxMessageSize ?? 1048576
79
69
  this.portRange = params.portRange
@@ -81,6 +71,7 @@ export class NodeWebrtcConnection extends EventEmitter<Events> implements IConne
81
71
 
82
72
  public start(isOffering: boolean): void {
83
73
  const nodeId = getNodeIdFromPeerDescriptor(this.remotePeerDescriptor)
74
+ this.offering = isOffering
84
75
  logger.trace(`Starting new connection for peer ${nodeId}`, { isOffering })
85
76
  this.connection = new PeerConnection(nodeId, {
86
77
  iceServers: this.iceServers.map(iceServerAsString),
@@ -89,11 +80,6 @@ export class NodeWebrtcConnection extends EventEmitter<Events> implements IConne
89
80
  portRangeEnd: this.portRange?.max,
90
81
  })
91
82
 
92
- this.connectingTimeoutRef = setTimeout(() => {
93
- logger.trace('connectingTimeout, this.closed === ' + this.closed)
94
- this.doClose(false)
95
- }, this.connectingTimeout)
96
-
97
83
  this.connection.onStateChange((state: string) => this.onStateChange(state))
98
84
  this.connection.onGatheringStateChange(() => {})
99
85
 
@@ -169,10 +155,6 @@ export class NodeWebrtcConnection extends EventEmitter<Events> implements IConne
169
155
 
170
156
  this.emit('disconnected', gracefulLeave, undefined, reason)
171
157
  this.removeAllListeners()
172
-
173
- if (this.connectingTimeoutRef) {
174
- clearTimeout(this.connectingTimeoutRef)
175
- }
176
158
 
177
159
  if (this.dataChannel) {
178
160
  try {
@@ -226,9 +208,6 @@ export class NodeWebrtcConnection extends EventEmitter<Events> implements IConne
226
208
  }
227
209
 
228
210
  private onDataChannelOpen(): void {
229
- if (this.connectingTimeoutRef) {
230
- clearTimeout(this.connectingTimeoutRef)
231
- }
232
211
  logger.trace(`DataChannel opened for peer ${getNodeIdFromPeerDescriptor(this.remotePeerDescriptor)}`)
233
212
  this.emit('connected')
234
213
  }
@@ -1,4 +1,5 @@
1
1
  import {
2
+ HandshakeError,
2
3
  IceCandidate,
3
4
  PeerDescriptor,
4
5
  RtcAnswer,
@@ -9,15 +10,16 @@ import { ListeningRpcCommunicator } from '../../transport/ListeningRpcCommunicat
9
10
  import { NodeWebrtcConnection } from './NodeWebrtcConnection'
10
11
  import { WebrtcConnectorRpcRemote } from './WebrtcConnectorRpcRemote'
11
12
  import { WebrtcConnectorRpcClient } from '../../proto/packages/dht/protos/DhtRpc.client'
12
- import { ManagedWebrtcConnection } from './ManagedWebrtcConnection'
13
13
  import { Logger } from '@streamr/utils'
14
14
  import * as Err from '../../helpers/errors'
15
- import { ManagedConnection } from '../ManagedConnection'
16
15
  import { PortRange } from '../ConnectionManager'
17
16
  import { ServerCallContext } from '@protobuf-ts/runtime-rpc'
18
17
  import { WebrtcConnectorRpcLocal } from './WebrtcConnectorRpcLocal'
19
18
  import { DhtAddress, areEqualPeerDescriptors, getNodeIdFromPeerDescriptor } from '../../identifiers'
20
19
  import { getOfferer } from '../../helpers/offering'
20
+ import { acceptHandshake, createIncomingHandshaker, createOutgoingHandshaker, rejectHandshake } from '../Handshaker'
21
+ import { isMaybeSupportedVersion } from '../../helpers/version'
22
+ import { PendingConnection } from '../PendingConnection'
21
23
 
22
24
  const logger = new Logger(module)
23
25
 
@@ -30,14 +32,14 @@ export const replaceInternalIpWithExternalIp = (candidate: string, ip: string):
30
32
  return parsed.join(' ')
31
33
  }
32
34
 
33
- export interface WebrtcConnectorConfig {
35
+ export interface WebrtcConnectorOptions {
36
+ onNewConnection: (connection: PendingConnection) => boolean
34
37
  transport: ITransport
35
38
  iceServers?: IceServer[]
36
39
  allowPrivateAddresses?: boolean
37
40
  bufferThresholdLow?: number
38
41
  bufferThresholdHigh?: number
39
42
  maxMessageSize?: number
40
- connectionTimeout?: number
41
43
  externalIp?: string
42
44
  portRange?: PortRange
43
45
  }
@@ -50,38 +52,37 @@ export interface IceServer {
50
52
  tcp?: boolean
51
53
  }
52
54
 
55
+ export interface ConnectingConnection {
56
+ managedConnection: PendingConnection
57
+ connection: NodeWebrtcConnection
58
+ }
59
+
53
60
  export class WebrtcConnector {
54
61
 
55
62
  private static readonly WEBRTC_CONNECTOR_SERVICE_ID = 'system/webrtc-connector'
56
63
  private readonly rpcCommunicator: ListeningRpcCommunicator
57
- private readonly ongoingConnectAttempts: Map<DhtAddress, ManagedWebrtcConnection> = new Map()
64
+ private readonly ongoingConnectAttempts: Map<DhtAddress, ConnectingConnection> = new Map()
58
65
  private localPeerDescriptor?: PeerDescriptor
59
66
  private stopped = false
60
- private config: WebrtcConnectorConfig
61
-
62
- constructor(
63
- config: WebrtcConnectorConfig,
64
- onNewConnection: (connection: ManagedConnection) => boolean
65
- ) {
66
- this.config = config
67
- this.rpcCommunicator = new ListeningRpcCommunicator(WebrtcConnector.WEBRTC_CONNECTOR_SERVICE_ID, config.transport, {
68
- rpcRequestTimeout: 15000 // TODO use config option or named constant?
67
+ private options: WebrtcConnectorOptions
68
+
69
+ constructor(options: WebrtcConnectorOptions) {
70
+ this.options = options
71
+ this.rpcCommunicator = new ListeningRpcCommunicator(WebrtcConnector.WEBRTC_CONNECTOR_SERVICE_ID, options.transport, {
72
+ rpcRequestTimeout: 15000 // TODO use options option or named constant?
69
73
  })
70
- this.registerLocalRpcMethods(config, onNewConnection)
74
+ this.registerLocalRpcMethods(options)
71
75
  }
72
76
 
73
- private registerLocalRpcMethods(
74
- config: WebrtcConnectorConfig,
75
- onNewConnection: (connection: ManagedConnection) => boolean
76
- ) {
77
+ private registerLocalRpcMethods(options: WebrtcConnectorOptions) {
77
78
  const localRpc = new WebrtcConnectorRpcLocal({
78
- createConnection: (targetPeerDescriptor: PeerDescriptor) => this.createConnection(targetPeerDescriptor),
79
- connect: (targetPeerDescriptor: PeerDescriptor) => this.connect(targetPeerDescriptor),
80
- onNewConnection,
79
+ connect: (targetPeerDescriptor: PeerDescriptor, doNotRequestConnection: boolean) =>
80
+ this.connect(targetPeerDescriptor, doNotRequestConnection),
81
+ onNewConnection: (connection: PendingConnection) => this.options.onNewConnection(connection),
81
82
  ongoingConnectAttempts: this.ongoingConnectAttempts,
82
83
  rpcCommunicator: this.rpcCommunicator,
83
84
  getLocalPeerDescriptor: () => this.localPeerDescriptor!,
84
- allowPrivateAddresses: config.allowPrivateAddresses ?? true
85
+ allowPrivateAddresses: options.allowPrivateAddresses ?? true
85
86
  })
86
87
  this.rpcCommunicator.registerRpcNotification(WebrtcConnectionRequest, 'requestConnection',
87
88
  async (_req: WebrtcConnectionRequest, context: ServerCallContext) => {
@@ -121,7 +122,7 @@ export class WebrtcConnector {
121
122
  )
122
123
  }
123
124
 
124
- connect(targetPeerDescriptor: PeerDescriptor): ManagedConnection {
125
+ connect(targetPeerDescriptor: PeerDescriptor, doNotRequestConnection: boolean): PendingConnection {
125
126
  if (areEqualPeerDescriptors(targetPeerDescriptor, this.localPeerDescriptor!)) {
126
127
  throw new Err.CannotConnectToSelf('Cannot open WebRTC Connection to self')
127
128
  }
@@ -131,7 +132,7 @@ export class WebrtcConnector {
131
132
  const nodeId = getNodeIdFromPeerDescriptor(targetPeerDescriptor)
132
133
  const existingConnection = this.ongoingConnectAttempts.get(nodeId)
133
134
  if (existingConnection) {
134
- return existingConnection
135
+ return existingConnection.managedConnection
135
136
  }
136
137
 
137
138
  const connection = this.createConnection(targetPeerDescriptor)
@@ -139,68 +140,75 @@ export class WebrtcConnector {
139
140
  const localNodeId = getNodeIdFromPeerDescriptor(this.localPeerDescriptor!)
140
141
  const targetNodeId = getNodeIdFromPeerDescriptor(targetPeerDescriptor)
141
142
  const offering = (getOfferer(localNodeId, targetNodeId) === 'local')
142
- let managedConnection: ManagedWebrtcConnection
143
-
144
- if (offering) {
145
- managedConnection = new ManagedWebrtcConnection(this.localPeerDescriptor!, connection)
146
- } else {
147
- managedConnection = new ManagedWebrtcConnection(this.localPeerDescriptor!, undefined, connection)
148
- }
149
-
150
- managedConnection.setRemotePeerDescriptor(targetPeerDescriptor)
151
-
152
- this.ongoingConnectAttempts.set(targetNodeId, managedConnection)
153
-
154
- const delFunc = () => {
155
- this.ongoingConnectAttempts.delete(nodeId)
156
- connection.off('disconnected', delFunc)
157
- managedConnection.off('handshakeCompleted', delFunc)
158
- }
159
- connection.on('disconnected', delFunc)
160
- managedConnection.on('handshakeCompleted', delFunc)
161
-
143
+ let pendingConnection: PendingConnection
162
144
  const remoteConnector = new WebrtcConnectorRpcRemote(
163
145
  this.localPeerDescriptor!,
164
146
  targetPeerDescriptor,
165
147
  this.rpcCommunicator,
166
148
  WebrtcConnectorRpcClient
167
149
  )
168
-
169
- connection.on('localCandidate', (candidate: string, mid: string) => {
170
- if (this.config.externalIp !== undefined) {
171
- candidate = replaceInternalIpWithExternalIp(candidate, this.config.externalIp)
172
- logger.debug(`onLocalCandidate injected external ip ${candidate} ${mid}`)
173
- }
174
- remoteConnector.sendIceCandidate(candidate, mid, connection.connectionId)
175
- })
176
-
150
+ const delFunc = () => {
151
+ this.ongoingConnectAttempts.delete(nodeId)
152
+ connection.off('disconnected', delFunc)
153
+ pendingConnection.off('disconnected', delFunc)
154
+ pendingConnection.off('connected', delFunc)
155
+ }
177
156
  if (offering) {
157
+ pendingConnection = new PendingConnection(targetPeerDescriptor)
158
+ createOutgoingHandshaker(this.localPeerDescriptor!, pendingConnection, connection, targetPeerDescriptor)
178
159
  connection.once('localDescription', (description: string) => {
160
+ logger.trace('Sending offer to remote peer')
179
161
  remoteConnector.sendRtcOffer(description, connection.connectionId)
180
162
  })
181
163
  } else {
164
+ pendingConnection = new PendingConnection(targetPeerDescriptor)
165
+ const handshaker = createIncomingHandshaker(this.localPeerDescriptor!, pendingConnection, connection)
182
166
  connection.once('localDescription', (description: string) => {
183
167
  remoteConnector.sendRtcAnswer(description, connection.connectionId)
184
168
  })
169
+ handshaker.on('handshakeRequest', (_sourceDescriptor: PeerDescriptor, remoteVersion: string) => {
170
+ if (!isMaybeSupportedVersion(remoteVersion)) {
171
+ rejectHandshake(pendingConnection!, connection, handshaker, HandshakeError.UNSUPPORTED_VERSION)
172
+ } else {
173
+ acceptHandshake(handshaker, pendingConnection, connection)
174
+ }
175
+ delFunc()
176
+ })
185
177
  }
186
178
 
179
+ this.ongoingConnectAttempts.set(targetNodeId, {
180
+ managedConnection: pendingConnection,
181
+ connection
182
+ })
183
+
184
+ connection.on('disconnected', delFunc)
185
+ pendingConnection.on('disconnected', delFunc)
186
+ pendingConnection.on('connected', delFunc)
187
+
188
+ connection.on('localCandidate', (candidate: string, mid: string) => {
189
+ if (this.options.externalIp !== undefined) {
190
+ candidate = replaceInternalIpWithExternalIp(candidate, this.options.externalIp)
191
+ logger.debug(`onLocalCandidate injected external ip ${candidate} ${mid}`)
192
+ }
193
+ remoteConnector.sendIceCandidate(candidate, mid, connection.connectionId)
194
+ })
195
+
187
196
  connection.start(offering)
188
197
 
189
- if (!offering) {
198
+ if (!doNotRequestConnection && !offering) {
190
199
  remoteConnector.requestConnection()
191
200
  }
192
201
 
193
- return managedConnection
202
+ return pendingConnection
194
203
  }
195
204
 
196
205
  private createConnection(targetPeerDescriptor: PeerDescriptor): NodeWebrtcConnection {
197
206
  return new NodeWebrtcConnection({
198
207
  remotePeerDescriptor: targetPeerDescriptor,
199
- iceServers: this.config.iceServers,
200
- bufferThresholdLow: this.config.bufferThresholdLow,
201
- bufferThresholdHigh: this.config.bufferThresholdHigh,
202
- connectingTimeout: this.config.connectionTimeout,
203
- portRange: this.config.portRange
208
+ iceServers: this.options.iceServers,
209
+ bufferThresholdLow: this.options.bufferThresholdLow,
210
+ bufferThresholdHigh: this.options.bufferThresholdHigh,
211
+ portRange: this.options.portRange
204
212
  // TODO should we pass maxMessageSize?
205
213
  })
206
214
  }
@@ -214,7 +222,10 @@ export class WebrtcConnector {
214
222
  this.stopped = true
215
223
 
216
224
  const attempts = Array.from(this.ongoingConnectAttempts.values())
217
- await Promise.allSettled(attempts.map((conn) => conn.close(false)))
225
+ await Promise.allSettled(attempts.map(async (conn) => {
226
+ conn.connection.destroy()
227
+ await conn.managedConnection.close(false)
228
+ }))
218
229
 
219
230
  this.rpcCommunicator.destroy()
220
231
  }
@@ -3,32 +3,27 @@ import { Logger } from '@streamr/utils'
3
3
  import { getAddressFromIceCandidate, isPrivateIPv4 } from '../../helpers/AddressTools'
4
4
  import { Empty } from '../../proto/google/protobuf/empty'
5
5
  import {
6
- HandshakeError,
7
6
  IceCandidate,
8
7
  PeerDescriptor,
9
8
  RtcAnswer,
10
9
  RtcOffer
11
10
  } from '../../proto/packages/dht/protos/DhtRpc'
12
- import { WebrtcConnectorRpcClient } from '../../proto/packages/dht/protos/DhtRpc.client'
13
11
  import { IWebrtcConnectorRpc } from '../../proto/packages/dht/protos/DhtRpc.server'
14
12
  import { DhtCallContext } from '../../rpc-protocol/DhtCallContext'
15
13
  import { ListeningRpcCommunicator } from '../../transport/ListeningRpcCommunicator'
16
- import { ManagedConnection } from '../ManagedConnection'
17
- import { ManagedWebrtcConnection } from './ManagedWebrtcConnection'
18
14
  import { NodeWebrtcConnection } from './NodeWebrtcConnection'
19
- import { WebrtcConnectorRpcRemote } from './WebrtcConnectorRpcRemote'
20
15
  import { DhtAddress, getNodeIdFromPeerDescriptor } from '../../identifiers'
21
- import { isMaybeSupportedVersion } from '../../helpers/version'
22
16
  import { ConnectionID } from '../IConnection'
17
+ import { ConnectingConnection } from './WebrtcConnector'
18
+ import { PendingConnection } from '../PendingConnection'
23
19
 
24
20
  const logger = new Logger(module)
25
21
 
26
- interface WebrtcConnectorRpcLocalConfig {
27
- createConnection: (targetPeerDescriptor: PeerDescriptor) => NodeWebrtcConnection
28
- connect: (targetPeerDescriptor: PeerDescriptor) => ManagedConnection
29
- onNewConnection: (connection: ManagedConnection) => boolean
22
+ interface WebrtcConnectorRpcLocalOptions {
23
+ connect: (targetPeerDescriptor: PeerDescriptor, doNotRequestConnection: boolean) => PendingConnection
24
+ onNewConnection: (connection: PendingConnection) => boolean
30
25
  // TODO pass accessor methods instead of passing a mutable entity
31
- ongoingConnectAttempts: Map<DhtAddress, ManagedWebrtcConnection>
26
+ ongoingConnectAttempts: Map<DhtAddress, ConnectingConnection>
32
27
  rpcCommunicator: ListeningRpcCommunicator
33
28
  getLocalPeerDescriptor: () => PeerDescriptor
34
29
  allowPrivateAddresses: boolean
@@ -36,71 +31,46 @@ interface WebrtcConnectorRpcLocalConfig {
36
31
 
37
32
  export class WebrtcConnectorRpcLocal implements IWebrtcConnectorRpc {
38
33
 
39
- private readonly config: WebrtcConnectorRpcLocalConfig
34
+ private readonly options: WebrtcConnectorRpcLocalOptions
40
35
 
41
- constructor(config: WebrtcConnectorRpcLocalConfig) {
42
- this.config = config
36
+ constructor(options: WebrtcConnectorRpcLocalOptions) {
37
+ this.options = options
43
38
  }
44
39
 
45
40
  async requestConnection(context: ServerCallContext): Promise<Empty> {
46
41
  const targetPeerDescriptor = (context as DhtCallContext).incomingSourceDescriptor!
47
- if (this.config.ongoingConnectAttempts.has(getNodeIdFromPeerDescriptor(targetPeerDescriptor))) {
42
+ if (this.options.ongoingConnectAttempts.has(getNodeIdFromPeerDescriptor(targetPeerDescriptor))) {
48
43
  return {}
49
44
  }
50
- const managedConnection = this.config.connect(targetPeerDescriptor)
51
- managedConnection.setRemotePeerDescriptor(targetPeerDescriptor)
52
- this.config.onNewConnection(managedConnection)
45
+ const pendingConnection = this.options.connect(targetPeerDescriptor, false)
46
+ this.options.onNewConnection(pendingConnection)
53
47
  return {}
54
48
  }
55
49
 
56
50
  async rtcOffer(request: RtcOffer, context: ServerCallContext): Promise<Empty> {
57
- const remotePeer = (context as DhtCallContext).incomingSourceDescriptor!
58
- const nodeId = getNodeIdFromPeerDescriptor(remotePeer)
59
- let managedConnection = this.config.ongoingConnectAttempts.get(nodeId)
60
- let connection = managedConnection?.getWebrtcConnection()
51
+ const remotePeerDescriptor = (context as DhtCallContext).incomingSourceDescriptor!
52
+ const nodeId = getNodeIdFromPeerDescriptor(remotePeerDescriptor)
53
+ let connection: NodeWebrtcConnection
54
+ let pendingConnection: PendingConnection
61
55
 
62
- if (!managedConnection) {
63
- connection = this.config.createConnection(remotePeer)
64
- managedConnection = new ManagedWebrtcConnection(this.config.getLocalPeerDescriptor(), undefined, connection)
65
- managedConnection.setRemotePeerDescriptor(remotePeer)
66
- this.config.ongoingConnectAttempts.set(nodeId, managedConnection)
67
- this.config.onNewConnection(managedConnection)
68
- const remoteConnector = new WebrtcConnectorRpcRemote(
69
- this.config.getLocalPeerDescriptor(),
70
- remotePeer,
71
- this.config.rpcCommunicator,
72
- WebrtcConnectorRpcClient
73
- )
74
- connection.on('localCandidate', (candidate: string, mid: string) => {
75
- remoteConnector.sendIceCandidate(candidate, mid, connection!.connectionId)
76
- })
77
- connection.once('localDescription', (description: string) => {
78
- remoteConnector.sendRtcAnswer(description, connection!.connectionId)
79
- })
80
- connection.start(false)
56
+ if (!this.options.ongoingConnectAttempts.has(nodeId)) {
57
+ pendingConnection = this.options.connect(remotePeerDescriptor, true)
58
+ connection = this.options.ongoingConnectAttempts.get(nodeId)!.connection
59
+ this.options.onNewConnection(pendingConnection)
60
+ } else {
61
+ pendingConnection = this.options.ongoingConnectAttempts.get(nodeId)!.managedConnection
62
+ connection = this.options.ongoingConnectAttempts.get(nodeId)!.connection
81
63
  }
82
-
83
64
  // Always use offerers connectionId
84
65
  connection!.setConnectionId(request.connectionId as ConnectionID)
85
66
  connection!.setRemoteDescription(request.description, 'offer')
86
-
87
- managedConnection.on('handshakeRequest', (_sourceDescriptor: PeerDescriptor, remoteVersion: string) => {
88
- if (this.config.ongoingConnectAttempts.has(nodeId)) {
89
- this.config.ongoingConnectAttempts.delete(nodeId)
90
- }
91
- if (!isMaybeSupportedVersion(remoteVersion)) {
92
- managedConnection.rejectHandshake(HandshakeError.UNSUPPORTED_VERSION)
93
- } else {
94
- managedConnection.acceptHandshake()
95
- }
96
- })
97
67
  return {}
98
68
  }
99
69
 
100
70
  async rtcAnswer(request: RtcAnswer, context: ServerCallContext): Promise<Empty> {
101
71
  const remotePeerDescriptor = (context as DhtCallContext).incomingSourceDescriptor!
102
72
  const nodeId = getNodeIdFromPeerDescriptor(remotePeerDescriptor)
103
- const connection = this.config.ongoingConnectAttempts.get(nodeId)?.getWebrtcConnection()
73
+ const connection = this.options.ongoingConnectAttempts.get(nodeId)?.connection
104
74
  if (!connection) {
105
75
  return {}
106
76
  } else if (connection.connectionId !== request.connectionId) {
@@ -114,7 +84,7 @@ export class WebrtcConnectorRpcLocal implements IWebrtcConnectorRpc {
114
84
  async iceCandidate(request: IceCandidate, context: ServerCallContext): Promise<Empty> {
115
85
  const remotePeerDescriptor = (context as DhtCallContext).incomingSourceDescriptor!
116
86
  const nodeId = getNodeIdFromPeerDescriptor(remotePeerDescriptor)
117
- const connection = this.config.ongoingConnectAttempts.get(nodeId)?.getWebrtcConnection()
87
+ const connection = this.options.ongoingConnectAttempts.get(nodeId)?.connection
118
88
  if (!connection) {
119
89
  return {}
120
90
  } else if (connection.connectionId !== request.connectionId) {
@@ -127,7 +97,7 @@ export class WebrtcConnectorRpcLocal implements IWebrtcConnectorRpc {
127
97
  }
128
98
 
129
99
  private isIceCandidateAllowed(candidate: string): boolean {
130
- if (!this.config.allowPrivateAddresses) {
100
+ if (!this.options.allowPrivateAddresses) {
131
101
  const address = getAddressFromIceCandidate(candidate)
132
102
  if ((address !== undefined) && isPrivateIPv4(address)) {
133
103
  return false
@@ -44,7 +44,13 @@ export abstract class AbstractWebsocketClientConnection extends EventEmitter<Con
44
44
  logger.trace(`Sending data with size ${data.byteLength}`)
45
45
  this.socket?.send(data)
46
46
  } else {
47
- logger.debug('Tried to send data on a non-open connection')
47
+ // Could this throw for faster feedback on RPC calls?
48
+ // Currently this log line is seen if a connection is closing but the disconnected event has not been emitted yet.
49
+ logger.debug('Tried to send data on a non-open connection', {
50
+ id: this.connectionId,
51
+ readyState: this.socket!.readyState,
52
+ destroyed: this.destroyed
53
+ })
48
54
  }
49
55
  } else {
50
56
  logger.debug('Tried to send() on stopped connection')
@@ -58,7 +64,7 @@ export abstract class AbstractWebsocketClientConnection extends EventEmitter<Con
58
64
  logger.trace(`Closing socket for connection ${this.connectionId}`)
59
65
  this.socket?.close(gracefulLeave ? CUSTOM_GOING_AWAY : undefined)
60
66
  } else {
61
- logger.debug('Tried to close() a stopped connection')
67
+ logger.debug('Tried to close() a stopped connection', { id: this.connectionId })
62
68
  }
63
69
  }
64
70
 
@@ -37,7 +37,7 @@ export interface IAutoCertifierClient {
37
37
  on(eventName: string, cb: (subdomain: CertifiedSubdomain) => void): void
38
38
  }
39
39
 
40
- interface AutoCertifierClientFacadeConfig {
40
+ interface AutoCertifierClientFacadeOptions {
41
41
  url: string
42
42
  configFile: string
43
43
  transport: ITransport
@@ -55,24 +55,24 @@ export class AutoCertifierClientFacade {
55
55
 
56
56
  private autoCertifierClient: IAutoCertifierClient
57
57
  private readonly rpcCommunicator: ListeningRpcCommunicator
58
- private readonly config: AutoCertifierClientFacadeConfig
58
+ private readonly options: AutoCertifierClientFacadeOptions
59
59
 
60
- constructor(config: AutoCertifierClientFacadeConfig) {
61
- this.config = config
62
- this.rpcCommunicator = new ListeningRpcCommunicator(AUTO_CERTIFIER_SERVICE_ID, config.transport)
63
- this.autoCertifierClient = config.createClientFactory ? config.createClientFactory()
60
+ constructor(options: AutoCertifierClientFacadeOptions) {
61
+ this.options = options
62
+ this.rpcCommunicator = new ListeningRpcCommunicator(AUTO_CERTIFIER_SERVICE_ID, options.transport)
63
+ this.autoCertifierClient = options.createClientFactory ? options.createClientFactory()
64
64
  : defaultAutoCertifierClientFactory(
65
- config.configFile,
66
- config.url,
65
+ options.configFile,
66
+ options.url,
67
67
  this.rpcCommunicator,
68
- config.wsServerPort
68
+ options.wsServerPort
69
69
  )
70
70
  }
71
71
 
72
72
  async start(): Promise<void> {
73
73
  this.autoCertifierClient.on('updatedCertificate', (subdomain: CertifiedSubdomain) => {
74
- this.config.setHost(subdomain.fqdn)
75
- this.config.updateCertificate(subdomain.certificate, subdomain.privateKey)
74
+ this.options.setHost(subdomain.fqdn)
75
+ this.options.updateCertificate(subdomain.certificate, subdomain.privateKey)
76
76
  logger.trace(`Updated certificate`)
77
77
  })
78
78
  await Promise.all([
@@ -28,7 +28,7 @@ export class WebsocketClientConnection extends AbstractWebsocketClientConnection
28
28
  }
29
29
  })
30
30
  } else {
31
- logger.debug('Tried to connect() a stopped connection')
31
+ logger.debug('Tried to connect() a stopped connection', { id: this.connectionId })
32
32
  }
33
33
  }
34
34