mirror of
https://github.com/curl/curl.git
synced 2026-07-24 12:27:16 +03:00
writeout: -w now supports remote_ip/port and local_ip/port
Added mention to the curl.1 man page. Test case 1223 verifies remote_ip/port.
This commit is contained in:
parent
0b3180b4f5
commit
65e8ba8e1d
4 changed files with 107 additions and 1 deletions
|
|
@ -54,6 +54,10 @@ typedef enum {
|
|||
VAR_REDIRECT_URL,
|
||||
VAR_SSL_VERIFY_RESULT,
|
||||
VAR_EFFECTIVE_FILENAME,
|
||||
VAR_PRIMARY_IP,
|
||||
VAR_PRIMARY_PORT,
|
||||
VAR_LOCAL_IP,
|
||||
VAR_LOCAL_PORT,
|
||||
VAR_NUM_OF_VARS /* must be the last */
|
||||
} replaceid;
|
||||
|
||||
|
|
@ -88,6 +92,10 @@ static const struct variable replacements[]={
|
|||
{"redirect_url", VAR_REDIRECT_URL},
|
||||
{"ssl_verify_result", VAR_SSL_VERIFY_RESULT},
|
||||
{"filename_effective", VAR_EFFECTIVE_FILENAME},
|
||||
{"remote_ip", VAR_PRIMARY_IP},
|
||||
{"remote_port", VAR_PRIMARY_PORT},
|
||||
{"local_ip", VAR_LOCAL_IP},
|
||||
{"local_port", VAR_LOCAL_PORT},
|
||||
{NULL, VAR_NONE}
|
||||
};
|
||||
|
||||
|
|
@ -247,6 +255,30 @@ void ourWriteOut(CURL *curl, struct OutStruct *outs, const char *writeinfo)
|
|||
if(outs->filename)
|
||||
fprintf(stream, "%s", outs->filename);
|
||||
break;
|
||||
case VAR_PRIMARY_IP:
|
||||
if(CURLE_OK ==
|
||||
curl_easy_getinfo(curl, CURLINFO_PRIMARY_IP,
|
||||
&stringp))
|
||||
fprintf(stream, "%s", stringp);
|
||||
break;
|
||||
case VAR_PRIMARY_PORT:
|
||||
if(CURLE_OK ==
|
||||
curl_easy_getinfo(curl, CURLINFO_PRIMARY_PORT,
|
||||
&longinfo))
|
||||
fprintf(stream, "%ld", longinfo);
|
||||
break;
|
||||
case VAR_LOCAL_IP:
|
||||
if(CURLE_OK ==
|
||||
curl_easy_getinfo(curl, CURLINFO_LOCAL_IP,
|
||||
&stringp))
|
||||
fprintf(stream, "%s", stringp);
|
||||
break;
|
||||
case VAR_LOCAL_PORT:
|
||||
if(CURLE_OK ==
|
||||
curl_easy_getinfo(curl, CURLINFO_LOCAL_PORT,
|
||||
&longinfo))
|
||||
fprintf(stream, "%ld", longinfo);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue