pttbbs

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

README

簡介

這邊是 pttbbs 的 driver

參考文件

系統檔案列表

   1 歡迎畫面                             etc/Welcome
    2 出站畫面                             etc/Logout
    3 錯誤登入訊息                         etc/goodbye
    4 站長名單                             etc/sysop
    5 帳號站長信箱收信列表                 etc/mail_account_sysop
    6 帳號站長信箱收信說明                 etc/mail_account_sysop_desc
    7 拒絕連線IP列表 (BANIP)               etc/banip.conf
    8 進站畫面0                            etc/Welcome_login.0
    9 進站畫面1                            etc/Welcome_login.1
   10 進站畫面2                            etc/Welcome_login.2
   11 進站畫面3                            etc/Welcome_login.3
   12 進站畫面4                            etc/Welcome_login.4
   13 過度轉錄開的罰單通知信               etc/crosspost.txt
   14 我的最愛預設列表                     etc/myfav_defaults
   15 發文注意事項                         etc/post.note
   16 看板期限                             etc/expire2.conf
   17 節日                                 etc/feast
   18 故鄉                                 etc/domain_name_query.cidr
   19 註冊 email 白名單                    etc/whitemail
   20 註冊 email 未在白名單的通知訊息      etc/whitemail.notice
   21 註冊 email 黑名單                    etc/banemail
   22 註冊範例                             etc/register
   23 註冊通過通知                         etc/registered
   24 新使用者需知                         etc/newuser
   25 退註通知附加說明                     etc/reg_reject.notes
   26 註冊單填寫說明                       etc/regnotes/front
   27 註冊細項說明[是否現住台灣]           etc/regnotes/foreign
   28 註冊細項說明[姓名]                   etc/regnotes/name
   29 註冊細項說明[職業]                   etc/regnotes/career
   30 註冊細項說明[住址]                   etc/regnotes/address
   31 註冊細項說明[電話]                   etc/regnotes/phone
   32 註冊細項說明[手機]                   etc/regnotes/mobile
   33 註冊細項說明[生日]                   etc/regnotes/birthday
   34 註冊細項說明[性別]                   etc/regnotes/sex
  35 看板列表說明                         etc/boardlist.help
   36 文章列表說明                         etc/board.help
   37 小天使認證通知                       etc/angel_notify
   38 小天使功能說明                       etc/angel_usage
   39 小天使功能說明(有留言)               etc/angel_usage2
   40 小天使離線訊息(有留言)               etc/angel_offline2
   41 外籍使用者認證通知                   etc/foreign_welcome
   42 外籍使用者過期警告通知               etc/foreign_expired_warn

建立新看板的設定值

  【 建立新板 】



A. (無作用)             X              Q. 不可噓               X
B. 不列入統計           X              R. (無作用)             X
C. (無作用)             X              S. 限看板會員發文       X
D. 群組板               X              T. Guest可以發表        X
E. 隱藏板               X              U. 冷靜                 X
F. 限制(不需設定)       X              V. 自動留轉錄記錄       ˇ
G. 匿名板               X              W. 禁止快速推文         X
H. 預設匿名板           X              X. 推文記錄 IP          X
I. 發文無獎勵           X              Y. 十八禁               X
J. 連署專用看板         X              Z. 對齊式推文           X
K. 已警告要廢除         X              0. 不可自刪             X
L. 熱門看板群組         X              1. 板主可刪特定文字     X
M. 不可推薦             X              2. 沒想到               X
N. 小天使可匿名         X              3. 沒想到               X
O. 板主設定列入記錄     X              4. 沒想到               X
P. 連結看板             X              5. 沒想到               X

發表權限

  設定 [test] 看板之(發表)權限:

A. 基本權力             X              Q. 不列入排行榜         X
B. 進入聊天室           X              R. 違法通緝中           X
C. 找人聊天             X              S. 小天使(本站無效)     X
D. 發表文章             X              T. 不允許認證碼註冊     X
E. 註冊程序認證         X              U. 視覺站長             X
F. 信件無上限           X              V. 觀察使用者行蹤       X
G. 隱身術               X              W. 禠奪公權             X
H. 看見忍者             X              X. 群組長               X
I. 永久保留帳號         X              Y. 帳號審核組           X
J. 站長隱身術           X              Z. 程式組               X
K. 板主                 X              0. 活動組               X
L. 帳號總管             X              1. 美工組               X
M. 聊天室總管           X              2. 警察總管             X
N. 看板總管             X              3. 小組長               X
O. 站長                 X              4. 退休站長             X
P. BBSADM               X              5. 警察                 X

PosOf的命名慣例以及解析方式

