Joined: 25 Jun 2004 Posts: 126 Location: Liverpool(home) or Derby(uni), UK votes: 3
Posted: Sun Jan 06, 2008 1:17 pm Post subject: Perl string comparison
Something a little weird is happening here:
The bot sends the initial VER command to the msn server with the protocol that it wants to use. The server replies with a list of protocols that it will support. Then the bot loads the handlers for that protocol, as they differ between some.
Once the first NS gives you an XFR command, it closes the connection and you have to send a VER to a different NS and start over. Well the second time we do this I obviously dont want to reload the handlers as we know which protocol we are going to use already. I have a simple string comparison to check this, but its not working:
Code:
my $fn = shift;
my $srd = shift;
my($cmd, $trid, @protos) = split(/ /,$srd);
As you can see, two strange things are happening here but one is my fault. As I havent yet set up the detail loading, I have hard coded the protocol values in and got the second set wrong (P15 to 13 instead of 13 to 11). Even with this bug in, the second problem shouldnt happen but does:
"Protocol: Unknown" is the initial contents of $bot->{MSN}->{Details}->{Protocol}
The second, "Protocol: MSNP13" is the contents of the same variable the second time around. Then the value is checked against the constant string 'Unknown' and for some odd reason thinks that the strings 'MSNP13' and 'Unknown' are the same, so continues to reload the protocol specific handlers (in this case it loads the p15 handlers because of the bug I mentioned before).
Clearly this is wrong, but I dont know why it is happening. Anyone shed some light?