1 # Copyright (C) 2016-2018 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
4 # represents an NNTPD (currently a singleton),
5 # see script/public-inbox-nntpd for how it is used
6 package PublicInbox::NNTPD;
10 require PublicInbox::Config;
14 my $pi_config = PublicInbox::Config->new;
15 my $name = $pi_config->{'publicinbox.nntpserver'};
16 if (!defined($name) or $name eq '') {
18 } elsif (ref($name) eq 'ARRAY') {
28 greet => \"201 $name ready - post via email\r\n",
29 # accept_tls => { SSL_server => 1, ..., SSL_reuse_ctx => ... }
33 sub refresh_groups () {
35 my $pi_config = PublicInbox::Config->new;
38 $pi_config->each_inbox(sub {
40 my $ngname = $ng->{newsgroup} or return;
42 warn 'multiple newsgroups not supported: '.
43 join(', ', @$ngname). "\n";
44 } elsif ($ng->nntp_usable) {
45 # Only valid if msgmap and search works
46 $new->{$ngname} = $ng;
50 @list = sort { $a->{newsgroup} cmp $b->{newsgroup} } @list;
51 $self->{grouplist} = \@list;
52 # this will destroy old groups that got deleted
53 %{$self->{groups}} = %$new;