Example #1
0
bool
bot_hand_shake(struct bot *bot)
{
	char buff[128];
	int len;
	bool ret;

	ret = socket_send_msg(bot->socket, HELLO_MSG, strlen(HELLO_MSG));
	if (ret == false) {
		DEBUG(LOG_DEFAULT, "send_msg handshake fail\n");
		return false;
	}

	ret = socket_recv_line(bot->socket, buff, &len, sizeof(buff));
	
	if (ret == false) {
		DEBUG(LOG_DEFAULT, "send_msg handshake fail\n");
		return false;
	}
	
	if (bot_validate_server(bot, buff, len) == false) {
		DEBUG(LOG_DEFAULT, "Host validation fail\n");
		return false;
	}

	DEBUG(LOG_DEFAULT, "hand shake success\n");

	return true;
}
Example #2
0
int proxy_recv_line(struct proxy *self, char *buff, int len)
{
	int err;

	assert(self);
	assert(self->s);

	err = socket_recv_line(self->s, buff, len);

	return err;
}
Example #3
0
bool
bot_get_next_cmd(struct bot *bot, struct command_ctx *ctx)
{
	char buff[BUF_SZ];
	int len;

	if (socket_recv_line(bot->socket, buff, &len, BUF_SZ) == false)
		return false;
	
	buff[len] = '\0';
	DEBUG(LOG_VERBOSE, "recived msg = %s\n", buff);

	command_get(buff, len, ctx);

	return true;
}