nntpserver

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: MIT Imports: 14 Imported by: 1

Documentation

Overview

Package nntpserver provides everything you need for your own NNTP server.

Index

Constants

View Source
const (
	DefaultDBPath    = "nntp.db"
	ArticleNumberKey = "article_number"
)
View Source
const (
	Unknown             = PostingStatus(0)
	PostingPermitted    = PostingStatus('y')
	PostingNotPermitted = PostingStatus('n')
	PostingModerated    = PostingStatus('m')
)

PostingStatus values.

Variables

View Source
var ErrAuthRejected = &NNTPError{452, "authorization rejected"}
View Source
var ErrAuthRequired = &NNTPError{450, "authorization required"}
View Source
var ErrInvalidArticleNumber = &NNTPError{423, "No article with that number"}
View Source
var ErrInvalidMessageID = &NNTPError{430, "No article with that message-id"}
View Source
var ErrNoCurrentArticle = &NNTPError{420, "Current article number is invalid"}
View Source
var ErrNoGroupSelected = &NNTPError{412, "No newsgroup selected"}
View Source
var ErrNoSuchGroup = &NNTPError{411, "No such newsgroup"}
View Source
var ErrNotAuthenticated = &NNTPError{480, "authentication required"}
View Source
var ErrNotWanted = &NNTPError{435, "Article not wanted"}
View Source
var ErrPostingFailed = &NNTPError{441, "posting failed"}
View Source
var ErrPostingNotPermitted = &NNTPError{440, "Posting not permitted"}
View Source
var ErrSyntax = &NNTPError{501, "not supported, or syntax error"}
View Source
var ErrUnknownCommand = &NNTPError{500, "Unknown command"}

Functions

This section is empty.

Types

type Article

type Article struct {
	Header textproto.MIMEHeader
	Body   io.Reader
	Bytes  int
	Lines  int
}

func (*Article) MessageID

func (a *Article) MessageID() string

type Backend

type Backend interface {
	ListGroups(max int) ([]*Group, error)
	GetGroup(name string) (*Group, error)
	GetArticle(group *Group, id string) (*Article, error)
	GetArticles(group *Group, from, to int64) ([]NumberedArticle, error)
	Authorized() bool
	Authenticate(user, pass string) (Backend, error)
	AllowPost() bool
	Post(article *Article) error
	Stat(group *Group, id string) (string, string, error)
}

type DiskBackend

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

func NewDiskBackend

func NewDiskBackend(
	cleanOnClose bool,
	dbPath string,
) *DiskBackend

func (*DiskBackend) AllowPost

func (b *DiskBackend) AllowPost() bool

func (*DiskBackend) Authenticate

func (b *DiskBackend) Authenticate(user, pass string) (Backend, error)

func (*DiskBackend) Authorized

func (b *DiskBackend) Authorized() bool

func (*DiskBackend) Close

func (b *DiskBackend) Close() error

func (*DiskBackend) GetArticle

func (b *DiskBackend) GetArticle(group *Group, id string) (*Article, error)

func (*DiskBackend) GetArticles

func (b *DiskBackend) GetArticles(group *Group, from, to int64) ([]NumberedArticle, error)

func (*DiskBackend) GetGroup

func (b *DiskBackend) GetGroup(name string) (*Group, error)

func (*DiskBackend) ListGroups

func (b *DiskBackend) ListGroups(max int) ([]*Group, error)

func (*DiskBackend) Post

func (b *DiskBackend) Post(article *Article) error

func (*DiskBackend) Stat

func (b *DiskBackend) Stat(group *Group, id string) (string, string, error)

type Group

type Group struct {
	Name        string
	Description string
	Count       int64
	High        int64
	Low         int64
	Posting     PostingStatus
}

type Handler

type Handler func(args []string, s *session, c *textproto.Conn) error

type NNTPError

type NNTPError struct {
	Code int
	Msg  string
}

func (*NNTPError) Error

func (e *NNTPError) Error() string

type NumberedArticle

type NumberedArticle struct {
	Num     int64
	Article *Article
}

type PostingStatus

type PostingStatus byte

PostingStatus type for groups.

func (PostingStatus) String

func (ps PostingStatus) String() string

type Server

type Server struct {
	Handlers map[string]Handler
	Backend  Backend
	// contains filtered or unexported fields
}

func NewServer

func NewServer(backend Backend) *Server

func (*Server) Process

func (s *Server) Process(nc net.Conn)

Process an NNTP session.

Jump to

Keyboard shortcuts

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