Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 988461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:38:24+00:00 2026-05-16T05:38:24+00:00

I have a public server(configured with indy 10) . some unknown clients are sending

  • 0

I have a public server(configured with indy 10) . some unknown clients are sending thousands of no content messages that it change the server’s cpu usage to 50% . i have no firewall on my server , so i tried to block the unknown clients with this codes :

This is a function that works with a Timer :

var
  i, j: integer;
begin
  IX2 := IX2 + 1;
  SetLength(ClientIPs, IX2);
  ClientIPs[IX2 - 1] := StrIP;
  j := 0;
  for i := low(ClientIPs) to high(ClientIPs) do
  begin
    Application.ProcessMessages;
    if ClientIPs[i] = StrIP then
      j := j + 1;
  end;
  if j > 10 then
  begin
    Result := false;
    exit;
  end;
  Result := true;

And it’s my Timer code :

  //Reset filtering measures
  IX2 := 0;
  SetLength(ClientIPs, 0);

So i use it in OnExecute event :

  LogIP := AContext.Connection.Socket.Binding.PeerIP;

  if IPFilter(LogIP) <> true then
  begin
    AContext.Connection.disconnect;
    exit;
  end;

  //Get Data *********
  Data := AContext.Connection.IOHandler.ReadLn();

finally , if a client sends many message in a short time , it will be disconnect . but there is a problem . in fact , after client disconnection , the Onexecute event is still working and i can not stop the operation Fully .anyway i need to block some IPs completely .

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T05:38:25+00:00Added an answer on May 16, 2026 at 5:38 am

    Followup to my earlier comment:

    function TForm1.IPFilter(const StrIP: string): Boolean;
    var 
      i, j: integer; 
      list: TList;
    begin 
      j := 0; 
      list := IdTCPServer1.Contexts.LockList;
      try
        for i := 0 to list.Count-1 do 
        begin 
          if TIdContext(list[i]).Binding.PeerIP = StrIP then
            Inc(j); 
        end; 
        Result := j <= 10; 
      finally
        IdTCPServer1.Contexts.UnlockList;
      end;
    end;
    
    procedure TForm1.IdTCPServer1Execute(AContext: TIdContext);
    begin
      // the simpliest way to force a disconnect and stop
      // the calling thread is to raise an exception...
      if not IPFilter(AContext.Binding.PeerIP) then
        Abort();
    
      // alternatively, if you call Disconnect(), make sure
      // the IOHandler's InputBuffer is empty, or else
      // AContext.Connection.Connected() will continue
      // returning True!...
      {if not IPFilter(AContext.Binding.PeerIP) then
      begin
        AContext.Connection.Disconnect;
        AContext.Connection.IOHandler.InputBuffer.Clear;
        Exit;
      end;}
    
      //Get Data ********* 
      Data := AContext.Connection.IOHandler.ReadLn(); 
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an on premise service bus that is configured to handle messages from
Logger Hi, I have a Spring MVC webapps that needs some server side logging
I have Apache running on a public-facing Debian server, and am a bit worried
I have written a custom server control which (pseudo-code) looks like public class MyCustomCtrl
we have a local staging server running sql server 2000 and a remote public
I have the following methods on the server (RIA services): public IQueryable<Customer> GetCustomers() {
I have a method to insert data into server like this: public void doInsert(){
I have a class that serves as a delegate to another. public class Delegate
I have public site with some forms. Simple question: What kind of informations should
I have configured git so that I can push my local dev-repository to my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.