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:
- 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.
- 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 NumberedArticle ¶
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.
Click to show internal directories.
Click to hide internal directories.