srnd

package
v0.0.0-...-27b812d Latest Latest
Warning

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

Go to latest
Published: May 29, 2016 License: MIT Imports: 54 Imported by: 0

Documentation

Overview

daemon.go

database.go

expiration.go content expiration

frontend.go srnd frontend interfaces

frontend_http.go

srnd http frontend implementation

markup.go memeposting markup parser

message.go

mod.go post moderation

model.go template model interfaces

model_mem.go

models held in memory

nntp.go -- nntp interface for peering

policy.go

postgres db backend

templates.go template model interfaces

tools.go -- srndv2 cli tool functions

Index

Constants

View Source
const (
	ARTICLE_PREFIX               = APP_PREFIX + "Article::"
	ARTICLE_POST_PREFIX          = APP_PREFIX + "ArticlePost::"
	ARTICLE_KEY_PREFIX           = APP_PREFIX + "ArticleKey::"
	ARTICLE_NUMBERS_PREFIX       = APP_PREFIX + "ArticleNumbers::"
	HASH_MESSAGEID_PREFIX        = APP_PREFIX + "HashMessageID::"
	ATTACHMENT_PREFIX            = APP_PREFIX + "Attachment::"
	BANNED_GROUP_PREFIX          = APP_PREFIX + "BannedGroup::"
	BANNED_ARTICLE_PREFIX        = APP_PREFIX + "BannedArticle::"
	MOD_KEY_PREFIX               = APP_PREFIX + "ModKey::"
	NNTP_LOGIN_PREFIX            = APP_PREFIX + "Login::"
	ENCRYPTED_ADDRS_PREFIX       = APP_PREFIX + "EncryptedAddrs::"
	ADDRS_ENCRYPTED_ADDRS_PREFIX = APP_PREFIX + "AddrsEncryptedAddrs::"
	ENCRYPTED_IP_BAN_PREFIX      = APP_PREFIX + "EncIPBan::"
	IP_BAN_PREFIX                = APP_PREFIX + "IPBan::"
	IP_RANGE_BAN_PREFIX          = APP_PREFIX + "IPRangeBan::"
)
View Source
const (
	GROUP_POSTTIME_WKR                = APP_PREFIX + "GroupPostTimeWKR"
	GROUP_ARTICLE_POSTTIME_WKR_PREFIX = APP_PREFIX + "GroupArticlePostTimeWKR::"
	GROUP_THREAD_POSTTIME_WKR_PREFIX  = APP_PREFIX + "GroupThreadPostTimeWKR::"
	GROUP_THREAD_BUMPTIME_WKR_PREFIX  = APP_PREFIX + "GroupThreadBumpTimeWKR::"
	GROUP_MOD_KEY_REVERSE_KR_PREFIX   = APP_PREFIX + "GroupModKeysKR::"
	THREAD_POST_WKR                   = APP_PREFIX + "ThreadPostsWKR::"
	ARTICLE_WKR                       = APP_PREFIX + "ArticleWKR"
	THREAD_BUMPTIME_WKR               = APP_PREFIX + "ThreadBumpTimeWKR"
	HEADER_KR_PREFIX                  = APP_PREFIX + "HeaderKR::"
	MESSAGEID_HEADER_KR_PREFIX        = APP_PREFIX + "MessageIDHeaderKR::"
	ARTICLE_ATTACHMENT_KR_PREFIX      = APP_PREFIX + "ArticleAttachmentsKR::"
	ATTACHMENT_ARTICLE_KR_PREFIX      = APP_PREFIX + "AttachmentArticlesKR::"
	IP_RANGE_BAN_KR                   = APP_PREFIX + "IPRangeBanKR"
)
View Source
const (
	HISTORY            = CACHE_PREFIX + "History"
	INDEX              = CACHE_PREFIX + "Index"
	BOARDS             = CACHE_PREFIX + "Boards"
	UKKO               = CACHE_PREFIX + "Ukko"
	JSON_UKKO          = "JSON::" + UKKO
	THREAD_PREFIX      = CACHE_PREFIX + "Thread::"
	JSON_THREAD_PREFIX = "JSON::" + THREAD_PREFIX
	GROUP_PREFIX       = CACHE_PREFIX + "Group::"
	JSON_GROUP_PREFIX  = "JSON::" + GROUP_PREFIX
	CATALOG_PREFIX     = CACHE_PREFIX + "Catalog::"
)
View Source
const APP_PREFIX = "NNTP::"
View Source
const CACHE_PREFIX = "NNTPCache::"
View Source
const MIN_REDIS_VERSION = "3.0"

Variables

View Source
var Discard = new(discardCloser)

like ioutil.Discard but an io.WriteCloser

View Source
var TlsFailedToLoadCA = errors.New("could not load CA files")
View Source
var TlsNotSupported = errors.New("TLS not supported")

Functions

func CheckConfig

func CheckConfig()

check for config files generate defaults on demand

func CheckFile

func CheckFile(fname string) bool

func DelFile

func DelFile(fname string)

func EnsureDir

func EnsureDir(dirname string)

ensure a directory exists

func GenFeedsConfig

func GenFeedsConfig() error

generate default feeds.ini

func GenSRNdConfig

func GenSRNdConfig() *configparser.Configuration

generate default srnd.ini

func GenTLS

func GenTLS(cfg *CryptoConfig) (tcfg *tls.Config, err error)

generate tls config, private key and certificate

func HandleStartTLS

func HandleStartTLS(conn net.Conn, config *tls.Config) (econn *textproto.Conn, state tls.ConnectionState, err error)

handle STARTTLS on connection

func HashMessageID

func HashMessageID(msgid string) string

message id hash

func IPNet2MinMax

func IPNet2MinMax(inet *net.IPNet) (min, max net.IP)

func InitI18n

func InitI18n(locale, dir string)

Read all .ini files in dir, where the filenames are BCP 47 tags Use the language matcher to get the best match for the locale preference

func InstallerEnabled

func InstallerEnabled() bool

func IsDir

func IsDir(dirname string) bool

func IsSubnet

func IsSubnet(cidr string) (bool, *net.IPNet)

func KeygenTool

func KeygenTool()

generate a keypair from the command line

func MessageIDWillDoDubs

func MessageIDWillDoDubs(msgid string) bool

will this message id produce dubs?

func MessageIDWillDoQuads

func MessageIDWillDoQuads(msgid string) bool

will this message id produce quads?

func MessageIDWillDoTrips

func MessageIDWillDoTrips(msgid string) bool

will this message id produce trips?

func OpenFileWriter

func OpenFileWriter(fname string) (io.WriteCloser, error)

func RedisEnabled

func RedisEnabled() bool

func RegenTool

func RegenTool()

func RunModEngine

func RunModEngine(mod ModEngine, regen RegenFunc)

run a mod engine logic mainloop

func SaveFeeds

func SaveFeeds(feeds []FeedConfig) (err error)

save a list of feeds to overwrite feeds.ini

func SendStartTLS

func SendStartTLS(conn net.Conn, config *tls.Config) (econn *textproto.Conn, state tls.ConnectionState, err error)

func ShortHashMessageID

func ShortHashMessageID(msgid string) string

short message id hash

func ShorterHashMessageID

func ShorterHashMessageID(msgid string) string

shorter message id hash

func ThumbnailTool

func ThumbnailTool()

run thumbnailer with 4 threads

func ValidMessageID

func ValidMessageID(id string) bool

func Version

func Version() string

func ZeroIPString

func ZeroIPString(ip net.IP) string

Types

type APIConfig

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

type APIModel

type APIModel struct {
	ErrorModel
	StepModel
	// contains filtered or unexported fields
}

func (*APIModel) Secret

func (self *APIModel) Secret() string

func (*APIModel) User

func (self *APIModel) User() string

type AdminFunc

type AdminFunc func(param map[string]interface{}) (interface{}, error)

does an action for the administrator takes in json

type ArticleEntry

type ArticleEntry [2]string

a ( MessageID , newsgroup ) tuple

func (ArticleEntry) MessageID

func (self ArticleEntry) MessageID() string

func (ArticleEntry) Newsgroup

func (self ArticleEntry) Newsgroup() string

type ArticleHeaders

type ArticleHeaders map[string][]string

func (ArticleHeaders) Add

func (self ArticleHeaders) Add(key, val string)

func (ArticleHeaders) Get

func (self ArticleHeaders) Get(key, fallback string) string

func (ArticleHeaders) Has

func (self ArticleHeaders) Has(key string) bool

func (ArticleHeaders) Set

func (self ArticleHeaders) Set(key, val string)

type ArticleStore

type ArticleStore interface {
	MessageReader

	// full filepath to attachment directory
	AttachmentDir() string

	// get the filepath for an attachment
	AttachmentFilepath(fname string) string
	// get the filepath for an attachment's thumbnail
	ThumbnailFilepath(fname string) string
	// do we have this article?
	HasArticle(msgid string) bool
	// create a file for a message
	CreateFile(msgid string) io.WriteCloser
	// get the filename of a message
	GetFilename(msgid string) string
	// Get a message given its messageid
	GetMessage(msgid string) NNTPMessage
	// open a message in the store for reading given its message-id
	// return io.ReadCloser, error
	OpenMessage(msgid string) (io.ReadCloser, error)
	// get article headers only
	GetHeaders(msgid string) ArticleHeaders
	// get our temp directory for articles
	TempDir() string
	// get a list of all the attachments we have
	GetAllAttachments() ([]string, error)
	// generate a thumbnail
	GenerateThumbnail(fname string) error
	// generate all thumbanils for this message
	ThumbnailMessage(msgid string)
	// did we enable compression?
	Compression() bool
	// process body of nntp message, register attachments and the article
	// write the body into writer as we go through the body
	// does NOT write mime header
	ProcessMessageBody(wr io.Writer, hdr textproto.MIMEHeader, body io.Reader) error
	// register this post with the daemon
	RegisterPost(nntp NNTPMessage) error
	// register signed message
	RegisterSigned(msgid, pk string) error
}

type AttachmentModel

type AttachmentModel interface {
	BaseModel

	Thumbnail() string
	Source() string
	Filename() string
}

for attachments

type BaseDialogModel

type BaseDialogModel struct {
	ErrorModel
	StepModel
}

type BaseModel

type BaseModel interface {

	// site url prefix
	Prefix() string

	// impelements json.Marshaller
	MarshalJSON() ([]byte, error)
}

base model type

type BinaryModel

type BinaryModel struct {
	ErrorModel
	StepModel
	// contains filtered or unexported fields
}

func (*BinaryModel) Convert

func (self *BinaryModel) Convert() string

func (*BinaryModel) FFmpeg

func (self *BinaryModel) FFmpeg() string

func (*BinaryModel) Sox

func (self *BinaryModel) Sox() string

type BoardModel

type BoardModel interface {
	BaseModel
	NavbarModel

	Frontend() string
	Name() string
	Threads() []ThreadModel

	AllowFiles() bool
	SetAllowFiles(files bool)

	// JUST update this thread
	// if we don't have it already loaded do nothing
	UpdateThread(message_id string, db Database)

	// get a thread model with this id
	// returns nil if we don't have it
	GetThread(message_id string) ThreadModel

	// put a thread back after updating externally
	PutThread(th ThreadModel)

	// deprecated, use GetThread
	HasThread(message_id string) bool

	// update the board's contents
	Update(db Database)
}

board interface for 1 page on a board

type CacheInterface

type CacheInterface interface {
	RegenAll()
	RegenFrontPage()
	RegenOnModEvent(string, string, string, int)
	RegenerateBoard(group string)
	Regen(msg ArticleEntry)

	DeleteThreadMarkup(root_post_id string)
	DeleteBoardMarkup(group string)

	Start()
	Close()

	GetThreadChan() chan ArticleEntry
	GetGroupChan() chan groupRegenRequest
	GetHandler() http.Handler
}

func NewCache

func NewCache(cache_type, host, port, user, password string, config map[string]string, db Database, store ArticleStore) CacheInterface

TODO only pass needed config

func NewFileCache

func NewFileCache(prefix, webroot, name string, threads int, attachments bool, db Database, store ArticleStore) CacheInterface

func NewNullCache

func NewNullCache(prefix, webroot, name string, attachments bool, db Database, store ArticleStore) CacheInterface

func NewRedisCache

func NewRedisCache(prefix, webroot, name string, threads int, attachments bool, db Database, host, port, password string) CacheInterface

type CatalogItemModel

type CatalogItemModel interface {
	OP() PostModel
	ReplyCount() string
	Page() string
}

type CatalogModel

type CatalogModel interface {
	BaseModel
	NavbarModel

	Frontend() string
	Name() string
	Threads() []CatalogItemModel
}

type CryptoConfig

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

type CryptoModel

type CryptoModel struct {
	ErrorModel
	StepModel
	// contains filtered or unexported fields
}

func (*CryptoModel) Host

func (self *CryptoModel) Host() string

func (*CryptoModel) Key

func (self *CryptoModel) Key() string

type DBModel

type DBModel struct {
	ErrorModel
	StepModel
	// contains filtered or unexported fields
}

func (*DBModel) Host

func (self *DBModel) Host() string

func (*DBModel) Port

func (self *DBModel) Port() string

func (*DBModel) Username

func (self *DBModel) Username() string

type Database

