fastnntp

package module
v0.0.0-...-b16c261 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2021 License: MIT Imports: 10 Imported by: 17

README

fastnntp

Fast NNTP server

Documentation

Index

Constants

View Source
const (
	LAM_Full = ListActiveMode(iota)
	LAM_Active
	LAM_Newsgroups
)

Variables

View Source
var DefaultCaps = new(defCaps)
View Source
var ErrAuthRejected = &NNTPError{452, "authorization rejected"}

ErrAuthRejected is returned for invalid authentication.

View Source
var ErrAuthRequired = &NNTPError{450, "authorization required"}

ErrAuthRequired is returned to indicate authentication is required to proceed.

View Source
var ErrIHaveFailed = &NNTPError{436, "Transfer failed; try again later"}

ErrIHaveFailed is returned when an attempt to ihave an article fails AFTER the transfer of the article.

View Source
var ErrIHaveNotPossible = &NNTPError{436, "Transfer not possible; try again later"}

ErrIHaveNopPossible is the same as ErrIHaveFailed, except the text. ErrIHaveNopPossible is returned when an attempt to ihave an article fails BEFORE the transfer of the article.

View Source
var ErrIHaveRejected = &NNTPError{437, "Transfer rejected; do not retry"}

ErrIHaveRejected is returned when an attempt to ihave an article is rejected due the server not wanting the article.

View Source
var ErrInvalidArticleNumber = &NNTPError{423, "No article with that number"}

ErrInvalidArticleNumber is returned when an article is requested that can't be found.

View Source
var ErrInvalidArticleRange = &NNTPError{423, "No articles in that range"}

ErrInvalidArticleNumber with other text

View Source
var ErrInvalidMessageID = &NNTPError{430, "No article with that message-id"}

ErrInvalidMessageID is returned when a message is requested that can't be found.

View Source
var ErrNoCurrentArticle = &NNTPError{420, "Current article number is invalid"}

ErrNoCurrentArticle is returned when a command is executed that requires a current article when one has not been selected.

View Source
var ErrNoGroupSelected = &NNTPError{412, "No newsgroup selected"}

ErrNoSuchGroup is returned for a request that requires a current group when none has been selected.

View Source
var ErrNoNextArticle = &NNTPError{421, "No next article to retrieve"}

ErrNoNextArticle is returned when LAST or NEXT reaches the end of its iteration

View Source
var ErrNoPreviousArticle = &NNTPError{422, "No previous article to retrieve"}

ErrNoPreviousArticle is returned when LAST or NEXT reaches the end of its iteration

View Source
var ErrNoSuchGroup = &NNTPError{411, "No such newsgroup"}

ErrNoSuchGroup is returned for a request for a group that can't be found.

View Source
var ErrNotAuthenticated = &NNTPError{480, "authentication required"}

ErrNotAuthenticated is returned when a command is issued that requires authentication, but authentication was not provided.

View Source
var ErrNotWanted = &NNTPError{435, "Article not wanted"}

ErrNotWanted is returned when an attempt to ihave an article is rejected due the server not wanting the article.

View Source
var ErrPostingFailed = &NNTPError{441, "posting failed"}

ErrPostingFailed is returned when an attempt to post an article fails.

View Source
var ErrPostingNotPermitted = &NNTPError{440, "Posting not permitted"}

ErrPostingNotPermitted is returned as the response to an attempt to post an article where posting is not permitted.

View Source
var ErrSyntax = &NNTPError{501, "not supported, or syntax error"}

ErrSyntax is returned when a command can't be parsed.

View Source
var ErrUnknownCommand = &NNTPError{500, "Unknown command"}

ErrUnknownCommand is returned for unknown comands.

Functions

func AcquireBufferedWriter

func AcquireBufferedWriter(w io.Writer) (bw *bufio.Writer)

func AppendUint

func AppendUint(dst []byte, n int64) []byte

func ParseRange

func ParseRange(src []byte) (int64, int64)

func ParseUint

func ParseUint(src []byte) (i int64)

func ReleaseBufferedWriter

func ReleaseBufferedWriter(bw *bufio.Writer)

Types

type Article

type Article struct {
	MessageId []byte
	Group     []byte
	Number    int64
	HasId     bool
	HasNum    bool
}

type ArticleCaps

type ArticleCaps interface {
	StatArticle(a *Article) bool
	GetArticle(a *Article, head, body bool) func(w *DotWriter)
	WriteOverview(ar *ArticleRange) func(w IOverview)
}

type ArticleRange

type ArticleRange struct {
	Article
	LastNumber int64
}

type DotReader

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

func (*DotReader) Consume

func (d *DotReader) Consume()

Consumes until end.

func (*DotReader) Read

func (d *DotReader) Read(b []byte) (int, error)

func (*DotReader) Release

func (r *DotReader) Release()
func AcquireDotReader() *DotReader {
	return pool_DotReader.Get().(*DotReader)
}

type DotWriter

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

A io.Writer-Wrapper, that enables dot-line ended content to be written. After the final ".\r\n", any further content is discarded. The final ".\r\n" is addedd, if the content didn't contain any.

func AcquireDotWriter

func AcquireDotWriter() *DotWriter

func (*DotWriter) Close

func (w *DotWriter) Close() (e error)

func (*DotWriter) Release

func (w *DotWriter) Release()

func (*DotWriter) Reset

func (w *DotWriter) Reset(wr io.Writer)

func (*DotWriter) Write

func (w *DotWriter) Write(buf []byte) (int, error)

type Group

type Group struct {
	Group  []byte
	Number int64
	Low    int64
	High   int64
}

type GroupCaps

