Thread View: news.software.nntp
10 messages
10 total messages
Started by Steve Crook
Thu, 21 Jun 2012 13:28
Perl filter - attributes hash
Author: Steve Crook
Date: Thu, 21 Jun 2012 13:28
Date: Thu, 21 Jun 2012 13:28
13 lines
1525 bytes
1525 bytes
Hi all, If I'm reading nnrpd/perl.c correctly, it looks as though the attributes hash is created for Perl Auth and Access functions. Is there any reason why the same hash cannot be created for filter_nnrpd.pl purposes? My incentive for looking at this was that currently there doesn't appear to be an easy way to interrogate the client IP Address from within filter_nnrpd.pl. The hostname may exist in the hdr hash (in NNTP-Posting-Host or Injection-Info) but it seems a lot of work to resolve this back to an address when the client ip must already be known. Steve
Re: Perl filter - attributes hash
Author: Alexander Bartolich
Date: Thu, 21 Jun 2012 16:48
Date: Thu, 21 Jun 2012 16:48
21 lines
2047 bytes
2047 bytes
Steve Crook wrote:
> [...]
> My incentive for looking at this was that currently there doesn't appear
> to be an easy way to interrogate the client IP Address from within
> filter_nnrpd.pl. The hostname may exist in the hdr hash
> (in NNTP-Posting-Host or Injection-Info) but it seems a lot of work to
> resolve this back to an address when the client ip must already be known.
I, for one, have complete switched off reverse lookups. It just slows
everything down. Especially since not every dial-up network provides
host names.
man nnrpd
# -n The -n flag turns off resolution of IP addresses to names.
# If you only use IP-based restrictions in readers.conf and
# can handle IP addresses in your logs, using this flag may
# result in some additional speed.
Ciao
Alexander.
Re: Perl filter - attributes hash
Author: Julien ÉLIE
Date: Thu, 21 Jun 2012 19:38
Date: Thu, 21 Jun 2012 19:38
14 lines
1849 bytes
1849 bytes
Hi Steve, > If I'm reading nnrpd/perl.c correctly, it looks as though the attributes > hash is created for Perl Auth and Access functions. Is there any reason > why the same hash cannot be created for filter_nnrpd.pl purposes? I think that adding %attributes to filter_nnrpd.pl would not be a problem. HandleHeaders() in nnrpd/perl.c could do the same thing as the two other functions you mention. -- Julien ÉLIE « Deficiente uino, deficit omne. »
Re: Perl filter - attributes hash
Author: Steve Crook
Date: Mon, 25 Jun 2012 12:16
Date: Mon, 25 Jun 2012 12:16
14 lines
1685 bytes
1685 bytes
On Thu, 21 Jun 2012 21:38:01 +0200, Julien ÉLIE wrote in Message-Id: <jrvt6p$1lk$1@news.trigofacile.com>: > Hi Steve, > >> If I'm reading nnrpd/perl.c correctly, it looks as though the attributes >> hash is created for Perl Auth and Access functions. Is there any reason >> why the same hash cannot be created for filter_nnrpd.pl purposes? > > I think that adding %attributes to filter_nnrpd.pl would not be a > problem. HandleHeaders() in nnrpd/perl.c could do the same thing as the > two other functions you mention. Thanks Julien, it works! :)
Re: Perl filter - attributes hash
Author: Julien ÉLIE
Date: Mon, 25 Jun 2012 17:59
Date: Mon, 25 Jun 2012 17:59
20 lines
2054 bytes
2054 bytes
Hi Steve, >>> If I'm reading nnrpd/perl.c correctly, it looks as though the attributes >>> hash is created for Perl Auth and Access functions. Is there any reason >>> why the same hash cannot be created for filter_nnrpd.pl purposes? >> >> I think that adding %attributes to filter_nnrpd.pl would not be a >> problem. HandleHeaders() in nnrpd/perl.c could do the same thing as the >> two other functions you mention. > > Thanks Julien, it works! :) Is it a feature you would want to be included in INN 2.5.4? -- Julien ÉLIE « – Par Jupiter ! – Par Toutatis ! – Par pitié ! » (Astérix)
Re: Perl filter - attributes hash
Author: Steve Crook
Date: Tue, 26 Jun 2012 16:59
Date: Tue, 26 Jun 2012 16:59
11 lines
1551 bytes
1551 bytes
On Mon, 25 Jun 2012 19:59:09 +0200, Julien ÉLIE wrote in Message-Id: <jsa8td$m31$2@news.trigofacile.com>: > Is it a feature you would want to be included in INN 2.5.4? Hi Julien, I think yes, it would be a nice feature to include. If it was a lot of work then maybe not but my "Hello World" level of C was sufficient. :) Steve
Re: Perl filter - attributes hash
Author: Steve Crook
Date: Tue, 28 May 2013 15:05
Date: Tue, 28 May 2013 15:05
62 lines
3266 bytes
3266 bytes
On Mon, 25 Jun 2012 19:59:09 +0200, Julien ÉLIE wrote in
Message-Id: <jsa8td$m31$2@news.trigofacile.com>:
> Hi Steve,
>
>>>> If I'm reading nnrpd/perl.c correctly, it looks as though the attributes
>>>> hash is created for Perl Auth and Access functions. Is there any reason
>>>> why the same hash cannot be created for filter_nnrpd.pl purposes?
>>>
>>> I think that adding %attributes to filter_nnrpd.pl would not be a
>>> problem. HandleHeaders() in nnrpd/perl.c could do the same thing as the
>>> two other functions you mention.
>>
>> Thanks Julien, it works! :)
>
> Is it a feature you would want to be included in INN 2.5.4?
Hi Julien,
I'm digging up a thread from this time last year. :)
Regarding the change we discussed to nnrpd/perl.c to make the
attributes hash accessible to filter_nnrpd.pl: I don't think it ever
made it into INN's development stream.
Currently I'm applying the following patch at each INN update:-
--- /usr/local/news/dev/inn/nnrpd/perl.c 2012-06-21
09:52:23.000000000 +0100
+++ perl.c 2012-06-22 10:44:51.000000000 +0100
@@ -52,6 +52,7 @@
{
dSP;
HEADER *hp;
+ HV *attribs;
HV *hdr;
SV *body;
int rc;
@@ -82,7 +83,16 @@
ENTER;
SAVETMPS;
- /* Create the Perl hash. */
+ /* Create the Perl attributes hash. */
+ attribs = perl_get_hv("attributes", true);
+ (void) hv_store(attribs, "hostname", 8, newSVpv(Client.host, 0), 0);
+ (void) hv_store(attribs, "ipaddress", 9, newSVpv(Client.ip, 0), 0);
+ (void) hv_store(attribs, "port", 4, newSViv(Client.port), 0);
+ (void) hv_store(attribs, "interface", 9, newSVpv(Client.serverhost, 0), 0);
+ (void) hv_store(attribs, "intipaddr", 9, newSVpv(Client.serverip, 0), 0);
+ (void) hv_store(attribs, "intport", 7, newSViv(Client.serverport), 0);
+
+ /* Create the Perl header hash. */
hdr = perl_get_hv("hdr", true);
for (hp = Table; hp < EndOfTable; hp++) {
if (hp->Body)
--
What shall we use
To fill the empty spaces
Where we used to talk?
Re: Perl filter - attributes hash
Author: Julien ÉLIE
Date: Wed, 29 May 2013 17:39
Date: Wed, 29 May 2013 17:39
59 lines
2877 bytes
2877 bytes
Hi Steve,
> Regarding the change we discussed to nnrpd/perl.c to make the
> attributes hash accessible to filter_nnrpd.pl: I don't think it ever
> made it into INN's development stream.
>
> Currently I'm applying the following patch at each INN update:
Thanks for having taken the time to provide a patch.
Is it still working fine with the following additions? (I still have
not tested.)
Index: nnrpd/perl.c
===================================================================
--- nnrpd/perl.c (révision 9460)
+++ nnrpd/perl.c (copie de travail)
@@ -177,6 +187,7 @@
#endif /* DEBUG_MODIFY */
}
+ hv_undef(attribs);
hv_undef(hdr);
sv_setsv(body, &PL_sv_undef);
@@ -292,6 +303,7 @@
}
free(buffer);
+ hv_undef(attribs);
PUTBACK;
FREETMPS;
Index: innd/perl.c
===================================================================
--- innd/perl.c (révision 9460)
+++ innd/perl.c (copie de travail)
@@ -253,6 +253,8 @@
failure = false;
}
+ hv_undef(mode);
+
PUTBACK;
FREETMPS;
LEAVE;
--
Julien ÉLIE
« – Nous parlerons quand l'interprète dormira. [Bong !]
– Il dort. On peut parler. » (Astérix)
Re: Perl filter - attributes hash
Author: Steve Crook
Date: Thu, 30 May 2013 07:54
Date: Thu, 30 May 2013 07:54
26 lines
2005 bytes
2005 bytes
On Wed, 29 May 2013 19:39:53 +0200, Julien ÉLIE wrote in Message-Id: <ko5eh9$90l$1@news.trigofacile.com>: > Hi Steve, > >> Regarding the change we discussed to nnrpd/perl.c to make the >> attributes hash accessible to filter_nnrpd.pl: I don't think it ever >> made it into INN's development stream. >> >> Currently I'm applying the following patch at each INN update: > > Thanks for having taken the time to provide a patch. > Is it still working fine with the following additions? (I still have > not tested.) Hi Julian, Thanks for your patch. I applied it yesterday and everything is working fine. Steve -- What shall we use To fill the empty spaces Where we used to talk?
Re: Perl filter - attributes hash
Author: Julien ÉLIE
Date: Thu, 06 Jun 2013 20:15
Date: Thu, 06 Jun 2013 20:15
29 lines
2493 bytes
2493 bytes
Hi Steve,
>>> Regarding the change we discussed to nnrpd/perl.c to make the
>>> attributes hash accessible to filter_nnrpd.pl: I don't think it ever
>>> made it into INN's development stream.
[...]
> Thanks for your patch. I applied it yesterday and everything is working
> fine.
It also works fine at my end side.
Your new feature is now committed to the development stream of INN 2.5.4:
http://inn.eyrie.org/trac/changeset/9481
http://inn.eyrie.org/trac/changeset/9483
Thanks again for it!
>>> Currently I'm applying the following patch at each INN update
It won't now be needed!
Incidentally, do you have other patches to suggest for inclusion to the
development stream?
--
Julien ÉLIE
« There's a way of transferring funds that is even faster than
electronic banking. It's called marriage. » (Sam Kinison)
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads