예제 #1
0
static ret_t
configure (cherokee_rule_request_t   *rule,
	   cherokee_config_node_t    *conf,
	   cherokee_virtual_server_t *vsrv)
{
	ret_t                   ret;
	cherokee_regex_table_t *regexs = VSERVER_SRV(vsrv)->regexs;

	/* Read the configuration entry
	 */
	ret = cherokee_config_node_copy (conf, "request", &rule->pattern);
	if (ret != ret_ok) {
		LOG_CRITICAL (CHEROKEE_ERROR_RULE_NO_PROPERTY,
			      RULE(rule)->priority, "request");
		return ret_error;
	}

	/* Add it to the regular extension table
	 */
	ret = cherokee_regex_table_add (regexs, rule->pattern.buf);
	if (ret != ret_ok)
		return ret;

	ret = cherokee_regex_table_get (regexs, rule->pattern.buf, &rule->pcre);
	if (ret != ret_ok)
		return ret;

	return ret_ok;
}
예제 #2
0
static ret_t
configure (cherokee_rule_header_t    *rule,
	   cherokee_config_node_t    *conf,
	   cherokee_virtual_server_t *vsrv)
{
	ret_t                   ret;
	cherokee_buffer_t      *type     = NULL;
	cherokee_buffer_t      *header   = NULL;
	cherokee_regex_table_t *regexs   = VSERVER_SRV(vsrv)->regexs;

	/* Read the header
	 */
	ret = cherokee_config_node_read (conf, "header", &header);
	if (ret != ret_ok) {
		LOG_ERROR (CHEROKEE_ERROR_RULE_NO_PROPERTY,
			   RULE(rule)->priority, "header");
		return ret_error;
	}

	ret = header_str_to_type (header, &rule->header);
	if (ret != ret_ok) {
		return ret;
	}

	/* Type
	 */
	ret = cherokee_config_node_read (conf, "type", &type);
	if (ret == ret_ok) {
		ret = type_str_to_type (type, &rule->type);
		if (ret != ret_ok) {
			return ret;
		}
	}

	/* Read the match
	 */
	ret = cherokee_config_node_copy (conf, "match", &rule->match);
	if (ret != ret_ok) {
		if (equal_buf_str (type, "regex")) {
			LOG_ERROR (CHEROKEE_ERROR_RULE_NO_PROPERTY,
				   RULE(rule)->priority, "match");
			return ret_error;
		}
	}

	/* Compile the regular expression
	 */
	if (! cherokee_buffer_is_empty (&rule->match)) {
		ret = cherokee_regex_table_add (regexs, rule->match.buf);
		if (ret != ret_ok)
			return ret;

		ret = cherokee_regex_table_get (regexs, rule->match.buf, &rule->pcre);
		if (ret != ret_ok)
			return ret;
	}

	return ret_ok;
}
예제 #3
0
ret_t
cherokee_logger_ncsa_init_base (cherokee_logger_ncsa_t    *logger,
				cherokee_virtual_server_t *vsrv,
				cherokee_config_node_t    *config)
{
	ret_t                   ret;
	cherokee_config_node_t *subconf;
	static int              callback_init = 0;

	/* Init the local buffers
	 */
	cherokee_buffer_init (&logger->now_dtm);
	cherokee_buffer_init (&logger->referer);
	cherokee_buffer_init (&logger->useragent);
	cherokee_buffer_ensure_size (&logger->now_dtm,   64);
	cherokee_buffer_ensure_size (&logger->referer, 1024);
	cherokee_buffer_ensure_size (&logger->useragent, 512);

	/* Init the logger writer
	 */
	ret = cherokee_config_node_get (config, "access", &subconf);
	if (ret != ret_ok) {
		LOG_CRITICAL (CHEROKEE_ERROR_LOGGER_NO_KEY, "access");
		return ret_error;
	}

	ret = cherokee_server_get_log_writer (VSERVER_SRV(vsrv), subconf, &logger->writer_access);
	if (ret != ret_ok) {
		return ret_error;
	}

	/* Callback init
	 */
	if (callback_init == 0) {
		cherokee_buffer_init (&now);
		cherokee_bogotime_add_callback (bogotime_callback, logger, 1);
	}

	return ret_ok;
}
예제 #4
0
ret_t
cherokee_socket_init_tls (cherokee_socket_t         *socket,
			  cherokee_virtual_server_t *vserver,
			  cherokee_socket_status_t  *blocking)
{
	ret_t              ret;
	cherokee_server_t *srv = VSERVER_SRV(vserver);

	if (socket->cryptor == NULL) {
		ret = cherokee_cryptor_socket_new (srv->cryptor, &socket->cryptor);
		if (ret != ret_ok)
			return ret;
	}

	ret = cherokee_cryptor_socket_init_tls (socket->cryptor, socket, vserver, blocking);
	if (ret != ret_ok) {
		return ret;
	}

	socket->is_tls = TLS;
	return ret_ok;
}