nntp

package module
Version: v0.0.0-...-d0382e0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2015 License: MIT Imports: 10 Imported by: 1

README

nntp

-- import "github.com/andrewstuart/nntp"

Usage

const (
	ArticleFound    = 220
	NoArticleWithId = 430
)
const (
	AuthAccepted   = 281
	PasswordNeeded = 381
	AuthNeeded     = 480
	BadAuth        = 481
	ConnsExceeded  = 502
)

https://tools.ietf.org/html/rfc4643

const (
	GroupJoined = 211
	NoSuchGroup = 411
)
const (
	CapabilitiesFollow = 101
)
const HeadersFollow = 221
const (
	InfoFollows = 215
)
var (
	TooManyConns = ConnErr{ConnsExceeded, "too many connections"}
	AuthRejected = ConnErr{BadAuth, "credentials rejected"}
)
var (
	IllegalResponse = fmt.Errorf("illegal response")
	IllegalHeader   = fmt.Errorf("illegal headers")
)
type Client
type Client struct {
	MaxConns, Port     int
	Server, User, Pass string
	Tls                bool
}
func NewClient
func NewClient(server string, port int) *Client
func (*Client) Auth
func (cli *Client) Auth(u, p string) error
func (*Client) Capabilities
func (cli *Client) Capabilities() ([]string, error)
func (*Client) Do
func (cli *Client) Do(format string, args ...interface{}) (*Response, error)
func (*Client) GetArticle
func (cli *Client) GetArticle(group, id string) (res *Response, err error)

Client method GetArticle

func (*Client) Head
func (cli *Client) Head(group, id string) (*Response, error)
func (*Client) JoinGroup
func (cli *Client) JoinGroup(name string) error
func (*Client) List
func (cli *Client) List() ([]Group, error)
func (*Client) ListGroup
func (cli *Client) ListGroup(gid string) ([]string, error)
func (*Client) SetMaxConns
func (cli *Client) SetMaxConns(n int)
type Conn
type Conn struct {
}
func NewConn
func NewConn(c io.ReadWriteCloser, wrappers ...func(io.Reader) io.Reader) *Conn
func (*Conn) Auth
func (conn *Conn) Auth(u, p string) error
func (*Conn) Close
func (c *Conn) Close() error
func (*Conn) Do
func (c *Conn) Do(format string, is ...interface{}) (*Response, error)
func (*Conn) Wrap
func (c *Conn) Wrap(fn ...func(io.Reader) io.Reader)
type ConnErr
type ConnErr struct {
	Code   int    `json:"code"xml:"code"`
	Reason string `json:"reason"xml:"reason"`
}
func (ConnErr) Error
func (c ConnErr) Error() string
type Group
type Group struct {
	Id           string
	Count, First int
}
type Reader
type Reader struct {
	R *bufio.Reader
}

A Reader is a read/closer that strips NNTP newlines and will unescape characters.

func NewReader
func NewReader(r io.Reader) *Reader

NewReader returns an nntp.Reader for the body of the nttp article.

func (*Reader) Close
func (r *Reader) Close() error

Close allows users of a Reader to signal that they are done using the reader.

func (*Reader) Read
func (r *Reader) Read(p []byte) (bytesRead int, err error)

The Read method handles translation of the NNTP escaping and marking EOF when the end of a body is received.

type Response
type Response struct {
	Code    int                  `json:"code"xml:"code"`
	Message string               `json:"message"xml:"message"`
	Headers textproto.MIMEHeader `json:"headers"xml:"headers"`
	Body    io.ReadCloser        `json:"body"xml:"body"` //Presence (non-nil) indicates multi-line response
}
func NewResponse
func NewResponse(r io.Reader) (*Response, error)

Documentation

Index

Constants

View Source
const (
	ArticleFound    = 220
	NoArticleWithId = 430
)
View Source
const (
	AuthAccepted   = 281
	PasswordNeeded = 381
	AuthNeeded     = 480
	BadAuth        = 481
	ConnsExceeded  = 502
)

https://tools.ietf.org/html/rfc4643

View Source
const (
	GroupJoined = 211
	NoSuchGroup = 411
)
View Source
const (
	CapabilitiesFollow = 101
)
View Source
const HeadersFollow = 221
View Source
const (
	InfoFollows = 215
)

Variables

View Source
var (
	TooManyConns = ConnErr{ConnsExceeded, "too many connections"}
	AuthRejected = ConnErr{BadAuth, "credentials rejected"}
)
View Source
var (
	IllegalResponse = fmt.Errorf("illegal response")
	IllegalHeader   = fmt.Errorf("illegal headers")
)

Functions

This section is empty.

Types

type Client

type Client struct {
	MaxConns, Port     int
	Server, User, Pass string
	Tls                bool
	// contains filtered or unexported fields
}

func NewClient

func NewClient(server string, port int) *Client

func (*Client) Auth

func (cli *Client) Auth(u, p string) error

func (*Client) Capabilities

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

func (*Client) Do

func (cli *Client) Do(format string, args ...interface{}) (*Response, error)

func (*Client) GetArticle

func (cli *Client) GetArticle(group, id string) (res *Response, err error)

Client method GetArticle

func (*Client) Head

func (cli *Client) Head(group, id string) (*Response, error)

func (*Client) JoinGroup

func (cli *Client) JoinGroup(name string) error

func (*Client) List

func (cli *Client) List() ([]Group, error)

func (*Client) ListGroup

func (cli *Client) ListGroup(gid string) ([]string, error)

func (*Client) SetMaxConns

func (cli *Client) SetMaxConns(n int)

type Conn

type Conn struct {
	// contains filtered or unexported fields
}

func NewConn

func NewConn(c io.ReadWriteCloser, wrappers ...func(io.Reader) io.Reader) *Conn

func (*Conn) Auth

func (conn *Conn) Auth(u, p string) error

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) Do

func (c *Conn) Do(format string, is ...interface{}) (*Response, error)

func (*Conn) Wrap

func (c *Conn) Wrap(fn ...func(io.Reader) io.Reader)

type ConnErr

type ConnErr struct {
	Code   int    `json:"code"xml:"code"`
	Reason string `json:"reason"xml:"reason"`
}

func (ConnErr) Error

func (c ConnErr) Error() string

type Group

type Group struct {
	Id           string
	Count, First int
}

type Reader

type Reader struct {
	R *bufio.Reader
	// contains filtered or unexported fields
}

A Reader is a read/closer that strips NNTP newlines and will unescape characters.

func NewReader

func NewReader(r io.Reader) *Reader

NewReader returns an nntp.Reader for the body of the nttp article.

func (*Reader) Close

func (r *Reader) Close() error

Close allows users of a Reader to signal that they are done using the reader.

func (*Reader) Read

func (r *Reader) Read(p []byte) (bytesRead int, err error)

The Read method handles translation of the NNTP escaping and marking EOF when the end of a body is received.

type Response

type Response struct {
	Code    int                  `json:"code"xml:"code"`
	Message string               `json:"message"xml:"message"`
	Headers textproto.MIMEHeader `json:"headers"xml:"headers"`
	Body    io.ReadCloser        `json:"body"xml:"body"` //Presence (non-nil) indicates multi-line response
	// contains filtered or unexported fields
}

func NewResponse

func NewResponse(r io.Reader) (*Response, error)

Jump to

Keyboard shortcuts

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