雖然 binary.Read 確實是方便好用,但實際上各站的 BBS 維護者可能不小心在該站的檔案結構中因為增加欄位長度沒考慮到 Padding 問題, 舉例來說不一定 BBS 站都會有宣告到 __attribute__((__packed__)) ,因此在不同架構的環境下編譯出的 struct 長度可能會不同。

因此為了方便其他人維護,專案目前採用PosOf手動算出欄位記憶體相對位置的方式,效率上可能較低,但是有可能被編譯器最佳化因此未來也不確定低多少。 未來如果需要加速同時很確定貴站的資料結構時,推薦在testing以及benchmark都確定過之後切換成以 binary.Read 實作的版本。

目前因為為了要支援多套BBS版本的緣故,因此命名結構會是以下形式:

PosOfPttFileHeaderFilename

  • PosOf 開頭
  • Ptt 站點本身的 Code Name
  • FileHeader 哪個結構體名稱
  • Filename 欄位名稱

預設省略版本號,如果需要新增版本號的範例如下

PosOfPttR5939FileHeaderFilename

  • R5939 就是版本號

Documentation

Index

Constants

View Source
const (
	PosOfPTTBoardName       = 0
	PosOfPTTBoardTitle      = PosOfPTTBoardName + PTT_IDLEN + 1
	PosOfPTTBM              = PosOfPTTBoardTitle + PTT_BTLEN + 1
	PosOfBrdAttr            = 3 + PTT_IDLEN*3 + 3 + PosOfPTTBM
	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
)
View Source
const (
	PTT_BRD_POSTMASK   = 0x00000020
	PTT_BRD_GROUPBOARD = 0x00000008
	PTT_PERM_SYSOP     = 000000040000
	PTT_PERM_BM        = 000000002000
	PTT_BRD_HIDE       = 0x00000010
)
View Source
const (
	//////////
	//pttstruch.h
	//////////
	PTT_IDLEN   = 12 /* Length of bid/uid */
	PTT_IPV4LEN = 15 /* a.b.c.d form */

	PTT_PASS_INPUT_LEN = 8 /* Length of valid input password length.
	   For DES, set to 8. */
	PTT_PASSLEN = 14 /* Length of encrypted passwd field */
	PTT_REGLEN  = 38 /* Length of registration data */

	PTT_REALNAMESZ = 20 /* Size of real-name field */
	PTT_NICKNAMESZ = 24 /* SIze of nick-name field */
	PTT_EMAILSZ    = 50 /* Size of email field */
	PTT_ADDRESSSZ  = 50 /* Size of address field */
	PTT_CAREERSZ   = 40 /* Size of career field */
	PTT_PHONESZ    = 20 /* Size of phone field */

	PTT_PASSWD_VERSION = 4194 /* passwd version */

	PTT_TTLEN = 64 /* Length of title */
	PTT_FNLEN = 28 /* Length of filename */
)
View Source
const (
	//////////
	//pttstruch.h: 292
	//////////
	PTT_FILE_LOCAL     = 0x01 /* local saved,  non-mail */
	PTT_FILE_READ      = 0x01 /* already read, mail only */
	PTT_FILE_MARKED    = 0x02 /* non-mail + mail */
	PTT_FILE_DIGEST    = 0x04 /* digest,       non-mail */
	PTT_FILE_REPLIED   = 0x04 /* replied,      mail only */
	PTT_FILE_BOTTOM    = 0x08 /* push_bottom,  non-mail */
	PTT_FILE_MULTI     = 0x08 /* multi send,   mail only */
	PTT_FILE_SOLVED    = 0x10 /* problem solved, sysop/BM non-mail only */
	PTT_FILE_HIDE      = 0x20 /* hide,	in announce */
	PTT_FILE_BID       = 0x20 /* bid,		in non-announce */
	PTT_FILE_BM        = 0x40 /* BM only,	in announce */
	PTT_FILE_VOTE      = 0x40 /* for vote,	in non-announce */
	PTT_FILE_ANONYMOUS = 0x80 /* anonymous file */
)
View Source
const (
	PosOfPttFileHeaderFilename  = 0
	PosOfPttFileHeaderModified  = PosOfPttFileHeaderFilename + PTT_FNLEN
	PosOfPttFileHeaderRecommend = 1 + PosOfPttFileHeaderModified + 4
	PosOfPttFileHeaderOwner     = PosOfPttFileHeaderRecommend + 1
	PosOfPttFileHeaderDate      = PosOfPttFileHeaderOwner + PTT_IDLEN + 2
	PosOfPttFileHeaderTitle     = PosOfPttFileHeaderDate + 6

	PosOfPttFileHeaderUnionMulti = 1 + PosOfPttFileHeaderTitle + PTT_TTLEN + 1
	PosOfPttFileHeaderFilemode   = PosOfPttFileHeaderUnionMulti + 4
)
View Source
const (
	PosOfPttPasswdVersion      = 0
	PosOfPttPasswdUserId       = PosOfPttPasswdVersion + 4
	PosOfPttPasswdRealName     = PosOfPttPasswdUserId + PTT_IDLEN + 1
	PosOfPttPasswdNickname     = PosOfPttPasswdRealName + 20
	PosOfPttPasswdPassword     = PosOfPttPasswdNickname + 24
	PosOfPttPasswdUserFlag     = PosOfPttPasswdPassword + 15
	PosOfPttPasswdUserLevel    = PosOfPttPasswdUserFlag + 4 + 4
	PosOfPttPasswdNumLoginDays = PosOfPttPasswdUserLevel + 4
	PosOfPttPasswdNumPosts     = PosOfPttPasswdNumLoginDays + 4
	PosOfPttPasswdFirstLogin   = PosOfPttPasswdNumPosts + 4
	PosOfPttPasswdLastLogin    = PosOfPttPasswdFirstLogin + 4
	PosOfPttPasswdLastHost     = PosOfPttPasswdLastLogin + 4
	PosOfPttPasswdMoney        = PosOfPttPasswdLastHost + PTT_IPV4LEN + 1
	PosOfPttPasswdEmail        = PosOfPttPasswdMoney + 4 + 4
	PosOfPttPasswdAddress      = PosOfPttPasswdEmail + PTT_EMAILSZ
	PosOfPttPasswdJustify      = PosOfPttPasswdAddress + PTT_ADDRESSSZ
	PosOfPttPasswdOver18       = PosOfPttPasswdJustify + PTT_REGLEN + 1 + 3
	PosOfPttPasswdPagerUiType  = PosOfPttPasswdOver18 + 1
	PosOfPttPasswdPager        = PosOfPttPasswdPagerUiType + 1
	PosOfPttPasswdInvisible    = PosOfPttPasswdPager + 1
	PosOfPttPasswdExMailBox    = PosOfPttPasswdInvisible + 1 + 2

	PosOfPttPasswdCareer        = PosOfPttPasswdExMailBox + 4 + 4
	PosOfPttPasswdRole          = PosOfPttPasswdCareer + 40 + 20 + 4 + 44
	PosOfPttPasswdLastSeen      = PosOfPttPasswdRole + 4
	PosOfPttPasswdTimeSetAngel  = PosOfPttPasswdLastSeen + 4
	PosOfPttPasswdTimePlayAngel = PosOfPttPasswdTimeSetAngel + 4

	PosOfPttPasswdLastSong  = PosOfPttPasswdTimePlayAngel + 4
	PosOfPttPasswdLoginView = PosOfPttPasswdLastSong + 4

	PosOfPttPasswdLawCounter = PosOfPttPasswdLoginView + 2
	PosOfPttPasswdFiveWin    = PosOfPttPasswdLawCounter + 2
	PosOfPttPasswdFiveLose   = PosOfPttPasswdFiveWin + 2
	PosOfPttPasswdFiveTie    = PosOfPttPasswdFiveLose + 2
	PosOfPttPasswdChcWin     = PosOfPttPasswdFiveTie + 2
	PosOfPttPasswdChcLose    = PosOfPttPasswdChcWin + 2
	PosOfPttPasswdChcTie     = PosOfPttPasswdChcLose + 2
	PosOfPttPasswdConn6Win   = PosOfPttPasswdChcTie + 2
	PosOfPttPasswdConn6Lose  = PosOfPttPasswdConn6Win + 2
	PosOfPttPasswdConn6Tie   = PosOfPttPasswdConn6Lose + 2
	PosOfPttPasswdGoWin      = PosOfPttPasswdConn6Tie + 4
	PosOfPttPasswdGoLose     = PosOfPttPasswdGoWin + 2
	PosOfPttPasswdGoTie      = PosOfPttPasswdGoLose + 2
	PosOfPttPasswdDarkWin    = PosOfPttPasswdGoTie + 2
	PosOfPttPasswdDarkLose   = PosOfPttPasswdDarkWin + 2
	PosOfPttPasswdUaVersion  = PosOfPttPasswdDarkLose + 2

	PosOfPttPasswdSignature = PosOfPttPasswdUaVersion + 1
	PosOfPttPasswdBadPost   = PosOfPttPasswdSignature + 2
	PosOfPttPasswdDarkTie   = PosOfPttPasswdBadPost + 1
	PosOfPttPasswdMyAngel   = PosOfPttPasswdDarkTie + 2

	PosOfPttPasswdChessEloRating    = PosOfPttPasswdMyAngel + PTT_IDLEN + 1 + 1
	PosOfPttPasswdWithMe            = PosOfPttPasswdChessEloRating + 2
	PosOfPttPasswdTimeRemoveBadPost = PosOfPttPasswdWithMe + 4
	PosOfPttPasswdTimeViolateLaw    = PosOfPttPasswdTimeRemoveBadPost + 4
)
View Source
const (
	PTT_BTLEN = 48
)
View Source
const (
	TIME4TBytes = 4 // Bytes for time4_t

)
View Source
const (
	// UserIdLength is fixed to 12
	UserIdLength = 12
)

