static int process_z_request(association *assoc, request *req, char **msg);
-static void assoc_init_reset(association *assoc)
+static void assoc_init_reset(association *assoc, const char *peer_name1)
{
+ const char *peer_name2 = cs_addrstr(assoc->client_link);
+
xfree(assoc->init);
assoc->init = (bend_initrequest *) xmalloc(sizeof(*assoc->init));
assoc->init->charneg_response = NULL;
assoc->init->decode = assoc->decode;
- assoc->init->peer_name =
- odr_strdup(assoc->encode, cs_addrstr(assoc->client_link));
+
+ assoc->init->peer_name = (char *)
+ odr_malloc(assoc->encode,
+ (peer_name1 ? strlen(peer_name1) : 0)
+ + 4 + strlen(peer_name2));
+ strcpy(assoc->init->peer_name, "");
+ if (peer_name1)
+ {
+ strcat(assoc->init->peer_name, peer_name1);
+ strcat(assoc->init->peer_name, ", ");
+ }
+ strcat(assoc->init->peer_name, peer_name2);
yaz_log(log_requestdetail, "peer %s", assoc->init->peer_name);
}
-static int srw_bend_init(association *assoc, Z_SRW_diagnostic **d, int *num, Z_SRW_PDU *sr)
+static int srw_bend_init(association *assoc, Z_HTTP_Header *headers,
+ Z_SRW_diagnostic **d, int *num, Z_SRW_PDU *sr)
{
statserv_options_block *cb = statserv_getcontrol();
if (!assoc->init)
bend_initresult *binitres;
yaz_log(log_requestdetail, "srw_bend_init config=%s", cb->configname);
- assoc_init_reset(assoc);
+ assoc_init_reset(assoc, z_HTTP_header_lookup(headers, "X-Forwarded-For"));
if (sr->username)
{
}
static void srw_bend_search(association *assoc,
+ Z_HTTP_Header *headers,
Z_SRW_PDU *sr,
Z_SRW_PDU *res,
int *http_code)
*http_code = 200;
yaz_log(log_requestdetail, "Got SRW SearchRetrieveRequest");
- srw_bend_init(assoc, &srw_res->diagnostics, &srw_res->num_diagnostics, sr);
+ srw_bend_init(assoc, headers,
+ &srw_res->diagnostics, &srw_res->num_diagnostics, sr);
if (srw_res->num_diagnostics == 0 && assoc->init)
{
bend_search_rr rr;
}
static void srw_bend_explain(association *assoc,
+ Z_HTTP_Header *headers,
Z_SRW_PDU *sr,
Z_SRW_explainResponse *srw_res,
int *http_code)
{
Z_SRW_explainRequest *srw_req = sr->u.explain_request;
yaz_log(log_requestdetail, "Got SRW ExplainRequest");
- srw_bend_init(assoc, &srw_res->diagnostics, &srw_res->num_diagnostics, sr);
+ srw_bend_init(assoc, headers,
+ &srw_res->diagnostics, &srw_res->num_diagnostics, sr);
if (!assoc->init && srw_res->num_diagnostics == 0)
*http_code = 404;
if (assoc->init)
}
static void srw_bend_scan(association *assoc,
+ Z_HTTP_Header *headers,
Z_SRW_PDU *sr,
Z_SRW_PDU *res,
int *http_code)
yaz_log(log_requestdetail, "Got SRW ScanRequest");
*http_code = 200;
- srw_bend_init(assoc, &srw_res->diagnostics, &srw_res->num_diagnostics, sr);
+ srw_bend_init(assoc, headers,
+ &srw_res->diagnostics, &srw_res->num_diagnostics, sr);
if (srw_res->num_diagnostics == 0 && assoc->init)
{
int step_size = 0;
}
static void srw_bend_update(association *assoc,
+ Z_HTTP_Header *headers,
Z_SRW_PDU *sr,
Z_SRW_updateResponse *srw_res,
int *http_code)
Z_SRW_updateRequest *srw_req = sr->u.update_request;
yaz_log(log_session, "SRWUpdate action=%s", srw_req->operation);
yaz_log(YLOG_DEBUG, "num_diag = %d", srw_res->num_diagnostics );
- srw_bend_init(assoc, &srw_res->diagnostics, &srw_res->num_diagnostics, sr);
+ srw_bend_init(assoc, headers,
+ &srw_res->diagnostics, &srw_res->num_diagnostics, sr);
if (!assoc->init && srw_res->num_diagnostics == 0)
*http_code = 404;
if (assoc->init)
}
else
{
- srw_bend_search(assoc, sr, res, &http_code);
+ srw_bend_search(assoc, hreq->headers, sr, res, &http_code);
}
if (http_code == 200)
soap_package->u.generic->p = res;
res->u.explain_response->diagnostics = diagnostic;
res->u.explain_response->num_diagnostics = num_diagnostic;
}
- srw_bend_explain(assoc, sr, res->u.explain_response, &http_code);
+ srw_bend_explain(assoc, hreq->headers,
+ sr, res->u.explain_response, &http_code);
if (http_code == 200)
soap_package->u.generic->p = res;
}
res->u.scan_response->diagnostics = diagnostic;
res->u.scan_response->num_diagnostics = num_diagnostic;
}
- srw_bend_scan(assoc, sr, res, &http_code);
+ srw_bend_scan(assoc, hreq->headers, sr, res, &http_code);
if (http_code == 200)
soap_package->u.generic->p = res;
}
res->u.update_response->num_diagnostics = num_diagnostic;
}
yaz_log(YLOG_DEBUG, "num_diag = %d", res->u.update_response->num_diagnostics );
- srw_bend_update(assoc, sr, res->u.update_response, &http_code);
+ srw_bend_update(assoc, hreq->headers,
+ sr, res->u.update_response, &http_code);
if (http_code == 200)
soap_package->u.generic->p = res;
}
yaz_log(log_requestdetail, "Version: %s",
req->implementationVersion);
- assoc_init_reset(assoc);
-
+ assoc_init_reset(assoc,
+ yaz_oi_get_string_oid(&req->otherInfo,
+ yaz_oid_userinfo_client_ip, 1, 0));
assoc->init->auth = req->idAuthentication;
assoc->init->referenceId = req->referenceId;