type Database interface {
	Close()
	CreateTables()
	HasNewsgroup(group string) bool
	HasArticle(message_id string) bool
	HasArticleLocal(message_id string) bool
	RegisterNewsgroup(group string)
	RegisterArticle(article NNTPMessage) error
	GetAllArticlesInGroup(group string, send chan ArticleEntry)
	CountAllArticlesInGroup(group string) (int64, error)
	GetAllArticles() []ArticleEntry

	// check if a newsgroup is banned
	NewsgroupBanned(group string) (bool, error)

	// ban / unban newsgroup
	BanNewsgroup(group string) error
	UnbanNewsgroup(group string) error

	// delete an entire newsgroup
	// delete from the article store too
	NukeNewsgroup(group string, store ArticleStore)

	// return true if this is root post has expired
	IsExpired(root_message_id string) bool

	// get an article's MessageID given the hash of the MessageID
	// return an article entry or nil when it doesn't exist + and error if it happened
	GetMessageIDByHash(hash string) (ArticleEntry, error)

	// get root message_id, newsgroup, pageno for a post regardless if it's rootpost or not
	GetInfoForMessage(msgid string) (string, string, int64, error)

	// what page is the thread with this root post on?
	// return newsgroup, pageno
	GetPageForRootMessage(root_message_id string) (string, int64, error)

	// record that a message given a message id was posted signed by this pubkey
	RegisterSigned(message_id, pubkey string) error

	// get the number of articles we have
	ArticleCount() int64

	// return true if this thread has any replies
	ThreadHasReplies(root_message_id string) bool

	// get the number of posts in a certain newsgroup since N seconds ago
	// if N <= 0 then count all we have now
	CountPostsInGroup(group string, time_frame int64) int64

	// get all replies to a thread
	// if last > 0 then get that many of the last replies
	// start at reply number start
	GetThreadReplies(root_message_id string, start, last int) []string

	// count the number of replies to this thread
	CountThreadReplies(root_message_id string) int64

	// get all attachments for this message
	GetPostAttachments(message_id string) []string

	// get all attachments for this message
	GetPostAttachmentModels(prefix, message_id string) []AttachmentModel

	// return true if this newsgroup has posts
	GroupHasPosts(newsgroup string) bool

	// get all active threads on a board
	// send each thread's ArticleEntry down a channel
	GetGroupThreads(newsgroup string, send chan ArticleEntry)

	// get every message id for root posts that need to be expired in a newsgroup
	// threadcount is the upperbound limit to how many root posts we keep
	GetRootPostsForExpiration(newsgroup string, threadcount int) []string

	// get the number of pages a board has
	GetGroupPageCount(newsgroup string) int64

	// get board page number N
	// prefix and frontend are injected
	// does not load replies for thread, only gets root posts
	GetGroupForPage(prefix, frontend, newsgroup string, pageno, perpage int) BoardModel

	// get the root posts of the last N bumped threads in a given newsgroup or globally for ukko
	GetLastBumpedThreads(newsgroup string, threadcount int) []ArticleEntry

	// get the PostModels for replies to a thread
	// prefix is injected into the post models
	GetThreadReplyPostModels(prefix, rootMessageID string, start, limit int) []PostModel

	// get a post model for a post
	// prefix is injected into the post model
	GetPostModel(prefix, messageID string) PostModel

	// add a public key to the database
	AddModPubkey(pubkey string) error

	// mark that a mod with this pubkey can act on all boards
	MarkModPubkeyGlobal(pubkey string) error

	// revoke mod with this pubkey the privilege of being able to act on all boards
	UnMarkModPubkeyGlobal(pubkey string) error

	// check if this mod pubkey can moderate at a global level
	CheckModPubkeyGlobal(pubkey string) bool

	// check if a mod with this pubkey has permission to moderate at all
	CheckModPubkey(pubkey string) bool

	// check if a mod with this pubkey can moderate on the given newsgroup
	CheckModPubkeyCanModGroup(pubkey, newsgroup string) bool

	// add a pubkey to be able to mod a newsgroup
	MarkModPubkeyCanModGroup(pubkey, newsgroup string) error

	// remote a pubkey to they can't mod a newsgroup
	UnMarkModPubkeyCanModGroup(pubkey, newsgroup string) error

	// ban an article
	BanArticle(messageID, reason string) error

	// check if an article is banned or not
	ArticleBanned(messageID string) bool

	// Get ip address given the encrypted version
	// return emtpy string if we don't have it
	GetIPAddress(encAddr string) (string, error)

	// check if an ip is banned from our local
	CheckIPBanned(addr string) (bool, error)

	// check if an encrypted ip is banned from our local
	CheckEncIPBanned(encAddr string) (bool, error)

	// ban an ip address from the local
	BanAddr(addr string) error

	// unban an ip address from the local
	UnbanAddr(addr string) error

	// ban an encrypted ip address from the remote
	BanEncAddr(encAddr string) error

	// return the encrypted version of an IPAddress
	// if it's not already there insert it into the database
	GetEncAddress(addr string) (string, error)

	// get the decryption key for an encrypted address
	// return empty string if we don't have it
	GetEncKey(encAddr string) (string, error)

	// delete an article from the database
	DeleteArticle(msg_id string) error

	// detele the existance of a thread from the threads table, does NOT remove replies
	DeleteThread(root_msg_id string) error

	// get threads per page for a newsgroup
	GetThreadsPerPage(group string) (int, error)

	// get pages per board for a newsgroup
	GetPagesPerBoard(group string) (int, error)

	// get every newsgroup we know of
	GetAllNewsgroups() []string

	// get all post models in a newsgroup
	// ordered from oldest to newest
	GetPostsInGroup(group string) ([]PostModel, error)

	// get the numerical id of the last , first article for a given group
	GetLastAndFirstForGroup(group string) (int64, int64, error)

	// get a message id give a newsgroup and the nntp id
	GetMessageIDForNNTPID(group string, id int64) (string, error)

	// get nntp id for a given message-id
	GetNNTPIDForMessageID(group, msgid string) (int64, error)

	// get the last N days post count in decending order
	GetLastDaysPosts(n int64) []PostEntry

	// get the last N days post count in decending order
	GetLastDaysPostsForGroup(newsgroup string, n int64) []PostEntry

	// get post history per month since beginning of time
	GetMonthlyPostHistory() []PostEntry

	// get the last N posts that were made globally
	GetLastPostedPostModels(prefix string, n int64) []PostModel

	// check if an nntp login cred is correct
	CheckNNTPLogin(username, passwd string) (bool, error)

	// add an nntp login credential
	AddNNTPLogin(username, passwd string) error

	// remove an nntp login credential
	RemoveNNTPLogin(username string) error

	// check if an nntp login credential given a user exists
	CheckNNTPUserExists(username string) (bool, error)

	// get the message ids of an article that has this header with the given value
	GetMessageIDByHeader(name, value string) ([]string, error)

	// get the headers for a message given its message-id
	GetHeadersForMessage(msgid string) (ArticleHeaders, error)

	// get all message-ids posted by posters in this cidr
	GetMessageIDByCIDR(cidr *net.IPNet) ([]string, error)

	// get all message-ids posted by poster with encrypted ip
	GetMessageIDByEncryptedIP(encaddr string) ([]string, error)
}

func NewDatabase

func NewDatabase(db_type, schema, host, port, user, password string) Database

func NewPostgresDatabase

func NewPostgresDatabase(host, port, user, password string) Database

func NewRedisDatabase

func NewRedisDatabase(host, port, password string) Database

type ErrorModel

type ErrorModel struct {
	Err error
}

func (*ErrorModel) Error

func (self *ErrorModel) Error() string

func (*ErrorModel) HasError

func (self *ErrorModel) HasError() bool

type ExpirationCore

type ExpirationCore interface {
	// do expiration for a group
	ExpireGroup(newsgroup string, keep int)
	// Delete a single post and all children
	ExpirePost(messageID string)
	// expire all orphaned articles
	ExpireOrphans()
	// run our mainloop
	Mainloop()
}

content expiration interface

type FeedConfig

type FeedConfig struct {
	Addr string

	Name string
	// contains filtered or unexported fields
}

