pttbbs

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2021 License: Apache-2.0 Imports: 17 Imported by: 1

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版本的緣故,因此命名結構會是以下形式:

PosOfFileHeaderFilename

  • PosOf 開頭
  • FileHeader 哪個結構體名稱
  • Filename 欄位名稱

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

PosOfR5939FileHeaderFilename

  • R5939 就是版本號

Documentation

Index

Constants

View Source
const (
	PosOfBoardName          = 0
	PosOfBoardTitle         = PosOfBoardName + IDLength + 1
	PosOfBM                 = PosOfBoardTitle + BoardTitleLength + 1
	PosOfBrdAttr            = 3 + PosOfBM + IDLength*3 + 3
	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 + 4*2
	PosOfParent             = PosOfFirstChild + 4*2
	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 (
	// 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
)
View Source
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 */
	// MachineName https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L358
	MachineNameLength = 27 /* Length of Machine Name */
	// MaxFriend https://github.com/ptt/pttbbs/blob/master/include/config.h#L224
	MaxFriend = 256
	// MaxReject https://github.com/ptt/pttbbs/blob/master/include/config.h#L228
	MaxReject = 32
	// MaxMsgs https://github.com/ptt/pttbbs/blob/master/include/config.h#L232
	MaxMsgs = 10
	// ChatIDLength https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L408
	ChatIDLength = 11
)
View Source
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 */
)
View Source
const (
	////////////
	// uflags.h
	// (https://github.com/ptt/pttbbs/blob/master/include/uflags.h)
	////////////
	UfFavNohilight uint32 = 0x00000001 /* false if hilight favorite */
	UfFavAddnew    uint32 = 0x00000002 /* true to add new board into one's fav */
	// UfPager uint32 = 0x00000004 /* deprecated by cuser.pager: true if pager was OFF last session */
	// UfCloak uint32 = 0x00000008 /* deprecated by cuser.invisible: true if cloak was ON last session */
	UfFriend        uint32 = 0x00000010 /* true if show friends only */
	UfBrdsort       uint32 = 0x00000020 /* true if the boards sorted alphabetical */
	UfAdbanner      uint32 = 0x00000040 /* (was: MOVIE_FLAG, true if show advertisement banner */
	UfAdbannerUsong uint32 = 0x00000080 /* true if show user songs in banner */
	// UfMind uint32 = 0x00000100 /* deprecated: true if mind search mode open <-Heat */
	UfDbcsAware      uint32 = 0x00000200 /* true if DBCS-aware enabled */
	UfDbcsNointresc  uint32 = 0x00000400 /* no Escapes interupting DBCS characters */
	UfDbscDropRepeat uint32 = 0x00000800 /* detect and drop repeated input from evil clients */
	UfNoModmark      uint32 = 0x00001000 /* true if modified files are NOT marked */
	UfColoredModmark uint32 = 0x00002000 /* true if mod-mark is coloured */
	// UfModmark??? uint32 = 0x00004000 /* reserved */
	// UfModmark??? uint32 = 0x00008000 /* reserved */
	UfDefbackup     uint32 = 0x00010000 /* true if user defaults to backup */
	UfNewAngelPager uint32 = 0x00020000 /* true if user (angel) wants the new pager */
	UfRejOuttamail  uint32 = 0x00040000 /* true if don't accept outside mails */
	UfSecureLogin   uint32 = 0x00080000 /* true if login from insecure (ex, telnet) connection will be rejected */
	UfForeign       uint32 = 0x00100000 /* true if a foreign */
	UfLiveright     uint32 = 0x00200000 /* true if get "liveright" already */
	// UfCountry??? uint32 = 0x00400000 /* reserved */
	// UfCountry??? uint32 = 0x00800000 /* reserved */
	UfMenuLightbar uint32 = 0x01000000 /* true to use lightbar-based menu */
	UfCursorASCII  uint32 = 0x02000000 /* true to enable ASCII-safe cursor */

)
View Source
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
)
View Source
const (
	PosOfPasswdVersion      = 0
	PosOfPasswdUserID       = PosOfPasswdVersion + 4
	PosOfPasswdRealName     = PosOfPasswdUserID + IDLength + 1
	PosOfPasswdNickname     = PosOfPasswdRealName + RealNameSize
	PosOfPasswdPassword     = PosOfPasswdNickname + NicknameSize
	PosOfPasswdUserFlag     = 1 + PosOfPasswdPassword + PasswordLength
	PosOfPasswdUserLevel    = 4 + PosOfPasswdUserFlag + 4
	PosOfPasswdNumLoginDays = PosOfPasswdUserLevel + 4
	PosOfPasswdNumPosts     = PosOfPasswdNumLoginDays + 4
	PosOfPasswdFirstLogin   = PosOfPasswdNumPosts + 4
	PosOfPasswdLastLogin    = PosOfPasswdFirstLogin + 4
	PosOfPasswdLastHost     = PosOfPasswdLastLogin + 4
	PosOfPasswdMoney        = PosOfPasswdLastHost + IPV4Length + 1
	PosOfPasswdEmail        = 4 + PosOfPasswdMoney + 4
	PosOfPasswdAddress      = PosOfPasswdEmail + EmailSize
	PosOfPasswdJustify      = PosOfPasswdAddress + AddressSize
	PosOfPasswdOver18       = 3 + PosOfPasswdJustify + RegistrationLength + 1
	PosOfPasswdPagerUIType  = PosOfPasswdOver18 + 1
	PosOfPasswdPager        = PosOfPasswdPagerUIType + 1
	PosOfPasswdInvisible    = PosOfPasswdPager + 1
	PosOfPasswdExMailBox    = 2 + PosOfPasswdInvisible + 1

	PosOfPasswdCareer        = 4 + PosOfPasswdExMailBox + 4
	PosOfPasswdRole          = 20 + 4 + 44 + PosOfPasswdCareer + CareerSize
	PosOfPasswdLastSeen      = PosOfPasswdRole + 4
	PosOfPasswdTimeSetAngel  = PosOfPasswdLastSeen + 4
	PosOfPasswdTimePlayAngel = PosOfPasswdTimeSetAngel + 4

	PosOfPasswdLastSong  = PosOfPasswdTimePlayAngel + 4
	PosOfPasswdLoginView = PosOfPasswdLastSong + 4

	PosOfPasswdLawCounter = 1 + 1 + PosOfPasswdLoginView + 4
	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      = 2 + PosOfPasswdConn6Tie + 2
	PosOfPasswdGoLose     = PosOfPasswdGoWin + 2
	PosOfPasswdGoTie      = PosOfPasswdGoLose + 2
	PosOfPasswdDarkWin    = PosOfPasswdGoTie + 2
	PosOfPasswdDarkLose   = PosOfPasswdDarkWin + 2
	PosOfPasswdUaVersion  = PosOfPasswdDarkLose + 2

	PosOfPasswdSignature = PosOfPasswdUaVersion + 1
	PosOfPasswdBadPost   = 1 + PosOfPasswdSignature + 1
	PosOfPasswdDarkTie   = PosOfPasswdBadPost + 1
	PosOfPasswdMyAngel   = PosOfPasswdDarkTie + 2

	PosOfPasswdChessEloRating    = 1 + PosOfPasswdMyAngel + IDLength + 1
	PosOfPasswdWithMe            = PosOfPasswdChessEloRating + 2
	PosOfPasswdTimeRemoveBadPost = PosOfPasswdWithMe + 4
	PosOfPasswdTimeViolateLaw    = PosOfPasswdTimeRemoveBadPost + 4
)
View Source
const (
	PosOfUserInfoUID      = 0
	PosOfUserInfoPID      = PosOfUserInfoUID + 4
	PosOfUserInfoSockAddr = PosOfUserInfoPID + 4

	PosOfUserInfoUserLevel  = PosOfUserInfoSockAddr + 4
	PosOfUserInfoUserID     = PosOfUserInfoUserLevel + 4
	PosOfUserInfoNickname   = PosOfUserInfoUserID + IDLength + 1
	PosOfUserInfoFrom       = PosOfUserInfoNickname + NicknameSize
	PosOfUserInfoFromIP     = PosOfUserInfoFrom + MachineNameLength
	PosOfUserInfoDarkWin    = PosOfUserInfoFromIP + 4
	PosOfUserInfoDarkLose   = PosOfUserInfoDarkWin + 2
	PosOfUserInfoAngelPause = PosOfUserInfoDarkLose + 2 + 1 // gap_0
	PosOfUserInfoDarkTie    = PosOfUserInfoAngelPause + 1

	PosOfUserInfoFriendTotal = PosOfUserInfoDarkTie + 2
	PosOfUserInfoNumFriends  = PosOfUserInfoFriendTotal + 4

	PosOfUserInfoMyFriend     = PosOfUserInfoNumFriends + 2 + 2             // _unused3
	PosOfUserInfoFriendOnline = PosOfUserInfoMyFriend + MaxFriend*4 + 4     // gap_1
	PosOfUserInfoReject       = PosOfUserInfoFriendOnline + MaxFriend*4 + 4 // gap_2

	PosOfUserInfoMsgCount = PosOfUserInfoReject + MaxReject*4 + 4 // gap_3
	PosOfUserInfoMsgs     = PosOfUserInfoMsgCount + 1 + 3         // _unused4

	PosOfUserInfoBirth     = PosOfUserInfoMsgs + MaxMsgs*100 + 100 // gap_4 and 100 is the size of msgque_t when run on my machine
	PosOfUserInfoActive    = PosOfUserInfoBirth + 1
	PosOfUserInfoInvisible = PosOfUserInfoActive + 1
	PosOfUserInfoMode      = PosOfUserInfoInvisible + 1
	PosOfUserInfoPager     = PosOfUserInfoMode + 1

	PosOfUserInfoConn6Win  = PosOfUserInfoPager + 1 + 1 // unused5
	PosOfUserInfoLastAct   = PosOfUserInfoConn6Win + 2
	PosOfUserInfoAlerts    = PosOfUserInfoLastAct + 4
	PosOfUserInfoConn6Lose = PosOfUserInfoAlerts + 1 + 1 // unused_mind

	PosOfUserInfoSig        = PosOfUserInfoConn6Lose + 2 + 1 // unused_mind2
	PosOfUserInfoConn6Tie   = PosOfUserInfoSig + 1
	PosOfUserInfoDestUID    = PosOfUserInfoConn6Tie + 2
	PosOfUserInfoDestUIP    = PosOfUserInfoDestUID + 4
	PosOfUserInfoSockActive = PosOfUserInfoDestUIP + 4

	PosOfUserInfoInChat = PosOfUserInfoSockActive + 1
	PosOfUserInfoChatID = PosOfUserInfoInChat + 1

	PosOfUserInfoLockMode = PosOfUserInfoChatID + ChatIDLength
	PosOfUserInfoTurn     = PosOfUserInfoLockMode + 1
	PosOfUserInfoMateID   = PosOfUserInfoTurn + 1
	PosOfUserInfoColor    = PosOfUserInfoMateID + IDLength + 1

	PosOfUserInfoFiveWin        = PosOfUserInfoColor + 1
	PosOfUserInfoFiveLose       = PosOfUserInfoFiveWin + 2
	PosOfUserInfoFiveTie        = PosOfUserInfoFiveLose + 2
	PosOfUserInfoChcWin         = PosOfUserInfoFiveTie + 2
	PosOfUserInfoChcLose        = PosOfUserInfoChcWin + 2
	PosOfUserInfoChcTie         = PosOfUserInfoFiveLose + 2
	PosOfUserInfoChessEloRating = PosOfUserInfoChcTie + 2
	PosOfUserInfoGoWin          = PosOfUserInfoChessEloRating + 2
	PosOfUserInfoGoLose         = PosOfUserInfoGoWin + 2
	PosOfUserInfoGoTie          = PosOfUserInfoGoLose + 2

	PosOfUserInfoWithMe = PosOfUserInfoGoTie + 2
	PosOfUserInfoBrcID  = PosOfUserInfoWithMe + 4

	PosOfUserInfoWBTime = PosOfUserInfoBrcID + 4
)
View Source
const (
	// BoardTitleLength https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L165
	BoardTitleLength = 48
)
View Source
const (
	// commmon.h: 232
	// MaxRecommends max recommend count
	MaxRecommends = 100
)
View Source
const (
	TIME4TBytes = 4 // Bytes for time4_t

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

Variables

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

Functions

func AppendBoardHeaderFileRecord

func AppendBoardHeaderFileRecord(filename string, newBoardHeader *BoardHeader) error

func AppendFileHeaderFileRecord added in v0.5.0

func AppendFileHeaderFileRecord(filename string, newFileHeader *FileHeader) error

func GetBoardArticleFilePath

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

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

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

func GetUserDraftPath(workDirectory string, userID string, draftID string) (string, error)

Get Draft file path of user

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.

func RemoveBoardHeaderFileRecord

func RemoveBoardHeaderFileRecord(filename string, index int) error

func UpdateFileHeaderFileRecord added in v0.8.1

func UpdateFileHeaderFileRecord(filename string, index uint, fileHeader *FileHeader) error

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 OpenBoardHeaderFile

func OpenBoardHeaderFile(filename string) ([]*BoardHeader, error)

func UnmarshalBoardHeader added in v0.4.0

func UnmarshalBoardHeader(data []byte) (*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) GetPostLimitBadPost added in v0.5.0

func (b *BoardHeader) GetPostLimitBadPost() uint8

func (*BoardHeader) GetPostLimitLogins added in v0.5.0

func (b *BoardHeader) GetPostLimitLogins() uint8

func (*BoardHeader) GetPostLimitPosts added in v0.5.0

func (b *BoardHeader) GetPostLimitPosts() uint8

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

func (c *Cache) Money(uid int) int32

Money returns the money user have with specific uid, uid start with 0

func (*Cache) UserID added in v0.3.0

func (c *Cache) UserID(uid int) string

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

func (*Cache) Version added in v0.3.0

func (c *Cache) Version() uint32

Version returns cache (SHM) version of pttbbs, it will be 4842 on pttbbs version 4d56e77 (2009/09 ~ )

type Connector

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

func (*Connector) AddArticleRecordFileRecord added in v0.5.0

func (c *Connector) AddArticleRecordFileRecord(name string, article bbs.ArticleRecord) error

func (*Connector) AddBoardRecordFileRecord added in v0.3.0

func (c *Connector) AddBoardRecordFileRecord(name string, brd bbs.BoardRecord) error

AddBoardRecordFileRecord given record file name and new record, should append file record in that file.

func (*Connector) AppendBoardArticleFile added in v0.8.1

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

func (*Connector) CreateBoardArticleFilename added in v0.8.1

func (c *Connector) CreateBoardArticleFilename(boardID string) (filename string, err error)

CreateBoardArticleFilename get available filename for board with boardID, it will test is this filename not exist And open a file to occupy this filename Please see fhdr_stamp in pttbbs fhdr_stamp.c also

func (*Connector) DeleteUserDraft added in v0.5.0

func (c *Connector) DeleteUserDraft(filename string) error

func (*Connector) GetBoardArticleFilePath

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

func (*Connector) GetBoardArticleRecordsPath

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

func (*Connector) GetBoardRecordsPath

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

func (*Connector) GetBoardTreasureFilePath

func (c *Connector) GetBoardTreasureFilePath(boardID string, treasureID []string, filename string) (string, error)

func (*Connector) GetBoardTreasureRecordsPath

func (c *Connector) GetBoardTreasureRecordsPath(boardID string, treasureID []string) (string, error)

func (*Connector) GetUserDraftPath added in v0.5.0

func (c *Connector) GetUserDraftPath(userID, draftID string) (string, error)

func (*Connector) GetUserFavoriteRecordsPath

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

func (*Connector) GetUserRecordsPath

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

func (*Connector) NewArticleRecord added in v0.5.0

func (c *Connector) NewArticleRecord(filename, owner, date, title string) (bbs.ArticleRecord, error)

NewArticleRecord returns a new ArticleRecord given a filename, owner, date, title

func (*Connector) NewArticleRecordWithMap added in v0.8.1

func (c *Connector) NewArticleRecordWithMap(args map[string]interface{}) (bbs.ArticleRecord, error)

func (*Connector) NewBoardRecord added in v0.3.0

func (c *Connector) NewBoardRecord(args map[string]interface{}) (bbs.BoardRecord, error)

func (*Connector) Open

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

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

func (*Connector) ReadBoardArticleFile

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

ReadBoardArticleFile returns raw file of specific filename article.

func (*Connector) ReadBoardRecordFileRecord added in v0.3.0

func (c *Connector) ReadBoardRecordFileRecord(name string, index uint) (bbs.BoardRecord, error)

ReadBoardRecordFileRecord return boardRecord brd on index in record file.

func (*Connector) ReadBoardRecordsFile

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

func (*Connector) ReadUserDraft added in v0.6.0

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

func (*Connector) ReadUserFavoriteRecordsFile

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

func (*Connector) ReadUserRecordsFile

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

func (*Connector) RemoveBoardRecordFileRecord added in v0.3.0

func (c *Connector) RemoveBoardRecordFileRecord(name string, index uint) error

RemoveBoardRecordFileRecord remove boardRecord brd on index in record file.

func (*Connector) UpdateArticleRecordFileRecord added in v0.8.1

func (c *Connector) UpdateArticleRecordFileRecord(filename string, index uint, article bbs.ArticleRecord) error

func (*Connector) UpdateBoardRecordFileRecord added in v0.3.0

func (c *Connector) UpdateBoardRecordFileRecord(name string, index uint, brd bbs.BoardRecord) error

UpdateBoardRecordFileRecord update boardRecord brd on index in record file, index is start with 0

func (*Connector) WriteBoardArticleFile added in v0.8.1

func (c *Connector) WriteBoardArticleFile(path string, content []byte) error

func (*Connector) WriteUserDraft added in v0.7.0

func (c *Connector) WriteUserDraft(filename string, draft []byte) 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 UnmarshalFavBoardItem added in v0.4.0

func UnmarshalFavBoardItem(data []byte, startIndex int) (*FavBoardItem, int, error)

UnmarshalFavBoardItem 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 OpenFavFile

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

OpenFavFile reads a fav file

func UnmarshalFavFile added in v0.4.0

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

UnmarshalFavFile parse data and return FavFile

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

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

UnmarshalFavFolder 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 UnmarshalFavFolderItem added in v0.4.0

func UnmarshalFavFolderItem(data []byte, startIndex int) (*FavFolderItem, int, error)

UnmarshalFavFolderItem 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 UnmarshalFavItem added in v0.4.0

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

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

func (*FavItem) BoardID added in v0.3.0

func (favi *FavItem) BoardID() string

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

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

func (*FavItem) Records

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

func (*FavItem) Title

func (favi *FavItem) Title() string

func (*FavItem) Type

func (favi *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 UnmarshalFavLineItem added in v0.4.0

func UnmarshalFavLineItem(data []byte, startIndex int) (*FavLineItem, int, error)

UnmarshalFavLineItem 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 NewFileHeader added in v0.5.0

func NewFileHeader() *FileHeader

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) AddRecommend added in v0.6.0

func (f *FileHeader) AddRecommend(update int8)

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) SetDate added in v0.5.0

