by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 18:21
    rlebeau commented #312
  • 18:19
    rlebeau commented #312
  • 18:18
    rlebeau commented #312
  • 18:13
    rlebeau commented #312
  • Jul 05 12:23
    VBGAMER45 commented #304
  • Jul 05 06:39
    D3lphi3r edited #312
  • Jul 05 06:20
    D3lphi3r edited #312
  • Jul 05 06:19
    D3lphi3r edited #312
  • Jul 05 06:18
    D3lphi3r edited #312
  • Jul 05 06:18
    D3lphi3r opened #312
  • Jul 02 02:01

    rlebeau on FTP-Active-Mode-Fix

    (compare)

  • Jun 27 00:35
    rlebeau commented #311
  • Jun 27 00:33
    rlebeau labeled #311
  • Jun 27 00:33
    rlebeau labeled #311
  • Jun 27 00:32
    rlebeau commented #311
  • Jun 26 14:48
    JoeSansalone edited #311
  • Jun 26 14:47
    JoeSansalone opened #311
  • Jun 26 11:28
    mezen commented #299
  • Jun 25 18:36
    rlebeau commented #299
  • Jun 25 18:36
    rlebeau commented #299
irawancepu
@irawancepu
@Remy As you can see from my code before and website i visited, one crucial network guy is to check a port is in open state or just closed. I did port forward some ports on my router to many devices like CCTV. Usually everything okay on high class devices. But now conditions change, many cheap models sold everywhere. They put logo like 'work on cloud directly'. On the other side, port on these cheap devices often get closed if not triggered by visiting website like yougetsignal.com, portchecker.co or canyouuseeme.org. Can i do what these website using Delphi and Indy? So i did not use these web service anymore. It is one of my dreams.
Remy Lebeau
@rlebeau
@irawancepu Indy lets you do just about anything, if you put in the work for it. What EXACTLY do you need to do?
irawancepu
@irawancepu
In the past time i have to visit those website in order to check port forwarding status. Now, after your help here, i will use my own program based on Indy 10.6.2.0. I already got good result using Indy. However, i still confused about what and how these website send data to my router so it can determine it's port status. I'm Mikrotik RB1100AHX@ as my router. I will try to sniff these website communication on my ports using WireShark. I will back after same evaluation on these packets. What i want? I want to do status port check my own way. So i do not depend on these website. What happened if these webs going down?
Remy Lebeau
@rlebeau
@irawancepu Why not just ask the router itself what its port status is, such as with uPNP? You don't really need to use an external site unless the router has disabled uPNP. You can't simulate a remote site locally. If you are sending a request to an external site, and that site is sending requests to the public ports of your router, you will have to keep doing that, you can't access the public side of the router from the LAN side.
Jos de Bruijn
@josdebr_twitter
@rlebeau the exact error message is: "ERangeError raised: Range check error". I get the error after I call "IMAPClient.Retrieve(i, Msg)", I do not have a complete call stack, because I cannot reproduce the error locally.
Sergey
@icegood
Remy wrote : @icegood TIdHTTP already does disconnect in case of socket errors....
OK. But socket error might also occur while sending request, might not it?
Moreover it occurs in place where connection is checked...

I have anothe question. We have in TIdIOHandlerStack.Connected
ReadFromSource(False, 0, False);

What indy is supposed to read here? Sometimes (vary rarely) my application based on RemObjects SuperTCPServer hangs there as there is nothing to read from server.

SandroHerbst
@SandroHerbst
@rlebeau Thanks for your answer, I´ve compiled the 5 packages in D2010, it was ok, but when I tried to install the 2 dcl packages, the IDE returns an error "The procedure entry point @Idstack@TIdStackLocalAddressList@GetAddress$qqri could not be located in the dynamic link library IndySystem140.bpl", do I need to remove some files from the old version?
Remy Lebeau
@rlebeau
@icegood Indy uses synchronous socket I/O, so the only way to test if a socket is still "connected" is to perform I/O on it. That is what Connected() is doing when it calls ReadFromSource(). It is checking if there is any inbound data on the socket (and if so, the data is read and put in the InputBuffer for later use), using a 0ms timeout and ignoring any disconnect/timeout errors. It should not be hanging if there is no data, unless the OS itself hangs when Indy calls the socket API select() function (which has been known to happen, despite the timeout - that is an OS issue, not an Indy issue).
@SandroHerbst yes, you need to remove the old version before installling the new version. This is explained in Indy's installation notes
SandroHerbst
@SandroHerbst
@rlebeau Thanks again, now it´s ok!
irawancepu
@irawancepu
@Remy I'm already doing NAT on my RB1100AHX2. Everything work fine but on this cheap DVR. However, AFTER testing it using web service from site like portchecker.co, yougetsignal.com or canyouseeme.org then it works again. Usually it will work for two or three days before did not work again. Here i need to use one of these web services again. So i think that there are some magic packets this site sends to my router. My router delivers these packet to this cheap DVR. The DVR works again after receiving these magic packets. Here i want to emulate/replicate these magic packets sent by website like portchecker.co by using Indy. Sorry for disturbing you so far. It is a real problem from a network guy facing cheap DVR.
Remy Lebeau
@rlebeau
@irawancepu there is no "magic packet" being sent by those sites through the router to the DVR, that is not how those sites work. You apparently don't understand what port scanning does, because there is no actually data sent at all. The sites are merely establishing a TCP connection to the chosen IP/port and then reporting success or failure. If successful, and if the IP/Port happens to be on a NAT router, the router just passes through the connection to the specified LAN server based on its port forwarding rules. That's it. The only thing the DVR sees (if anything) is an inbound TCP connection. You could just connect a TIdTCPClient directly to the DVR to do the same thing. If you want to check the router's port status, use uPNP for that. Or, just connect TIdTCPClient to the desired public IP/port on the router.
irawancepu
@irawancepu
@rlebeau Yup. I never touch port scanning in my life. I will try TCP Connection directly to ip:port on this cheap DVR periodically. I will back after two or three day, report back then. Thx for your explanation.
Sergey
@icegood