type FeedPolicy

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

func (*FeedPolicy) AllowsNewsgroup

func (self *FeedPolicy) AllowsNewsgroup(newsgroup string) (result bool)

do we allow this newsgroup?

type FileCache

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

func (*FileCache) Close

func (self *FileCache) Close()

func (*FileCache) DeleteBoardMarkup

func (self *FileCache) DeleteBoardMarkup(group string)

func (*FileCache) DeleteThreadMarkup

func (self *FileCache) DeleteThreadMarkup(root_post_id string)

try to delete root post's page

func (*FileCache) GetGroupChan

func (self *FileCache) GetGroupChan() chan groupRegenRequest

func (*FileCache) GetHandler

func (self *FileCache) GetHandler() http.Handler

func (*FileCache) GetThreadChan

func (self *FileCache) GetThreadChan() chan ArticleEntry

func (*FileCache) Regen

func (self *FileCache) Regen(msg ArticleEntry)

func (*FileCache) RegenAll

func (self *FileCache) RegenAll()

regen every newsgroup

func (*FileCache) RegenFrontPage

func (self *FileCache) RegenFrontPage()

regenerate the front page

func (*FileCache) RegenOnModEvent

func (self *FileCache) RegenOnModEvent(newsgroup, msgid, root string, page int)

regenerate pages after a mod event

func (*FileCache) RegenerateBoard

func (self *FileCache) RegenerateBoard(group string)

regen every page of the board

func (*FileCache) Start

func (self *FileCache) Start()

type Frontend

type Frontend interface {

	// channel that is for the frontend to pool for new posts from the nntpd
	PostsChan() chan frontendPost

	// run mainloop
	Mainloop()

	// do we want posts from a newsgroup?
	AllowNewsgroup(group string) bool

	// trigger a manual regen of indexes for a root post
	Regen(msg ArticleEntry)
}

frontend interface for any type of frontend

func MuxFrontends

func MuxFrontends(fronts ...Frontend) Frontend

func NewHTTPFrontend

func NewHTTPFrontend(daemon *NNTPDaemon, cache CacheInterface, config map[string]string, url string) Frontend

create a new http based frontend

type FrontendModel

type FrontendModel struct {
	ErrorModel
	StepModel
	// contains filtered or unexported fields
}

func (*FrontendModel) Locale

func (self *FrontendModel) Locale() string

func (*FrontendModel) Name

func (self *FrontendModel) Name() string

type GroupModel

type GroupModel []BoardModel

newsgroup model every page on a newsgroup

func (*GroupModel) Update

func (self *GroupModel) Update(page int, db Database)

update a certain page does nothing if out of bounds

func (*GroupModel) UpdateAll

func (self *GroupModel) UpdateAll(db Database)

TODO: optimize using 1 query? update every page

type Installer

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

func NewInstaller

func NewInstaller(result chan *configparser.Configuration) *Installer

func (*Installer) HandleInstallerGet

func (self *Installer) HandleInstallerGet(wr http.ResponseWriter, r *http.Request)

func (*Installer) HandleInstallerPost

func (self *Installer) HandleInstallerPost(wr http.ResponseWriter, r *http.Request)

func (*Installer) Start

func (self *Installer) Start()

func (*Installer) Stop

func (self *Installer) Stop()

type KeyModel

type KeyModel struct {
	ErrorModel
	StepModel
	// contains filtered or unexported fields
}

func (*KeyModel) Public

func (self *KeyModel) Public() string

func (*KeyModel) Secret

func (self *KeyModel) Secret() string

type LineWriter

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

func NewLineWriter

func NewLineWriter(w io.Writer) *LineWriter

func (*LineWriter) Write

func (l *LineWriter) Write(data []byte) (n int, err error)

type LinkModel

type LinkModel interface {
	Text() string
	LinkURL() string
}

type MessageReader

type MessageReader interface {
	// read a message from a reader
	ReadMessage(r io.Reader) (NNTPMessage, error)
}

type MessageWriter

type MessageWriter interface {
	// write a message to a writer
	WriteMessage(nntp NNTPMessage, wr io.Writer) error
}

type ModEngine

type ModEngine interface {
	// chan to send the mod engine posts given message_id
	MessageChan() chan string
	// delete post of a poster
	DeletePost(msgid string, regen RegenFunc) error
	// ban a cidr
	BanAddress(cidr string) error
	// do we allow this public key to delete?
	AllowDelete(pubkey string) bool
	// do we allow this public key to ban?
	AllowBan(pubkey string) bool
	// load a mod message
	LoadMessage(msgid string) NNTPMessage
}

type ModEvent

type ModEvent interface {
	// turn it into a string for putting into an article
	String() string
	// what type of mod event
	Action() string
	// what reason for the event
	Reason() string
	// what is the event acting on
	Target() string
	// scope of the event, regex of newsgroup
	Scope() string
	// when this mod event expires, unix nano
	Expires() int64
}

func ParseModEvent

func ParseModEvent(line string) ModEvent

type ModMessage

type ModMessage []ModEvent

moderation message wraps multiple mod events is turned into an NNTPMessage later

func (ModMessage) WriteTo

func (self ModMessage) WriteTo(wr io.Writer, delim []byte) (err error)

write this mod message's body

type ModUI

type ModUI interface {

	// channel for daemon to poll for nntp articles from the mod ui
	MessageChan() chan NNTPMessage

	// check if this key is allowed to access
	// return true if it can otherwise false
	CheckKey(privkey string) (bool, error)

	// serve the base page
	ServeModPage(wr http.ResponseWriter, r *http.Request)
	// handle a login POST request
	HandleLogin(wr http.ResponseWriter, r *http.Request)
	// handle a delete article request
	HandleDeletePost(wr http.ResponseWriter, r *http.Request)
	// handle a ban address request
	HandleBanAddress(wr http.ResponseWriter, r *http.Request)
	// handle an unban address request
	HandleUnbanAddress(wr http.ResponseWriter, r *http.Request)
	// handle add a pubkey
	HandleAddPubkey(wr http.ResponseWriter, r *http.Request)
	// handle removing a pubkey
	HandleDelPubkey(wr http.ResponseWriter, r *http.Request)
	// handle key generation
	HandleKeyGen(wr http.ResponseWriter, r *http.Request)
	// handle admin command
	HandleAdminCommand(wr http.ResponseWriter, r *http.Request)
}

interface for moderation ui

type NNTPAttachment

type NNTPAttachment interface {
	io.WriterTo
	io.Writer

	// the name of the file
	Filename() string
	// the filepath to the saved file
	Filepath() string
	// the mime type of the attachment
	Mime() string
	// the file extension of the attachment
	Extension() string
	// get the sha512 hash of the attachment
	Hash() []byte
	// do we need to generate a thumbnail?
	NeedsThumbnail() bool
	// mime header
	Header() textproto.MIMEHeader
	// make into a model
	ToModel(prefix string) AttachmentModel
	// base64'd file data
	Filedata() string
	// as raw string
	AsString() string
	// reset contents
	Reset()
	// get bytes
	Bytes() []byte
	// save to directory, filename is decided by the attachment
	Save(dir string) error
}

type NNTPDaemon

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

