Esempio n. 1
0
const string& PropertyBagString::setData( const string &data, bool convert ) {
	if (convert) {
		itemData = makeStringSafe(data);
		itemHasBeenConverted = true;
	} else {
		itemData = data;
		itemHasBeenConverted = false;
	}
	
	return itemData;
}
Esempio n. 2
0
void Client::mainLoop(fd_set *rset) {
	if(!FD_ISSET(sd,rset)) return;
	memset(&buff,0,sizeof(buff));
	len = recv(sd,buff,sizeof(buff),0);
	if(len<1) goto end;
	lastPacket = time(NULL);
	if(!do_db_check()) return
	gamespy3dxor(buff, len);
	buff[len]=0;
	makeStringSafe((char *)&buff, sizeof(buff));
	parseIncoming();
	return;
end:
	 deleteClient(this);
}
Esempio n. 3
0
void *openspy_mod_run(modLoadOptions *options)
{
#ifdef _WIN32
  WSADATA wsdata;
  WSAStartup(MAKEWORD(1,0),&wsdata);
#endif
  int sd;
  int len;
  char buf[1024];
  char skey[16];
  char key[512];
  struct sockaddr si_other;
  socklen_t slen;
  struct sockaddr_in si_me;
  if((sd=socket(AF_INET,SOCK_DGRAM, IPPROTO_UDP)) == -1)
   return NULL;
  memset((char *)&si_me, 0, sizeof(si_me));
  si_me.sin_family = AF_INET;
  si_me.sin_port = htons(KEYPORT);
  //int ip;
//  inet_pton(AF_INET, SERVIP,&ip);
  si_me.sin_addr.s_addr = options->bindIP;
  if(bind(sd,(struct sockaddr *)&si_me,sizeof(si_me)) == -1)
   return NULL;
  for(;;) {
    memset((char *)&buf,0, sizeof(buf));
    len = recvfrom(sd,(char *)&buf,sizeof(buf),0, (struct sockaddr *)&si_other, &slen);
    makeStringSafe((char *)&buf, sizeof(buf));
    if(len < 1) break;	
    gamespyxor(buf,len);
    memset(&key,0,sizeof(key));
    memset(&skey,0,sizeof(skey));
    if(!find_param("skey", buf, skey, sizeof(skey))) {
		continue;
    }
    if(find_param("resp", buf, key, sizeof(key))) {
		key[32] = 0;
    } else continue;
    sprintf_s(buf,sizeof(buf),"\\uok\\\\cd\\%s\\skey\\%s",key,skey);
    len = strlen(buf);
    gamespyxor(buf,len);
    sendto(sd,(char *)&buf,len,0,(struct sockaddr *)&si_other, slen);
  }
  return NULL;
}
Esempio n. 4
0
void *processConnection(threadOptions *options) {
	char buf[2048];
	char type[128];
	int len;
	int sd = options->sd;
	free((void *)options);
	struct timeval tv;
	tv.tv_sec = 30;
	tv.tv_usec = 0;
	setsockopt(sd, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv,  sizeof tv);
	len = recv(sd,buf,sizeof(buf),MSG_NOSIGNAL);
	if(len == -1) { //timeout
		sendError(sd,"The search has timedout");
		return NULL;
	}
	makeStringSafe((char *)&buf, sizeof(buf));
	if(!find_param(0, buf, type,sizeof(type))) {
		sendError(sd,"Error recieving request");
		return NULL;	
	}
	//TODO: pmatch(product matching), others(showing buddies),otherslist(wait until GPCM is implemented)
	if(stricmp(type,"valid") == 0) {
		checkEmailValid(sd,buf);
	} else if(stricmp(type,"nicks") == 0) {
		sendNicks(sd,buf);
	} else if(stricmp(type,"check") == 0) {
		checkNick(sd,buf);
	} else if(stricmp(type,"newuser") == 0) {
		newUser(sd,buf);
	} else if(stricmp(type,"search") == 0) { 
		searchUsers(sd,buf);
	} else if(stricmp(type,"others") == 0) {
		sendReverseBuddies(sd,buf);
	} else if(stricmp(type,"otherslist") == 0) {
		sendReverseBuddies(sd,buf);
	} else if(stricmp(type,"uniquesearch") == 0) { //nameinator
	} else if(stricmp(type,"profilelist") == 0) { //nameinator
	}else {
		sendError(sd,"Error recieving request");	
		return NULL;
	}
	close(sd);
	return NULL;
}