machina icon indicating copy to clipboard operation
machina copied to clipboard

MessageSent callback does not trigger when UseSocketFilter = true

Open highlyunavailable opened this issue 6 years ago • 1 comments

If I set the UseSocketFilter property of an FFXIVNetworkMonitor to true, the callback for MessageSent never triggers. I'm using raw sockets, not winpcap.

I've ensured that the app is allowed through the firewall and there are no errors in the trace log. At a deeper level, it looks like ProcessSentMessage is never called because no packets are ever returned for the sent side of the connection. Is this a limitation of UseSocketFilter or is there further configuration I need to do?

highlyunavailable avatar Jul 28 '19 16:07 highlyunavailable

I've finally tracked this down. The reason for this behavior is because the code is using winsock Connect() function to filter on the remote IP when UseSocketFilter is set to true. However, according to documentation https://docs.microsoft.com/en-us/windows/win32/winsock/tcp-ip-raw-sockets-2?redirectedfrom=MSDN:

If a foreign address is defined for the socket, it should correspond to the source address as specified in the IP header of the received datagram

For raw sockets, the received packets will have the expected remote ip as the source address. Unfortunately, packets originating from the game will have source address = local ip, and so this is the reason these packets are not available when this feature is turned on.

I will need to consider a larger change to Machina to resolve this - probably creating multiple raw sockets, one for each direction, when this flag is enabled.

ravahn avatar Nov 27 '21 19:11 ravahn