user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Jonathan Corbet <corbet@lwn.net>
To: meta@public-inbox.org
Cc: Jonathan Corbet <corbet@lwn.net>
Subject: [PATCH 1/2] Put the NNTP server name into Xref lines
Date: Tue,  4 Sep 2018 09:28:19 -0600	[thread overview]
Message-ID: <20180904152820.15594-2-corbet@lwn.net> (raw)
In-Reply-To: <20180904152820.15594-1-corbet@lwn.net>

RFC 5536 sec 3.2.14 says that the server-name in an Xref line is "which
news server generated the header field"; indeed, that is necessary for
newsreaders like gnus to handle references properly.  So pick up the server
name from the config if available, from the host name otherwise, and use it
rather than the domain name of the list server.
---
 lib/PublicInbox/NNTP.pm  | 4 ++--
 lib/PublicInbox/NNTPD.pm | 6 ++++++
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm
index cdbd8e9..cbd4ecf 100644
--- a/lib/PublicInbox/NNTP.pm
+++ b/lib/PublicInbox/NNTP.pm
@@ -94,7 +94,7 @@ sub new ($$$) {
 	my $self = fields::new($class);
 	$self->SUPER::new($sock);
 	$self->{nntpd} = $nntpd;
-	res($self, '201 server ready - post via email');
+	res($self, '201 ' . $nntpd->{servername} . ' ready - post via email');
 	$self->{rbuf} = '';
 	$self->watch_read(1);
 	update_idle_time($self);
@@ -410,7 +410,7 @@ sub header_append ($$$) {
 
 sub xref ($$$$) {
 	my ($self, $ng, $n, $mid) = @_;
-	my $ret = "$ng->{domain} $ng->{newsgroup}:$n";
+	my $ret = $self->{nntpd}->{servername} . " $ng->{newsgroup}:$n";
 
 	# num_for is pretty cheap and sometimes we'll lookup the existence
 	# of an article without getting even the OVER info.  In other words,
diff --git a/lib/PublicInbox/NNTPD.pm b/lib/PublicInbox/NNTPD.pm
index 117c9c0..666c53b 100644
--- a/lib/PublicInbox/NNTPD.pm
+++ b/lib/PublicInbox/NNTPD.pm
@@ -6,15 +6,21 @@
 package PublicInbox::NNTPD;
 use strict;
 use warnings;
+use Sys::Hostname;
 require PublicInbox::Config;
 
 sub new {
 	my ($class) = @_;
+	my $pi_config = PublicInbox::Config->new;
+	my $name = $pi_config->{'publicinbox.nntpserver'};
+	if ($name eq '') { $name = hostname; }
+
 	bless {
 		groups => {},
 		err => \*STDERR,
 		out => \*STDOUT,
 		grouplist => [],
+		servername => $name,
 	}, $class;
 }
 
-- 
2.17.1


  reply	other threads:[~2018-09-04 15:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-04 15:28 [PATCH 0/2] Make NNTP Xrefs work better Jonathan Corbet
2018-09-04 15:28 ` Jonathan Corbet [this message]
2018-09-05 21:34   ` [PATCH 1/2] Put the NNTP server name into Xref lines Eric Wong
2018-09-05 22:26     ` Jonathan Corbet
2018-09-04 15:28 ` [PATCH 2/2] Add Xrefs to over/xover lines Jonathan Corbet
  -- strict thread matches above, loose matches on Subject: below --
2018-10-13 21:42 [PATCH v2 0/2] Make NNTP Xrefs work better Jonathan Corbet
2018-10-13 21:42 ` [PATCH 1/2] Put the NNTP server name into Xref lines Jonathan Corbet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180904152820.15594-2-corbet@lwn.net \
    --to=corbet@lwn.net \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).