type GroupCaps interface {
	GetGroup(g *Group) bool
	ListGroup(g *Group, w *DotWriter, first, last int64)
	CursorMoveGroup(g *Group, i int64, backward bool, id_buf []byte) (ni int64, id []byte, ok bool)
}

type GroupListingCaps

type GroupListingCaps interface {
	// Performs a List-Active action.
	// the argument 'wm' may be nil.
	ListGroups(wm *WildMat, ila IListActive) bool
}

type Handler

func (*Handler) ServeConn

func (h *Handler) ServeConn(conn io.ReadWriteCloser) error

type HeadBodyWriter

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

A Writer for postings that consist of a Head and a Body.

Here is an example, of what kind of message will be split into Head and Body:

Subject: This is the head
Message-ID: Blubb blubb
From: Hugo Meyer <h.meyer@example.org>

This is the 1. line of the Body.
This is the 2. line of the Body.
...
This is the last line of the Body.
. (trailing <CRLF>.<CRLF>)

func AcquireHeadBodyWriter

func AcquireHeadBodyWriter() *HeadBodyWriter

func (*HeadBodyWriter) Release

func (w *HeadBodyWriter) Release()

func (*HeadBodyWriter) Reset

func (w *HeadBodyWriter) Reset(head, body io.Writer)

func (*HeadBodyWriter) Write

func (w *HeadBodyWriter) Write(buf []byte) (int, error)

type IListActive

type IListActive interface {
	GetListActiveMode() ListActiveMode

	// This function may be used if, and only if GetListActiveMode() returns LAM_Active
	WriteActive(group []byte, high, low int64, status byte) error

	// This function may be used if, and only if GetListActiveMode() returns LAM_Newsgroups
	WriteNewsgroups(group []byte, description []byte) error

	WriteFullInfo(group []byte, high, low int64, status byte, description []byte) error
}

type IOverview

type IOverview interface {
	WriteEntry(num int64, subject, from, date, msgId, refs []byte, lng, lines int64) error
}

type ListActive

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

func (*ListActive) GetListActiveMode

func (ov *ListActive) GetListActiveMode() ListActiveMode

func (*ListActive) WriteActive

func (ov *ListActive) WriteActive(group []byte, high, low int64, status byte) error

func (*ListActive) WriteFullInfo

func (ov *ListActive) WriteFullInfo(group []byte, high, low int64, status byte, description []byte) error

func (*ListActive) WriteNewsgroups

func (ov *ListActive) WriteNewsgroups(group []byte, description []byte) error

type ListActiveMode

type ListActiveMode int

type LoginCaps

type LoginCaps interface {
	// This Method SHOULD return true, if authentication has already occurred.
	AuthinfoDone(h *Handler) bool

	// Checks a privilege. Returns true if it is allowed.
	AuthinfoCheckPrivilege(p LoginPriv, h *Handler) bool

	// This Method returns true, if the combination of username is accepted without password.
	// The method can optionally return a new Handler object in place of the old one.
	AuthinfoUserOny(user []byte, oldh *Handler) (bool, *Handler)

	// This Method returns true, if the combination of username and password is accepted.
	AuthinfoUserPass(user, password []byte, oldh *Handler) (bool, *Handler)
}

NNTP Authentication. Documented outside RFC 3977 --> RFC 4643

type LoginPriv

type LoginPriv uint

Privilege for a user.

const (
	LoginPriv_Post LoginPriv = iota
)

type NNTPError

type NNTPError struct {
	Code int
	Msg  string
}

An NNTPError is a coded NNTP error message.

type Overview

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

func (*Overview) WriteEntry

func (ov *Overview) WriteEntry(num int64, subject, from, date, msgId, refs []byte, lng, lines int64) error

type PostingCaps

type PostingCaps interface {
	CheckPostId(id []byte) (wanted bool, possible bool)
	CheckPost() (possible bool)
	PerformPost(id []byte, r *DotReader) (rejected bool, failed bool)
}

type Reader

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

A reader.

func AcquireReader

func AcquireReader() *Reader

func (*Reader) DotReader

func (r *Reader) DotReader() (d *DotReader)

func (*Reader) Init

func (r *Reader) Init(rdr io.Reader) *Reader

func (*Reader) Read

func (r *Reader) Read(b []byte) (int, error)

func (*Reader) ReadLineB

func (r *Reader) ReadLineB(ext []byte) ([]byte, error)

func (*Reader) Release

func (r *Reader) Release()

type WildMat

type WildMat struct {
	RuleSets []*WildMatRuleSet
}

func ParseWildMat

func ParseWildMat(wm string) *WildMat

func ParseWildMatBinary

func ParseWildMatBinary(wm []byte) *WildMat

func (*WildMat) Compile

func (wmrs *WildMat) Compile() error

func (*WildMat) Match

func (wmrs *WildMat) Match(s []byte) bool

func (*WildMat) MatchString

func (wmrs *WildMat) MatchString(s string) bool

func (*WildMat) String

func (wmrs *WildMat) String() string

type WildMatRuleSet

type WildMatRuleSet struct {
	Positive []string
	Negative []string
	PR       *regexp.Regexp
	NR       *regexp.Regexp
}

func (*WildMatRuleSet) Compile

func (wmrs *WildMatRuleSet) Compile() (e error)

func (*WildMatRuleSet) Match

func (wmrs *WildMatRuleSet) Match(s []byte) bool

func (*WildMatRuleSet) MatchString

func (wmrs *WildMatRuleSet) MatchString(s string) bool

Directories

Path Synopsis
Utilities for Article Posting processing.
Utilities for Article Posting processing.

Jump to

Keyboard shortcuts

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