@@ -10,6 +10,7 @@ open NBitcoin
10
10
open DotNetLightning.Peer
11
11
open DotNetLightning.Utils
12
12
open ResultUtils.Portability
13
+ open NOnion
13
14
open NOnion.Network
14
15
open NOnion.Directory
15
16
open NOnion.Services
@@ -36,7 +37,7 @@ type PeerDisconnectedError =
36
37
not self.Abruptly
37
38
38
39
type HandshakeError =
39
- | TcpConnect of seq < SocketException >
40
+ | TcpConnect of seq < Exception >
40
41
| TcpAccept of seq < SocketException >
41
42
| DisconnectedOnAct1 of PeerDisconnectedError
42
43
| InvalidAct1 of PeerError
@@ -48,7 +49,7 @@ type HandshakeError =
48
49
member self.Message =
49
50
match self with
50
51
| TcpConnect errs ->
51
- let messages = Seq.map ( fun ( err : SocketException ) -> err.Message) errs
52
+ let messages = Seq.map ( fun ( err : Exception ) -> err.Message) errs
52
53
SPrintF1 " TCP connection failed: %s " ( String.concat " ; " messages)
53
54
| TcpAccept errs ->
54
55
let messages = Seq.map ( fun ( err : SocketException ) -> err.Message) errs
@@ -331,7 +332,7 @@ type internal TransportStream =
331
332
static member private TcpTransportConnect
332
333
( localEndPointOpt : Option < IPEndPoint >)
333
334
( remoteEndPoint : IPEndPoint )
334
- : Async < Result < TcpClient , seq < SocketException >>> = async {
335
+ : Async < Result < TcpClient , seq < Exception >>> = async {
335
336
let client = new TcpClient ( remoteEndPoint.AddressFamily)
336
337
match localEndPointOpt with
337
338
| Some localEndPoint ->
@@ -352,7 +353,13 @@ type internal TransportStream =
352
353
| ex ->
353
354
client.Close()
354
355
let socketExceptions = FindSingleException< SocketException> ex
355
- return Error socketExceptions
356
+ let exceptions =
357
+ seq {
358
+ for socketException in socketExceptions do
359
+ yield socketException :> Exception
360
+ }
361
+
362
+ return Error exceptions
356
363
}
357
364
358
365
static member private AcceptAny ( listener : IncomingConnectionMethod )
@@ -419,23 +426,33 @@ type internal TransportStream =
419
426
420
427
static member private TorTransportConnect
421
428
( nonionEndPoint : NOnionEndPoint )
422
- : Async < Result < TorServiceClient , seq < SocketException >>> =
429
+ : Async < Result < TorServiceClient , seq < Exception >>> =
423
430
async {
424
431
let! directory = TorOperations.GetTorDirectory()
425
432
try
426
- let! torClient = TorOperations.TorConnect directory nonionEndPoint.Url
427
- Infrastructure.LogDebug <| SPrintF1 " Connected %s " nonionEndPoint.Url
428
- return Ok torClient
433
+ let! maybeTorClient = TorOperations.TorConnect directory nonionEndPoint.Url
434
+ match maybeTorClient with
435
+ | Ok torClient ->
436
+ Infrastructure.LogDebug <| SPrintF1 " Connected %s " nonionEndPoint.Url
437
+ return Ok torClient
438
+ | Error ex ->
439
+ return Error ( ex :> Exception |> Seq .singleton )
429
440
with
430
441
| ex ->
431
442
let socketExceptions = FindSingleException< SocketException> ex
432
- return Error socketExceptions
443
+ let exceptions =
444
+ seq {
445
+ for socketException in socketExceptions do
446
+ yield socketException :> Exception
447
+ }
448
+
449
+ return Error exceptions
433
450
}
434
451
435
452
static member private TransportConnect
436
453
( localEndPointOpt : Option < IPEndPoint >)
437
454
( node : NodeIdentifier )
438
- : Async < Result < TransportClientType , seq < SocketException >>> =
455
+ : Async < Result < TransportClientType , seq < Exception >>> =
439
456
async {
440
457
match node with
441
458
| NodeIdentifier.TcpEndPoint remoteEndPoint ->
0 commit comments