nntpclient

package
v0.0.0-...-f00d51c Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2021 License: MIT Imports: 8 Imported by: 4

Documentation

Overview

Package nntpclient provides an NNTP Client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Banner string
	// contains filtered or unexported fields
}

Client is an NNTP client.

func New

func New(network, addr string) (*Client, error)

New connects a client to an NNTP server.

func NewConn

func NewConn(netconn net.Conn) (*Client, error)

NewConn wraps an existing connection, for example one opened with tls.Dial

func NewTLS

func NewTLS(network, addr string, config *tls.Config) (*Client, error)

NewTLS connects to an NNTP server over a dedicated TLS port like 563

func (*Client) Article

func (c *Client) Article(specifier string) (int64, string, io.Reader, error)

Article grabs an article

func (*Client) Authenticate

func (c *Client) Authenticate(user, pass string) (msg string, err error)

Authenticate against an NNTP server using authinfo user/pass

func (*Client) Body

func (c *Client) Body(specifier string) (int64, string, io.Reader, error)

Body gets the body of an article

func (*Client) Capabilities

func (c *Client) Capabilities() ([]string, error)

Capabilities retrieves a list of supported capabilities.

See https://datatracker.ietf.org/doc/html/rfc3977#section-5.2.2

func (*Client) Close

func (c *Client) Close() error

Close this client.

func (*Client) Command

func (c *Client) Command(cmd string, expectCode int) (int, string, error)

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 (*Client) GetCapability

func (c *Client) GetCapability(capability string) string

GetCapability returns a complete capability line.

"Each capability line consists of one or more tokens, which MUST be separated by one or more space or TAB characters."

From https://datatracker.ietf.org/doc/html/rfc3977#section-3.3.1

func (*Client) Group

func (c *Client) Group(name string) (rv nntp.Group, err error)

Group selects a group.

func (*Client) HasCapabilityArgument

func (c *Client) HasCapabilityArgument(
	capability, argument string,
) (bool, error)

HasCapabilityArgument indicates whether a capability arg is supported.

Here, "argument" means any token after the label in a capabilities response line. Some, like "ACTIVE" in "LIST ACTIVE", are not command arguments but rather "keyword" components of compound commands called "variants."

See https://datatracker.ietf.org/doc/html/rfc3977#section-9.5

func (*Client) HasTLS

func (c *Client) HasTLS() bool

func (*Client) Head

func (c *Client) Head(specifier string) (int64, string, io.Reader, error)

Head gets the headers for an article

func (*Client) List

func (c *Client) List(sub string) (rv []nntp.Group, err error)

List groups

func (*Client) ListOverviewFmt

func (c *Client) ListOverviewFmt() ([]string, error)

ListOverviewFmt performs a LIST OVERVIEW.FMT query.

According to the spec, the presence of an "OVER" line in the capabilities response means this LIST variant is supported, so there's no reason to check for it among the keywords in the "LIST" line, strictly speaking.

See https://datatracker.ietf.org/doc/html/rfc3977#section-3.3.2

func (*Client) Over

func (c *Client) Over(specifier string) ([]string, error)

Over returns a list of raw overview lines with tab-separated fields.

func (*Client) Post

func (c *Client) Post(r io.Reader) error

Post a new article

The reader should contain the entire article, headers and body in RFC822ish format.

func (*Client) StartTLS

func (c *Client) StartTLS(config *tls.Config) error

StartTLS sends the STARTTLS command and refreshes capabilities.

See https://datatracker.ietf.org/doc/html/rfc4642 and net/smtp.go, from which this was adapted, and maybe NNTP.startls in Python's nntplib also.

Jump to

Keyboard shortcuts

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