Variables

View Source
var (
	InvalidFavTypeError  = errors.New("invalid Favorite type")
	IndexOutOfBoundError = errors.New("index out of range, file format invalid")
)
View Source
var (
	InvalidLoginsBadFormat = errors.New("Invalid logins.bad line format")
)

Functions

func GetBoardArticleFilePath added in v0.2.1

func GetBoardArticleFilePath(workDirectory string, boardId string, filename string) (string, error)

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 added in v0.2.1

func GetBoardArticlesDirectoryPath(workDirectory string, boardId string) (string, error)

Get Directory normal file path of board

func GetBoardNameFilePath

func GetBoardNameFilePath(workDirectory string, boardId string) (string, error)

Get Directory digest file path of board

func GetBoardPath

func GetBoardPath(workDirectory string) (string, error)

Get Board file path of system

func GetBoardTreasureFilePath added in v0.2.1

func GetBoardTreasureFilePath(workDirectory string, boardId string, path []string, filename string) (string, error)

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

func GetLoginRecentPath(workDirectory string, userid string) (string, error)

Get Login Recent file path of user

func GetPasswdsPath

func GetPasswdsPath(workDirectory string) (string, error)

Get Passwd file path of system

func GetUserFavoritePath

func GetUserFavoritePath(workDirectory string, userid string) (string, error)

