Documentation ¶
Overview ¶
RFC5322 date parsing. Copied from net/mail Go standard library package.
Package nntp implements a client for the news protocol NNTP, as defined in RFC 3977.
Index ¶
- type Article
- type Conn
- func (c *Conn) Article(id string) (*Article, error)
- func (c *Conn) ArticleText(id string) ([]string, error)
- func (c *Conn) Authenticate(username, password string) error
- func (c *Conn) Body(id string) ([]string, error)
- func (c *Conn) Capabilities() ([]string, error)
- func (c *Conn) Command(cmd string, expectCode int) (int, string, error)
- func (c *Conn) Date() (time.Time, error)
- func (c *Conn) Group(group string) (*Group, error)
- func (c *Conn) Head(id string) (*Article, error)
- func (c *Conn) HeadText(id string) ([]string, error)
- func (c *Conn) Help() ([]string, error)
- func (c *Conn) Last() (number, msgid string, err error)
- func (c *Conn) List(a ...string) ([]string, error)
- func (c *Conn) ModeReader() error
- func (c *Conn) MultilineCommand(cmd string, expectCode int) (int, []string, error)
- func (c *Conn) NewGroups(since time.Time) ([]*Group, error)
- func (c *Conn) NewNews(group string, since time.Time) ([]string, error)
- func (c *Conn) Next() (number, msgid string, err error)
- func (c *Conn) Overview(begin, end int64) ([]MessageOverview, error)
- func (c *Conn) Quit() error
- func (c *Conn) RawPost(r io.Reader) error
- func (c *Conn) SetCompression() error
- func (c *Conn) Stat(id string) (number, msgid string, err error)
- type Group
- type MessageOverview
- type ProtocolError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Conn ¶
type Conn struct { Banner string // contains filtered or unexported fields }
A Conn represents a connection to an NNTP server. The connection with an NNTP server is stateful; it keeps track of what group you have selected, if any, and (if you have a group selected) which article is current, next, or previous.
Some methods that return information about a specific message take either a message-id, which is global across all NNTP servers, groups, and messages, or a message-number, which is an integer number that is local to the NNTP session and currently selected group.
For all methods that return an io.Reader (or an *Article, which contains an io.Reader), that io.Reader is only valid until the next call to a method of Conn.
func New ¶
New connects to an NNTP server. The network and addr are passed to net.Dial to make the connection.
Example:
conn, err := nntp.Dial("tcp", "my.news:nntp")
func (*Conn) ArticleText ¶
ArticleText returns the article named by id as a []string. The article is in plain text format, not NNTP wire format.
func (*Conn) Authenticate ¶
Authenticate logs in to the NNTP server. It only sends the password if the server requires one.
func (*Conn) Capabilities ¶
Capabilities returns a list of features this server performs. Not all servers support capabilities.
func (*Conn) Command ¶
Command sends a low-level command and get a response.
This will return an error if the code doesn't match the expectCode prefix. For example, if you specify "200", the response code MUST be 200 or you'll get an error. If you specify "2", any code from 200 (inclusive) to 300 (exclusive) will be success. An expectCode of -1 disables this behavior.
func (*Conn) Date ¶
Date returns the current time on the server. Typically the time is later passed to NewGroups or NewNews.
func (*Conn) Head ¶
Head returns the header for the article named by id as an *Article. The Body field in the Article is nil.
func (*Conn) HeadText ¶
HeadText returns the header for the article named by id as []string. The article is in plain text format, not NNTP wire format.
func (*Conn) List ¶
List returns a list of groups present on the server. Valid forms are:
List() - return active groups List(keyword) - return different kinds of information about groups List(keyword, pattern) - filter groups against a glob-like pattern called a wildmat
func (*Conn) ModeReader ¶
ModeReader switches the NNTP server to "reader" mode, if it is a mode-switching server.
func (*Conn) MultilineCommand ¶
MultilineCommand wraps the functionality to
func (*Conn) NewNews ¶
NewNews returns a list of the IDs of articles posted to the given group since the given time.
func (*Conn) Overview ¶
func (c *Conn) Overview(begin, end int64) ([]MessageOverview, error)
Overview returns overviews of all messages in the current group with message number between begin and end, inclusive.
func (*Conn) SetCompression ¶
SetCompression turns on compression for this connection
type Group ¶
type Group struct { Name string // High and low message-numbers High int64 Low int64 // Estimated count of articles in the group Count int64 // Status indicates if general posting is allowed -- // typical values are "y", "n", or "m". Status string }
A Group gives information about a single news group on the server.
type MessageOverview ¶
type MessageOverview struct { MessageNumber int64 // Message number in the group Subject string // Subject header value. Empty if the header is missing. From string // From header value. Empty is the header is missing. Date time.Time // Parsed Date header value. Zero if the header is missing or unparseable. MessageID string // Message-Id header value. Empty is the header is missing. References []string // Message-Id's of referenced messages (References header value, split on spaces). Empty if the header is missing. Bytes int // Message size in bytes, called :bytes metadata item in RFC3977. Lines int // Message size in lines, called :lines metadata item in RFC3977. Extra []string // Any additional fields returned by the server. }
MessageOverview of a message returned by OVER/XOVER command.
func (*MessageOverview) Xref ¶
func (m *MessageOverview) Xref() string
Xref returns the Xref header if set otherwise the empty string.
type ProtocolError ¶
type ProtocolError string
A ProtocolError represents responses from an NNTP server that seem incorrect for NNTP.
func (ProtocolError) Error ¶
func (p ProtocolError) Error() string