@rlebeau ,
your comment makes sense in case if it hangs while calling Readable (ATimeout) in TIdIOHandler.ReadFromSource. But in reality it hangs inside call
LByteCount := ReadDataFromSource(LBuffer); a few lines below. I can imagine next multithread scenario:
1) first thread actively does IO over socket
2) second thread checks for connection and for this moment due activity of first thread Readable returns true.
3) Second thread calls ReadDataFromSource, but for this moment first thread fully has processed data => second thread hangs there.

Remobject's SuperTCPServer depends on Indy library and assumes that Indy10 supports multithread processing.

As for me fix should be in calling of just Readable inside TIdIOHandlerStack.Connected instead of ReadFromSource

Remy Lebeau
@rlebeau
@icegood It is not safe for multiple threads to read from a socket at the same time. That includes calling Connected(). For exactly the reason you mentioned - it gets the socket state out of sync. I/O must be synchronized across threads. It is safe for 1 thread to write while another thread reads, that does not need to be synchronized. But having 2+ threads reading, or 2+ threads writing, must be synchronized. On the other hand, 99% of the time there is no need to call Connected() directly, just let Indy raise an exception during normal I/O operations. That being said, having Connected() call Readable() instead of ReadFromSource() is not good enough, since a socket is marked as readable during a graceful disconnect, an actual read is needed to discover the disconnect.
Sergey
@icegood
Tnx, Remy!
Jos de Bruijn
@josdebr_twitter
@josdebr_twitter what is the EXACT error message? What does the call stack look like when the error occurs?
Hi Remy,
the exact error message is: "ERangeError raised: Range check error". I get the error after I call "IMAPClient.Retrieve(i, Msg)"
I've managed to generate a callstack, I can even get you a Eureka log file if you can read it. But here is the callstack extracted from my log:
IdGlobalProtocols.pas| |GetUniqueFileName |1644[45] |
IdGlobalProtocols.pas| |GetUniqueFileName |1599[0] |
IdGlobalProtocols.pas| |MakeTempFilename |1584[35] |
IdGlobalProtocols.pas| |MakeTempFilename |1549[0] |
IdAttachmentFile.pas |TIdAttachmentFile |PrepareTempStream |144[3] |
IdMessageClient.pas | |ProcessAttachment |840[7] |
IdMessageClient.pas | |ProcessAttachment |833[0] |
IdMessageClient.pas |TIdMessageClient |ReceiveBody |1024[115]|
IdMessageClient.pas |TIdMessageClient |ProcessMessage |1535[8] |
IdMessageClient.pas |TIdMessageClient |ProcessMessage |1527[0] |
IdMessageHelper.pas | |Internal_TIdMessageClientHelper_ProcessMessage|60[12] |
IdMessageHelper.pas | |Internal_TIdMessageClientHelper_ProcessMessage|48[0] |
IdMessageHelper.pas | |Internal_TIdMessageHelper_LoadFromStream |85[9] |
IdMessageHelper.pas | |Internal_TIdMessageHelper_LoadFromStream |76[0] |
IdMessageHelper.pas | |TIdMessageHelper_LoadFromStream |97[1] |
IdMessageHelper.pas | |TIdMessageHelper_LoadFromStream |96[0] |
IdIMAP4.pas |TIdIMAP4 |InternalRetrieve |4951[59] |
IdIMAP4.pas |TIdIMAP4 |InternalRetrieve |4892[0] |
IdIMAP4.pas |TIdIMAP4 |Retrieve |4601[2] |
IdIMAP4.pas |TIdIMAP4 |Retrieve |4599[0] |
Ryan Truran
@RyanTruran
@rlebeau I'm running into your name everywhere looking for a solution to my smtp not relaying to an address outside of my domain.
Ryan Truran
@RyanTruran
http://stackoverflow.com/questions/43742574/send-email-outside-of-domain-in-cbuilder
I have posted a question on stackoverflow with the link provided above. to summarize my issue I am trying to send an email outside of my domain. I am using TIdSMTP to connect to my smtp server. Everything works fine when I am only trying to send within my domain, but if I have to relay to another domain the email will not send. I receive a "Unable to relay" error when providing the correct username and password with an AuthType of satDefault. If I change the AuthType to satSASL and add an SASL mechanism I get an error that reads "Doesn't support AUTH or the specified SASL handlers!!"
Remy Lebeau
@rlebeau
@josdebr_twitter it is odd to see a range error in GetUniqueFileName(), the only thing I can see it doing that might cause that is it calls Ticks64() in a loop until FileExists() returns false. But I don't see Ticks64() in your call stack. And your line numbers do not coorespond to the latest version of IdGlobalProtocols.pas. What exactly is on line 1644 of your copy?
@RyanTruran Your server is refusing to relay, which could happen if you are not logging in correctly. The SASL error means there is no TIdSASL component in the TIdSMTP.SASLMechanisms property that matches what the server is expecting (see the AUTH entries in the TIdSMTP.Capabilities property after connecting and before logging in). If you use satDefault instead, try setting the TIdSMTP.ValidateAuthLoginCapability property to False, otherwise login might be skipped if TIdSMTP.Capabilities does not include an entry for the AUTH LOGIN command even if the server actually supports it (it is not a secure command, unless used over SSL/TLS, so it is not always advertised as supported)
Remy Lebeau
@rlebeau
@RyanTruran I updated my answer on SO.
Ryan Truran
@RyanTruran
@rlebeau where is the AUTH entry in the capabilities property? all I see is Fdelimiter, FLineBreak, FQuoteChar , etc. no AUTH or Fauth
Remy Lebeau
@rlebeau
@RyanTruran you need to look at the content of the list. Capabilities is a plain TStringList. It contains the strings that the SMTP server returns in reply to the EHLO command. Amongst other things, it will contain "AUTH=..." and/or "AUTH ..." strings for the supported authentication schemes
Ryan Truran
@RyanTruran
that's what I assumed. the list is empty
it should be under FDefined right?
Remy Lebeau
@rlebeau
@RyanTruran no, FDefined is only used for keeping track of which delimiter properties have been assigned values (Delimiter, StrictDelimiter, QuoteChar, NameValueSeparator, and LineBreak). The AUTH strings are in the Strings[] subproperty instead. Have you ever worked with TStringList before?
Ryan Truran
@RyanTruran
AUTH NTLM?
Remy Lebeau
@rlebeau
@RyanTruran Yes, those strings. Which means you need to add TIdSASLNTLM in the TIdSMTP.SASLMechanisms property, at least.
Ryan Truran
@RyanTruran
So will I need to create that or is there a mechanism already built that I can use.
I'm not seeing one with my version of c++ builder
I guess I need to add the source file
Remy Lebeau
@rlebeau
@RyanTruran Indy has many TIdSASL components. They should be on your IDE's Component Palette on the "Indy SASL" page. Or instantiate them in code at runtime instead. But either way, you need to built up the contents of the TIdSASLMechanisms property to point at those components, before you login to the server.
Ryan Truran
@RyanTruran
gotcha that's what I was doing before just not with NTLM as that does not show up in my Indy SASL tool pallete
Remy Lebeau
@rlebeau
@RyanTruran doesn't look like TIdSASLNTLM is registered by default. Not sure if it was ever finalized or not.
Ryan Truran
@RyanTruran
so what would I need to do to add it.
Remy Lebeau
@rlebeau
@RyanTruran unless you recompile Indy to register it, you should just add IdSASL_NTLM.pas to your project directly, then #include the resulting IdSASL_NTLM.hpp file in your code and instantiate a TIdSASLNTLM object at runtime and Add() it to the SASLMechanisms property.
Ryan Truran
@RyanTruran
so I should grab the .pas off of github right?
Remy Lebeau
@rlebeau
@RyanTruran I have no idea if TIdSASLNTLM works or not, which is probably why it is still not registered by default. Is that the only AUTH the server is reporting?
@RyanTruran Indy's code is not on GitHub. It is on AToZed's own SVN server (link is on Indy's website). GitHub is only used for chat and issue tracking
Ryan Truran
@RyanTruran
so are you with indy?
Remy Lebeau
@rlebeau
@RyanTruran yes, I am the primary developer of Indy, and one of its admins. But I'm not with AToZed. And I didn't write TIdSASLNTLM, and have no way of testing it myself (no access to any servers that use NTLM authentication).
Ryan Truran
@RyanTruran
gotcha
so when I add the .pas to the project does it generate a .hpp? that I can include?
Remy Lebeau
@rlebeau
@RyanTruran It will, when the project compiles the .pas file. C++Builder projects can include Pascal source files, and it will always compile Pascal files before C/C++ files, for exactly the reason of generating any necessary .hpp files that may be used by the C/C++ code.
Ryan Truran
@RyanTruran
which will occur when I compile the project right?
Remy Lebeau
@rlebeau
@RyanTruran yes
Jos de Bruijn
@josdebr_twitter
@rlebeau I am using 10.6.2.0.
On line 1644 i've got the following code: Result := LFName + IntToHex(LNamePart, 8) + LFQE;