Documentation ¶
Index ¶
- Constants
- Variables
- func AppendBoardHeaderFileRecord(filename string, newBoardHeader *BoardHeader) error
- func GetBoardArticleFilePath(workDirectory string, boardID string, filename string) (string, error)
- func GetBoardArticlesDirectoryPath(workDirectory string, boardID string) (string, error)
- func GetBoardNameFilePath(workDirectory string, boardID string) (string, error)
- func GetBoardPath(workDirectory string) (string, error)
- func GetBoardTreasureFilePath(workDirectory string, boardID string, path []string, filename string) (string, error)
- func GetBoardTreasuresDirectoryPath(workDirectory string, boardID string, path []string) (string, error)
- func GetLoginRecentPath(workDirectory string, userid string) (string, error)
- func GetPasswdsPath(workDirectory string) (string, error)
- func GetUserFavoritePath(workDirectory string, userid string) (string, error)
- func GetUserMailPath(workDirectory string, userID string, filename string) (string, error)
- func RemoveBoardHeaderFileRecord(filename string, index int) error
- type BoardHeader
- func (b *BoardHeader) BM() []string
- func (b *BoardHeader) BoardID() string
- func (b *BoardHeader) ClassID() string
- func (b *BoardHeader) IsAlignedComment() bool
- func (b *BoardHeader) IsAngelAnonymous() bool
- func (b *BoardHeader) IsAnonymous() bool
- func (b *BoardHeader) IsBMCount() bool
- func (b *BoardHeader) IsBMMaskContent() bool
- func (b *BoardHeader) IsCPLog() bool
- func (b *BoardHeader) IsClass() bool
- func (b *BoardHeader) IsCooldown() bool
- func (b *BoardHeader) IsDefaultAnonymous() bool
- func (b *BoardHeader) IsGroupBoard() bool
- func (b *BoardHeader) IsGuestPost() bool
- func (b *BoardHeader) IsHide() bool
- func (b *BoardHeader) IsIPLogRecommend() bool
- func (b *BoardHeader) IsIsSymbolic() bool
- func (b *BoardHeader) IsNoBoo() bool
- func (b *BoardHeader) IsNoCount() bool
- func (b *BoardHeader) IsNoCredit() bool
- func (b *BoardHeader) IsNoFastRecommend() bool
- func (b *BoardHeader) IsNoRecommend() bool
- func (b *BoardHeader) IsNoReply() bool
- func (b *BoardHeader) IsNoSelfDeletePost() bool
- func (b *BoardHeader) IsOver18() bool
- func (b *BoardHeader) IsPostMask() bool
- func (b *BoardHeader) IsRestrictedPost() bool
- func (b *BoardHeader) IsTop() bool
- func (b *BoardHeader) IsVoteBoard() bool
- func (b *BoardHeader) IsWarnEL() bool
- func (b *BoardHeader) MarshalBinary() ([]byte, error)
- func (b *BoardHeader) SetBoardID(newValue string)
- func (b *BoardHeader) SetTitle(newValue string)
- func (b *BoardHeader) Title() string
- type Cache
- type Connector
- func (c *Connector) AddBoardRecordFileRecord(name string, brd bbs.BoardRecord) error
- func (c *Connector) GetBoardArticleFilePath(boardID string, filename string) (string, error)
- func (c *Connector) GetBoardArticleRecordsPath(boardID string) (string, error)
- func (c *Connector) GetBoardRecordsPath() (string, error)
- func (c *Connector) GetBoardTreasureFilePath(boardID string, treasureID []string, filename string) (string, error)
- func (c *Connector) GetBoardTreasureRecordsPath(boardID string, treasureID []string) (string, error)
- func (c *Connector) GetUserFavoriteRecordsPath(userID string) (string, error)
- func (c *Connector) GetUserRecordsPath() (string, error)
- func (c *Connector) NewBoardRecord(args map[string]interface{}) (bbs.BoardRecord, error)
- func (c *Connector) Open(dataSourceName string) error
- func (c *Connector) ReadArticleRecordsFile(filename string) ([]bbs.ArticleRecord, error)
- func (c *Connector) ReadBoardArticleFile(filename string) ([]byte, error)
- func (c *Connector) ReadBoardRecordFileRecord(name string, index uint) (bbs.BoardRecord, error)
- func (c *Connector) ReadBoardRecordsFile(path string) ([]bbs.BoardRecord, error)
- func (c *Connector) ReadUserFavoriteRecordsFile(filename string) ([]bbs.FavoriteRecord, error)
- func (c *Connector) ReadUserRecordsFile(filename string) ([]bbs.UserRecord, error)
- func (c *Connector) RemoveBoardRecordFileRecord(name string, index uint) error
- func (c *Connector) UpdateBoardRecordFileRecord(name string, index uint, brd bbs.BoardRecord) error
- type FavAttr
- type FavBoardItem
- type FavFile
- type FavFolder
- type FavFolderItem
- type FavItem
- func (favi *FavItem) BoardID() string
- func (favi *FavItem) GetBoard() *FavBoardItem
- func (favi *FavItem) GetFolder() *FavFolderItem
- func (favi *FavItem) GetLine() *FavLineItem
- func (favi *FavItem) MarshalBinary() ([]byte, error)
- func (favi *FavItem) Records() []bbs.FavoriteRecord
- func (favi *FavItem) Title() string
- func (favi *FavItem) Type() bbs.FavoriteType
- type FavItemType
- type FavLineItem
- type FileHeader
- func (f *FileHeader) Date() string
- func (f *FileHeader) Filename() string
- func (f *FileHeader) IsVotePost() bool
- func (f *FileHeader) MarshalToByte() ([]byte, error)
- func (f *FileHeader) Modified() time.Time
- func (f *FileHeader) Money() int
- func (f *FileHeader) Owner() string
- func (f *FileHeader) Recommend() int
- func (f *FileHeader) Title() string
- type LoginAttempt
- type LoginRecentRecord
- type MemoryMappingSetting
- type MessageQueueCache
- type UserInfoCache
- type Userec
- func (u *Userec) HashedPassword() string
- func (u *Userec) LastHost() string
- func (u *Userec) LastLogin() time.Time
- func (u *Userec) MarshalToByte() ([]byte, error)
- func (u *Userec) Money() int
- func (u *Userec) Nickname() string
- func (u *Userec) NumLoginDays() int
- func (u *Userec) NumPosts() int
- func (u *Userec) RealName() string
- func (u *Userec) UserID() string
- func (u *Userec) VerifyPassword(password string) error
- type UserecGameScore
- type VoteLimits
Constants ¶
const ( PosOfBoardName = 0 PosOfBoardTitle = PosOfBoardName + IDLength + 1 PosOfBM = PosOfBoardTitle + BoardTitleLength + 1 PosOfBrdAttr = 3 + IDLength*3 + 3 + PosOfBM PosOfChessCountry = PosOfBrdAttr + 4 PosOfVoteLimitPosts = PosOfChessCountry + 1 PosOfVoteLimitLogins = PosOfVoteLimitPosts + 1 PosOfBUpdate = 1 + PosOfVoteLimitLogins + 1 PosOfPostLimitPosts = PosOfBUpdate + 4 PosOfPostLimitLogins = PosOfPostLimitPosts + 1 PosOfBVote = 1 + PosOfPostLimitLogins + 1 PosOfVTime = PosOfBVote + 1 PosOfLevel = PosOfVTime + 4 PosOfPermReload = PosOfLevel + 4 PosOfGid = PosOfPermReload + 4 PosOfNext = PosOfGid + 4 PosOfFirstChild = PosOfNext + 8 PosOfParent = PosOfFirstChild + 8 PosOfChildCount = PosOfParent + 4 PosOfNuser = PosOfChildCount + 4 PosOfPostExpire = PosOfNuser + 4 PosOfEndGamble = PosOfPostExpire + 4 PosOfPostType = PosOfEndGamble + 4 PosOfPostTypeF = PosOfPostType + 33 PosOfFastRecommendPause = PosOfPostTypeF + 1 PosOfVoteLimitBadPost = PosOfFastRecommendPause + 1 PosOfPostLimitBadPost = PosOfVoteLimitBadPost + 1 PosOfSRExpire = 3 + PosOfPostLimitBadPost + 1 )
const ( // BoardPostMask https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L211 BoardPostMask = 0x00000020 // BoardGroupBoard https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L209 BoardGroupBoard = 0x00000008 // PermSYSOP https://github.com/ptt/pttbbs/blob/master/include/perm.h#L22 PermSYSOP = 000000040000 // PermBM https://github.com/ptt/pttbbs/blob/master/include/perm.h#L18 PermBM = 000000002000 // BoardHide https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L210 BoardHide = 0x00000010 BoardHeaderRecordLength = 256 )
const ( ////////// //pttstruch.h ////////// // IDLength https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L13 IDLength = 12 /* Length of bid/uid */ // IPV4Length https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L14 IPV4Length = 15 /* a.b.c.d form */ // PasswordInputLength https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L49 PasswordInputLength = 8 /* Length of valid input password length. For DES, set to 8. */ // PasswordLength https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L51 PasswordLength = 14 /* Length of encrypted passwd field */ // RegistrationLength https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L52 RegistrationLength = 38 /* Length of registration data */ // RealNameSize https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L62 RealNameSize = 20 /* Size of real-name field */ // NicknameSize https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L63 NicknameSize = 24 /* SIze of nick-name field */ // EmailSize https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L53 EmailSize = 50 /* Size of email field */ // AddressSize https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L79 AddressSize = 50 /* Size of address field */ // CareerSize https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L91 CareerSize = 40 /* Size of career field */ // PhoneSize https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L92 PhoneSize = 20 /* Size of phone field */ // PasswdVersion https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L55 PasswdVersion = 4194 /* passwd version */ // TitleLength https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L253 TitleLength = 64 /* Length of title */ // FileNameLength https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L254 FileNameLength = 28 /* Length of filename */ )
const ( ////////// //pttstruch.h: 292 ////////// // FileLocal https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L292 FileLocal = 0x01 /* local saved, non-mail */ // FileRead https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L293 FileRead = 0x01 /* already read, mail only */ // FileMarked https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L294 FileMarked = 0x02 /* non-mail + mail */ // FileDigest https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L295 FileDigest = 0x04 /* digest, non-mail */ // FileReplied https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L296 FileReplied = 0x04 /* replied, mail only */ // FileBottom https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L297 FileBottom = 0x08 /* push_bottom, non-mail */ // FileMulti https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L298 FileMulti = 0x08 /* multi send, mail only */ // FileSolved https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L299 FileSolved = 0x10 /* problem solved, sysop/BM non-mail only */ // FileHide https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L300 FileHide = 0x20 /* hide, in announce */ // FileBoardID https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L301 FileBoardID = 0x20 /* bid, in non-announce */ // FileBoardMaster https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L302 FileBoardMaster = 0x40 /* BM only, in announce */ // FileVote https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L303 FileVote = 0x40 /* for vote, in non-announce */ // FileAnonymous https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L304 FileAnonymous = 0x80 /* anonymous file */ )
const ( PosOfFileHeaderFilename = 0 PosOfFileHeaderModified = PosOfFileHeaderFilename + FileNameLength PosOfFileHeaderRecommend = 1 + PosOfFileHeaderModified + 4 PosOfFileHeaderOwner = PosOfFileHeaderRecommend + 1 PosOfFileHeaderDate = PosOfFileHeaderOwner + IDLength + 2 PosOfFileHeaderTitle = PosOfFileHeaderDate + 6 PosOfFileHeaderUnionMulti = 1 + PosOfFileHeaderTitle + TitleLength + 1 PosOfFileHeaderFilemode = PosOfFileHeaderUnionMulti + 4 )
const ( PosOfPasswdVersion = 0 PosOfPasswdUserID = PosOfPasswdVersion + 4 PosOfPasswdRealName = PosOfPasswdUserID + IDLength + 1 PosOfPasswdNickname = PosOfPasswdRealName + RealNameSize PosOfPasswdPassword = PosOfPasswdNickname + NicknameSize PosOfPasswdUserFlag = PosOfPasswdPassword + PasswordLength + 1 PosOfPasswdUserLevel = PosOfPasswdUserFlag + 4 + 4 PosOfPasswdNumLoginDays = PosOfPasswdUserLevel + 4 PosOfPasswdNumPosts = PosOfPasswdNumLoginDays + 4 PosOfPasswdFirstLogin = PosOfPasswdNumPosts + 4 PosOfPasswdLastLogin = PosOfPasswdFirstLogin + 4 PosOfPasswdLastHost = PosOfPasswdLastLogin + 4 PosOfPasswdMoney = PosOfPasswdLastHost + IPV4Length + 1 PosOfPasswdEmail = PosOfPasswdMoney + 4 + 4 PosOfPasswdAddress = PosOfPasswdEmail + EmailSize PosOfPasswdJustify = PosOfPasswdAddress + AddressSize PosOfPasswdOver18 = PosOfPasswdJustify + RegistrationLength + 1 + 3 PosOfPasswdPagerUIType = PosOfPasswdOver18 + 1 PosOfPasswdPager = PosOfPasswdPagerUIType + 1 PosOfPasswdInvisible = PosOfPasswdPager + 1 PosOfPasswdExMailBox = PosOfPasswdInvisible + 1 + 2 PosOfPasswdCareer = PosOfPasswdExMailBox + 4 + 4 PosOfPasswdRole = PosOfPasswdCareer + CareerSize + 20 + 4 + 44 PosOfPasswdLastSeen = PosOfPasswdRole + 4 PosOfPasswdTimeSetAngel = PosOfPasswdLastSeen + 4 PosOfPasswdTimePlayAngel = PosOfPasswdTimeSetAngel + 4 PosOfPasswdLastSong = PosOfPasswdTimePlayAngel + 4 PosOfPasswdLoginView = PosOfPasswdLastSong + 4 PosOfPasswdLawCounter = PosOfPasswdLoginView + 4 + 2 PosOfPasswdFiveWin = PosOfPasswdLawCounter + 2 PosOfPasswdFiveLose = PosOfPasswdFiveWin + 2 PosOfPasswdFiveTie = PosOfPasswdFiveLose + 2 PosOfPasswdChcWin = PosOfPasswdFiveTie + 2 PosOfPasswdChcLose = PosOfPasswdChcWin + 2 PosOfPasswdChcTie = PosOfPasswdChcLose + 2 PosOfPasswdConn6Win = PosOfPasswdChcTie + 2 PosOfPasswdConn6Lose = PosOfPasswdConn6Win + 2 PosOfPasswdConn6Tie = PosOfPasswdConn6Lose + 2 PosOfPasswdGoWin = PosOfPasswdConn6Tie + 2 + 2 PosOfPasswdGoLose = PosOfPasswdGoWin + 2 PosOfPasswdGoTie = PosOfPasswdGoLose + 2 PosOfPasswdDarkWin = PosOfPasswdGoTie + 2 PosOfPasswdDarkLose = PosOfPasswdDarkWin + 2 PosOfPasswdUaVersion = PosOfPasswdDarkLose + 2 PosOfPasswdSignature = PosOfPasswdUaVersion + 1 PosOfPasswdBadPost = PosOfPasswdSignature + 1 + 1 PosOfPasswdDarkTie = PosOfPasswdBadPost + 1 PosOfPasswdMyAngel = PosOfPasswdDarkTie + 2 PosOfPasswdChessEloRating = PosOfPasswdMyAngel + IDLength + 1 + 1 PosOfPasswdWithMe = PosOfPasswdChessEloRating + 2 PosOfPasswdTimeRemoveBadPost = PosOfPasswdWithMe + 4 PosOfPasswdTimeViolateLaw = PosOfPasswdTimeRemoveBadPost + 4 )
const (
// BoardTitleLength https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L165
BoardTitleLength = 48
)
const (
TIME4TBytes = 4 // Bytes for time4_t
)
const (
// UserIDLength is fixed to 12
UserIDLength = 12
)
Variables ¶
var ( ErrInvalidFavType = errors.New("invalid Favorite type") ErrIndexOutOfBound = errors.New("index out of range, file format invalid") )
var (
ErrInvalidLoginsBadFormat = errors.New("Invalid logins.bad line format")
)
Functions ¶
func AppendBoardHeaderFileRecord ¶
func AppendBoardHeaderFileRecord(filename string, newBoardHeader *BoardHeader) error
func GetBoardArticleFilePath ¶
Get Directory article file path of board, `workDirectory` is BBSHome usually, `boardID` means which board, and filename is actual file in board, notice that, we will check is file exist or user has permission for open this file. eg, .DIR file, so please check filename before call this function.
func GetBoardArticlesDirectoryPath ¶
Get Directory normal file path of board
func GetBoardNameFilePath ¶
Get Directory digest file path of board
func GetBoardPath ¶
Get Board file path of system
func GetBoardTreasuresDirectoryPath ¶
func GetBoardTreasuresDirectoryPath(workDirectory string, boardID string, path []string) (string, error)
GetBoardTreasuresDirectoryPath return dir file path of specific board and path, `workDirectory` is BBSHome usually, `boardID` means which board and `path` is a slice figure out each directory, eg: `["M.971228479.A", "M.1035338027.A"]` in formosa BBS or `["D690", "D6C2", "D6D1"]` in pttbbs.
func GetLoginRecentPath ¶
Get Login Recent file path of user
func GetPasswdsPath ¶
Get Passwd file path of system
func GetUserFavoritePath ¶
Get Favorite file path of user
func GetUserMailPath ¶
Get Directory digest file path of board, `workDirectory` is BBSHome usually, `userID` means which user, and filename is actual file in user, notice that, we will check is file exist or user has permission for open this file. eg, .DIR file, so please check filename before call this function.
Types ¶
type BoardHeader ¶
type BoardHeader struct { BrdName string Brdattr uint32 // uid[.] ChessCountry string VoteLimitPosts uint8 VoteLimitLogins uint8 BUpdate time.Time PostLimitPosts uint8 PostLimitLogins uint8 BVote uint8 VTime time.Time Level uint32 PermReload time.Time // Parent class id, first item is start from 1. Gid int32 Next []int32 FirstChild []int32 Parent int32 ChildCount int32 Nuser int32 PostExpire int32 EndGamble time.Time PostType string PostTypeF string FastRecommendPause uint8 VoteLimitBadPost uint8 PostLimitBadPost uint8 SRexpire time.Time // contains filtered or unexported fields }
func NewBoardHeader ¶ added in v0.3.0
func NewBoardHeader() *BoardHeader
func NewBoardHeaderWithByte ¶
func NewBoardHeaderWithByte(data []byte) (*BoardHeader, error)
func OpenBoardHeaderFile ¶
func OpenBoardHeaderFile(filename string) ([]*BoardHeader, error)
func (*BoardHeader) BM ¶
func (b *BoardHeader) BM() []string
func (*BoardHeader) BoardID ¶ added in v0.3.0
func (b *BoardHeader) BoardID() string
func (*BoardHeader) ClassID ¶ added in v0.3.0
func (b *BoardHeader) ClassID() string
func (*BoardHeader) IsAlignedComment ¶
func (b *BoardHeader) IsAlignedComment() bool
func (*BoardHeader) IsAngelAnonymous ¶
func (b *BoardHeader) IsAngelAnonymous() bool
func (*BoardHeader) IsAnonymous ¶
func (b *BoardHeader) IsAnonymous() bool
func (*BoardHeader) IsBMCount ¶
func (b *BoardHeader) IsBMCount() bool
func (*BoardHeader) IsBMMaskContent ¶
func (b *BoardHeader) IsBMMaskContent() bool
func (*BoardHeader) IsCPLog ¶
func (b *BoardHeader) IsCPLog() bool
func (*BoardHeader) IsClass ¶
func (b *BoardHeader) IsClass() bool
func (*BoardHeader) IsCooldown ¶
func (b *BoardHeader) IsCooldown() bool
func (*BoardHeader) IsDefaultAnonymous ¶
func (b *BoardHeader) IsDefaultAnonymous() bool
func (*BoardHeader) IsGroupBoard ¶
func (b *BoardHeader) IsGroupBoard() bool
func (*BoardHeader) IsGuestPost ¶
func (b *BoardHeader) IsGuestPost() bool
func (*BoardHeader) IsHide ¶
func (b *BoardHeader) IsHide() bool
func (*BoardHeader) IsIPLogRecommend ¶
func (b *BoardHeader) IsIPLogRecommend() bool
func (*BoardHeader) IsIsSymbolic ¶
func (b *BoardHeader) IsIsSymbolic() bool
func (*BoardHeader) IsNoBoo ¶
func (b *BoardHeader) IsNoBoo() bool
func (*BoardHeader) IsNoCount ¶
func (b *BoardHeader) IsNoCount() bool
func (*BoardHeader) IsNoCredit ¶
func (b *BoardHeader) IsNoCredit() bool
func (*BoardHeader) IsNoFastRecommend ¶
func (b *BoardHeader) IsNoFastRecommend() bool
func (*BoardHeader) IsNoRecommend ¶
func (b *BoardHeader) IsNoRecommend() bool
func (*BoardHeader) IsNoReply ¶
func (b *BoardHeader) IsNoReply() bool
func (*BoardHeader) IsNoSelfDeletePost ¶
func (b *BoardHeader) IsNoSelfDeletePost() bool
func (*BoardHeader) IsOver18 ¶
func (b *BoardHeader) IsOver18() bool
func (*BoardHeader) IsPostMask ¶
func (b *BoardHeader) IsPostMask() bool
func (*BoardHeader) IsRestrictedPost ¶
func (b *BoardHeader) IsRestrictedPost() bool
func (*BoardHeader) IsTop ¶
func (b *BoardHeader) IsTop() bool
func (*BoardHeader) IsVoteBoard ¶
func (b *BoardHeader) IsVoteBoard() bool
func (*BoardHeader) IsWarnEL ¶
func (b *BoardHeader) IsWarnEL() bool
func (*BoardHeader) MarshalBinary ¶
func (b *BoardHeader) MarshalBinary() ([]byte, error)
func (*BoardHeader) SetBoardID ¶ added in v0.3.0
func (b *BoardHeader) SetBoardID(newValue string)
func (*BoardHeader) SetTitle ¶ added in v0.3.0
func (b *BoardHeader) SetTitle(newValue string)
func (*BoardHeader) Title ¶
func (b *BoardHeader) Title() string
type Cache ¶ added in v0.3.0
type Cache struct { cache.Cache *MemoryMappingSetting // contains filtered or unexported fields }
Cache provides an IPC(inter-process communication) bridge with process-based pttbbs process, and shars the cache with board info, user info ...
func NewCache ¶ added in v0.3.0
func NewCache(connectionString string, settings *MemoryMappingSetting) (*Cache, error)
NewCache returns Cache (SHM) by connectionString, connectionString indicate the shm location with uri format eg. shmkey:1228 or file:/tmp/ramdisk/bbs.shm
func (*Cache) Money ¶ added in v0.3.0
Money returns the money user have with specific uid, uid start with 0
func (*Cache) UserID ¶ added in v0.3.0
UserID returns userId string with specific uid, such as "SYSOP", uid means the index in PASSWD file, start with 0.
func (*Cache) UserInfo ¶ added in v0.3.0
func (c *Cache) UserInfo(uid int) UserInfoCache
type Connector ¶
type Connector struct {
// contains filtered or unexported fields
}
func (*Connector) AddBoardRecordFileRecord ¶ added in v0.3.0
AddBoardRecordFileRecord given record file name and new record, should append file record in that file.
func (*Connector) GetBoardArticleFilePath ¶
func (*Connector) GetBoardArticleRecordsPath ¶
func (*Connector) GetBoardRecordsPath ¶
func (*Connector) GetBoardTreasureFilePath ¶
func (*Connector) GetBoardTreasureRecordsPath ¶
func (*Connector) GetUserFavoriteRecordsPath ¶
func (*Connector) GetUserRecordsPath ¶
func (*Connector) NewBoardRecord ¶ added in v0.3.0
func (*Connector) Open ¶
Open connect a file directory or SHMs, dataSourceName pointer to bbs home And it can append argument for SHM for example `file:///home/bbs/?UTMP=1993`
func (*Connector) ReadArticleRecordsFile ¶
func (*Connector) ReadBoardArticleFile ¶
ReadBoardArticleFile returns raw file of specific filename article.
func (*Connector) ReadBoardRecordFileRecord ¶ added in v0.3.0
ReadBoardRecordFileRecord return boardRecord brd on index in record file.
func (*Connector) ReadBoardRecordsFile ¶
func (*Connector) ReadUserFavoriteRecordsFile ¶
func (*Connector) ReadUserRecordsFile ¶
func (*Connector) RemoveBoardRecordFileRecord ¶ added in v0.3.0
RemoveBoardRecordFileRecord remove boardRecord brd on index in record file.
type FavBoardItem ¶
type FavBoardItem struct { BoardID uint32 LastVisit time.Time Attr uint32 // contains filtered or unexported fields }
FavBoardItem represents a Board in FavFolder. FavBoardItem takes 12 bytes
func NewFavBoardItem ¶
func NewFavBoardItem(data []byte, startIndex int) (*FavBoardItem, int, error)
NewFavBoardItem takes a []byte and parse it starting from startIndex, return FavBoardItem, end index and error
func (*FavBoardItem) MarshalBinary ¶
func (favbi *FavBoardItem) MarshalBinary() ([]byte, error)
type FavFile ¶
FavFile represents the entire fav file. Starts with 2 bytes of Version and at most 1 FavFolder.
func NewFavFile ¶
NewFavFile parse data and return FavFile
func (*FavFile) MarshalBinary ¶
type FavFolder ¶
type FavFolder struct { NAlloc uint16 DataTail uint16 NBoards uint16 NLines uint8 NFolders uint8 LineID uint8 FolderID uint8 FavItems []*FavItem }
FavFolder represents a folder in .fav file. Each folder could contain NBoards of board, NLines of lines and NFolders of sub-folders.
func NewFavFolder ¶
NewFavFolder takes a []byte, parse it starting with startIndex, return an instance of FavFolder, endIndex and error.
func (*FavFolder) MarshalBinary ¶
type FavFolderItem ¶
FavFolderItem represents a Folder in FavFolder. FavFolderItem takes 50 bytes
func NewFavFolderItem ¶
func NewFavFolderItem(data []byte, startIndex int) (*FavFolderItem, int, error)
NewFavFolderItem takes a []byte and parse it starting from startIndex, return FavFolderItem, end index and error
func (*FavFolderItem) MarshalBinary ¶
func (favfi *FavFolderItem) MarshalBinary() ([]byte, error)
type FavItem ¶
type FavItem struct { FavType FavItemType FavAttr uint8 Item interface{} // This could be either FavBoardItem / FavFolderItem / FavLineItem }
FavItem represents 1 Item in FavFolder
func NewFavItem ¶
NewFavItem parse data starting from startIndex and return FavItem. FavItem.Item might be either FavBoardItem, FavFolderItem or FavLineItem
func (*FavItem) GetBoard ¶
func (favi *FavItem) GetBoard() *FavBoardItem
GetBoard tries to cast Item to FavBoardItem; return nil if it is not
func (*FavItem) GetFolder ¶
func (favi *FavItem) GetFolder() *FavFolderItem
GetFolder tries to cast Item to FavFolderItem; return nil if it is not
func (*FavItem) GetLine ¶
func (favi *FavItem) GetLine() *FavLineItem
GetLine tries to cast Item to FavLineItem; return nil if it is not
func (*FavItem) MarshalBinary ¶
type FavItemType ¶
type FavItemType uint8
const ( FavItemTypeBoard FavItemType = 1 // FAVT_BOARD FavItemTypeFolder FavItemType = 2 // FAVT_FOLDER FavItemTypeLine FavItemType = 3 // FAVT_LINE )
type FavLineItem ¶
type FavLineItem struct {
LineID uint8
}
FavLineItem represents a Line in FavFolder. FavLineItem takes 1 byte
func NewFavLineItem ¶
func NewFavLineItem(data []byte, startIndex int) (*FavLineItem, int, error)
NewFavLineItem takes a []byte and parse it starting from startIndex, return FavLineItem, end index and error
func (*FavLineItem) MarshalBinary ¶
func (favli *FavLineItem) MarshalBinary() ([]byte, error)
type FileHeader ¶
type FileHeader struct { AnnoUID int VoteLimits ReferRef uint // 至底公告? ReferFlag bool // 至底公告? Filemode uint8 // contains filtered or unexported fields }
FileHeader records article's metainfo
func NewFileHeaderWithByte ¶
func NewFileHeaderWithByte(data []byte) (*FileHeader, error)
func OpenFileHeaderFile ¶
func OpenFileHeaderFile(filename string) ([]*FileHeader, error)
OpenFileHeaderFile function open a .DIR file in board directory. It returns slice of FileHeader.
func (*FileHeader) Date ¶
func (f *FileHeader) Date() string
func (*FileHeader) Filename ¶
func (f *FileHeader) Filename() string
func (*FileHeader) IsVotePost ¶
func (f *FileHeader) IsVotePost() bool
func (*FileHeader) MarshalToByte ¶
func (f *FileHeader) MarshalToByte() ([]byte, error)
func (*FileHeader) Modified ¶
func (f *FileHeader) Modified() time.Time
func (*FileHeader) Money ¶
func (f *FileHeader) Money() int
func (*FileHeader) Owner ¶
func (f *FileHeader) Owner() string
func (*FileHeader) Recommend ¶
func (f *FileHeader) Recommend() int
func (*FileHeader) Title ¶
func (f *FileHeader) Title() string
type LoginAttempt ¶
LoginAttempt represents an entry in logins.bad file to indicate a successful or failed login attempt for a UserID. Note that UserID could be empty if the logins.bad is under user dir.
func OpenBadLoginFile ¶
func OpenBadLoginFile(filename string) ([]*LoginAttempt, error)
OpenBadLoginFile opens logins.bad file and returns a slice of LoginAttempt. Note that depending on different format of logins.bad as descirbed above, each LoginAttempt might not have LoginAttempt.UserID field
func (*LoginAttempt) IsUnderBbsHome ¶
func (l *LoginAttempt) IsUnderBbsHome() bool
IsUnderBbsHome return true if this LoginAttempt was read from logins.bad from under BBSHOME. The difference between logins.bad between under BBSHOME and under User Dir is whether it contains UserID
func (*LoginAttempt) MarshalText ¶
func (l *LoginAttempt) MarshalText() ([]byte, error)
MarshalText implements encoding.TextMarshaler to marshal receiver to text
func (*LoginAttempt) UnmarshalText ¶
func (l *LoginAttempt) UnmarshalText(text []byte) error
UnmarshalText implements encoding.TextUnmarshaler to unmarshal text to the receiver
type LoginRecentRecord ¶
LoginRecentRecord records Login record, please see https://github.com/ptt/pttbbs/blob/446c2bc34867286a2a093615ea69501f32c127e4/mbbsd/mbbsd.c#L1123
func NewLoginRecentRecord ¶
func NewLoginRecentRecord(line string) (*LoginRecentRecord, error)
func OpenLoginRecentFile ¶
func OpenLoginRecentFile(filename string) ([]*LoginRecentRecord, error)
type MemoryMappingSetting ¶ added in v0.3.0
type MemoryMappingSetting struct { AlignmentBytes int // 1, 2, 4 or 8, 1 for no aligment MaxUsers int IDLen int UseCoolDown bool HashBits int }
MemoryMappingSetting provides parameters for calculating the memory position of
the relevant fields.
type MessageQueueCache ¶ added in v0.3.0
type MessageQueueCache []byte
MessageQueueCache is `msgque_t` in pttstruct.h, all of those object will be store in shared memory
type UserInfoCache ¶ added in v0.3.0
type UserInfoCache []byte
UserInfoCache is `userinfo_t` in pttstruct.h, all of those object will be store in shared memory
type Userec ¶
type Userec struct { Version uint32 // Magic Number UserFlag uint32 UserLevel uint32 // 權限 Email string Address string Justify string Over18 bool PagerUIType uint8 Pager uint8 Invisible bool ExMailBox uint32 Career string Role uint32 LastSeen time.Time TimeSetAngel time.Time TimePlayAngel time.Time LastSong time.Time LoginView uint32 ViolateLaw uint16 Five UserecGameScore ChineseChess UserecGameScore Conn6 UserecGameScore GoChess UserecGameScore DarkChess UserecGameScore UaVersion uint8 // User Agreement Version Signature uint8 BadPost uint8 MyAngel string ChessEloRating uint16 WithMe uint32 TimeRemoveBadPost time.Time TimeViolateLaw time.Time // contains filtered or unexported fields }
func NewUserecWithByte ¶
func OpenUserecFile ¶
func (*Userec) HashedPassword ¶
func (*Userec) MarshalToByte ¶
func (*Userec) Nickname ¶
Nickname return a string for user's nickname, this string may change depend on user's mood, return empty string if this bbs system do not support
func (*Userec) NumLoginDays ¶
NumLoginDays return how many days this have been login since account created.
func (*Userec) RealName ¶
RealName return a string for user's real name, this string may not be changed return empty string if this bbs system do not support
func (*Userec) VerifyPassword ¶
VerifyPassword will check user's password is OK. it will return null when OK and error when there are something wrong