IndySockets / Indy

Indy - Internet Direct
https://www.indyproject.org
434 stars 147 forks source link

CTCP PING does not return correct value #519

Closed stuxamber closed 3 months ago

stuxamber commented 5 months ago

Hello,

When receiving a CTCP ping on the irc client, it returns a value that is very far off than what seems correct.

I thought it was an error, and have tested with multiple irc clients and all leading to the same result.

Thanks.

rlebeau commented 5 months ago

Can you be more specific? What is the exact problem? And, if multiple IRC clients have the same problem, what would you like Indy to do about it? Sounds like maybe it is a server-side problem.

stuxamber commented 5 months ago

Sorry for not being specific.

When running an irc client under IdIRC.pas, I would use a different irc client such as mIRC to ping the id irc client, but it returns weird values such as PING REPLY 47367hrs 30mins 54secs.

It doesn’t make sense for a ping reply to take that long.

I have tested with different irc clients and all gave the correct response except for IdIRC.

You can test it by running a connection to any irc server using IdIRC, and then use a different irc client to ping it.

rlebeau commented 5 months ago

I think the problem stems from TIdIRC treating a CTCP PING request the same as a CTCP TIME request, ie it sends a human-readable date/time string for the current machine that TIdIRC is running on. But a CTCP PING request is supposed to contain a timestamp that the requesting client chooses, and the target client is supposed to echo that timestamp back to the sender so the difference in times can be calculated relative to the requester's local clock.

Try this - in IdIRC.pas, change line 1579 (in the PING handler of TIdIRC.CommandPRIVMSG()) from this:

CTCPReply(FSenderNick, LCTCP, DateTimeToStr(Now)); {do not localize}

To this instead:

if LData = '' then begin
  LData := DateTimeToStr(Now);
end;
CTCPReply(FSenderNick, LCTCP, LData); {do not localize}

If that works, I will merge it in.

stuxamber commented 5 months ago

I tried the change but it doesn’t seems to work, or I am doing it wrongly.

I changed the source directly from the folder and saved it and run my project but it doesn’t seems to reflect the changes.

rlebeau commented 5 months ago

I changed the source directly from the folder and saved it and run my project but it doesn’t seems to reflect the changes.

Are you compiling Indy's source files directly into your project? If not, then you have to recompile+reinstall the Indy libs and link them into your project.

rlebeau commented 4 months ago

Any update?