FlipFlop, on 26 April 2011 - 10:32 AM, said:
There seems to be a bug in calculating or formatting the $Key:
$Lock was:
EXTENDEDPROTOCOL_FLEXHUB_MULTIPROTOCOL_ML26
Received :
$Key ÑÀ° A ѱ±ÀÀ01‘ ÑÑqÑ!‘Ñ‘ ѱ±ÀÀ01!ç@a³e´1q¡/%DCN096%/åáá
Should have been:
$Key DÑÀ° A ѱ±ÀÀ01‘ ÑÑqÑ!‘Ñ‘ ѱ±ÀÀ01!ç@
It looks like the key isn't calculated at all, just sending the same key everytime.
It'll send the same key if the lock doesn't change. It looks like they're the same for most of it, i wonder what's going on?
My lock2key is compatible with PtokaX, at least, although i know it's one of the more lenient hubsofts.
Here's what's going on under the hood, in nmdc.cpp;
//NMDCHub::handle_command(char* szCommand)
if (strcmp(szCommand, "$Lock")==0) {
push_event(NMDC_SYSTEM_MSG, "\0", "Found a hub.");
char key[BUFS]; parse_lock(szCommandNext, key, BUFS);
sprintf_s(szSay, BUFL,
"$Supports NoGetINFO UserIP2|$Key %s|$ValidateNick %s|",
key, self.szNick);
SayExplicit(szSay);
// ...
void NMDCHub::parse_lock(char *lock, char* destBuff, int out_buffsize) {
int len = strlen(lock);
char* key = new char[len + 1];
//lock-to-key transform
for(int i = 1; i < len; i++) { key[i] = lock[i] ^ lock[i-1]; }
key[0] = lock[0] ^ lock[len-1] ^ lock[len-2] ^ 5;
for(int i = 0; i < len; i++) { key[i] = ((key[i]<<4) & 0xF0) | ((key[i]>>4) & 0x0F); }
//sanitise
memset(destBuff, 0, out_buffsize);
char* newkey_p = destBuff;
for(int i = 0; i < len; i++) {
switch(key[i]) {
case 0: case 5: case 36: case 96: case 124: case 126:
sprintf_s(newkey_p, out_buffsize-(newkey_p-destBuff)-1, "/%%DCN%03d%%/", key[i]);
newkey_p += 10;
break;
default:
*newkey_p = key[i];
newkey_p++;
}
}
*newkey_p = '\0';
//tidy up
delete key; key=NULL;
}
I have an alternate nmdc core that uses STL strings instead of <cstring>, guess i should transition dcwebui over to that core instead as well, but to be honest i don't like this approach as much as flexdc, my flash-based webui. This is more cumbersome, and the one advantage that javascript has over flash, working on mobile devices, doesn't seem to apply to me personally (i have a S40-Webkit).
EDIT: Like you mentioned in the flexdc thread, this could be caused by locale settings.
Edited by mappy, 29 April 2011 - 12:28 PM.