func (*NNTPDaemon) AddNNTPLogin

func (self *NNTPDaemon) AddNNTPLogin(username, password string)

for srnd tool

func (*NNTPDaemon) CanTLS

func (self *NNTPDaemon) CanTLS() (can bool)

return true if we can do tls

func (*NNTPDaemon) DelNNTPLogin

func (self *NNTPDaemon) DelNNTPLogin(username string)

for srnd tool

func (NNTPDaemon) End

func (self NNTPDaemon) End()

func (*NNTPDaemon) Federate

func (self *NNTPDaemon) Federate() (federate bool)

func (*NNTPDaemon) GetDatabase

func (self *NNTPDaemon) GetDatabase() Database

func (*NNTPDaemon) GetOurTLSConfig

func (self *NNTPDaemon) GetOurTLSConfig() *tls.Config

func (*NNTPDaemon) GetTLSConfig

func (self *NNTPDaemon) GetTLSConfig(hostname string) *tls.Config

func (*NNTPDaemon) RequireTLS

func (self *NNTPDaemon) RequireTLS() (require bool)

func (*NNTPDaemon) Run

func (self *NNTPDaemon) Run()

run daemon

func (*NNTPDaemon) Setup

func (self *NNTPDaemon) Setup()

func (*NNTPDaemon) WrapSign

func (self *NNTPDaemon) WrapSign(nntp NNTPMessage) NNTPMessage

sign an article as coming from our daemon

type NNTPMessage

type NNTPMessage interface {
	// this message's messsge id
	MessageID() string
	// the parent message's messageid if it's specified
	Reference() string
	// the newsgroup this post is in
	Newsgroup() string
	// the name of the poster
	Name() string
	// any email address associated with the post
	Email() string
	// the subject of the post
	Subject() string
	// when this was posted
	Posted() int64
	// the path header
	Path() string
	// get signed part
	SignedPart() NNTPAttachment
	// append something to path
	// return message with new path
	AppendPath(part string) NNTPMessage
	// the type of this message usually a mimetype
	ContentType() string
	// was this post a sage?
	Sage() bool
	// was this post a root post?
	OP() bool
	// all attachments
	Attachments() []NNTPAttachment
	// all headers
	Headers() ArticleHeaders
	// write out everything
	WriteTo(wr io.Writer) error
	// write out body
	WriteBody(wr io.Writer) error
	// attach a file
	Attach(att NNTPAttachment)
	// get the plaintext message if it exists
	Message() string
	// pack the whole message and prepare for write
	Pack()
	// get the pubkey for this message if it was signed, otherwise empty string
	Pubkey() string
	// get the origin encrypted address, i2p destination or empty string for onion posters
	Addr() string
	// reset contents
	Reset()
	// get inner signed message
	Signed() NNTPMessage
}

type NameModel

type NameModel struct {
	ErrorModel
	StepModel
	// contains filtered or unexported fields
}

func (*NameModel) Name

func (self *NameModel) Name() string
type NavbarModel interface {
	Navbar() string
}

interface for models that have a navbar

type NullCache

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

func (*NullCache) Close

func (self *NullCache) Close()

func (*NullCache) DeleteBoardMarkup

func (self *NullCache) DeleteBoardMarkup(group string)

func (*NullCache) DeleteThreadMarkup

func (self *NullCache) DeleteThreadMarkup(root_post_id string)

try to delete root post's page

func (*NullCache) GetGroupChan

func (self *NullCache) GetGroupChan() chan groupRegenRequest

func (*NullCache) GetHandler

func (self *NullCache) GetHandler() http.Handler

func (*NullCache) GetThreadChan

func (self *NullCache) GetThreadChan() chan ArticleEntry

func (*NullCache) Regen

func (self *NullCache) Regen(msg ArticleEntry)

func (*NullCache) RegenAll

func (self *NullCache) RegenAll()

regen every newsgroup

func (*NullCache) RegenFrontPage

func (self *NullCache) RegenFrontPage()

func (*NullCache) RegenOnModEvent

func (self *NullCache) RegenOnModEvent(newsgroup, msgid, root string, page int)

regenerate pages after a mod event

func (*NullCache) RegenerateBoard

func (self *NullCache) RegenerateBoard(group string)

regen every page of the board

func (*NullCache) Start

func (self *NullCache) Start()

type PostEntry

type PostEntry [2]int64

a ( time point, post count ) tuple

func (PostEntry) Count

func (self PostEntry) Count() int64

func (PostEntry) Time

func (self PostEntry) Time() time.Time

type PostModel

type PostModel interface {
	BaseModel

	CSSClass() string

	MessageID() string
	PostHash() string
	ShortHash() string
	PostURL() string
	Frontend() string
	Subject() string
	Name() string
	Date() string
	OP() bool
	Attachments() []AttachmentModel
	Board() string
	Sage() bool
	Pubkey() string
	Reference() string
	ReferenceHash() string

	RenderBody() string
	RenderPost() string

	IsI2P() bool
	IsTor() bool
	IsClearnet() bool

	// truncate body to a certain size
	// return copy
	Truncate() PostModel

	// what is our position in this thread?
	// 0 for OP, nonzero for reply
	Index() int
	// set post index
	SetIndex(idx int)
}

for individual posts

func PostModelFromMessage

func PostModelFromMessage(parent, prefix string, nntp NNTPMessage) PostModel

type PostgresDatabase

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

func (*PostgresDatabase) AddModPubkey

func (self *PostgresDatabase) AddModPubkey(pubkey string) error

func (*PostgresDatabase) AddNNTPLogin

func (self *PostgresDatabase) AddNNTPLogin(username, passwd string) (err error)

func (*PostgresDatabase) ArticleBanned

func (self *PostgresDatabase) ArticleBanned(messageID string) (result bool)

func (*PostgresDatabase) ArticleCount

func (self *PostgresDatabase) ArticleCount() (count int64)

count articles we have

func (*PostgresDatabase) BanAddr

func (self *PostgresDatabase) BanAddr(addr string) (err error)

func (*PostgresDatabase) BanArticle

func (self *PostgresDatabase) BanArticle(messageID, reason string) error

func (*PostgresDatabase) BanEncAddr

func (self *PostgresDatabase) BanEncAddr(encaddr string) (err error)

func (*PostgresDatabase) BanNewsgroup

func (self *PostgresDatabase) BanNewsgroup(group string) (err error)

func (*PostgresDatabase) CheckEncIPBanned

func (self *PostgresDatabase) CheckEncIPBanned(encaddr string) (banned bool, err error)

func (*PostgresDatabase) CheckIPBanned

func (self *PostgresDatabase) CheckIPBanned(addr string) (banned bool, err error)

func (*PostgresDatabase) CheckModPubkey

func (self *PostgresDatabase) CheckModPubkey(pubkey string) bool

func (*PostgresDatabase) CheckModPubkeyCanModGroup

func (self *PostgresDatabase) CheckModPubkeyCanModGroup(pubkey, newsgroup string) bool

func (*PostgresDatabase) CheckModPubkeyGlobal

func (self *PostgresDatabase) CheckModPubkeyGlobal(pubkey string) bool

func (*PostgresDatabase) CheckNNTPLogin

