瀏覽代碼

Update App version to 5.6 and NetProtocol available version to 14

PascalCoin 3 年之前
父節點
當前提交
3be3ed6b3e
共有 2 個文件被更改,包括 17 次插入8 次删除
  1. 2 2
      src/core/UConst.pas
  2. 15 6
      src/core/UNetProtocol.pas

+ 2 - 2
src/core/UConst.pas

@@ -135,7 +135,7 @@ Const
   CT_NetProtocol_Version: Word = 12;
   // IMPORTANT NOTE!!!
   // NetProtocol_Available MUST BE always >= NetProtocol_version
-  CT_NetProtocol_Available: Word = {$IFDEF PRODUCTION}13{$ELSE}13{$ENDIF};
+  CT_NetProtocol_Available: Word = {$IFDEF PRODUCTION}14{$ELSE}14{$ENDIF};
 
   CT_MaxAccountOperationsPerBlockWithoutFee = 1;
 
@@ -198,7 +198,7 @@ Const
   CT_OpSubtype_Data_Signer                = 103;
   CT_OpSubtype_Data_Receiver              = 104;
 
-  CT_ClientAppVersion : String = {$IFDEF PRODUCTION}'5.5'{$ELSE}{$IFDEF TESTNET}'TESTNET 5.5'{$ELSE}{$ENDIF}{$ENDIF};
+  CT_ClientAppVersion : String = {$IFDEF PRODUCTION}'5.6'{$ELSE}{$IFDEF TESTNET}'TESTNET 5.6'{$ELSE}{$ENDIF}{$ENDIF};
 
   CT_Discover_IPs = {$IFDEF PRODUCTION}'bpascal1.dynamic-dns.net;bpascal2.dynamic-dns.net;pascalcoin1.dynamic-dns.net;pascalcoin2.dynamic-dns.net;pascalcoin1.dns1.us;pascalcoin2.dns1.us;pascalcoin1.dns2.us;pascalcoin2.dns2.us'
                     {$ELSE}'pascaltestnet1.dynamic-dns.net;pascaltestnet2.dynamic-dns.net;pascaltestnet1.dns1.us;pascaltestnet2.dns1.us'{$ENDIF};

+ 15 - 6
src/core/UNetProtocol.pas

@@ -164,7 +164,8 @@ Type
     Function LockList : TList<Pointer>;
     Procedure UnlockList;
     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;
     procedure SetNodeServerAddress(const nodeServerAddress : TNodeServerAddress);
     Procedure UpdateNetConnection(netConnection : TNetConnection);
@@ -821,11 +822,12 @@ begin
   end;
 end;
 
-function TOrderedServerAddressListTS.IsBlackListed(const ip: String): Boolean;
+function TOrderedServerAddressListTS.IsBlackListed(const ip: String; out AReason : string): Boolean;
 Var i : Integer;
   P : PNodeServerAddress;
 begin
   Result := false;
+  AReason := '';
   FCritical.Acquire;
   Try
     SecuredFindByIp(ip,0,i);
@@ -835,6 +837,7 @@ begin
       if Not SameStr(P^.ip,ip) then exit;
       if P^.is_blacklisted then begin
         Result := Not P^.its_myself;
+        AReason := P^.BlackListText;
       end;
       inc(i);
     end;
@@ -843,6 +846,12 @@ begin
   End;
 end;
 
+function TOrderedServerAddressListTS.IsBlackListed(const ip: String): Boolean;
+var LReason : String;
+begin
+  Result := IsBlackListed(ip,LReason);
+end;
+
 function TOrderedServerAddressListTS.LockList: TList<Pointer>;
 begin
   FCritical.Acquire;
@@ -2417,7 +2426,7 @@ end;
 
 procedure TNetServer.OnNewIncommingConnection(Sender : TObject; Client : TNetTcpIpClient);
 Var n : TNetServerClient;
-  DebugStep : String;
+  DebugStep, LReason : String;
   tc : TTickCount;
 begin
   DebugStep := '';
@@ -2433,10 +2442,10 @@ begin
       TNetData.NetData.IncStatistics(1,1,0,0,0,0);
       TNetData.NetData.NodeServersAddresses.CleanBlackList(False);
       DebugStep := 'Checking blacklisted';
-      if (TNetData.NetData.NodeServersAddresses.IsBlackListed(Client.RemoteHost)) then begin
+      if (TNetData.NetData.NodeServersAddresses.IsBlackListed(Client.RemoteHost,LReason)) then begin
         // Invalid!
         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
         sleep(5000);
       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',
         [TPCOperationsComp.OperationBlockToText(original_OperationBlock),TPCOperationsComp.OperationBlockToText(operationsComp.OperationBlock)]));
       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)]));
       end;
       if Not TPCSafeBox.IsValidOperationBlock(original_OperationBlock,errors) then begin