func (f *FileHeader) SetDate(newValue string)

func (*FileHeader) SetFilename added in v0.5.0

func (f *FileHeader) SetFilename(newValue string)

func (*FileHeader) SetModified added in v0.6.0

func (f *FileHeader) SetModified(newModified time.Time)

func (*FileHeader) SetOwner added in v0.5.0

func (f *FileHeader) SetOwner(newValue string)

func (*FileHeader) SetTitle added in v0.5.0

func (f *FileHeader) SetTitle(newValue string)

func (*FileHeader) Title

func (f *FileHeader) Title() string

type GameScore added in v0.12.0

type GameScore struct {
	Win  uint16
	Lose uint16
	Tie  uint16
}

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 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 struct {
	SockAddr int32

	UserLevel uint32

	DarkChess  GameScore
	AngelPause uint8

	FriendTotal int32
	NumFriends  int16

	MyFriend     [MaxFriend]int32
	FriendOnline [MaxFriend]uint32

	Reject [MaxReject]int32

	MsgCount uint8
	Msgs     [MaxMsgs]MessageQueueCache

	Birth     bool // whether it's birthday today
	Active    bool
	Invisible bool
	Mode      uint8
	Pager     bool

	Conn6   GameScore
	LastAct time.Time
	Alerts  uint8 // mail alert, passwd update ...

	Signature  uint8
	DestUID    int32
	DestUIP    int32
	SockActive uint8

	InChat uint8
	ChatID string

	LockMode uint8
	Turn     bool
	MateID   string
	Color    uint8

	// game record
	Five           GameScore
	ChineseChess   GameScore
	ChessEloRating uint16
	GoChess        GameScore

	WithMe uint32
	// contains filtered or unexported fields
}

