zdpgo_nntp

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2022 License: MIT Imports: 19 Imported by: 0

README

zdpgo_nntp

NNTP服务,文件上传

版本历史

  • v0.1.0 2022/05/31 新增:NNTP服务和文件上传校验
  • v0.1.1 2022/06/06 升级:升级password密码组件
  • v0.1.2 2022/06/15 升级:升级日志
  • v0.1.3 2022/06/28 优化:移除日志

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultBackend = ServerBackend{
	// contains filtered or unexported fields
}

DefaultBackend 默认后台

Functions

This section is empty.

Types

type Article

type Article struct {
	Uuid       string    `json:"uuid"`
	Group      string    `json:"group"`
	Author     string    `json:"author"`
	Title      string    `json:"title"`
	Content    string    `json:"content"`
	Date       int       `json:"date"`
	DateString string    `json:"date_string"`
	DateTime   time.Time `json:"date_time"`
	MessageId  string    `json:"message_id"`
}

type Auth

type Auth struct {
	Username string `yaml:"username" json:"username"`
	Password string `yaml:"password" json:"password"`
}

type Client

type Client struct {
	Config *Config
}

Client 客户端对象

func (*Client) AddArticle

func (c *Client) AddArticle(article *Article) error

AddArticle 添加文章

func (*Client) GetAddress

func (c *Client) GetAddress() string

GetAddress 获取连接地址

func (*Client) GetArticle

func (c *Client) GetArticle(uuid string) (*Article, error)

GetArticle 根据UUID获取文章

func (*Client) Md5 added in v0.1.3

func (c *Client) Md5(data string) string

Md5 校验MD5

func (*Client) PostBytes

func (c *Client) PostBytes(title string, data []byte) (*Response, error)

PostBytes 上传字节数组

func (*Client) UploadFileAndCheckMd5

func (c *Client) UploadFileAndCheckMd5(filePath string) bool

UploadFileAndCheckMd5 上传文件并检查MD5

type Config

type Config struct {
	Auths  map[string]Auth `yaml:"auths" json:"auths"`
	Server HttpInfo        `yaml:"server" json:"server"`
	Client HttpInfo        `yaml:"client" json:"client"`
	Group  string          `yaml:"group" json:"group"`
	From   string          `yaml:"from" json:"from"`
}

type HttpInfo

type HttpInfo struct {
	Host     string `yaml:"host" json:"host"`
	Port     int    `yaml:"port" json:"port"`
	Username string `yaml:"username" json:"username"`
	Password string `yaml:"password" json:"password"`
}

type Nntp

type Nntp struct {
	Config *Config
}

func New

func New() *Nntp

func NewWithConfig

func NewWithConfig(config *Config) *Nntp

func (*Nntp) GetClient

func (n *Nntp) GetClient() *Client

GetClient 获取客户端

func (*Nntp) GetServer

func (n *Nntp) GetServer() *Server

GetServer 获取服务对象

func (*Nntp) Md5 added in v0.1.3

func (n *Nntp) Md5(data string) string

Md5 校验MD5

type Response

type Response struct {
	StatusCode int    `json:"status_code"`
	Content    []byte `json:"content"`
	Text       string `json:"text"`
	Uuid       string `json:"uuid"`
}

Response 响应结果

type Server

type Server struct {
	Config     *Config
	NntpServer *nntpserver.Server
}

Server NNTP服务

func (*Server) GetAddress

func (s *Server) GetAddress() string

GetAddress 获取服务地址

func (*Server) GetListener

func (s *Server) GetListener() (*net.TCPListener, error)

func (*Server) Handle

func (s *Server) Handle(conn net.Conn)

Handle 处理连接

func (*Server) Run

func (s *Server) Run() error

Run 运行服务

type ServerBackend

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

ServerBackend 服务后台

func (*ServerBackend) AllowPost

func (tb *ServerBackend) AllowPost() bool

AllowPost 是否运行POST提交

func (*ServerBackend) Authenticate

func (s *ServerBackend) Authenticate(user, pass string) (nntpserver.Backend, error)

Authenticate 校验用户名和密码

func (*ServerBackend) Authorized

func (s *ServerBackend) Authorized() bool

Authorized 是否开启权限校验

func (*ServerBackend) GetArticle

func (tb *ServerBackend) GetArticle(group *nntp.Group, id string) (*nntp.Article, error)

GetArticle 获取文章

func (*ServerBackend) GetArticles

func (tb *ServerBackend) GetArticles(group *nntp.Group,
	from, to int64) ([]nntpserver.NumberedArticle, error)

GetArticles 获取文章列表

func (*ServerBackend) GetGroup

func (tb *ServerBackend) GetGroup(name string) (*nntp.Group, error)

GetGroup 获取分组

func (*ServerBackend) ListGroups

func (tb *ServerBackend) ListGroups(max int) ([]*nntp.Group, error)

ListGroups 分组列表

func (*ServerBackend) Post

func (tb *ServerBackend) Post(article *nntp.Article) error

Post 新建文章

Directories

Path Synopsis
RFC5322 date parsing.
RFC5322 date parsing.
examples
Package nntp provides base NNTP definitions.
Package nntp provides base NNTP definitions.
client
Package nntpclient provides an NNTP Client.
Package nntpclient provides an NNTP Client.
server
Package nntpserver provides everything you need for your own NNTP server.
Package nntpserver provides everything you need for your own NNTP server.

Jump to

Keyboard shortcuts

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