|
@@ -164,7 +164,8 @@ Type
|
|
Function LockList : TList<Pointer>;
|
|
Function LockList : TList<Pointer>;
|
|
Procedure UnlockList;
|
|
Procedure UnlockList;
|
|
procedure ResetConnectAttempts;
|
|
procedure ResetConnectAttempts;
|
|
- function IsBlackListed(const ip: String): Boolean;
|
|
|
|
|
|
+ function IsBlackListed(const ip: String; out AReason : string): Boolean; overload;
|
|
|
|
+ function IsBlackListed(const ip: String): Boolean; overload;
|
|
function GetNodeServerAddress(const ip : String; port:Word; CanAdd : Boolean; var nodeServerAddress : TNodeServerAddress) : Boolean;
|
|
function GetNodeServerAddress(const ip : String; port:Word; CanAdd : Boolean; var nodeServerAddress : TNodeServerAddress) : Boolean;
|
|
procedure SetNodeServerAddress(const nodeServerAddress : TNodeServerAddress);
|
|
procedure SetNodeServerAddress(const nodeServerAddress : TNodeServerAddress);
|
|
Procedure UpdateNetConnection(netConnection : TNetConnection);
|
|
Procedure UpdateNetConnection(netConnection : TNetConnection);
|
|
@@ -821,11 +822,12 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TOrderedServerAddressListTS.IsBlackListed(const ip: String): Boolean;
|
|
|
|
|
|
+function TOrderedServerAddressListTS.IsBlackListed(const ip: String; out AReason : string): Boolean;
|
|
Var i : Integer;
|
|
Var i : Integer;
|
|
P : PNodeServerAddress;
|
|
P : PNodeServerAddress;
|
|
begin
|
|
begin
|
|
Result := false;
|
|
Result := false;
|
|
|
|
+ AReason := '';
|
|
FCritical.Acquire;
|
|
FCritical.Acquire;
|
|
Try
|
|
Try
|
|
SecuredFindByIp(ip,0,i);
|
|
SecuredFindByIp(ip,0,i);
|
|
@@ -835,6 +837,7 @@ begin
|
|
if Not SameStr(P^.ip,ip) then exit;
|
|
if Not SameStr(P^.ip,ip) then exit;
|
|
if P^.is_blacklisted then begin
|
|
if P^.is_blacklisted then begin
|
|
Result := Not P^.its_myself;
|
|
Result := Not P^.its_myself;
|
|
|
|
+ AReason := P^.BlackListText;
|
|
end;
|
|
end;
|
|
inc(i);
|
|
inc(i);
|
|
end;
|
|
end;
|
|
@@ -843,6 +846,12 @@ begin
|
|
End;
|
|
End;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+function TOrderedServerAddressListTS.IsBlackListed(const ip: String): Boolean;
|
|
|
|
+var LReason : String;
|
|
|
|
+begin
|
|
|
|
+ Result := IsBlackListed(ip,LReason);
|
|
|
|
+end;
|
|
|
|
+
|
|
function TOrderedServerAddressListTS.LockList: TList<Pointer>;
|
|
function TOrderedServerAddressListTS.LockList: TList<Pointer>;
|
|
begin
|
|
begin
|
|
FCritical.Acquire;
|
|
FCritical.Acquire;
|
|
@@ -2417,7 +2426,7 @@ end;
|
|
|
|
|
|
procedure TNetServer.OnNewIncommingConnection(Sender : TObject; Client : TNetTcpIpClient);
|
|
procedure TNetServer.OnNewIncommingConnection(Sender : TObject; Client : TNetTcpIpClient);
|
|
Var n : TNetServerClient;
|
|
Var n : TNetServerClient;
|
|
- DebugStep : String;
|
|
|
|
|
|
+ DebugStep, LReason : String;
|
|
tc : TTickCount;
|
|
tc : TTickCount;
|
|
begin
|
|
begin
|
|
DebugStep := '';
|
|
DebugStep := '';
|
|
@@ -2433,10 +2442,10 @@ begin
|
|
TNetData.NetData.IncStatistics(1,1,0,0,0,0);
|
|
TNetData.NetData.IncStatistics(1,1,0,0,0,0);
|
|
TNetData.NetData.NodeServersAddresses.CleanBlackList(False);
|
|
TNetData.NetData.NodeServersAddresses.CleanBlackList(False);
|
|
DebugStep := 'Checking blacklisted';
|
|
DebugStep := 'Checking blacklisted';
|
|
- if (TNetData.NetData.NodeServersAddresses.IsBlackListed(Client.RemoteHost)) then begin
|
|
|
|
|
|
+ if (TNetData.NetData.NodeServersAddresses.IsBlackListed(Client.RemoteHost,LReason)) then begin
|
|
// Invalid!
|
|
// Invalid!
|
|
TLog.NewLog(ltinfo,Classname,'Refusing Blacklist ip: '+Client.ClientRemoteAddr);
|
|
TLog.NewLog(ltinfo,Classname,'Refusing Blacklist ip: '+Client.ClientRemoteAddr);
|
|
- n.SendError(ntp_autosend,CT_NetOp_Error, 0,CT_NetError_IPBlackListed,'Your IP is blacklisted:'+Client.ClientRemoteAddr);
|
|
|
|
|
|
+ n.SendError(ntp_autosend,CT_NetOp_Error, 0,CT_NetError_IPBlackListed,'Your IP is blacklisted:'+Client.ClientRemoteAddr+' '+LReason);
|
|
// Wait some time before close connection
|
|
// Wait some time before close connection
|
|
sleep(5000);
|
|
sleep(5000);
|
|
end else begin
|
|
end else begin
|
|
@@ -3929,7 +3938,7 @@ var operationsComp : TPCOperationsComp;
|
|
TLog.NewLog(lterror,ClassName,Format('Constructed a distinct FAST PROPAGATION block with my mempool operations. Received: %s Constructed: %s',
|
|
TLog.NewLog(lterror,ClassName,Format('Constructed a distinct FAST PROPAGATION block with my mempool operations. Received: %s Constructed: %s',
|
|
[TPCOperationsComp.OperationBlockToText(original_OperationBlock),TPCOperationsComp.OperationBlockToText(operationsComp.OperationBlock)]));
|
|
[TPCOperationsComp.OperationBlockToText(original_OperationBlock),TPCOperationsComp.OperationBlockToText(operationsComp.OperationBlock)]));
|
|
end else begin
|
|
end else begin
|
|
- TLog.NewLog(ltdebug,ClassName,Format('Constructed a distinct FAST PROPAGATION block with my mempool operations. Received: %s Constructed: %s',
|
|
|
|
|
|
+ TLog.NewLog(lterror,ClassName,Format('Constructed a distinct FAST PROPAGATION block with my mempool operations. Posible double-spend attempt. Received: %s Constructed: %s',
|
|
[TPCOperationsComp.OperationBlockToText(original_OperationBlock),TPCOperationsComp.OperationBlockToText(operationsComp.OperationBlock)]));
|
|
[TPCOperationsComp.OperationBlockToText(original_OperationBlock),TPCOperationsComp.OperationBlockToText(operationsComp.OperationBlock)]));
|
|
end;
|
|
end;
|
|
if Not TPCSafeBox.IsValidOperationBlock(original_OperationBlock,errors) then begin
|
|
if Not TPCSafeBox.IsValidOperationBlock(original_OperationBlock,errors) then begin
|