Documentation
¶
Overview ¶
Package nntp implements the Network News Transfer Protocol as defined in RFC 3977.
Index ¶
Constants ¶
const ( Unknown = PostingStatus(0) PostingPermitted = PostingStatus('y') PostingNotPermitted = PostingStatus('n') PostingModerated = PostingStatus('m') )
Variables ¶
var ErrAuthRejected = &Error{452, "authorization rejected"}
ErrAuthRejected is returned for invalid authentication.
var ErrAuthRequired = &Error{450, "authorization required"}
ErrAuthRequired is returned to indicate authentication is required to proceed.
var ErrInvalidArticleNumber = &Error{423, "No article with that number"}
ErrInvalidArticleNumber is returned when an article is requested that can't be found.
var ErrInvalidMessageID = &Error{430, "No article with that message-id"}
ErrInvalidMessageID is returned when a message is requested that can't be found.
var ErrNoCurrentArticle = &Error{420, "Current article number is invalid"}
ErrNoCurrentArticle is returned when a command is executed that requires a current article when one has not been selected.
var ErrNoGroupSelected = &Error{412, "No newsgroup selected"}
ErrNoSuchGroup is returned for a request that requires a current group when none has been selected.
var ErrNoSuchGroup = &Error{411, "No such newsgroup"}
ErrNoSuchGroup is returned for a request for a group that can't be found.
var ErrNotAuthenticated = &Error{480, "authentication required"}
ErrNotAuthenticated is returned when a command is issued that requires authentication, but authentication was not provided.
var ErrNotWanted = &Error{435, "Article not wanted"}
ErrNotWanted is returned when an attempt to post an article is rejected due the server not wanting the article.
var ErrPostingFailed = &Error{441, "posting failed"}
ErrPostingFailed is returned when an attempt to post an article fails.
var ErrPostingNotPermitted = &Error{440, "posting not permitted"}
ErrPostingNotPermitted is returned as the response to an attempt to post an article where posting is not permitted.
var ErrSyntax = &Error{501, "not supported, or syntax error"}
ErrSyntax is returned when a command can't be parsed.
var ErrUnknownCommand = &Error{500, "Unknown command"}
ErrUnknownCommand is returned for unknown comands.
Functions ¶
This section is empty.
Types ¶
type Article ¶
type Article struct { // The article's headers Header textproto.MIMEHeader // The article's body Body io.Reader // Number of bytes in the article body (used by OVER/XOVER) Bytes int // Number of lines in the article body (used by OVER/XOVER) Lines int }
An Article that may appear in one or more groups.
type Backend ¶
type Backend interface { ListGroups(max int) ([]*Group, error) GetGroup(name string) (*Group, error) GetArticle(g *Group, id string) (*Article, error) GetArticles(g *Group, from, to int64) ([]NumberedArticle, error) Authorized() bool // Authenticate and optionally swap out the backend for this session. // You may return nil to continue using the same backend. Authenticate(user, pass string) (Backend, error) AllowPost() bool Post(article *Article) error }
The Backend that provides the things and does the stuff.
type Error ¶
An NNTPError is a coded NNTP error message.
type Group ¶
type Group struct { Name string Description string Count int64 High int64 Low int64 Posting PostingStatus }
Group represents a newsgroup.
type Handler ¶
Handler is a low-level protocol handler
type NumberedArticle ¶
A NumberedArticle provides local sequence nubers to articles When listing articles in a group.
type PostingStatus ¶
type PostingStatus byte
PostingStatus type for groups.
func (PostingStatus) String ¶
func (ps PostingStatus) String() string
type Server ¶
type Server struct { // Handlers are dispatched by command name. Handlers map[string]Handler // The backend (your code) that provides data Backend Backend // contains filtered or unexported fields }
The Server handle.
func NewServer ¶
NewServer builds a new server handle request to a backend.