nntpd

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package nntpd is a vendored, lightly patched copy of github.com/dustin/go-nntp/server (MIT, Dustin Sallings). Two changes make it a faithful, members-only Usenet server:

  1. AUTHINFO USER/PASS now return RFC 4643 response codes (381 "password required" then 281 "authentication accepted"). Upstream returned 350/250, which neither the matching go-nntp client nor standard newsreaders (slrn, tin) accept — so authentication was effectively broken.
  2. The per-command and drop-connection logging is routed through an optional Server.ErrLog and the noisy "Got cmd" line is dropped (a public server on a small box should not log every protocol verb).

Everything else is upstream. The Backend interface is unchanged, so backends written against go-nntp/server work here verbatim.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoSuchGroup          = &NNTPError{411, "No such newsgroup"}
	ErrNoGroupSelected      = &NNTPError{412, "No newsgroup selected"}
	ErrInvalidMessageID     = &NNTPError{430, "No article with that message-id"}
	ErrInvalidArticleNumber = &NNTPError{423, "No article with that number"}
	ErrNoCurrentArticle     = &NNTPError{420, "Current article number is invalid"}
	ErrUnknownCommand       = &NNTPError{500, "Unknown command"}
	ErrSyntax               = &NNTPError{501, "not supported, or syntax error"}
	ErrPostingNotPermitted  = &NNTPError{440, "Posting not permitted"}
	ErrPostingFailed        = &NNTPError{441, "posting failed"}
	ErrNotWanted            = &NNTPError{435, "Article not wanted"}
	ErrAuthRequired         = &NNTPError{450, "authorization required"}
	ErrAuthRejected         = &NNTPError{452, "authorization rejected"}
	ErrNotAuthenticated     = &NNTPError{480, "authentication required"}
)

Sentinel errors, returned by backends and rendered to the client.

Functions

This section is empty.

Types

type Backend

type Backend interface {
	ListGroups(max int) ([]*nntp.Group, error)
	GetGroup(name string) (*nntp.Group, error)
	GetArticle(group *nntp.Group, id string) (*nntp.Article, error)
	GetArticles(group *nntp.Group, from, to int64) ([]NumberedArticle, error)
	Authorized() bool
	// Authenticate validates the credentials and optionally returns a
	// replacement backend for this session (nil keeps the current one).
	Authenticate(user, pass string) (Backend, error)
	AllowPost() bool
	Post(article *nntp.Article) error
}

Backend provides the data and does the work.

type Handler

type Handler func(args []string, s *session, c *textproto.Conn) error

Handler is a low-level protocol handler.

type NNTPError

type NNTPError struct {
	Code int
	Msg  string
}

An NNTPError is a coded NNTP error message.

func (*NNTPError) Error

func (e *NNTPError) Error() string

type NumberedArticle

type NumberedArticle struct {
	Num     int64
	Article *nntp.Article
}

NumberedArticle ties an article to its per-group sequence number.

type Server

type Server struct {
	Handlers map[string]Handler
	Backend  Backend
	// ErrLog, when non-nil, receives connection-level errors. Protocol verbs
	// are never logged (a public server should not log every command).
	ErrLog *log.Logger
}

Server is an NNTP server handle.

func NewServer

func NewServer(backend Backend) *Server

NewServer builds a server bound to a backend.

func (*Server) Process

func (s *Server) Process(nc net.Conn)

Process handles a single NNTP connection.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL