Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Neo/Ledger/Blockchain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,8 @@ private static void InvokeHandlers(Delegate[] handlers, Action<Delegate> handler
}
catch (Exception ex) when (handler.Target is Plugin plugin)
{
Utility.Log(nameof(plugin.Name), LogLevel.Error, $"{plugin.Name} exception: {ex.Message}{Environment.NewLine}{ex.StackTrace}");
var cause = ex.InnerException ?? ex;
Utility.Log(nameof(plugin.Name), LogLevel.Error, $"{plugin.Name} exception: {cause.Message}{Environment.NewLine}{cause.StackTrace}");
switch (plugin.ExceptionPolicy)
{
case UnhandledExceptionPolicy.StopNode:
Expand Down
12 changes: 11 additions & 1 deletion src/Neo/Network/P2P/Peer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
using Akka.Actor;
using Akka.IO;
using Neo.Extensions;
using Neo.Extensions.Factories;
using System;
using System.Buffers.Binary;
using System.Collections.Concurrent;
Expand Down Expand Up @@ -201,6 +200,11 @@ protected override void OnReceive(object message)
ConnectToPeer(connect.EndPoint, connect.IsTrusted);
break;
case Tcp.Connected connected:
if (connected.RemoteAddress is null)
{
Sender.Tell(Tcp.Abort.Instance);
break;
}
OnTcpConnected(((IPEndPoint)connected.RemoteAddress).UnMap(), ((IPEndPoint)connected.LocalAddress).UnMap());
break;
case Tcp.Bound _:
Expand Down Expand Up @@ -249,6 +253,12 @@ private void OnStart(ChannelsConfig config)
/// <param name="local">The local endpoint of TCP connection.</param>
private void OnTcpConnected(IPEndPoint remote, IPEndPoint local)
{
if (Config is null) // OnStart is not called yet
{
Sender.Tell(Tcp.Abort.Instance);
return;
}

ImmutableInterlocked.Update(ref ConnectingPeers, p => p.Remove(remote));
if (Config.MaxConnections != -1 && ConnectedPeers.Count >= Config.MaxConnections && !TrustedIpAddresses.Contains(remote.Address))
{
Expand Down