Documentation
¶
Overview ¶
Package nntpcli is a generated GoMock package.
Package nntp provides base NNTP definitions.
Package nntpcli is a generated GoMock package.
Index ¶
- Constants
- Variables
- func IsArticleNotFoundError(err error) bool
- func IsSegmentAlreadyExistsError(err error) bool
- type Article
- type ArticleBodyReader
- type Client
- type Config
- type Connection
- type ContextDialer
- type DialConfig
- type Group
- type MockClient
- type MockClientMockRecorder
- type MockConnection
- func (m *MockConnection) Authenticate(username, password string) error
- func (m *MockConnection) BodyDecoded(msgID string, w io.Writer, discard int64) (int64, error)
- func (m *MockConnection) BodyPipelined(requests []PipelineRequest) []PipelineResult
- func (m *MockConnection) BodyReader(msgID string) (ArticleBodyReader, error)
- func (m *MockConnection) Capabilities() ([]string, error)
- func (m *MockConnection) Close() error
- func (m *MockConnection) CurrentJoinedGroup() string
- func (m *MockConnection) EXPECT() *MockConnectionMockRecorder
- func (m *MockConnection) JoinGroup(name string) error
- func (m *MockConnection) MaxAgeTime() time.Time
- func (m *MockConnection) Ping() error
- func (m *MockConnection) Post(r io.Reader) (int64, error)
- func (m *MockConnection) Stat(msgID string) (int, error)
- func (m *MockConnection) TestPipelineSupport(testMsgID string) (bool, int, error)
- type MockConnectionMockRecorder
- func (mr *MockConnectionMockRecorder) Authenticate(username, password any) *gomock.Call
- func (mr *MockConnectionMockRecorder) BodyDecoded(msgID, w, discard any) *gomock.Call
- func (mr *MockConnectionMockRecorder) BodyPipelined(requests any) *gomock.Call
- func (mr *MockConnectionMockRecorder) BodyReader(msgID any) *gomock.Call
- func (mr *MockConnectionMockRecorder) Capabilities() *gomock.Call
- func (mr *MockConnectionMockRecorder) Close() *gomock.Call
- func (mr *MockConnectionMockRecorder) CurrentJoinedGroup() *gomock.Call
- func (mr *MockConnectionMockRecorder) JoinGroup(name any) *gomock.Call
- func (mr *MockConnectionMockRecorder) MaxAgeTime() *gomock.Call
- func (mr *MockConnectionMockRecorder) Ping() *gomock.Call
- func (mr *MockConnectionMockRecorder) Post(r any) *gomock.Call
- func (mr *MockConnectionMockRecorder) Stat(msgID any) *gomock.Call
- func (mr *MockConnectionMockRecorder) TestPipelineSupport(testMsgID any) *gomock.Call
- type MockContextDialer
- type MockContextDialerMockRecorder
- type NNTPError
- type Option
- type PipelineRequest
- type PipelineResult
- type PostingStatus
- type YencHeaders
Constants ¶
const ( // 2xx - Positive Completion StatusReady = 200 // Service available, posting allowed StatusReadyNoPosting = 201 // Service available, posting prohibited StatusQuit = 205 // Connection closing StatusGroupSelected = 211 // Group selected StatusBodyFollows = 222 // Body article retrieved StatusStatSuccess = 223 // Article exists StatusArticlePosted = 240 // Article posted successfully StatusAuthenticated = 281 // Authentication successful // 3xx - Positive Intermediate StatusPasswordRequired = 340 // Password required StatusMoreAuthInfoRequired = 381 // More authentication information required // 4xx - Transient Negative Completion StatusNoSuchGroup = 411 // No such newsgroup StatusNoArticleSelected = 420 // No article selected StatusNoSuchArticleNumber = 423 // No article with that number StatusNoSuchArticle = 430 // No article with that message-id // 5xx - Permanent Negative Completion StatusCommandUnknown = 500 // Command not recognized StatusCommandSyntaxError = 501 // Command syntax error StatusPermissionDenied = 502 // Permission denied / Too many connections StatusProgramFault = 503 // Program fault )
NNTP response codes as defined in RFC 3977
const ( Unknown = PostingStatus(0) PostingPermitted = PostingStatus('y') PostingNotPermitted = PostingStatus('n') PostingModerated = PostingStatus('m') )
PostingStatus values.
const ( SegmentAlreadyExistsErrCode = 441 TooManyConnectionsErrCode = 502 CanNotJoinGroup = 411 ArticleNotFoundErrCode = 430 )
const (
NumberOfStatResParams = 3
)
Legacy constants for backward compatibility
Variables ¶
var ( ErrCapabilitiesUnpopulated = errors.New("capabilities unpopulated") ErrNoSuchCapability = errors.New("no such capability") ErrNilNttpConn = errors.New("nil nntp connection") ErrArticleNotFound = errors.New("article not found") ErrSegmentAlreadyExists = errors.New("segment already exists") )
Functions ¶
func IsArticleNotFoundError ¶
Types ¶
type Article ¶
type Article struct {
// The article's headers
Header textproto.MIMEHeader
// The article's body
Body io.Reader
// Number of bytes in the article body (used by OVER/XOVER)
Bytes int
// Number of lines in the article body (used by OVER/XOVER)
Lines int
}
An Article that may appear in one or more groups.
type ArticleBodyReader ¶
type ArticleBodyReader interface {
io.ReadCloser
GetYencHeaders() (YencHeaders, error)
}
type Client ¶
type Client interface {
Dial(
ctx context.Context,
host string,
port int,
config ...DialConfig,
) (Connection, error)
DialTLS(
ctx context.Context,
host string,
port int,
insecureSSL bool,
config ...DialConfig,
) (Connection, error)
}
type Connection ¶
type Connection interface {
io.Closer
Authenticate(username, password string) (err error)
JoinGroup(name string) error
BodyDecoded(msgID string, w io.Writer, discard int64) (int64, error)
BodyReader(msgID string) (ArticleBodyReader, error)
// BodyPipelined sends multiple BODY commands in a pipeline and returns results in order.
// This method sends all BODY commands before reading any responses, which can significantly
// improve throughput on high-latency connections.
// If requests is empty, returns an empty slice.
// If requests has only one element, falls back to sequential BodyDecoded for simplicity.
BodyPipelined(requests []PipelineRequest) []PipelineResult
// TestPipelineSupport tests if the server supports pipelining by sending multiple
// STAT commands for the same message ID and verifying all responses are received correctly.
// Returns true if pipelining is supported, along with a suggested pipeline depth based on
// measured round-trip latency.
// Suggested depth ranges: 2-4 for <50ms latency, 4-6 for 50-100ms, 6-10 for >100ms.
TestPipelineSupport(testMsgID string) (supported bool, suggestedDepth int, err error)
Post(r io.Reader) (int64, error)
Ping() error
CurrentJoinedGroup() string
MaxAgeTime() time.Time
Stat(msgID string) (int, error)
Capabilities() ([]string, error)
}
type ContextDialer ¶ added in v2.3.0
type ContextDialer interface {
DialContext(ctx context.Context, network, address string) (net.Conn, error)
}
ContextDialer is a dialer that supports context. Use this for proxy connections or custom dialing behavior.
type DialConfig ¶
type DialConfig struct {
KeepAliveTime time.Duration
DialTimeout time.Duration
// Dialer is an optional custom dialer. If nil, net.Dialer is used.
// Use this for proxy connections.
Dialer ContextDialer
}
type Group ¶
type Group struct {
Name string
Description string
Count int64
High int64
Low int64
Posting PostingStatus
}
Group represents a usenet newsgroup.
type MockClient ¶
type MockClient struct {
// contains filtered or unexported fields
}
MockClient is a mock of Client interface.
func NewMockClient ¶
func NewMockClient(ctrl *gomock.Controller) *MockClient
NewMockClient creates a new mock instance.
func (*MockClient) Dial ¶
func (m *MockClient) Dial(ctx context.Context, host string, port int, config ...DialConfig) (Connection, error)
Dial mocks base method.
func (*MockClient) DialTLS ¶
func (m *MockClient) DialTLS(ctx context.Context, host string, port int, insecureSSL bool, config ...DialConfig) (Connection, error)
DialTLS mocks base method.
func (*MockClient) EXPECT ¶
func (m *MockClient) EXPECT() *MockClientMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MockClientMockRecorder ¶
type MockClientMockRecorder struct {
// contains filtered or unexported fields
}
MockClientMockRecorder is the mock recorder for MockClient.
type MockConnection ¶
type MockConnection struct {
// contains filtered or unexported fields
}
MockConnection is a mock of Connection interface.
func NewMockConnection ¶
func NewMockConnection(ctrl *gomock.Controller) *MockConnection
NewMockConnection creates a new mock instance.
func (*MockConnection) Authenticate ¶
func (m *MockConnection) Authenticate(username, password string) error
Authenticate mocks base method.
func (*MockConnection) BodyDecoded ¶
BodyDecoded mocks base method.
func (*MockConnection) BodyPipelined ¶ added in v2.3.0
func (m *MockConnection) BodyPipelined(requests []PipelineRequest) []PipelineResult
BodyPipelined mocks base method.
func (*MockConnection) BodyReader ¶
func (m *MockConnection) BodyReader(msgID string) (ArticleBodyReader, error)
BodyReader mocks base method.
func (*MockConnection) Capabilities ¶
func (m *MockConnection) Capabilities() ([]string, error)
Capabilities mocks base method.
func (*MockConnection) CurrentJoinedGroup ¶
func (m *MockConnection) CurrentJoinedGroup() string
CurrentJoinedGroup mocks base method.
func (*MockConnection) EXPECT ¶
func (m *MockConnection) EXPECT() *MockConnectionMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockConnection) JoinGroup ¶
func (m *MockConnection) JoinGroup(name string) error
JoinGroup mocks base method.
func (*MockConnection) MaxAgeTime ¶
func (m *MockConnection) MaxAgeTime() time.Time
MaxAgeTime mocks base method.
func (*MockConnection) Post ¶
func (m *MockConnection) Post(r io.Reader) (int64, error)
Post mocks base method.
func (*MockConnection) Stat ¶
func (m *MockConnection) Stat(msgID string) (int, error)
Stat mocks base method.
func (*MockConnection) TestPipelineSupport ¶ added in v2.3.0
func (m *MockConnection) TestPipelineSupport(testMsgID string) (bool, int, error)
TestPipelineSupport mocks base method.
type MockConnectionMockRecorder ¶
type MockConnectionMockRecorder struct {
// contains filtered or unexported fields
}
MockConnectionMockRecorder is the mock recorder for MockConnection.
func (*MockConnectionMockRecorder) Authenticate ¶
func (mr *MockConnectionMockRecorder) Authenticate(username, password any) *gomock.Call
Authenticate indicates an expected call of Authenticate.
func (*MockConnectionMockRecorder) BodyDecoded ¶
func (mr *MockConnectionMockRecorder) BodyDecoded(msgID, w, discard any) *gomock.Call
BodyDecoded indicates an expected call of BodyDecoded.
func (*MockConnectionMockRecorder) BodyPipelined ¶ added in v2.3.0
func (mr *MockConnectionMockRecorder) BodyPipelined(requests any) *gomock.Call
BodyPipelined indicates an expected call of BodyPipelined.
func (*MockConnectionMockRecorder) BodyReader ¶
func (mr *MockConnectionMockRecorder) BodyReader(msgID any) *gomock.Call
BodyReader indicates an expected call of BodyReader.
func (*MockConnectionMockRecorder) Capabilities ¶
func (mr *MockConnectionMockRecorder) Capabilities() *gomock.Call
Capabilities indicates an expected call of Capabilities.
func (*MockConnectionMockRecorder) Close ¶
func (mr *MockConnectionMockRecorder) Close() *gomock.Call
Close indicates an expected call of Close.
func (*MockConnectionMockRecorder) CurrentJoinedGroup ¶
func (mr *MockConnectionMockRecorder) CurrentJoinedGroup() *gomock.Call
CurrentJoinedGroup indicates an expected call of CurrentJoinedGroup.
func (*MockConnectionMockRecorder) JoinGroup ¶
func (mr *MockConnectionMockRecorder) JoinGroup(name any) *gomock.Call
JoinGroup indicates an expected call of JoinGroup.
func (*MockConnectionMockRecorder) MaxAgeTime ¶
func (mr *MockConnectionMockRecorder) MaxAgeTime() *gomock.Call
MaxAgeTime indicates an expected call of MaxAgeTime.
func (*MockConnectionMockRecorder) Ping ¶
func (mr *MockConnectionMockRecorder) Ping() *gomock.Call
Ping indicates an expected call of Ping.
func (*MockConnectionMockRecorder) Post ¶
func (mr *MockConnectionMockRecorder) Post(r any) *gomock.Call
Post indicates an expected call of Post.
func (*MockConnectionMockRecorder) Stat ¶
func (mr *MockConnectionMockRecorder) Stat(msgID any) *gomock.Call
Stat indicates an expected call of Stat.
func (*MockConnectionMockRecorder) TestPipelineSupport ¶ added in v2.3.0
func (mr *MockConnectionMockRecorder) TestPipelineSupport(testMsgID any) *gomock.Call
TestPipelineSupport indicates an expected call of TestPipelineSupport.
type MockContextDialer ¶ added in v2.3.0
type MockContextDialer struct {
// contains filtered or unexported fields
}
MockContextDialer is a mock of ContextDialer interface.
func NewMockContextDialer ¶ added in v2.3.0
func NewMockContextDialer(ctrl *gomock.Controller) *MockContextDialer
NewMockContextDialer creates a new mock instance.
func (*MockContextDialer) DialContext ¶ added in v2.3.0
func (m *MockContextDialer) DialContext(ctx context.Context, network, address string) (net.Conn, error)
DialContext mocks base method.
func (*MockContextDialer) EXPECT ¶ added in v2.3.0
func (m *MockContextDialer) EXPECT() *MockContextDialerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MockContextDialerMockRecorder ¶ added in v2.3.0
type MockContextDialerMockRecorder struct {
// contains filtered or unexported fields
}
MockContextDialerMockRecorder is the mock recorder for MockContextDialer.
func (*MockContextDialerMockRecorder) DialContext ¶ added in v2.3.0
func (mr *MockContextDialerMockRecorder) DialContext(ctx, network, address any) *gomock.Call
DialContext indicates an expected call of DialContext.
type NNTPError ¶ added in v2.3.2
NNTPError represents a numeric error response from an NNTP server. It replaces textproto.Error to remove the dependency on net/textproto.
type PipelineRequest ¶ added in v2.3.0
type PipelineRequest struct {
// MessageID is the article message ID to retrieve.
MessageID string
// Writer is the destination for the decoded body content.
Writer io.Writer
// Discard is the number of bytes to discard from the beginning of the body.
// Use 0 for full download.
Discard int64
}
PipelineRequest represents a single body request in a pipeline.
type PipelineResult ¶ added in v2.3.0
type PipelineResult struct {
// MessageID is the article message ID that was requested.
MessageID string
// BytesWritten is the number of bytes written to the writer.
BytesWritten int64
// Error is any error that occurred during the request.
// nil indicates success.
Error error
}
PipelineResult represents the result of a pipelined body request.
type PostingStatus ¶
type PostingStatus byte
PostingStatus type for groups.
func (PostingStatus) String ¶
func (ps PostingStatus) String() string