Get Favorite file path of user

func GetUserMailPath

func GetUserMailPath(workDirectory string, userId string, filename string) (string, error)

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 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.2.1

func (b *BoardHeader) BoardId() string

func (*BoardHeader) ClassId added in v0.2.4

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 added in v0.2.1

func (b *BoardHeader) IsClass() bool

func (*BoardHeader) IsCooldown

func (b *BoardHeader) IsCooldown() bool

func (*BoardHeader) IsDefaultAnonymous

func (b *BoardHeader) IsDefaultAnonymous() bool

func (*BoardHeader) IsGroupBoard added in v0.2.1

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) Title

func (b *BoardHeader) Title() string

type Connector

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

func (*Connector) GetBoardArticleFilePath added in v0.2.2

func (c *Connector) GetBoardArticleFilePath(boardId string, filename string) (string, error)

func (*Connector) GetBoardArticleRecordsPath added in v0.2.1

func (c *Connector) GetBoardArticleRecordsPath(boardId string) (string, error)

func (*Connector) GetBoardRecordsPath

func (c *Connector) GetBoardRecordsPath() (string, error)

func (*Connector) GetBoardTreasureFilePath added in v0.2.2

func (c *Connector) GetBoardTreasureFilePath(boardId string, treasureId []string, filename string) (string, error)

func (*Connector) GetBoardTreasureRecordsPath added in v0.2.1

func (c *Connector) GetBoardTreasureRecordsPath(boardId string, treasureId []string) (string, error)

func (*Connector) GetUserFavoriteRecordsPath added in v0.2.3

func (c *Connector) GetUserFavoriteRecordsPath(userId string) (string, error)

func (*Connector) GetUserRecordsPath

func (c *Connector) GetUserRecordsPath() (string, error)

func (*Connector) Open added in v0.2.1

func (c *Connector) Open(dataSourceName string) error

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 added in v0.2.2

func (c *Connector) ReadArticleRecordsFile(filename string) ([]bbs.ArticleRecord, error)

func (*Connector) ReadBoardArticleFile added in v0.2.1

func (c *Connector) ReadBoardArticleFile(filename string) ([]byte, error)

ReadBoardArticleFile returns raw file of specific filename article.

func (*Connector) ReadBoardRecordsFile

func (c *Connector) ReadBoardRecordsFile(path string) ([]bbs.BoardRecord, error)

func (*Connector) ReadUserFavoriteRecordsFile added in v0.2.3

func (c *Connector) ReadUserFavoriteRecordsFile(filename string) ([]bbs.FavoriteRecord, error)