func (self *PostgresDatabase) CheckNNTPLogin(username, passwd string) (valid bool, err error)

func (*PostgresDatabase) CheckNNTPUserExists

func (self *PostgresDatabase) CheckNNTPUserExists(username string) (exists bool, err error)

func (*PostgresDatabase) Close

func (self *PostgresDatabase) Close()

finalize all transactions close database connections

func (*PostgresDatabase) CountAllArticlesInGroup

func (self *PostgresDatabase) CountAllArticlesInGroup(group string) (count int64, err error)

func (*PostgresDatabase) CountPostsInGroup

func (self *PostgresDatabase) CountPostsInGroup(newsgroup string, time_frame int64) (result int64)

func (*PostgresDatabase) CountThreadReplies

func (self *PostgresDatabase) CountThreadReplies(root_message_id string) (repls int64)

func (*PostgresDatabase) CreateTables

func (self *PostgresDatabase) CreateTables()

func (*PostgresDatabase) DeleteArticle

func (self *PostgresDatabase) DeleteArticle(msgid string) (err error)

func (*PostgresDatabase) DeleteThread

func (self *PostgresDatabase) DeleteThread(msgid string) (err error)

func (*PostgresDatabase) GetAllArticles

func (self *PostgresDatabase) GetAllArticles() (articles []ArticleEntry)

get all articles send result down a channel

func (*PostgresDatabase) GetAllArticlesInGroup

func (self *PostgresDatabase) GetAllArticlesInGroup(group string, recv chan ArticleEntry)

get all articles in a newsgroup send result down a channel

func (*PostgresDatabase) GetAllNewsgroups

func (self *PostgresDatabase) GetAllNewsgroups() (groups []string)

func (*PostgresDatabase) GetEncAddress

func (self *PostgresDatabase) GetEncAddress(addr string) (encaddr string, err error)

func (*PostgresDatabase) GetEncKey

func (self *PostgresDatabase) GetEncKey(encAddr string) (enckey string, err error)

func (*PostgresDatabase) GetGroupForMessage

func (self *PostgresDatabase) GetGroupForMessage(message_id string) (group string, err error)

func (*PostgresDatabase) GetGroupForPage

func (self *PostgresDatabase) GetGroupForPage(prefix, frontend, newsgroup string, pageno, perpage int) BoardModel

only fetches root posts does not update the thread contents

func (*PostgresDatabase) GetGroupPageCount

func (self *PostgresDatabase) GetGroupPageCount(newsgroup string) int64

func (*PostgresDatabase) GetGroupThreads

func (self *PostgresDatabase) GetGroupThreads(group string, recv chan ArticleEntry)

func (*PostgresDatabase) GetHeadersForMessage

func (self *PostgresDatabase) GetHeadersForMessage(msgid string) (hdr ArticleHeaders, err error)

func (*PostgresDatabase) GetIPAddress

func (self *PostgresDatabase) GetIPAddress(encaddr string) (addr string, err error)

func (*PostgresDatabase) GetInfoForMessage

func (self *PostgresDatabase) GetInfoForMessage(msgid string) (root string, newsgroup string, page int64, err error)

func (*PostgresDatabase) GetLastAndFirstForGroup

func (self *PostgresDatabase) GetLastAndFirstForGroup(group string) (last, first int64, err error)

func (*PostgresDatabase) GetLastBumpedThreads

func (self *PostgresDatabase) GetLastBumpedThreads(newsgroup string, threads int) (roots []ArticleEntry)

func (*PostgresDatabase) GetLastDaysPosts

func (self *PostgresDatabase) GetLastDaysPosts(n int64) (posts []PostEntry)

func (*PostgresDatabase) GetLastDaysPostsForGroup

func (self *PostgresDatabase) GetLastDaysPostsForGroup(newsgroup string, n int64) (posts []PostEntry)

func (*PostgresDatabase) GetLastPostedPostModels

func (self *PostgresDatabase) GetLastPostedPostModels(prefix string, n int64) (posts []PostModel)

func (*PostgresDatabase) GetMessageIDByCIDR

func (self *PostgresDatabase) GetMessageIDByCIDR(cidr *net.IPNet) (msgids []string, err error)

func (*PostgresDatabase) GetMessageIDByEncryptedIP

func (self *PostgresDatabase) GetMessageIDByEncryptedIP(encaddr string) (msgids []string, err error)

func (*PostgresDatabase) GetMessageIDByHash

func (self *PostgresDatabase) GetMessageIDByHash(hash string) (article ArticleEntry, err error)

func (*PostgresDatabase) GetMessageIDByHeader

func (self *PostgresDatabase) GetMessageIDByHeader(name, val string) (msgids []string, err error)

get message ids of articles with this header name and value

func (*PostgresDatabase) GetMessageIDForNNTPID

func (self *PostgresDatabase) GetMessageIDForNNTPID(group string, id int64) (msgid string, err error)

func (*PostgresDatabase) GetMonthlyPostHistory

func (self *PostgresDatabase) GetMonthlyPostHistory() (posts []PostEntry)

func (*PostgresDatabase) GetNNTPIDForMessageID

func (self *PostgresDatabase) GetNNTPIDForMessageID(group, msgid string) (id int64, err error)

func (*PostgresDatabase) GetPageForRootMessage

func (self *PostgresDatabase) GetPageForRootMessage(root_message_id string) (group string, page int64, err error)

func (*PostgresDatabase) GetPagesPerBoard

func (self *PostgresDatabase) GetPagesPerBoard(group string) (int, error)

func (*PostgresDatabase) GetPostAttachmentModels

func (self *PostgresDatabase) GetPostAttachmentModels(prefix, messageID string) (atts []AttachmentModel)

func (*PostgresDatabase) GetPostAttachments

func (self *PostgresDatabase) GetPostAttachments(messageID string) (atts []string)

func (*PostgresDatabase) GetPostModel

func (self *PostgresDatabase) GetPostModel(prefix, messageID string) PostModel

func (*PostgresDatabase) GetPostsInGroup

func (self *PostgresDatabase) GetPostsInGroup(newsgroup string) (models []PostModel, err error)

func (*PostgresDatabase) GetRootPostsForExpiration

func (self *PostgresDatabase) GetRootPostsForExpiration(newsgroup string, threadcount int) (roots []string)

func (*PostgresDatabase) GetThreadReplies

func (self *PostgresDatabase) GetThreadReplies(rootpost string, start, limit int) (repls []string)

func (*PostgresDatabase) GetThreadReplyPostModels

func (self *PostgresDatabase) GetThreadReplyPostModels(prefix, rootpost string, start, limit int) (repls []PostModel)

func (*PostgresDatabase) GetThreadsPerPage

func (self *PostgresDatabase) GetThreadsPerPage(group string) (int, error)

func (*PostgresDatabase) GroupHasPosts

func (self *PostgresDatabase) GroupHasPosts(group string) bool

func (*PostgresDatabase) HasArticle

func (self *PostgresDatabase) HasArticle(message_id string) bool

check if an article exists

func (*PostgresDatabase) HasArticleLocal

func (self *PostgresDatabase) HasArticleLocal(message_id string) bool

check if an article exists locally

func (*PostgresDatabase) HasNewsgroup

