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

--
unsubscribe: [email protected]
archive: https://public-inbox.org/meta/

Reply via email to