void smtp_server_connection_set_proxy_data(
	struct smtp_server_connection *conn,
	const struct smtp_proxy_data *proxy_data)
{
	if (proxy_data->source_ip.family != 0)
		conn->conn.remote_ip = proxy_data->source_ip;
	if (proxy_data->source_port != 0)
		conn->conn.remote_port = proxy_data->source_port;
	if (proxy_data->helo != NULL) {
		i_free(conn->helo_domain);
		conn->helo_domain = i_strdup(proxy_data->helo);
		conn->helo.domain = conn->helo_domain;
		conn->helo.domain_valid = TRUE;
	}
	if (proxy_data->login != NULL) {
		i_free(conn->username);
		conn->username = i_strdup(proxy_data->login);
	}
	if (proxy_data->proto != SMTP_PROXY_PROTOCOL_UNKNOWN)
		conn->proxy_proto = proxy_data->proto;

	if (proxy_data->ttl_plus_1 > 0)
		conn->proxy_ttl_plus_1 = proxy_data->ttl_plus_1;
	if (conn->proxy_timeout_secs > 0)
		conn->proxy_timeout_secs = proxy_data->timeout_secs;

	if (conn->callbacks != NULL &&
	    conn->callbacks->conn_proxy_data_updated != NULL) {
		struct smtp_proxy_data full_data;

		i_zero(&full_data);
		full_data.source_ip = conn->conn.remote_ip;
		full_data.source_port = conn->conn.remote_port;
		full_data.helo = conn->helo.domain;
		full_data.login = conn->username;
		full_data.proto = conn->proxy_proto;
		full_data.ttl_plus_1 = conn->proxy_ttl_plus_1;
		full_data.timeout_secs = conn->proxy_timeout_secs;

		conn->callbacks->
			conn_proxy_data_updated(conn->context, &full_data);
	}
}
void smtp_server_connection_set_proxy_data(
	struct smtp_server_connection *conn,
	const struct smtp_proxy_data *proxy_data)
{
	if (proxy_data->source_ip.family != 0)
		conn->conn.remote_ip = proxy_data->source_ip;
	if (proxy_data->source_port != 0)
		conn->conn.remote_port = proxy_data->source_port;
	if (proxy_data->helo != NULL) {
		i_free(conn->helo_domain);
		conn->helo_domain = i_strdup(proxy_data->helo);
		conn->helo.domain = conn->helo_domain;
		conn->helo.domain_valid = TRUE;
	}
	if (proxy_data->login != NULL) {
		i_free(conn->username);
		conn->username = i_strdup(proxy_data->login);
	}
	if (proxy_data->proto != SMTP_PROXY_PROTOCOL_UNKNOWN)
		conn->proxy_proto = proxy_data->proto;

	if (proxy_data->ttl_plus_1 > 0)
		conn->proxy_ttl_plus_1 = proxy_data->ttl_plus_1;
	if (conn->proxy_timeout_secs > 0)
		conn->proxy_timeout_secs = proxy_data->timeout_secs;

	if (conn->callbacks != NULL &&
	    conn->callbacks->conn_proxy_data_updated != NULL) {
		struct smtp_proxy_data full_data;

		i_zero(&full_data);
		full_data.source_ip = conn->conn.remote_ip;
		full_data.source_port = conn->conn.remote_port;
		full_data.helo = conn->helo.domain;
		full_data.login = conn->username;
		full_data.proto = conn->proxy_proto;
		full_data.ttl_plus_1 = conn->proxy_ttl_plus_1;
		full_data.timeout_secs = conn->proxy_timeout_secs;

		conn->callbacks->
			conn_proxy_data_updated(conn->context, &full_data);
	}
}