UserInfoCache is `userinfo_t` in pttstruct.h, all of those object will be store in shared memory

func OpenUserInfoCache added in v0.12.0

func OpenUserInfoCache(filename string) ([]*UserInfoCache, error)

function used for testing unmarshal and marshal function

func UnmarshalUserInfo added in v0.12.0

func UnmarshalUserInfo(data []byte) *UserInfoCache

func (*UserInfoCache) MarshalBinary added in v0.12.0

func (u *UserInfoCache) MarshalBinary() []byte

type Userec

type Userec struct {
	Version uint32 // Magic Number

	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         GameScore
	ChineseChess GameScore
	Conn6        GameScore
	GoChess      GameScore
	DarkChess    GameScore
	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 OpenUserecFile

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

func UnmarshalUserec added in v0.4.0

func UnmarshalUserec(data []byte) (*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) MarshalBinary added in v0.4.0

func (u *Userec) MarshalBinary() ([]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) UserFlag

func (u *Userec) UserFlag() uint32

UserFlag return user setting. uint32, see https://github.com/ptt/pttbbs/blob/master/include/uflags.h

func (*Userec) UserID added in v0.3.0

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 VoteLimits

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

VoteLimits shows the limitation of a vote post.

Directories

Path Synopsis
internal
fnv

Jump to

Keyboard shortcuts

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