... which contains the address the request came in on.
For external filters the variable is called $PRIVOXY_LISTEN_ADDRESS.
Original patch contributed by pursievro.
#
# File : $Source: /cvsroot/ijbswa/current/default.filter,v $
#
-# $Id: default.filter,v 1.91 2014/06/20 09:46:13 fabiankeil Exp $
+# $Id: default.filter,v 1.92 2014/10/17 14:45:10 fabiankeil Exp $
#
# Purpose : Rules to process the content of web pages
#
# quoting.
#
# 'D' (Dynamic) allows the use of variables. Supported variables are:
-# $host, $origin (the IP address the request came from), $path and $url.
+# $host, $listen-address, $origin (the IP address the request came
+# from), $path and $url.
#
# Note that '$' is a bad choice as delimiter for dynamic filters as you
# might end up with unintended variables if you use a variable name
This file belongs into
ijbswa.sourceforge.net:/home/groups/i/ij/ijbswa/htdocs/
- $Id: user-manual.sgml,v 2.210 2016/05/03 13:20:20 fabiankeil Exp $
+ $Id: user-manual.sgml,v 2.211 2016/05/22 12:42:11 fabiankeil Exp $
Copyright (C) 2001-2016 Privoxy Developers https://www.privoxy.org/
See LICENSE.
</subscript>
</pubdate>
-<pubdate>$Id: user-manual.sgml,v 2.210 2016/05/03 13:20:20 fabiankeil Exp $</pubdate>
+<pubdate>$Id: user-manual.sgml,v 2.211 2016/05/22 12:42:11 fabiankeil Exp $</pubdate>
<!--
<para>
The non-standard option letter <literal>D</literal> (dynamic) allows
to use the variables $host, $origin (the IP address the request came from),
- $path and $url. They will be replaced with the value they refer to before
- the filter is executed.
+ $path, $url and $listen-address (the address on which Privoxy accepted the
+ client request. Example: 127.0.0.1:8118).
+ They will be replaced with the value they refer to before the filter
+ is executed.
</para>
<para>
</para>
<para>
External filters read the content from STDIN and write the rewritten
- content to STDOUT. The environment variables PRIVOXY_URL, PRIVOXY_PATH,
- PRIVOXY_HOST, PRIVOXY_ORIGIN can be used to get some details about the
- client request.
+ content to STDOUT.
+ The environment variables PRIVOXY_URL, PRIVOXY_PATH, PRIVOXY_HOST,
+ PRIVOXY_ORIGIN, PRIVOXY_LISTEN_ADDRESS can be used to get some details
+ about the client request.
</para>
<para>
&my-app; will temporary store the content to filter in the
-const char filters_rcs[] = "$Id: filters.c,v 1.200 2016/02/26 12:29:38 fabiankeil Exp $";
+const char filters_rcs[] = "$Id: filters.c,v 1.201 2016/03/17 10:40:53 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/filters.c,v $
{"path", csp->http->path, 1},
{"host", csp->http->host, 1},
{"origin", csp->ip_addr_str, 1},
+ {"listen-address", csp->listen_addr_str, 1},
{NULL, NULL, 1}
};
{ "PRIVOXY_PATH", csp->http->path },
{ "PRIVOXY_HOST", csp->http->host },
{ "PRIVOXY_ORIGIN", csp->ip_addr_str },
+ { "PRIVOXY_LISTEN_ADDRESS", csp->listen_addr_str },
};
for (i = 0; i < SZ(env); i++)
-const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.134 2015/11/06 13:37:35 fabiankeil Exp $";
+const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.135 2016/01/16 12:33:35 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/jbsockets.c,v $
int max_selected_socket;
fd_set selected_fds;
jb_socket fd;
+ size_t listen_addr_size;
c_length = sizeof(client);
csp->ip_addr_long = ntohl(client.sin_addr.s_addr);
#endif /* def HAVE_RFC2553 */
+ /*
+ * Save the name and port of the accepting socket for later lookup.
+ *
+ * The string needs space for strlen(...) + 7 characters:
+ * strlen(haddr[i]) + 1 (':') + 5 (port digits) + 1 ('\0')
+ */
+ listen_addr_size = strlen(csp->config->haddr[i]) + 7;
+ csp->listen_addr_str = malloc_or_die(listen_addr_size);
+ retval = snprintf(csp->listen_addr_str, listen_addr_size,
+ "%s:%d", csp->config->haddr[i], csp->config->hport[i]);
+ if ((-1 == retval) || listen_addr_size <= retval)
+ {
+ log_error(LOG_LEVEL_ERROR,
+ "Server name (%s) and port number (%d) ASCII decimal representation"
+ "don't fit into %d bytes",
+ csp->config->haddr[i], csp->config->hport[i], listen_addr_size);
+ return 0;
+ }
+
return 1;
}
-const char jcc_rcs[] = "$Id: jcc.c,v 1.442 2016/03/17 10:40:53 fabiankeil Exp $";
+const char jcc_rcs[] = "$Id: jcc.c,v 1.443 2016/05/22 12:43:07 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/jcc.c,v $
"Waiting for the next client connection. Currently active threads: %d",
active_threads);
+ /*
+ * This config may be outdated, but for accept_connection()
+ * it's fresh enough.
+ */
+ csp->config = config;
+
if (!accept_connection(csp, bfds))
{
log_error(LOG_LEVEL_CONNECT, "accept failed: %E");
"Connection from %s on socket %d dropped due to ACL", csp->ip_addr_str, csp->cfd);
close_socket(csp->cfd);
freez(csp->ip_addr_str);
+ freez(csp->listen_addr_str);
freez(csp_list);
continue;
}
strlen(TOO_MANY_CONNECTIONS_RESPONSE));
close_socket(csp->cfd);
freez(csp->ip_addr_str);
+ freez(csp->listen_addr_str);
freez(csp_list);
continue;
}
-const char loaders_rcs[] = "$Id: loaders.c,v 1.103 2016/05/08 10:45:32 fabiankeil Exp $";
+const char loaders_rcs[] = "$Id: loaders.c,v 1.104 2016/05/22 12:43:07 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/loaders.c,v $
#ifdef FEATURE_CLIENT_TAGS
freez(csp->client_address);
#endif
+ freez(csp->listen_addr_str);
freez(csp->client_iob->buf);
freez(csp->iob->buf);
freez(csp->error_message);
#ifndef PROJECT_H_INCLUDED
#define PROJECT_H_INCLUDED
/** Version string. */
-#define PROJECT_H_VERSION "$Id: project.h,v 1.214 2016/03/30 11:13:25 fabiankeil Exp $"
+#define PROJECT_H_VERSION "$Id: project.h,v 1.215 2016/05/22 12:43:07 fabiankeil Exp $"
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/project.h,v $
unsigned long ip_addr_long;
#endif /* def HAVE_RFC2553 */
+ /** The host name and port (as a string of the form '<hostname>:<port>')
+ of the server socket to which the client connected. */
+ char *listen_addr_str;
+
/** The URL that was requested */
struct http_request http[1];
#
# File : $Source: /cvsroot/ijbswa/current/user.filter,v $
#
-# $Id: user.filter,v 1.2 2006/07/18 14:48:47 david__schmidt Exp $
+# $Id: user.filter,v 1.3 2008/05/21 20:17:03 fabiankeil Exp $
#
# Purpose : Rules to process the content of web pages
#
# quoting.
#
# 'D' (Dynamic) allows the use of variables. Supported variables are:
-# $host, $origin (the IP address the request came from), $path and $url.
+# $host, $listen-address, $origin (the IP address the request came
+# from), $path and $url.
#
# Note that '$' is a bad choice as delimiter for dynamic filters as you
# might end up with unintended variables if you use a variable name