func (self *PostgresDatabase) HasNewsgroup(group string) bool

check if a newsgroup exists

func (*PostgresDatabase) IsExpired

func (self *PostgresDatabase) IsExpired(root_message_id string) bool

func (*PostgresDatabase) MarkModPubkeyCanModGroup

func (self *PostgresDatabase) MarkModPubkeyCanModGroup(pubkey, group string) (err error)

func (*PostgresDatabase) MarkModPubkeyGlobal

func (self *PostgresDatabase) MarkModPubkeyGlobal(pubkey string) (err error)

func (*PostgresDatabase) NewsgroupBanned

func (self *PostgresDatabase) NewsgroupBanned(group string) (banned bool, err error)

func (*PostgresDatabase) NukeNewsgroup

func (self *PostgresDatabase) NukeNewsgroup(group string, store ArticleStore)

func (*PostgresDatabase) RegisterArticle

func (self *PostgresDatabase) RegisterArticle(message NNTPMessage) (err error)

register a message with the database

func (*PostgresDatabase) RegisterNewsgroup

func (self *PostgresDatabase) RegisterNewsgroup(group string)

register a new newsgroup

func (*PostgresDatabase) RegisterSigned

func (self *PostgresDatabase) RegisterSigned(message_id, pubkey string) (err error)

func (*PostgresDatabase) RemoveNNTPLogin

func (self *PostgresDatabase) RemoveNNTPLogin(username string) (err error)

func (*PostgresDatabase) ThreadHasReplies

func (self *PostgresDatabase) ThreadHasReplies(rootpost string) bool

func (*PostgresDatabase) UnMarkModPubkeyCanModGroup

func (self *PostgresDatabase) UnMarkModPubkeyCanModGroup(pubkey, group string) (err error)

func (*PostgresDatabase) UnMarkModPubkeyGlobal

func (self *PostgresDatabase) UnMarkModPubkeyGlobal(pubkey string) (err error)

func (*PostgresDatabase) UnbanAddr

func (self *PostgresDatabase) UnbanAddr(addr string) (err error)

assumes it is there

func (*PostgresDatabase) UnbanNewsgroup

func (self *PostgresDatabase) UnbanNewsgroup(group string) (err error)

type ProfilingConfig

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

pprof settings

type RedisCache

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

func (*RedisCache) Close

func (self *RedisCache) Close()

func (*RedisCache) DeleteBoardMarkup

func (self *RedisCache) DeleteBoardMarkup(group string)

func (*RedisCache) DeleteThreadMarkup

func (self *RedisCache) DeleteThreadMarkup(root_post_id string)

try to delete root post's page

func (*RedisCache) GetGroupChan

func (self *RedisCache) GetGroupChan() chan groupRegenRequest

func (*RedisCache) GetHandler

func (self *RedisCache) GetHandler() http.Handler

func (*RedisCache) GetThreadChan

func (self *RedisCache) GetThreadChan() chan ArticleEntry

func (*RedisCache) Regen

func (self *RedisCache) Regen(msg ArticleEntry)

func (*RedisCache) RegenAll

func (self *RedisCache) RegenAll()

regen every newsgroup

func (*RedisCache) RegenFrontPage

func (self *RedisCache) RegenFrontPage()

func (*RedisCache) RegenOnModEvent

func (self *RedisCache) RegenOnModEvent(newsgroup, msgid, root string, page int)

regenerate pages after a mod event

func (*RedisCache) RegenerateBoard

func (self *RedisCache) RegenerateBoard(group string)

regen every page of the board TODO do this manually so we can use pipes

func (*RedisCache) Start

func (self *RedisCache) Start()

type RedisDB

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

func (RedisDB) AddModPubkey

func (self RedisDB) AddModPubkey(pubkey string) error

func (RedisDB) AddNNTPLogin

func (self RedisDB) AddNNTPLogin(username, passwd string) (err error)

func (RedisDB) ArticleBanned

func (self RedisDB) ArticleBanned(messageID string) (result bool)

func (RedisDB) ArticleCount

func (self RedisDB) ArticleCount() (count int64)

count articles we have

func (RedisDB) BanAddr

func (self RedisDB) BanAddr(addr string) (err error)

func (RedisDB) BanArticle

func (self RedisDB) BanArticle(messageID, reason string) error

func (RedisDB) BanEncAddr

func (self RedisDB) BanEncAddr(encaddr string) (err error)

func (RedisDB) BanNewsgroup

func (self RedisDB) BanNewsgroup(group string) (err error)

func (RedisDB) CheckEncIPBanned

func (self RedisDB) CheckEncIPBanned(encaddr string) (banned bool, err error)

func (RedisDB) CheckIPBanned

func (self RedisDB) CheckIPBanned(addr string) (banned bool, err error)

func (RedisDB) CheckModPubkey

func (self RedisDB) CheckModPubkey(pubkey string) bool

func (RedisDB) CheckModPubkeyCanModGroup

func (self RedisDB) CheckModPubkeyCanModGroup(pubkey, newsgroup string) bool

func (RedisDB) CheckModPubkeyGlobal

func (self RedisDB) CheckModPubkeyGlobal(pubkey string) bool

func (RedisDB) CheckNNTPLogin

func (self RedisDB) CheckNNTPLogin(username, passwd string) (valid bool, err error)

func (RedisDB) CheckNNTPUserExists

func (self RedisDB) CheckNNTPUserExists(username string) (exists bool, err error)

func (RedisDB) Close

func (self RedisDB) Close()

finalize all transactions close database connections

func (RedisDB) CountAllArticlesInGroup

func (self RedisDB) CountAllArticlesInGroup(group string) (count int64, err error)

func (RedisDB) CountPostsInGroup

func (self RedisDB) CountPostsInGroup(newsgroup string, time_frame int64) (result int64)

func (RedisDB) CountThreadReplies

func (self RedisDB) CountThreadReplies(root_message_id string) (repls int64)

func (RedisDB) CreateTables

func (self RedisDB) CreateTables()

func (RedisDB) DeleteArticle

func (self RedisDB) DeleteArticle(msgid string) (err error)

func (RedisDB) DeleteThread

func (self RedisDB) DeleteThread(msgid string) (err error)

func (RedisDB) GetAllArticles

func (self RedisDB) GetAllArticles() (articles []ArticleEntry)

get all articles

func (RedisDB) GetAllArticlesInGroup

func (self RedisDB) GetAllArticlesInGroup(group string, recv chan ArticleEntry)

get all articles in a newsgroup send result down a channel

func (RedisDB) GetAllNewsgroups

func (self RedisDB) GetAllNewsgroups() (groups []string)

func (RedisDB) GetEncAddress

func (self RedisDB) GetEncAddress(addr string) (encaddr string, err error)

func (RedisDB) GetEncKey

func (self RedisDB) GetEncKey(encAddr string) (enckey string, err error)

func (RedisDB) GetGroupForMessage

func (self RedisDB) GetGroupForMessage(message_id string) (group string, err error)

func (RedisDB) GetGroupForPage

func (self RedisDB) GetGroupForPage(prefix, frontend, newsgroup string, pageno, perpage int) BoardModel

only fetches root posts does not update the thread contents

func (RedisDB) GetGroupPageCount