func (*Connector) ReadUserRecordsFile

func (c *Connector) ReadUserRecordsFile(filename string) ([]bbs.UserRecord, error)

type FavAttr

type FavAttr uint8

FavAttr represents fav attr

const (
	FavhFav    FavAttr = 0x00000001 // FAVH_FAV
	FavhTag    FavAttr = 0x00000002 // FAVH_TAG
	FavhUnread FavAttr = 0x00000004 // FAVH_UNREAD
	FavhAdmTag FavAttr = 0x00000008 // FAVH_ADM_TAG
)

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

type FavFile struct {
	Version uint16
	Folder  *FavFolder
}

FavFile represents the entire fav file. Starts with 2 bytes of Version and at most 1 FavFolder.

func NewFavFile

func NewFavFile(data []byte) (*FavFile, error)

NewFavFile parse data and return FavFile

func OpenFavFile

func OpenFavFile(filename string) (*FavFile, error)

OpenFavFile reads a fav file

func (*FavFile) MarshalBinary

func (favf *FavFile) MarshalBinary() ([]byte, error)

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

func NewFavFolder(data []byte, startIndex int) (*FavFolder, int, error)

NewFavFolder takes a []byte, parse it starting with startIndex, return an instance of FavFolder, endIndex and error.

func (*FavFolder) MarshalBinary

func (favf *FavFolder) MarshalBinary() ([]byte, error)

type FavFolderItem

type FavFolderItem struct {
	FolderId   uint8
	Title      string
	ThisFolder *FavFolder
}

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

func NewFavItem(data []byte, startIndex int) (*FavItem, int, error)

NewFavItem parse data starting from startIndex and return FavItem. FavItem.Item might be either FavBoardItem, FavFolderItem or FavLineItem

func (*FavItem) BoardId added in v0.2.3

func (f *FavItem) BoardId() string

func (*FavItem) GetBoard

func (favt *FavItem) GetBoard() *FavBoardItem

GetBoard tries to cast Item to FavBoardItem; return nil if it is not

func (*FavItem) GetFolder

func (favt *FavItem) GetFolder() *FavFolderItem

GetFolder tries to cast Item to FavFolderItem; return nil if it is not

func (*FavItem) GetLine

func (favt *FavItem) GetLine() *FavLineItem

GetLine tries to cast Item to FavLineItem; return nil if it is not

func (*FavItem) MarshalBinary

func (favi *FavItem) MarshalBinary() ([]byte, error)

func (*FavItem) Records added in v0.2.3

func (f *FavItem) Records() []bbs.FavoriteRecord

func (*FavItem) Title added in v0.2.3

func (f *FavItem) Title() string

func (*FavItem) Type added in v0.2.3

func (f *FavItem) Type() bbs.FavoriteType

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 (h *FileHeader) IsVotePost() bool

func (*FileHeader) MarshalToByte

func (h *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

type LoginAttempt struct {
	Success        bool
	UserId         string
	LoginStartTime time.Time
	FromHost       string
}

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

type LoginRecentRecord struct {
	LoginStartTime time.Time
	FromHost       string
}

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 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 NewUserecWithByte(data []byte) (*Userec, error)

func OpenUserecFile

func OpenUserecFile(filename string) ([]*Userec, error)

func (*Userec) HashedPassword

func (u *Userec) HashedPassword() string

func (*Userec) LastHost

func (u *Userec) LastHost() string

func (*Userec) LastLogin

func (u *Userec) LastLogin() time.Time

func (*Userec) MarshalToByte

func (r *Userec) MarshalToByte() ([]byte, error)

func (*Userec) Money

func (u *Userec) Money() int

Money return the money this user have.

func (*Userec) Nickname

func (u *Userec) Nickname() string

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

func (u *Userec) NumLoginDays() int

NumLoginDays return how many days this have been login since account created.

func (*Userec) NumPosts

func (u *Userec) NumPosts() int

NumPosts return how many posts this user has posted.

func (*Userec) RealName

func (u *Userec) RealName() string

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) UserId

func (u *Userec) UserId() string

func (*Userec) VerifyPassword

func (u *Userec) VerifyPassword(password string) error

VerifyPassword will check user's password is OK. it will return null when OK and error when there are something wrong

type UserecGameScore

type UserecGameScore struct {
	Win  uint16
	Lose uint16
	Tie  uint16
}

type VoteLimits

type VoteLimits struct {
	Posts   uint8
	Logins  uint8
	Regtime uint8
	Badpost uint8
}

VoteLimits shows the limitation of a vote post.

Jump to

Keyboard shortcuts

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