Dumping the IP address will help admins use the (standard)
output of these servers to track abusive IMAP and POP3 scanners
looking for private mail. NNTP doesn't seem affected at
the moment, but it's easier to keep the common code
across all three of these stateful protocols.
# for IMAP, NNTP, and POP3 which greet clients upon connect
sub greet {
# for IMAP, NNTP, and POP3 which greet clients upon connect
sub greet {
- my ($self, $sock) = @_;
+ my ($self, $sock, $addr) = @_;
my $ev = EPOLLOUT;
if ($sock->can('accept_SSL') && !$sock->accept_SSL) {
return if $! != EAGAIN || !($ev = PublicInbox::TLS::epollbit());
my $ev = EPOLLOUT;
if ($sock->can('accept_SSL') && !$sock->accept_SSL) {
return if $! != EAGAIN || !($ev = PublicInbox::TLS::epollbit());
}
push @{$self->{wbuf}}, $self->can('do_greet');
new($self, $sock, $ev | EPOLLONESHOT);
}
push @{$self->{wbuf}}, $self->can('do_greet');
new($self, $sock, $ev | EPOLLONESHOT);
+ ($addr, my $port) = PublicInbox::Daemon::host_with_port($addr);
+ $self->out('['.fileno($sock)."] accept $addr:$port");
$tlsd->refresh_groups($sig);
};
$xn{post_accept} = $tlsd->can('post_accept_cb') ?
$tlsd->refresh_groups($sig);
};
$xn{post_accept} = $tlsd->can('post_accept_cb') ?
- $tlsd->post_accept_cb : sub { $modc->new($_[0], $tlsd) };
+ $tlsd->post_accept_cb :
+ sub { $modc->new(@_[0, 1], $tlsd) };
if ($modc eq 'PublicInbox::HTTP') {
$xn{af_default} = 'httpready';
if (my $p = $opt->{psgi}) {
if ($modc eq 'PublicInbox::HTTP') {
$xn{af_default} = 'httpready';
if (my $p = $opt->{psgi}) {
- my (undef, $sock, $imapd) = @_;
- (bless { imapd => $imapd }, 'PublicInbox::IMAP_preauth')->greet($sock)
+ my (undef, $sock, $addr, $imapd) = @_;
+ (bless { imapd => $imapd }, 'PublicInbox::IMAP_preauth')
+ ->greet($sock, $addr)
sub do_greet ($) { $_[0]->write($_[0]->{nntpd}->{greet}) };
sub new {
sub do_greet ($) { $_[0]->write($_[0]->{nntpd}->{greet}) };
sub new {
- my ($cls, $sock, $nntpd) = @_;
- (bless { nntpd => $nntpd }, $cls)->greet($sock)
+ my ($cls, $sock, $addr, $nntpd) = @_;
+ (bless { nntpd => $nntpd }, $cls)->greet($sock, $addr)
- my ($cls, $sock, $pop3d) = @_;
- (bless { pop3d => $pop3d }, $cls)->greet($sock)
+ my ($cls, $sock, $addr, $pop3d) = @_;
+ (bless { pop3d => $pop3d }, $cls)->greet($sock, $addr)
}
# POP user is $UUID1@$NEWSGROUP[.$SLICE][?QUERY_ARGS]
}
# POP user is $UUID1@$NEWSGROUP[.$SLICE][?QUERY_ARGS]