func (self RedisDB) GetGroupPageCount(newsgroup string) int64

func (RedisDB) GetGroupThreads

func (self RedisDB) GetGroupThreads(group string, recv chan ArticleEntry)

func (RedisDB) GetHeadersForMessage

func (self RedisDB) GetHeadersForMessage(msgid string) (hdr ArticleHeaders, err error)

func (RedisDB) GetIPAddress

func (self RedisDB) GetIPAddress(encaddr string) (addr string, err error)

func (RedisDB) GetInfoForMessage

func (self RedisDB) GetInfoForMessage(msgid string) (root string, newsgroup string, page int64, err error)

func (RedisDB) GetLastAndFirstForGroup

func (self RedisDB) GetLastAndFirstForGroup(group string) (last, first int64, err error)

func (RedisDB) GetLastBumpedThreads

func (self RedisDB) GetLastBumpedThreads(newsgroup string, threads int) (roots []ArticleEntry)

func (RedisDB) GetLastDaysPosts

func (self RedisDB) GetLastDaysPosts(n int64) (posts []PostEntry)

func (RedisDB) GetLastDaysPostsForGroup

func (self RedisDB) GetLastDaysPostsForGroup(newsgroup string, n int64) (posts []PostEntry)

func (RedisDB) GetLastPostedPostModels

func (self RedisDB) GetLastPostedPostModels(prefix string, n int64) (posts []PostModel)

func (RedisDB) GetMessageIDByCIDR

func (self RedisDB) GetMessageIDByCIDR(cidr *net.IPNet) (msgids []string, err error)

func (RedisDB) GetMessageIDByEncryptedIP

func (self RedisDB) GetMessageIDByEncryptedIP(encip string) (msgids []string, err error)

func (RedisDB) GetMessageIDByHash

func (self RedisDB) GetMessageIDByHash(hash string) (article ArticleEntry, err error)

func (RedisDB) GetMessageIDByHeader

func (self RedisDB) GetMessageIDByHeader(name, val string) (msgids []string, err error)

get message ids of articles with this header name and value

func (RedisDB) GetMessageIDForNNTPID

func (self RedisDB) GetMessageIDForNNTPID(group string, id int64) (msgid string, err error)

func (RedisDB) GetMonthlyPostHistory

func (self RedisDB) GetMonthlyPostHistory() (posts []PostEntry)

func (RedisDB) GetNNTPIDForMessageID

func (self RedisDB) GetNNTPIDForMessageID(group, msgid string) (id int64, err error)

func (RedisDB) GetPageForRootMessage

func (self RedisDB) GetPageForRootMessage(root_message_id string) (group string, page int64, err error)

func (RedisDB) GetPagesPerBoard

func (self RedisDB) GetPagesPerBoard(group string) (int, error)

func (RedisDB) GetPostAttachmentModels

func (self RedisDB) GetPostAttachmentModels(prefix, messageID string) (atts []AttachmentModel)

func (RedisDB) GetPostAttachments

func (self RedisDB) GetPostAttachments(messageID string) (atts []string)

func (RedisDB) GetPostModel

func (self RedisDB) GetPostModel(prefix, messageID string) PostModel

func (RedisDB) GetPostsInGroup

func (self RedisDB) GetPostsInGroup(newsgroup string) (models []PostModel, err error)

func (RedisDB) GetRootPostsForExpiration

func (self RedisDB) GetRootPostsForExpiration(newsgroup string, threadcount int) (roots []string)

func (RedisDB) GetThreadReplies

func (self RedisDB) GetThreadReplies(rootpost string, start, limit int) (repls []string)

func (RedisDB) GetThreadReplyPostModels

func (self RedisDB) GetThreadReplyPostModels(prefix, rootpost string, start, limit int) (repls []PostModel)

func (RedisDB) GetThreadsPerPage

func (self RedisDB) GetThreadsPerPage(group string) (int, error)

func (RedisDB) GroupHasPosts

func (self RedisDB) GroupHasPosts(group string) bool

func (RedisDB) HasArticle

func (self RedisDB) HasArticle(message_id string) bool

check if an article exists

func (RedisDB) HasArticleLocal

func (self RedisDB) HasArticleLocal(message_id string) bool

check if an article exists locally

func (RedisDB) HasNewsgroup

func (self RedisDB) HasNewsgroup(group string) bool

check if a newsgroup exists

func (RedisDB) IsExpired

func (self RedisDB) IsExpired(root_message_id string) bool

func (RedisDB) MarkModPubkeyCanModGroup

func (self RedisDB) MarkModPubkeyCanModGroup(pubkey, group string) (err error)

func (RedisDB) MarkModPubkeyGlobal

func (self RedisDB) MarkModPubkeyGlobal(pubkey string) (err error)

func (RedisDB) NewsgroupBanned

func (self RedisDB) NewsgroupBanned(group string) (banned bool, err error)

func (RedisDB) NukeNewsgroup

func (self RedisDB) NukeNewsgroup(group string, store ArticleStore)

func (RedisDB) RegisterArticle

func (self RedisDB) RegisterArticle(message NNTPMessage) (err error)

register a message with the database

func (RedisDB) RegisterNewsgroup

func (self RedisDB) RegisterNewsgroup(group string)

register a new newsgroup

func (RedisDB) RegisterSigned

func (self RedisDB) RegisterSigned(message_id, pubkey string) (err error)

func (RedisDB) RemoveNNTPLogin

func (self RedisDB) RemoveNNTPLogin(username string) (err error)

func (RedisDB) ThreadHasReplies

func (self RedisDB) ThreadHasReplies(rootpost string) bool

func (RedisDB) UnMarkModPubkeyCanModGroup

func (self RedisDB) UnMarkModPubkeyCanModGroup(pubkey, group string) (err error)

func (RedisDB) UnMarkModPubkeyGlobal

func (self RedisDB) UnMarkModPubkeyGlobal(pubkey string) (err error)

func (RedisDB) UnbanAddr

func (self RedisDB) UnbanAddr(addr string) (err error)

func (RedisDB) UnbanNewsgroup

func (self RedisDB) UnbanNewsgroup(group string) (err error)

type RegenFunc

type RegenFunc func(newsgroup, msgid, root string, page int)

regenerate pages function

type SRNdConfig

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

func ReadConfig

func ReadConfig() *SRNdConfig

read config files

func (*SRNdConfig) Validate

func (self *SRNdConfig) Validate()

fatals on failed validation

type StepModel

type StepModel struct {
	Node *dialogNode
}

func (*StepModel) HasNext

func (self *StepModel) HasNext() bool

func (*StepModel) HasPrevious

func (self *StepModel) HasPrevious() bool

type ThreadModel

type ThreadModel interface {
	BaseModel
	NavbarModel

	SetAllowFiles(allow bool)
	AllowFiles() bool
	OP() PostModel
	Replies() []PostModel
	Board() string
	BoardURL() string
	// return a short version of the thread
	// does not include all replies
	Truncate() ThreadModel
	// update the thread's replies
	Update(db Database)
	// is this thread dirty and needing updating?
	IsDirty() bool
	// mark thread as dirty
	MarkDirty()
}

for threads

Jump to

Keyboard shortcuts

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