Documentation ¶
Overview ¶
RFC5322 date parsing. Copied from net/mail Go standard library package.
The nntp package 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) (io.Reader, error)
- func (c *Conn) Authenticate(username, password string) error
- func (c *Conn) Body(id string) (io.Reader, error)
- func (c *Conn) Capabilities() ([]string, error)
- func (c *Conn) Date() (time.Time, error)
- func (c *Conn) Group(group string) (number, low, high int, err error)
- func (c *Conn) Head(id string) (*Article, error)
- func (c *Conn) HeadText(id string) (io.Reader, error)
- func (c *Conn) Help() (io.Reader, 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) 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 int) ([]MessageOverview, error)
- func (c *Conn) Post(a *Article) error
- func (c *Conn) Quit() error
- func (c *Conn) RawPost(r io.Reader) error
- func (c *Conn) Stat(id string) (number, msgid string, err error)
- type 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 {
// 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 Dial ¶
Dial 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 an io.Reader. 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) 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 an io.Reader. 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) 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 int) ([]MessageOverview, error)
Overview returns overviews of all messages in the current group with message number between begin and end, inclusive.
type Group ¶
type Group struct { Name string // High and low message-numbers High, Low int // 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 int // 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. }
Overview of a message returned by OVER command.
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