MCPcopy Create free account
hub / github.com/assaultcube/AC / checkclientinput

Function checkclientinput

source/src/master.cpp:542–592  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

540// :for AUTH
541
542bool checkclientinput(mclient &c)
543{
544 if(c.inputpos<0) return true;
545 char *end = (char *)memchr(c.input, '\n', c.inputpos);
546 while(end)
547 {
548 *end++ = '\0';
549 c.lastinput = servtime;
550
551 uint id; // for AUTH
552 string user, val; // for AUTH
553
554 int port;
555 if(!strncmp(c.input, "list", 4) && (!c.input[4] || isspace(c.input[4])))
556 {
557 genserverlist();
558 if(gameserverlists.empty() || c.message) return false;
559 c.message = gameserverlists.last();
560 c.message->refs++;
561 c.output.setsize(0);
562 c.outputpos = 0;
563 c.shouldpurge = true;
564 return true;
565 }
566 else if(sscanf(c.input, "regserv %d", &port) == 1)
567 {
568 if(checkban(servbans, c.address.host)) return false;
569 if(port < 0 || port + 1 < 0 || (c.servport >= 0 && port != c.servport)) outputf(c, "failreg invalid port\n");
570 else
571 {
572 c.servport = port;
573 addgameserver(c);
574 }
575 }
576 // for AUTH:
577 else if(sscanf(c.input, "reqauth %u %100s", &id, user) == 2)
578 {
579 reqauth(c, id, user);
580 }
581 else if(sscanf(c.input, "confauth %u %100s", &id, val) == 2)
582 {
583 confauth(c, id, val);
584 }
585 // :for AUTH
586 c.inputpos = &c.input[c.inputpos] - end;
587 memmove(c.input, end, c.inputpos);
588
589 end = (char *)memchr(c.input, '\n', c.inputpos);
590 }
591 return c.inputpos<(int)sizeof(c.input);
592}
593
594ENetSocketSet readset, writeset;
595

Callers 1

loopvFunction · 0.85

Calls 8

genserverlistFunction · 0.85
checkbanFunction · 0.85
outputfFunction · 0.85
addgameserverFunction · 0.85
reqauthFunction · 0.85
confauthFunction · 0.85
setsizeMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected