From 0fb2e7541d52b4ecd5bd4a65f2443054edbb5a5f Mon Sep 17 00:00:00 2001 From: Chuan-Heng Hsiao Date: Fri, 12 Jul 2024 10:18:27 -0400 Subject: [PATCH 1/2] refine docker settings 1. Dockerfile for both amd64 and arm64 2. print BBSHOME in docker_run 3. docker add postfix 4. docker-mand 5. change the attributes in the tests to be meaningful 6. mv docker-related files to docker. mv config-related files to docs/config. mv mac-related files to docs/mac 7. update golang to 1.22 in github workflow --- .github/workflows/go.yml | 2 +- README.en.md | 30 +- README.zh-TW.md | 33 +- api/get_user.go | 2 +- api/testcases_test.go | 18 +- bbs/testcases_test.go | 34 +- cmbbs/testcases_test.go | 42 +- Dockerfile => docker/Dockerfile | 13 +- .../go-pttbbs/docker-compose.yaml | 6 + docker/go-pttbbs/docker-compose.yaml.me | 19 + .../go-pttbbs/docker-compose.yaml.template | 0 docker/go-pttbbs/docker_compose.env | 5 + docker/go-pttbbs/docker_compose.env.template | 4 + docker_compose.env.template | 2 - .../config/00-config-production.go.template | 0 .../config/00-config.template.ini | 0 .../config/01-config-docker.go.template | 0 .../config/01-config.docker.ini | 0 .../config/02-config-run.go.template | 0 docs/config/02-config.run.ini | 505 ++++++++++++++++++ .../config/02-config.run.template.ini | 0 memory.plist => docs/mac/memory.plist | 0 go.mod | 2 +- go.sum | 7 + ptt/testcases_test.go | 77 +-- scripts/docker_build.sh | 8 +- scripts/docker_initbbs.sh | 4 +- scripts/docker_run.sh | 1 + scripts/run-in-docker.sh | 5 - scripts/run.sh | 2 +- 30 files changed, 689 insertions(+), 132 deletions(-) rename Dockerfile => docker/Dockerfile (71%) rename docker-compose.yaml => docker/go-pttbbs/docker-compose.yaml (60%) create mode 100644 docker/go-pttbbs/docker-compose.yaml.me rename docker-compose.yaml.template => docker/go-pttbbs/docker-compose.yaml.template (100%) create mode 100644 docker/go-pttbbs/docker_compose.env create mode 100644 docker/go-pttbbs/docker_compose.env.template delete mode 100644 docker_compose.env.template rename 00-config-production.go.template => docs/config/00-config-production.go.template (100%) rename 00-config.template.ini => docs/config/00-config.template.ini (100%) rename 01-config-docker.go.template => docs/config/01-config-docker.go.template (100%) rename 01-config.docker.ini => docs/config/01-config.docker.ini (100%) rename 02-config-run.go.template => docs/config/02-config-run.go.template (100%) create mode 100644 docs/config/02-config.run.ini rename 02-config.run.template.ini => docs/config/02-config.run.template.ini (100%) rename memory.plist => docs/mac/memory.plist (100%) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index b439179a..bf56b03f 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -14,7 +14,7 @@ jobs: - name: Set up Go 1.x uses: actions/setup-go@v5 with: - go-version: ^1.19 + go-version: ^1.22 - name: Check out code into the Go module directory uses: actions/checkout@v4 diff --git a/README.en.md b/README.en.md index 55533ec5..8e8ebe29 100644 --- a/README.en.md +++ b/README.en.md @@ -12,11 +12,11 @@ This project intends to be the go implementation of [ptt/pttbbs](https://github.com/ptt/pttbbs). -Collaborating with [Ptt-official-app middleware](https://github.com/ptt-official-app/go-openbbsmiddleware), go-pttbbs intends to be web-based bbs. +Collaborating with [Ptt-official-app go-pttbbsweb](https://github.com/ptt-official-app/go-pttbbsweb), go-pttbbs intends to be web-based bbs. ## Getting Started -You can start with the [swagger api](https://api.devptt.dev:8080) +You can start with the [swagger api](https://doc-pttbbs.devptt.dev) and check the api document. ## Coding Convention @@ -29,10 +29,10 @@ and check the api document. You can do the following to start with docker-compose: * copy `docs/etc/` to some etc directory (ex: `/etc/go-pttbbs`). -* copy `01-config.docker.ini` to the etc directory as production.ini (ex: `cp 01-config.docker.ini /etc/go-pttbbs/production.ini`). -* copy `docker_compose.env.template` to `docker_compose.env` and modify the settings. +* copy `docs/config/01-config.docker.ini` to the etc directory as production.ini (ex: `cp docs/config/01-config.docker.ini /etc/go-pttbbs/production.ini`). +* copy `docker/go-pttbbs/docker_compose.env.template` to `docker/go-pttbbs/docker_compose.env` and modify the settings. * `./scripts/docker_initbbs.sh [BBSHOME] pttofficialapps/go-pttbbs:latest` -* `docker-compose --env-file docker_compose.env -f docker-compose.yaml up -d` +* `docker-compose --env-file docker/go-pttbbs/docker_compose.env -f docker/go-pttbbs/docker-compose.yaml up -d` * register SYSOP and guest (api.GUEST) at `http://localhost:3456/v1/register` * register your account at `http://localhost:3456/register` * login at `http://localhost:3456/v1/login` @@ -69,9 +69,9 @@ You can do the following to increase users using docker: You can do the following to run with ./scripts/run.sh: * Mac: - Copy `memory.plist` to `/Library/LaunchDaemons` then reboot + Copy `docs/mac/memory.plist` to `/Library/LaunchDaemons` then reboot ```sh - sudo cp memory.plist /Library/LaunchDaemons/memory.plist + sudo cp docs/mac/memory.plist /Library/LaunchDaemons/memory.plist ``` * Check that we do have 16M shared-mem @@ -82,9 +82,9 @@ You can do the following to run with ./scripts/run.sh: ``` ./scripts/docker_initbbs.sh [BBSHOME] pttofficialapps/go-pttbbs:latest ``` -* `cp 02-config-run.go.template ptttype/02-config-run.go` -* `cp 02-config.run.template.ini 02-config.run.ini` -* Setup BBSHOME in 02-config.run.ini +* `cp docs/config/02-config-run.go.template ptttype/02-config-run.go` +* `cp docs/config/02-config.run.template.ini docs/config/02-config.run.ini` +* Setup BBSHOME in docs/config/02-config.run.ini * Do the following step ONLY IF you want to reset shared-mem: `ipcrm -M 0x000004cc` `ipcrm -S 0x000007da` @@ -124,11 +124,11 @@ For the normal config-variables, we use config.ini as the configuration. For the const config-variables in ptttype, -We use 00-config-[dev-mode].go with +build flag +We use docs/config/00-config-[dev-mode].go with +build flag -### 00-config.ini +### docs/config/00-config.ini We use viper and .ini as our config-framework. -00-config.template.ini is the config-template file. +docs/config/00-config.template.ini is the config-template file. We have 3 files For every module with the config: @@ -140,7 +140,7 @@ We have 3 files For every module with the config: We can customized ptttype/00-config-default.go with the following steps: -1. Copy 00-config-production.go.template to ptttype/00-config-production.go and change the +build and variables accordingly. +1. Copy docs/config/00-config-production.go.template to ptttype/00-config-production.go and change the +build and variables accordingly. 2. `go build -tag [dev-mode]` ## Swagger.sh @@ -150,6 +150,6 @@ which is a python-project. You can do following for the swagger-api: 1. setup the python virtualenv. -2. cd apidoc; pip install . && pip uninstall apidoc -y && python setup.py develop; cd .. +2. cd apidoc; pip install -e . ; cd .. 3. ./scripts/swagger.sh 4. browse to [http://localhost:8080](http://localhost:8080). diff --git a/README.zh-TW.md b/README.zh-TW.md index 4182737f..850cc5a0 100644 --- a/README.zh-TW.md +++ b/README.zh-TW.md @@ -12,11 +12,11 @@ 這是使用 go 實作的 [ptt/pttbbs](https://github.com/ptt/pttbbs) -與 [Ptt-official-app middleware](https://github.com/ptt-official-app/go-openbbsmiddleware) 一起成為 web-based BBS. +與 [Ptt-official-app go-pttbbsweb](https://github.com/ptt-official-app/go-pttbbsweb) 一起成為 web-based BBS. ## 開始 -您可以從 [swagger api](https://api.devptt.dev:8080) 查看 api 文件. +您可以從 [swagger api](https://doc-pttbbs.devptt.dev) 查看 api 文件. ## Coding Convention @@ -28,10 +28,10 @@ 您可以利用 docker-compose 開始: * 將 `docs/etc/` 複製到另一個 etc 目錄 (例: `/etc/go-pttbbs`). -* 將 `01-config.docker.ini` 複製到 etc 目錄為 production.ini (例: `cp 01-config.docker.ini /etc/go-pttbbs/production.ini`). -* 將 `docker_compose.env.template` 複製到 `docker_compose.env` 並且更改相關設定. +* 將 `docs/config/01-config.docker.ini` 複製到 etc 目錄為 production.ini (例: `cp docs/config/01-config.docker.ini /etc/go-pttbbs/production.ini`). +* 將 `docker/go-pttbbs/docker_compose.env.template` 複製到 `docker/go-pttbbs/docker_compose.env` 並且更改相關設定. * `./scripts/docker_initbbs.sh [BBSHOME] pttofficialapps/go-pttbbs:latest` -* `docker-compose --env-file docker_compose.env -f docker-compose.yaml up -d` +* `docker-compose --env-file docker/go-pttbbs/docker_compose.env -f docker/go-pttbbs/docker-compose.yaml up -d` * 使用 `http://localhost:3456/v1/register` 註冊 SYSOP 和 guest (api.GUEST). * 使用 `http://localhost:3456/register` 註冊您的帳號. * 使用 `http://localhost:3456/v1/login` 登入. @@ -68,9 +68,9 @@ 您可以使用以下方式執行 ./scripts/run.sh * Mac: - 將 `memory.plist` 複製到 `/Library/LaunchDaemons` 然後重新啟動 Mac. + 將 `docs/mac/memory.plist` 複製到 `/Library/LaunchDaemons` 然後重新啟動 Mac. ```sh - sudo cp memory.plist /Library/LaunchDaemons/memory.plist + sudo cp docs/mac/memory.plist /Library/LaunchDaemons/memory.plist ``` * 確認我們真的有 16M shared-mem @@ -80,10 +80,9 @@ * 起始您的 BBSHOME: ``` ./scripts/docker_initbbs.sh [BBSHOME] pttofficialapps/go-pttbbs:latest - ``` -* `cp 02-config-run.go.template ptttype/02-config-run.go` -* `cp 02-config.run.template.ini 02-config.run.ini` -* 在 02-config.run.ini 裡設定 BBSHOME. + +* `cp docs/config/02-config.run.template.ini docs/config/02-config.run.ini` +* 在 docs/config/02-config.run.ini 裡設定 BBSHOME. * "只有如果" 您想要重新設定 shared-mem, 您可以使用以下方式: `ipcrm -M 0x000004cc` `ipcrm -S 0x000007da` @@ -119,12 +118,12 @@ 對於一般的 config-variables, 我們在 config.ini 裡設定. -對於 ptttype 裡常數的 config-variables, 我們使用 00-config-[dev-mode].go 和 +build flag. +對於 ptttype 裡常數的 config-variables, 我們使用 docs/config/00-config-[dev-mode].go 和 +build flag. -### 00-config.ini +### docs/config/00-config.ini 我們使用 viper 和 .ini 作為我們的 config-framework. -00-config.template.ini 是 config-template file. +docs/config/00-config.template.ini 是 config-template file. 對於每個 module, 我們有以下 3 個 source files 來完成 config: @@ -132,11 +131,11 @@ 2. config.go: 定義設定 variables 的 func. 3. config_util.go: 輔助 functions. -### 00-config-\[dev-mode\].go +### docs/config/00-config-\[dev-mode\].go 我們可以使用以下方式更改 ptttype/00-config-default.go: -1. 複製 00-config-production.go.template 到 ptttype/00-config-[dev-mode].go 並且更改 +build 和 variables. +1. 複製 docs/config/00-config-production.go.template 到 ptttype/00-config-[dev-mode].go 並且更改 +build 和 variables. 2. `go build -tag [dev-mode]` ## Swagger.sh @@ -147,6 +146,6 @@ 您可以使用以下方式設定 swagger-api: 1. 設定 python virtualenv. -2. cd apidoc; pip install . && pip uninstall apidoc -y && python setup.py develop; cd .. +2. cd apidoc; pip install -e . ; cd .. 3. ./scripts/swagger.sh 4. 使用 browser 觀看 [http://localhost:8080](http://localhost:8080). diff --git a/api/get_user.go b/api/get_user.go index cb014675..a76276b2 100644 --- a/api/get_user.go +++ b/api/get_user.go @@ -31,7 +31,7 @@ func GetUser(remoteAddr string, uuserID bbs.UUserID, params interface{}, path in return nil, ErrInvalidUser } - user, err := bbs.GetUser(uuserID) + user, err := bbs.GetUser(thePath.UserID) if err != nil { return nil, err } diff --git a/api/testcases_test.go b/api/testcases_test.go index 5216ce4c..d11e73ad 100644 --- a/api/testcases_test.go +++ b/api/testcases_test.go @@ -59,8 +59,8 @@ func initTestVars() { Nickname: ptttype.Nickname_t{0xaf, 0xab}, // 神 PasswdHash: ptttype.Passwd_t{0x62, 0x68, 0x77, 0x76, 0x4f, 0x4a, 0x74, 0x66, 0x54, 0x31, 0x54, 0x41, 0x49, 0x00}, - UFlag: 33557088, - UserLevel: 7 | ptttype.PERM_BOARD | ptttype.PERM_POST | ptttype.PERM_LOGINOK, + UFlag: ptttype.UF_CURSOR_ASCII | ptttype.UF_DBCS_DROP_REPEAT | ptttype.UF_DBCS_AWARE | ptttype.UF_ADBANNER | ptttype.UF_BRDSORT, + UserLevel: ptttype.PERM_DEFAULT | ptttype.PERM_BOARD | ptttype.PERM_POST | ptttype.PERM_LOGINOK, NumLoginDays: 2, NumPosts: 0, FirstLogin: 1600681288, @@ -81,14 +81,14 @@ func initTestVars() { } testNewPostUserRaw1 = &ptttype.UserecRaw{ - Version: 4194, + Version: ptttype.PASSWD_VERSION, UserID: ptttype.UserID_t{65, 49}, // A1 RealName: ptttype.RealName_t{67, 111, 100, 105, 110, 103, 77, 97, 110}, Nickname: ptttype.Nickname_t{175, 171}, PasswdHash: ptttype.Passwd_t{98, 104, 119, 118, 79, 74, 116, 102, 84, 49, 84, 65, 73, 0}, - UFlag: 33557088, - UserLevel: 7 | ptttype.PERM_LOGINOK | ptttype.PERM_POST, + UFlag: ptttype.UF_CURSOR_ASCII | ptttype.UF_DBCS_DROP_REPEAT | ptttype.UF_DBCS_AWARE | ptttype.UF_ADBANNER | ptttype.UF_BRDSORT, + UserLevel: ptttype.PERM_DEFAULT | ptttype.PERM_LOGINOK | ptttype.PERM_POST, NumLoginDays: 2, NumPosts: 0, FirstLogin: 1600681288, @@ -110,8 +110,8 @@ func initTestVars() { }, Nickname: []byte{0xaf, 0xab}, // 神 - Uflag: 33557088, - Userlevel: 536871943, + Uflag: ptttype.UF_CURSOR_ASCII | ptttype.UF_DBCS_DROP_REPEAT | ptttype.UF_DBCS_AWARE | ptttype.UF_ADBANNER | ptttype.UF_BRDSORT, + Userlevel: ptttype.PERM_DEFAULT | ptttype.PERM_SYSSUBOP | ptttype.PERM_BM, Numlogindays: 2, Numposts: 0, Firstlogin: 1600681288, @@ -373,7 +373,7 @@ func initTestVars() { BM: []bbs.UUserID{}, IdxByName: "1...........", IdxByClass: "Li4uLg@1...........", - BrdAttr: 0x000008, + BrdAttr: ptttype.BRD_GROUPBOARD, } testClassDetail2 = &bbs.BoardDetail{ @@ -415,7 +415,7 @@ func initTestVars() { BM: []bbs.UUserID{}, IdxByName: "2...........", IdxByClass: "Li4uLg@2...........", - BrdAttr: 0x000008, + BrdAttr: ptttype.BRD_GROUPBOARD, } testClassDetail5 = &bbs.BoardDetail{ diff --git a/bbs/testcases_test.go b/bbs/testcases_test.go index b82a3f4d..415d8b9c 100644 --- a/bbs/testcases_test.go +++ b/bbs/testcases_test.go @@ -77,8 +77,8 @@ func initTestVars() { Nickname: ptttype.Nickname_t{0xaf, 0xab}, // 神 PasswdHash: ptttype.Passwd_t{0x62, 0x68, 0x77, 0x76, 0x4f, 0x4a, 0x74, 0x66, 0x54, 0x31, 0x54, 0x41, 0x49, 0x00}, - UFlag: 33557088, - UserLevel: 536871943, + UFlag: ptttype.UF_CURSOR_ASCII | ptttype.UF_DBCS_DROP_REPEAT | ptttype.UF_DBCS_AWARE | ptttype.UF_ADBANNER | ptttype.UF_BRDSORT, + UserLevel: ptttype.PERM_DEFAULT | ptttype.PERM_SYSSUBOP | ptttype.PERM_BM, NumLoginDays: 2, NumPosts: 0, FirstLogin: 1600681288, @@ -107,8 +107,8 @@ func initTestVars() { Nickname: ptttype.Nickname_t{0xaf, 0xab}, // 神 PasswdHash: ptttype.Passwd_t{0x62, 0x68, 0x77, 0x76, 0x4f, 0x4a, 0x74, 0x66, 0x54, 0x31, 0x54, 0x41, 0x49, 0x00}, - UFlag: 33557088, - UserLevel: 7 | ptttype.PERM_BOARD | ptttype.PERM_POST | ptttype.PERM_LOGINOK, + UFlag: ptttype.UF_CURSOR_ASCII | ptttype.UF_DBCS_DROP_REPEAT | ptttype.UF_DBCS_AWARE | ptttype.UF_ADBANNER | ptttype.UF_BRDSORT, + UserLevel: ptttype.PERM_DEFAULT | ptttype.PERM_BOARD | ptttype.PERM_POST | ptttype.PERM_LOGINOK, NumLoginDays: 2, NumPosts: 0, FirstLogin: 1600681288, @@ -137,7 +137,7 @@ func initTestVars() { Nickname: ptttype.Nickname_t{0xaf, 0xab}, // 神 PasswdHash: ptttype.Passwd_t{0x62, 0x68, 0x77, 0x76, 0x4f, 0x4a, 0x74, 0x66, 0x54, 0x31, 0x54, 0x41, 0x49, 0x00}, - UFlag: 33557088, + UFlag: ptttype.UF_CURSOR_ASCII | ptttype.UF_DBCS_DROP_REPEAT | ptttype.UF_DBCS_AWARE | ptttype.UF_ADBANNER | ptttype.UF_BRDSORT, UserLevel: ptttype.PERM_SYSOP, NumLoginDays: 2, NumPosts: 0, @@ -167,8 +167,8 @@ func initTestVars() { Nickname: ptttype.Nickname_t{0xaf, 0xab}, // 神 PasswdHash: ptttype.Passwd_t{0x62, 0x68, 0x77, 0x76, 0x4f, 0x4a, 0x74, 0x66, 0x54, 0x31, 0x54, 0x41, 0x49, 0x00}, - UFlag: 33557088, - UserLevel: 7 | ptttype.PERM_BOARD | ptttype.PERM_POST | ptttype.PERM_LOGINOK, + UFlag: ptttype.UF_CURSOR_ASCII | ptttype.UF_DBCS_DROP_REPEAT | ptttype.UF_DBCS_AWARE | ptttype.UF_ADBANNER | ptttype.UF_BRDSORT, + UserLevel: ptttype.PERM_DEFAULT | ptttype.PERM_BOARD | ptttype.PERM_POST | ptttype.PERM_LOGINOK, NumLoginDays: 2, NumPosts: 0, FirstLogin: 1600681288, @@ -197,7 +197,7 @@ func initTestVars() { Nickname: ptttype.Nickname_t{0xaf, 0xab}, // 神 PasswdHash: ptttype.Passwd_t{0x62, 0x68, 0x77, 0x76, 0x4f, 0x4a, 0x74, 0x66, 0x54, 0x31, 0x54, 0x41, 0x49, 0x00}, - UFlag: 33557088, + UFlag: ptttype.UF_CURSOR_ASCII | ptttype.UF_DBCS_DROP_REPEAT | ptttype.UF_DBCS_AWARE | ptttype.UF_ADBANNER | ptttype.UF_BRDSORT, UserLevel: ptttype.PERM_BASIC, NumLoginDays: 2, NumPosts: 0, @@ -225,8 +225,8 @@ func initTestVars() { Nickname: ptttype.Nickname_t{175, 171}, PasswdHash: ptttype.Passwd_t{98, 104, 119, 118, 79, 74, 116, 102, 84, 49, 84, 65, 73, 0}, - UFlag: 33557088, - UserLevel: 7 | ptttype.PERM_LOGINOK | ptttype.PERM_POST, + UFlag: ptttype.UF_CURSOR_ASCII | ptttype.UF_DBCS_DROP_REPEAT | ptttype.UF_DBCS_AWARE | ptttype.UF_ADBANNER | ptttype.UF_BRDSORT, + UserLevel: ptttype.PERM_DEFAULT | ptttype.PERM_LOGINOK | ptttype.PERM_POST, NumLoginDays: 2, NumPosts: 0, FirstLogin: 1600681288, @@ -248,8 +248,8 @@ func initTestVars() { }, Nickname: []byte{0xaf, 0xab}, // 神 - Uflag: 33557088, - Userlevel: 536871943, + Uflag: ptttype.UF_CURSOR_ASCII | ptttype.UF_DBCS_DROP_REPEAT | ptttype.UF_DBCS_AWARE | ptttype.UF_ADBANNER | ptttype.UF_BRDSORT, + Userlevel: ptttype.PERM_DEFAULT | ptttype.PERM_SYSSUBOP | ptttype.PERM_BM, Numlogindays: 2, Numposts: 0, Firstlogin: 1600681288, @@ -273,8 +273,8 @@ func initTestVars() { UUserID: UUserID("B1"), Username: "B1", Lasthost: "127.0.0.1", - Uflag: 33557088, - Userlevel: 7, + Uflag: ptttype.UF_CURSOR_ASCII | ptttype.UF_DBCS_DROP_REPEAT | ptttype.UF_DBCS_AWARE | ptttype.UF_ADBANNER | ptttype.UF_BRDSORT, + Userlevel: ptttype.PERM_DEFAULT, Numlogindays: 1, Pager: 1, Over18: true, @@ -526,7 +526,7 @@ func initTestVars() { BM: []UUserID{}, IdxByName: "mnewboard", IdxByClass: "Q1BCTA@mnewboard", - BrdAttr: 0x200000, + BrdAttr: ptttype.BRD_CPLOG, } testClassSummary2 = &BoardSummary{ @@ -546,7 +546,7 @@ func initTestVars() { BM: []UUserID{}, IdxByName: "1...........", IdxByClass: "Li4uLg@1...........", - BrdAttr: 0x000008, + BrdAttr: ptttype.BRD_GROUPBOARD, } testClassDetail2 = &BoardDetail{ @@ -588,7 +588,7 @@ func initTestVars() { BM: []UUserID{}, IdxByName: "2...........", IdxByClass: "Li4uLg@2...........", - BrdAttr: 0x000008, + BrdAttr: ptttype.BRD_GROUPBOARD, } testClassDetail5 = &BoardDetail{ diff --git a/cmbbs/testcases_test.go b/cmbbs/testcases_test.go index 38e41494..ed5c4241 100644 --- a/cmbbs/testcases_test.go +++ b/cmbbs/testcases_test.go @@ -4,14 +4,14 @@ import "github.com/Ptt-official-app/go-pttbbs/ptttype" var ( testUserecRaw1 = &ptttype.UserecRaw{ - Version: 4194, - UserID: ptttype.UserID_t{83, 89, 83, 79, 80}, - RealName: ptttype.RealName_t{67, 111, 100, 105, 110, 103, 77, 97, 110}, - Nickname: ptttype.Nickname_t{175, 171}, + Version: ptttype.PASSWD_VERSION, + UserID: ptttype.UserID_t{83, 89, 83, 79, 80}, // SYSOP + RealName: ptttype.RealName_t{67, 111, 100, 105, 110, 103, 77, 97, 110}, // CodingMan + Nickname: ptttype.Nickname_t{175, 171}, // 神 PasswdHash: ptttype.Passwd_t{98, 104, 119, 118, 79, 74, 116, 102, 84, 49, 84, 65, 73, 0}, - UFlag: 33557088, - UserLevel: 536871943, + UFlag: ptttype.UF_CURSOR_ASCII | ptttype.UF_DBCS_DROP_REPEAT | ptttype.UF_DBCS_AWARE | ptttype.UF_ADBANNER | ptttype.UF_BRDSORT, + UserLevel: ptttype.PERM_DEFAULT | ptttype.PERM_SYSSUBOP | ptttype.PERM_BM, NumLoginDays: 2, NumPosts: 0, FirstLogin: 1600681288, @@ -20,19 +20,19 @@ var ( Address: ptttype.Address_t{183, 115, 166, 203, 191, 164, 164, 108, 181, 234, 182, 109, 175, 81, 166, 179, 167, 248, 53, 52, 51, 184, 185}, Over18: true, Pager: ptttype.PAGER_ON, - Career: ptttype.Career_t{165, 254, 180, 186, 179, 110, 197, 233}, + Career: ptttype.Career_t{165, 254, 180, 186, 179, 110, 197, 233}, // 全景軟體 LastSeen: 1600681288, } testUserecRaw1Load = &ptttype.UserecRaw{ - Version: 4194, - UserID: ptttype.UserID_t{83, 89, 83, 79, 80}, - RealName: ptttype.RealName_t{67, 111, 100, 105, 110, 103, 77, 97, 110}, - Nickname: ptttype.Nickname_t{175, 171}, + Version: ptttype.PASSWD_VERSION, + UserID: ptttype.UserID_t{83, 89, 83, 79, 80}, // SYSOP + RealName: ptttype.RealName_t{67, 111, 100, 105, 110, 103, 77, 97, 110}, // CodingMan + Nickname: ptttype.Nickname_t{175, 171}, // 神 PasswdHash: ptttype.Passwd_t{98, 104, 119, 118, 79, 74, 116, 102, 84, 49, 84, 65, 73, 0}, - UFlag: 33557088, - UserLevel: 536871943, + UFlag: ptttype.UF_CURSOR_ASCII | ptttype.UF_DBCS_DROP_REPEAT | ptttype.UF_DBCS_AWARE | ptttype.UF_ADBANNER | ptttype.UF_BRDSORT, + UserLevel: ptttype.PERM_DEFAULT | ptttype.PERM_SYSSUBOP | ptttype.PERM_BM, NumLoginDays: 2, NumPosts: 100, FirstLogin: 1600681288, @@ -41,19 +41,19 @@ var ( Address: ptttype.Address_t{183, 115, 166, 203, 191, 164, 164, 108, 181, 234, 182, 109, 175, 81, 166, 179, 167, 248, 53, 52, 51, 184, 185}, Over18: true, Pager: ptttype.PAGER_ON, - Career: ptttype.Career_t{165, 254, 180, 186, 179, 110, 197, 233}, + Career: ptttype.Career_t{165, 254, 180, 186, 179, 110, 197, 233}, // 全景軟體 LastSeen: 1600681288, } testUserecRaw1Updated = &ptttype.UserecRaw{ - Version: 4194, - UserID: ptttype.UserID_t{83, 89, 83, 79, 80}, - RealName: ptttype.RealName_t{67, 111, 100, 105, 110, 103, 77, 97, 110}, - Nickname: ptttype.Nickname_t{175, 171}, + Version: ptttype.PASSWD_VERSION, + UserID: ptttype.UserID_t{83, 89, 83, 79, 80}, // SYSOP + RealName: ptttype.RealName_t{67, 111, 100, 105, 110, 103, 77, 97, 110}, // CodingMan + Nickname: ptttype.Nickname_t{175, 171}, // 神 PasswdHash: ptttype.Passwd_t{98, 104, 119, 118, 79, 74, 116, 102, 84, 49, 84, 65, 73, 0}, - UFlag: 33557088, - UserLevel: 536871943, + UFlag: ptttype.UF_CURSOR_ASCII | ptttype.UF_DBCS_DROP_REPEAT | ptttype.UF_DBCS_AWARE | ptttype.UF_ADBANNER | ptttype.UF_BRDSORT, + UserLevel: ptttype.PERM_DEFAULT | ptttype.PERM_SYSSUBOP | ptttype.PERM_BM, NumLoginDays: 2, NumPosts: 100, FirstLogin: 1600681288, @@ -62,7 +62,7 @@ var ( Address: ptttype.Address_t{183, 115, 166, 203, 191, 164, 164, 108, 181, 234, 182, 109, 175, 81, 166, 179, 167, 248, 53, 52, 51, 184, 185}, Over18: true, Pager: ptttype.PAGER_ON, - Career: ptttype.Career_t{165, 254, 180, 186, 179, 110, 197, 233}, + Career: ptttype.Career_t{165, 254, 180, 186, 179, 110, 197, 233}, // 全景軟體 LastSeen: 1600681288, } ) diff --git a/Dockerfile b/docker/Dockerfile similarity index 71% rename from Dockerfile rename to docker/Dockerfile index 44364a49..a8c6e88f 100644 --- a/Dockerfile +++ b/docker/Dockerfile @@ -1,9 +1,14 @@ FROM bbsdocker/imageptt:latest - # golang on debian +# THE_ARCH: uname -m +# THE_GOARCH: amd64 or arm64 WORKDIR /opt -RUN curl -L https://dl.google.com/go/go1.19.3.linux-amd64.tar.gz | tar -zxv && \ +RUN THE_ARCH=`uname -m` && \ + if [ "${THE_ARCH}" = "aarch64" -o "${THE_ARCH}" = "arm64" ]; then THE_GOARCH=arm64; else THE_GOARCH=amd64; fi && \ + echo "THE_ARCH: ${THE_ARCH} THE_GOARCH: ${THE_GOARCH}" && \ + sleep 3 && \ + curl -L https://dl.google.com/go/go1.22.2.linux-${THE_GOARCH}.tar.gz | tar -zxv && \ mv go /usr/local RUN DEBIAN_FRONTEND=noninteractive && \ @@ -28,8 +33,8 @@ ENV PATH=${PATH}:/usr/local/go/bin:/home/bbs/bin:/opt/bbs/bin COPY . /srv/go-pttbbs WORKDIR /srv/go-pttbbs -RUN cp 01-config-docker.go.template ptttype/01-config-docker.go && \ - mkdir -p /etc/go-pttbbs && cp 01-config.docker.ini /etc/go-pttbbs/production.ini && \ +RUN cp docs/config/01-config-docker.go.template ptttype/01-config-docker.go && \ + mkdir -p /etc/go-pttbbs && cp docs/config/01-config.docker.ini /etc/go-pttbbs/production.ini && \ cp docs/etc/* /etc/go-pttbbs && \ chown -R bbs . diff --git a/docker-compose.yaml b/docker/go-pttbbs/docker-compose.yaml similarity index 60% rename from docker-compose.yaml rename to docker/go-pttbbs/docker-compose.yaml index 96fca846..02967dc6 100644 --- a/docker-compose.yaml +++ b/docker/go-pttbbs/docker-compose.yaml @@ -10,3 +10,9 @@ services: volumes: - ${BBSHOME}:/home/bbs - ${ETC}:/etc/go-pttbbs + postfix: + image: chhsiao1981/docker-postfix + volumes: + - ${POSTFIX_MAIN_CF}:/etc/postfix/main.cf + - ${POSTFIX_MASTER_CF}:/etc/postfix/master.cf + restart: always diff --git a/docker/go-pttbbs/docker-compose.yaml.me b/docker/go-pttbbs/docker-compose.yaml.me new file mode 100644 index 00000000..95f0e22a --- /dev/null +++ b/docker/go-pttbbs/docker-compose.yaml.me @@ -0,0 +1,19 @@ +version: '2' +services: + go-pttbbs: + image: go-pttbbs:docker-2 + # entrypoint: + # - "/bin/bash" + # - "-c" + # - "while [ 1 -eq 1 ]; do date; echo 'to sleep 86400'; sleep 86400; done" + ports: + - "127.0.0.1:3456:3456" + - "127.0.0.1:8889:8888" + - "127.0.0.1:48765:48763" + - "127.0.0.1:5150:5150" + - "127.0.0.1:5151:5151" + restart: always + volumes: + - ${BBSHOME}:/home/bbs + - ${ETC}:/etc/go-pttbbs + # - ${GOPTTBBS}:/srv/go-pttbbs diff --git a/docker-compose.yaml.template b/docker/go-pttbbs/docker-compose.yaml.template similarity index 100% rename from docker-compose.yaml.template rename to docker/go-pttbbs/docker-compose.yaml.template diff --git a/docker/go-pttbbs/docker_compose.env b/docker/go-pttbbs/docker_compose.env new file mode 100644 index 00000000..5f997b55 --- /dev/null +++ b/docker/go-pttbbs/docker_compose.env @@ -0,0 +1,5 @@ +BBSHOME=/Users/chhsiao/ptt/home/bbs +GOPTTBBS=/Users/chhsiao/projects/go-pttbbs +ETC=/etc/go-pttbbs +POSTFIX_MAIN_CF=/etc/my-postfix/main.cf +POSTFIX_MASTER_CF=/etc/my-postfix/master.cf diff --git a/docker/go-pttbbs/docker_compose.env.template b/docker/go-pttbbs/docker_compose.env.template new file mode 100644 index 00000000..f9bcafca --- /dev/null +++ b/docker/go-pttbbs/docker_compose.env.template @@ -0,0 +1,4 @@ +BBSHOME=/home/bbs +ETC=/etc/go-pttbbs +POSTFIX_MAIN_CF=/etc/postfix/main.cf +POSTFIX_MASTER_CF=/etc/postfix/master.cf diff --git a/docker_compose.env.template b/docker_compose.env.template deleted file mode 100644 index b33e37e5..00000000 --- a/docker_compose.env.template +++ /dev/null @@ -1,2 +0,0 @@ -BBSHOME=/home/bbs -ETC=/etc/go-pttbbs diff --git a/00-config-production.go.template b/docs/config/00-config-production.go.template similarity index 100% rename from 00-config-production.go.template rename to docs/config/00-config-production.go.template diff --git a/00-config.template.ini b/docs/config/00-config.template.ini similarity index 100% rename from 00-config.template.ini rename to docs/config/00-config.template.ini diff --git a/01-config-docker.go.template b/docs/config/01-config-docker.go.template similarity index 100% rename from 01-config-docker.go.template rename to docs/config/01-config-docker.go.template diff --git a/01-config.docker.ini b/docs/config/01-config.docker.ini similarity index 100% rename from 01-config.docker.ini rename to docs/config/01-config.docker.ini diff --git a/02-config-run.go.template b/docs/config/02-config-run.go.template similarity index 100% rename from 02-config-run.go.template rename to docs/config/02-config-run.go.template diff --git a/docs/config/02-config.run.ini b/docs/config/02-config.run.ini new file mode 100644 index 00000000..e2947398 --- /dev/null +++ b/docs/config/02-config.run.ini @@ -0,0 +1,505 @@ +[go-pttbbs] +HTTP_HOST = 0.0.0.0:3456 # HTTP_HOST + +[go-pttbbs:api] +JWT_SECRET = jwt_secret # JWT secret +JWT_ISSUER = go-pttbbs # JWT issuer + +[go-pttbbs:types] +TIME_LOCATION = Asia/Taipei #timezone in location-format. + +[go-pttbbs:ptttype] +SERVICE_MODE = DEV + +# ////////// +# // make.conf +# ////////// +BBSHOME = /home/bbs # /* BBS home-dir. */ + +# ////////// +# // pttbbs.conf +# ////////// +# /* 定義 BBS 站名位址 */ +BBSNAME = 新批踢踢 # /* 中文站名 */ +BBSENAME = PTT2 # /* 英文站名 */ +MYHOSTNAME = ptt2.cc # /* 網路位址 */ +MYIP = 127.0.0.1 # /* IP位址 */ + +# /* 定義是否查詢文章的 web 版 URL,及 URL 用的 hostname/prefix */ +QUERY_ARTICLE_URL = true # /* 是否提供查詢文章 URL */ +URL_PREFIX = http://localhost/bbs # /* URL prefix */ +# /* +# http://www.ptt.cc/bbs/SYSOP/M.1197864962.A.476.html +# ^^^^^^^^^^^^^^^^^^^^^ +# 這個部分 +# */ + +# /* *** 以下為預設板名 (見 include/config.h) *** */ + +# /* 安全紀錄 */ +BN_SECURITY = Security +# /* 動態看板的家 */ +BN_NOTE = Note +# /* 紀錄 */ +BN_RECORD = Record + +# /* SYSOP 板 */ +BN_SYSOP = SYSOP +# /* 測試板 */ +BN_TEST = Test +# /* 發生錯誤時建議的回報板名為此板 */ +BN_BUGREPORT = BBSMNAME + Bug +# /* 法律訴訟的板 */ +BN_LAW = BBSMNAME + Law +# /* 新手板(會自動進我的最愛) */ +BN_NEWBIE = BBSMNAME + NewHand +# /* 找看板(會自動進我的最愛) */ +BN_ASKBOARD = AskBoard +# /* 外國板 */ +BN_FOREIGN = BBSMNAME + Foreign + +# /* *** 以下為定義時會多出功能的板名 *** */ + +# /* 若定義, 提供美工特別用板 */ +BN_ARTDSN = Artdsn + +# /* 若定義,該板發文不受行限或是可上傳 */ +BN_BBSMOVIE = BBSmovie + +# // /* 若定義,則.... */ +BN_WHOAMI = WhoAmI + +# /* 若定義, 則全站所有五子棋/象棋棋譜都會紀錄在此板 */ +IS_BN_FIVECHESS_LOG_INFERRED = true +BN_FIVECHESS_LOG = BBSMNAME + Five +IS_BN_CCHESS_LOG_INFERRED = true +BN_CCHESS_LOG = BBSMNAME + CChess + +# /* 若定義,則動態看板會動態檢查爭議性字眼 */ +BN_NOTE_AGGCHKDIR = <點歌> 動態看板 + +# /* 若定義則啟用修文自動合併系統 */ +EDITPOST_SMARTMERGE = false + +# /* 可以設定多重進站畫面 */ +MULTI_WELCOME_LOGIN = false + +# /* 若定義, 則所有編輯文章最下方都會加入編輯來源. +# 否則只有 SYSOP板會加入來源 */ +ALL_REEDIT_LOG = false + +# /* 板主可以按大寫 H切換隱形與否 */ +BMCHS = false + +# /* 水球整理, 看板備份等等外部程式 */ +OUTJOBSPOOL = true + +# /* 若定義, 則不能舉辦賭盤 */ +NO_GAMBLE = false + +# /* 可動態透過 GLOBALVAR[9]調整使用者上限 */ +DYMAX_ACTIVE = true + +# /* 程式每天最多可以跑多久 (in seconds) 因為有的時候會出現跑不停的 process */ +CPULIMIT_PER_DAY = 30 + +# /* 若定義, 若程式失敗, 會等待 86400 秒以讓 gdb來 attach */ +DEBUGSLEEP = true + +# /* 若定義, 在轉寄位址輸入錯誤時會有讓使用者回報訊息的提示 */ +# /* 這個選項存在的原因是因為有部份使用者信誓旦旦說他們沒打錯但看不出程式錯誤 */ +DEBUG_FWDADDRERR = false + +# /* 若定義, 則可在外部 (shmctl cmsignal) 要求將 mbbsd將 zapbuf 釋放掉. +# 會使用非正規的記憶體要求函式. (目前只在 FreeBSD上測試過) +# !!請注意!! +# 除非您確切知道這個能能在做什麼並且有須要, +# 否則請不要打開這個功能!! */ +CRITICAL_MEMORY = false + +# /* 對於 port 23的, 會預先 fork 幾隻出來. 如此在系統負荷高的時候, +# 仍可有好的上站率 */ +PRE_FORK = 10 + +# /* 若定義, 則開啟 Big5 轉 UTF-8 的功能 */ +CONVERT = true + +# /* 若定義, 則在文章列表的時候不同日期會標上不同顏色 */ +COLORDATE = false + +# /* 若定義, 在使用者註冊之前, 會先顯示出該檔案, 經使用者確認後才能註冊 */ +HAVE_USERAGREEMENT = etc/UserAgreement +HAVE_USERAGREEMENT_VERSION = etc/UserAgreementVersion +HAVE_USERAGREEMENT_ACCEPTABLE = etc/UserAgreementAcceptable + +# /* DBCS 相關設定 */ +# /* DBCS Aware: 讓游標不會跑到 DBCS trailing bytes 上 */ +DBCSAWARE = true + +# /* 若定義,guest 帳號預設不顯示一字雙色 */ +GUEST_DEFAULT_DBCS_NOINTRESC = false + +# /* 使用新式的 pmore (piaip's more) 代替舊式 bug 抓不完的 more 或是簡易的 minimore */ +USE_PMORE = false + +# /* 使用 rfork()取代 fork() . 目前只在 FreeBSD上有效 */ +USE_RFORK = false + +# /* 使用 HUGETLB shared memory . 目前只在 Linux 上有效 */ +USE_HUGETLB = false + +# /* 在某些平台之下, shared-memory規定需要為一定的 aligned size, +# 如在 linux x86_64 下使用 HUGETLB 時需為 4MB aligned, +# 而在 linux ia64 下使用 HUGETLB時需為 256MB aligned. +# 單位為 bytes */ +SHMALIGNEDSIZE = 1048576 # // 4MB for x86_64, 1MB for development + +# /* 讓過於熱門或被鬧的版冷靜, SHM 會變大一些些 */ +USE_COOLDOWN = true + +# /* 若定義, 則在刪除看板文章的時候, 僅會在 .DIR 中標明, 並不會將該資料 +# 從 .DIR 中拿掉. 可以避免多項問題 (尤其是熱門看板一堆推薦及編輯時) +# 須配合使用 (尚未完成) */ +SAFE_ARTICLE_DELETE = true + +# /* 若定義, 則在傳送水球的時候, 不會直接 kill 該程序. 理論上可以減少大 +# 量的系統負和 */ +NOKILLWATERBALL = false + +# /* 若定義, 則 SYSOP帳號並不會自動加上站長權限. +# 在第一次啟動時, 您並不能定義 (否則就拿不到站長權了) . +# 而在設定完成後, 若您站長帳號並不叫做 SYSOP, +# 則可透過 NO_SYSOP_ACCOUNT 關閉該帳號, 以避免安全問題發生. */ +NO_SYSOP_ACCOUNT = false + +# /* 開啟小天使小主人功能 */ +PLAY_ANGEL = false + +# /* 若定義, 則使用舊式推文 */ +OLDRECOMMEND = false + +# /* 若定義, 則 guest 可推文,格式變為 IP+日期 */ +GUESTRECOMMEND = false + +# /* 定義幾秒內算快速推文 */ +FASTRECMD_LIMIT = 90 + +# /* 若定義, 可設定轉錄自動在原文留下記錄 */ +USE_AUTOCPLOG = true + +# /* 若定義, 新板設定自動開記錄,不過 USE_AUTOCPLOG 還是要開才有用 */ +DEFAULT_AUTOCPLOG = true + +# /* 如果 time_t 是 8 bytes的話 (如 X86_64) */ +TIMET64 = true + +# /* 使用 utmpd, 在外部運算好友資料, 如果您確定這個在做什麼才開啟 */ +UTMPD = false +UTMPD_ADDR = 192.168.0.1:5120 +# /* 在 cacheserver 上面擋掉狂上下站的使用者 */ +NOFLOODING = false + +# /* 使用 daemon/fromd, 使用外部daemon紀錄上站故鄉名稱 */ +FROMD = false + +# /* 若定義, 則不允許註冊 guest */ +NO_GUEST_ACCOUNT_REG = false + +# /* 限制一個email能註冊的帳號數量 (要使用請在make的時候加 WITH_EMAILDB) */ +EMAILDB_LIMIT = 5 + +USE_REG_CAPTCHA = false +USE_POST_CAPTCHA_FOR_NOREG = false +USE_VOTE_CAPTCHA = false +USE_REMOTE_CAPTCHA = false +CAPTCHA_INSERT_SERVER_ADDR = 127.0.0.1:80 +IS_CAPTCHA_INSERT_HOST_INFERRED = true +CAPTCHA_INSERT_HOST = CAPTCHA_INSERT_SERVER_ADDR +CAPTCHA_INSERT_URI = /captcha/insert +CAPTCHA_INSERT_SECRET = +CAPTCHA_URL_PREFIX = http://localhost/captcha +CAPTCHA_CODE_LENGTH = 32 + +REQUIRE_SECURE_CONN_TO_REGISTER = false +REQUIRE_VERIFY_EMAIL_AT_REGISTER = false + +# /* 前進站畫面 */ +INSCREEN = + +# ////////// +# // config.h +# ////////// +BBSPROGPOSTFIX = /bin/mbbsd # /* 主程式 */ +BBSPROG = BBSHOME + BBSPROGPOSTFIX # /* 主程式 */ +BAN_FILE = BAN # /* 關站通告檔 */ +LOAD_FILE = /proc/loadavg # /* for Linux */ + +# ///////////////////////////////////////////////////////////////////////////// +# // System Name Configuration 系統名稱設定 + +# /* 系統名(郵件用),建議別超過 3 個字元。 詳見 sample/pttbbs.conf */ +BBSMNAME = Ptt + +# /* 系統名(選單用),建議剛好 4 個字元。 詳見 sample/pttbbs.conf */ +BBSMNAME2 = Ptt + +# /* 錢幣名,建議剛好 3 個字元。 詳見 sample/pttbbs.conf */ +IS_MONEYNAME_INFFERRED = true +MONEYNAME = BBSMNAME + 幣 + +# /* AID 顯示的站台名稱。 若 IP 太長請另行定義。 */ +IS_AID_HOSTNAME_INFERRED = true +AID_HOSTNAME = MYHOSTNAME + +# ///////////////////////////////////////////////////////////////////////////// +# // Themes 主題配色 + +TITLE_COLOR = 0;1;37;46 # /* 主畫面上方標題列 */ + +HLP_CATEGORY_COLOR = 0;1;32 # /* 說明表格內分類項 */ + +HLP_DESCRIPTION_COLOR = 0 # /* 說明表格內說明項 */ + +HLP_KEYLIST_COLOR = 0;1;36 # /* 說明表格內按鍵項 */ + +# ///////////////////////////////////////////////////////////////////////////// +# // OS Settings 作業系統相關設定 + +BBSUSER = bbs + +BBSUID = 501 + +BBSGID = 20 + +TAR_PATH = tar + +MUTT_PATH = mutt + +DEFAULT_FOLDER_CREATE_PERM = 0755 + +DEFAULT_FILE_CREATE_PERM = 0644 + +SHM_KEY = 1228 + +PASSWDSEM_KEY = 2010 # /* semaphore key */ + +# // SYSLOG_FACILITY = LOG_LOCAL0 (not sure the corresponding LOG_LOCAL0 in golang) + +# /* 若定義, 用一個奇怪的數字來檢查我的最愛和看板列表是否錯誤 */ +MEM_CHECK = 0x98761234 + +RELAY_SERVER_IP = 127.0.0.1 + +XCHATD_ADDR = :3838 + +# ///////////////////////////////////////////////////////////////////////////// +# // Default Board Names 預設看板名稱 + +BN_ID_PROBLEM = SYSOP + +BN_DELETED = deleted + +BN_JUNK = junk + +BN_POLICELOG = PoliceLog + +BN_UNANONYMOUS = UnAnonymous + +BN_NEWIDPOST = NEWIDPOST + +BN_ALLPOST = ALLPOST + +BN_ALLHIDPOST = ALLHIDPOST + +# ///////////////////////////////////////////////////////////////////////////// +# // Performance Parameters 效能參數 + +MAX_GUEST = 100 # /* 最多 guest 上站人數 */ + +MAX_CPULOAD = 70 # /* CPU 最高load */ + +DEBUGSLEEP_SECONDS = 3600 # /* debug 等待時間 */ + +OVERLOADBLOCKFDS = 0 # /* 超載後會保留這麼多個 fd */ + +MAX_SWAPUSED = 0.7 # /* SWAP最高使用率 */ + +TARQUEUE_TIME_STR = 深夜 # // 看板備份時間訊息 (應與 contab 一致) + +# ///////////////////////////////////////////////////////////////////////////// +# // More system messages 系統訊息 + +RECYCLE_BIN_NAME = 資源回收筒 # // 垃圾桶 + +RECYCLE_BIN_OWNER = [ + RECYCLE_BIN_NAME + ] + +TIME_CAPSULE_NAME = Magical Index # // Time Capsule + +# ///////////////////////////////////////////////////////////////////////////// +# // Site settings 站台功能設定 + +MAX_POST_MONEY = 100 # /* 發表文章稿費的上限 */ + +MAX_CHICKEN_MONEY = 100 # /* 養雞場獲利上限 */ + +MAX_GUEST_LIFE = 259200 # 3 * 24 * 60 * 60 /* 最長未認證使用者保留時間(秒) */ + +MAX_EDIT_LINE = 2048 # /* 文章最長編輯長度 */ + +MAX_EDIT_LINE_LARGE = 32000 # // 大檔最長編輯長度 + +MAX_LIFE = 10368000 # 120 * 24 * 60 * 60 /* 最長使用者保留時間(秒) */ + +KEEP_DAYS_REGGED = 120 # /* 已註冊使用者保留多久 */ + +KEEP_DAYS_UNREGGED = 15 # /* 未註冊使用者保留多久 */ + +THREAD_SEARCH_RANGE = 500 # /* 系列文章搜尋上限 */ + +# /* 定義是否使用外籍使用者註冊 +# 及外國人最長居留時間,之後需向站方申請永久居留權 */ +FOREIGN_REG = false + +FOREIGN_REG_DAY = 30 # /* 外籍使用者試用日期上限 */ + +FORCE_PROCESS_REGISTER_FORM = 0 + +# /* 定義看板好友名單將會在幾秒鐘後失效強迫重載 */ +HBFLexpire = 432000 + +MAX_EXKEEPMAIL = 1000 # /* 最多信箱加大多少封 */ + +# /* 在轉信時附上的時區. 若在台灣, 中國大陸等地, 用預設的即可. */ +INNTIMEZONE = +0800 (CST) + +ADD_EXMAILBOX = 0 # /* 贈送信箱 */ + +BADPOST_CLEAR_DURATION = 180 # // 消劣文時間限制 + +BADPOST_MIN_CLEAR_DURATION = 3 # // 劣文首消時間限制 + +MAX_CROSSNUM = 9 # /* 最多crosspost次數 */ + +# /* (deprecated) more.c 中文章頁數上限(lines/22), +4 for safe */ +# // MAX_PAGES = MAX_EDIT_LINE/22 + 4 + +MAX_QUERYLINES = 16 # /* 顯示 Query/Plan 訊息最大行數 */ + +MAX_LOGIN_INFO = 128 # /* 最多上線通知人數 */ + +MAX_POST_INFO = 32 # /* 最多新文章通知人數 */ + +MAX_NAMELIST = 128 # /* 最多其他特別名單人數 */ + +MAX_NOTE = 20 # /* 最多保留幾篇留言? */ + +MAX_SIGLINES = 6 # /* 簽名檔引入最大行數 */ + +LOGINATTEMPTS = 3 # /* 最大進站失誤次數 */ + +MAX_KEEPMAIL = 200 # /* 一般 user 最多保留幾封 MAIL? */ + +MAX_KEEPMAIL_SOFTLIMIT = 2500 # /* 除 admin 外,無法寄給此人 */ + +MAX_KEEPMAIL_HARDLIMIT = 20000 # /* 信箱數量的上限,超過就不給寄信 */ + +BADCIDCHARS = " *" # /* Chat Room 中禁用於 nick 的字元 */ + +MAX_ROOM = 16 # /* 聊天室最多有幾間包廂? */ + +MAXTAGS = 255 # /* t(tag) 的最大數量 */ + +WRAPMARGIN = 511 # /* 編輯器 wrap 長度 */ + +# // XXX we may need to take care of FROMHOST +# /* +# #ifdef USE_MASKED_FROMHOST +# #define FROMHOST fromhost_masked +# #else +# #define FROMHOST fromhost +# #endif +# */ + +# ///////////////////////////////////////////////////////////////////////////// +# // Logging 記錄設定 + +LOG_CONF_KEYWORD = false # // 記錄搜尋的關鍵字 + +LOG_CONF_INTERNETMAIL = false # // 記錄 internet outgoing mail + +LOG_CONF_PUSH = false # // 記錄推文 + +LOG_CONF_EDIT_CALENDAR = false # // 記錄編輯行事曆 + +LOG_CONF_POST = false # // 記錄發文 + +LOG_CONF_CRAWLER = false # // 記錄 crawlers + +LOG_CONF_CROSSPOST = false # // 記錄轉錄 + +LOG_CONF_BAD_REG_CODE = false # // 記錄打錯的註冊碼 + +LOG_CONF_VALIDATE_REG = false # // 記錄審核註冊單 + +LOG_CONF_MASS_DELETE = false # // 記錄大量刪除檔案 + +LOG_CONF_OSONG_VERBOSE = false # // 詳細點播記錄 + +LOG_CONF_EDIT_TITLE = false # // 編輯標題記錄 + +# ///////////////////////////////////////////////////////////////////////////// +# // Default Configurations 預設參數 + +# // 若想停用下列參數請在 pttbbs.conf 定義 NO_XXX (ex, NO_LOGINASNEW) +LOGINASNEW = true # /* 採用上站申請帳號制度 */ + +DOTIMEOUT = true # /* 處理閒置時間 */ + +INTERNET_EMAIL = true # /* 支援 InterNet Email 功能(含 Forward) */ + +SHOWUID = true # /* 站長可看見使用者 UID */ + +SHOWBOARD = true # /* 站長可看見使用者看板 */ + +SHOWPID = true # /* 站長可看見使用者 PID */ + +HAVE_ANONYMOUS = true # /* 提供 Anonymous 板 */ + +HAVE_ORIGIN = true # /* 顯示 author 來自何處 */ + +USE_BSMTP = true # /* 使用opus的BSMTP 寄收信? */ + +REJECT_FLOOD_POST = true # /* 防止BlahBlah式灌水 */ + +# // #define HAVE_INFO /* 顯示程式版本說明 */ +# // #define HAVE_LICENSE /* 顯示 GNU 版權畫面 */ +# // #define HAVE_REPORT /* (轉信)系統追蹤報告 */ + +IDLE_TIMEOUT = 43200 # /* 一般情況之 timeout (12hr) */ +SHOW_IDLE_TIME = true # /* 顯示閒置時間 */ + +# ////////// +# // common.h +# ////////// +SZ_RECENTLOGIN = 16000 # // size of max recent log before rotation +SZ_RECENTPAY = 16000 + +# // XXX FN_SAFEDEL +# // https://github.com/ptt/pttbbs/blob/master/include/common.h#L68 +# // pttbbs commit: 6bdd36898bde207683a441cdffe2981e95de5b20 +USE_EDIT_HISTORY = true +FN_SAFEDEL = .d + +STR_SAFEDEL_TITLE = (本文已被刪除) + +SAFE_ARTICLE_DELETE_NUSER = 0 + +# ////////// +# // proto.h +# ////////// +USE_COMMENTD = false +USE_EMAILDB = false +USE_REGCHECKD = false +USE_VERIFYDB = false + +IS_NEW_SHM = true # // whether to create new shm (use only with ShmInit) diff --git a/02-config.run.template.ini b/docs/config/02-config.run.template.ini similarity index 100% rename from 02-config.run.template.ini rename to docs/config/02-config.run.template.ini diff --git a/memory.plist b/docs/mac/memory.plist similarity index 100% rename from memory.plist rename to docs/mac/memory.plist diff --git a/go.mod b/go.mod index ba9b3c6c..c2a77a13 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/Ptt-official-app/go-pttbbs -go 1.19 +go 1.22 require ( github.com/gin-gonic/gin v1.10.0 diff --git a/go.sum b/go.sum index 4910f1b4..c229dcd5 100644 --- a/go.sum +++ b/go.sum @@ -11,6 +11,7 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= +github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0= @@ -20,6 +21,7 @@ github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU= github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= +github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= @@ -36,6 +38,7 @@ github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiu github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -50,7 +53,9 @@ github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuV github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= @@ -70,6 +75,7 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ= github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4= github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE= @@ -138,6 +144,7 @@ google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFW google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/ptt/testcases_test.go b/ptt/testcases_test.go index a5da5dbb..73c8afab 100644 --- a/ptt/testcases_test.go +++ b/ptt/testcases_test.go @@ -10,31 +10,40 @@ import ( var ( testUserecRaw1 = &ptttype.UserecRaw{ - Version: 4194, - UserID: ptttype.UserID_t{83, 89, 83, 79, 80}, - RealName: ptttype.RealName_t{67, 111, 100, 105, 110, 103, 77, 97, 110}, - Nickname: ptttype.Nickname_t{175, 171}, - PasswdHash: ptttype.Passwd_t{98, 104, 119, 118, 79, 74, 116, 102, 84, 49, 84, 65, 73, 0}, + Version: ptttype.PASSWD_VERSION, + UserID: ptttype.UserID_t{0x53, 0x59, 0x53, 0x4f, 0x50}, // SYSOP + RealName: ptttype.RealName_t{ // CodingMan + 0x43, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x4d, 0x61, 0x6e, + }, + Nickname: ptttype.Nickname_t{0xaf, 0xab}, // 神 + PasswdHash: ptttype.Passwd_t{0x62, 0x68, 0x77, 0x76, 0x4f, 0x4a, 0x74, 0x66, 0x54, 0x31, 0x54, 0x41, 0x49, 0x00}, - UFlag: 33557088, - UserLevel: 65535, + UFlag: ptttype.UF_CURSOR_ASCII | ptttype.UF_DBCS_DROP_REPEAT | ptttype.UF_DBCS_AWARE | ptttype.UF_ADBANNER | ptttype.UF_BRDSORT, + UserLevel: ptttype.PERM_DEFAULT | ptttype.PERM_POST | ptttype.PERM_LOGINOK | ptttype.PERM_MAILLIMIT | ptttype.PERM_CLOAK | ptttype.PERM_SEECLOAK | ptttype.PERM_XEMPT | ptttype.PERM_SYSOPHIDE | ptttype.PERM_BM | ptttype.PERM_ACCOUNTS | ptttype.PERM_CHATROOM | ptttype.PERM_BOARD | ptttype.PERM_SYSOP | ptttype.PERM_BBSADM, NumLoginDays: 2, NumPosts: 0, FirstLogin: 1600681288, LastLogin: 1600756094, - LastHost: ptttype.IPv4_t{53, 57, 46, 49, 50, 52, 46, 49, 54, 55, 46, 50, 50, 54}, - Address: ptttype.Address_t{183, 115, 166, 203, 191, 164, 164, 108, 181, 234, 182, 109, 175, 81, 166, 179, 167, 248, 53, 52, 51, 184, 185}, - Over18: true, - Pager: ptttype.PAGER_ON, - Career: ptttype.Career_t{165, 254, 180, 186, 179, 110, 197, 233}, - LastSeen: 1600681288, + LastHost: ptttype.IPv4_t{ // 59.124.167.226 + 0x35, 0x39, 0x2e, 0x31, 0x32, 0x34, 0x2e, 0x31, 0x36, 0x37, + 0x2e, 0x32, 0x32, 0x36, + }, + Address: ptttype.Address_t{ // 新竹縣子虛鄉烏有村543號 + 0xb7, 0x73, 0xa6, 0xcb, 0xbf, 0xa4, 0xa4, 0x6c, 0xb5, 0xea, + 0xb6, 0x6d, 0xaf, 0x51, 0xa6, 0xb3, 0xa7, 0xf8, 0x35, 0x34, + 0x33, 0xb8, 0xb9, + }, + Over18: true, + Pager: ptttype.PAGER_ON, + Career: ptttype.Career_t{0xa5, 0xfe, 0xb4, 0xba, 0xb3, 0x6e, 0xc5, 0xe9}, // 全景軟體 + LastSeen: 1600681288, } testUserecRaw2 = &ptttype.UserecRaw{ Version: ptttype.PASSWD_VERSION, UserID: ptttype.UserID_t{'C', 'o', 'd', 'i', 'n', 'g', 'M', 'a', 'n'}, - UFlag: 33557216, - UserLevel: 7, + UFlag: ptttype.UF_CURSOR_ASCII | ptttype.UF_DBCS_DROP_REPEAT | ptttype.UF_DBCS_AWARE | ptttype.UF_ADBANNER_USONG | ptttype.UF_ADBANNER | ptttype.UF_BRDSORT, + UserLevel: ptttype.PERM_DEFAULT, NumLoginDays: 1, NumPosts: 0, FirstLogin: 1600737659, @@ -45,8 +54,8 @@ var ( testUserecRaw3 = &ptttype.UserecRaw{ Version: ptttype.PASSWD_VERSION, UserID: ptttype.UserID_t{'t', 'e', 's', 't'}, - UFlag: 33557216, - UserLevel: 7 | ptttype.PERM_BOARD | ptttype.PERM_POST | ptttype.PERM_LOGINOK, + UFlag: ptttype.UF_CURSOR_ASCII | ptttype.UF_DBCS_DROP_REPEAT | ptttype.UF_DBCS_AWARE | ptttype.UF_ADBANNER_USONG | ptttype.UF_ADBANNER | ptttype.UF_BRDSORT, + UserLevel: ptttype.PERM_DEFAULT | ptttype.PERM_BOARD | ptttype.PERM_POST | ptttype.PERM_LOGINOK, NumLoginDays: 1, NumPosts: 0, FirstLogin: 1600737659, @@ -59,8 +68,8 @@ var ( UserID: ptttype.UserID_t{'S', 'Y', 'S', 'O', 'P', '3'}, Nickname: ptttype.Nickname_t{'s', 't', 'r', 'i', 'n', 'g'}, PasswdHash: ptttype.Passwd_t{0x2c, 0x52, 0x69, 0x36, 0x53, 0x6b, 0x55, 0x33, 0x34, 0x72, 0x65, 0x74, 0x41}, - UFlag: 33557088, - UserLevel: 7, + UFlag: ptttype.UF_CURSOR_ASCII | ptttype.UF_DBCS_DROP_REPEAT | ptttype.UF_DBCS_AWARE | ptttype.UF_ADBANNER | ptttype.UF_BRDSORT, + UserLevel: ptttype.PERM_DEFAULT, NumLoginDays: 23, NumPosts: 0, FirstLogin: 1608226066, @@ -79,8 +88,8 @@ var ( Nickname: ptttype.Nickname_t{175, 171}, PasswdHash: ptttype.Passwd_t{98, 104, 119, 118, 79, 74, 116, 102, 84, 49, 84, 65, 73, 0}, - UFlag: 33557088, - UserLevel: 7 | ptttype.PERM_LOGINOK | ptttype.PERM_POST, + UFlag: ptttype.UF_CURSOR_ASCII | ptttype.UF_DBCS_DROP_REPEAT | ptttype.UF_DBCS_AWARE | ptttype.UF_ADBANNER | ptttype.UF_BRDSORT, + UserLevel: ptttype.PERM_DEFAULT | ptttype.PERM_LOGINOK | ptttype.PERM_POST, NumLoginDays: 2, NumPosts: 0, FirstLogin: 1600681288, @@ -94,14 +103,14 @@ var ( } testNewPostUser2 = &ptttype.UserecRaw{ - Version: 4194, + Version: ptttype.PASSWD_VERSION, UserID: ptttype.UserID_t{65, 50}, // A2 RealName: ptttype.RealName_t{67, 111, 100, 105, 110, 103, 77, 97, 110}, Nickname: ptttype.Nickname_t{175, 171}, PasswdHash: ptttype.Passwd_t{98, 104, 119, 118, 79, 74, 116, 102, 84, 49, 84, 65, 73, 0}, - UFlag: 33557088, - UserLevel: 7 | ptttype.PERM_LOGINOK | ptttype.PERM_POST, + UFlag: ptttype.UF_CURSOR_ASCII | ptttype.UF_DBCS_DROP_REPEAT | ptttype.UF_DBCS_AWARE | ptttype.UF_ADBANNER | ptttype.UF_BRDSORT, + UserLevel: ptttype.PERM_DEFAULT | ptttype.PERM_LOGINOK | ptttype.PERM_POST, NumLoginDays: 2, NumPosts: 0, FirstLogin: 1600681288, @@ -115,14 +124,14 @@ var ( } testSetupNewUser1 = &ptttype.UserecRaw{ - Version: 4194, + Version: ptttype.PASSWD_VERSION, UserID: ptttype.UserID_t{65, 48}, // A0 RealName: ptttype.RealName_t{67, 111, 100, 105, 110, 103, 77, 97, 110}, Nickname: ptttype.Nickname_t{175, 171}, PasswdHash: ptttype.Passwd_t{98, 104, 119, 118, 79, 74, 116, 102, 84, 49, 84, 65, 73, 0}, - UFlag: 33557088, - UserLevel: 536871943, + UFlag: ptttype.UF_CURSOR_ASCII | ptttype.UF_DBCS_DROP_REPEAT | ptttype.UF_DBCS_AWARE | ptttype.UF_ADBANNER | ptttype.UF_BRDSORT, + UserLevel: ptttype.PERM_DEFAULT | ptttype.PERM_SYSSUBOP | ptttype.PERM_BM, NumLoginDays: 2, NumPosts: 0, FirstLogin: 1600681288, @@ -136,14 +145,14 @@ var ( } testNewRegister1 = &ptttype.UserecRaw{ - Version: 4194, + Version: ptttype.PASSWD_VERSION, UserID: ptttype.UserID_t{66, 49}, // B1 RealName: ptttype.RealName_t{67, 111, 100, 105, 110, 103, 77, 97, 110}, Nickname: ptttype.Nickname_t{175, 171}, PasswdHash: ptttype.Passwd_t{98, 104, 119, 118, 79, 74, 116, 102, 84, 49, 84, 65, 73, 0}, - UFlag: 33557088, - UserLevel: 7, + UFlag: ptttype.UF_CURSOR_ASCII | ptttype.UF_DBCS_DROP_REPEAT | ptttype.UF_DBCS_AWARE | ptttype.UF_ADBANNER | ptttype.UF_BRDSORT, + UserLevel: ptttype.PERM_DEFAULT, NumLoginDays: 1, NumPosts: 0, FirstLogin: 1600681288, @@ -164,8 +173,8 @@ var ( Nickname: ptttype.Nickname_t{0x1e, 0x80, 0x30, 0x40, 0x80, 0x40}, PasswdHash: ptttype.Passwd_t{98, 104, 119, 118, 79, 74, 116, 102, 84, 49, 84, 65, 73, 0}, - UFlag: 33557088, - UserLevel: 7, + UFlag: ptttype.UF_CURSOR_ASCII | ptttype.UF_DBCS_DROP_REPEAT | ptttype.UF_DBCS_AWARE | ptttype.UF_ADBANNER | ptttype.UF_BRDSORT, + UserLevel: ptttype.PERM_DEFAULT, NumLoginDays: 1, NumPosts: 0, FirstLogin: 1600681288, @@ -187,7 +196,7 @@ var ( UserID: ptttype.UserID_t{66, 49}, Nickname: ptttype.Nickname_t{0x30, 0x40, 0x80, 0x40, 0x00, 0x40}, - UserLevel: 7, + UserLevel: ptttype.PERM_DEFAULT, FromIP: 0xc0a80001, // 192.168.0.1 From: ptttype.From_t{'1', '9', '2', '.', '1', '6', '8', '.', '0', '.', '1'}, Pager: ptttype.PAGER_ON, @@ -200,7 +209,7 @@ var ( Nickname: ptttype.Nickname_t{0x30, 0x40, 0x80, 0x40, 0x00, 0x40}, - UserLevel: 7, + UserLevel: ptttype.PERM_DEFAULT, FromIP: 0xc0a80001, // 192.168.0.1 From: ptttype.From_t{'1', '9', '2', '.', '1', '6', '8', '.', '0', '.', '1'}, Pager: ptttype.PAGER_ON, diff --git a/scripts/docker_build.sh b/scripts/docker_build.sh index 7c91bd35..a6c05332 100755 --- a/scripts/docker_build.sh +++ b/scripts/docker_build.sh @@ -1,6 +1,10 @@ #!/bin/bash -branch=`git branch|grep '^*'|sed 's/^\* //g'|sed -E 's/^\(HEAD detached at //g'|sed -E 's/\)$//g'` +# branch +branch=`git rev-parse --abbrev-ref HEAD` +if [ "${branch}" == "HEAD" ]; then branch=`git describe --tags`; fi + +# project project=`basename \`pwd\`` -docker build -t ${project}:${branch} . +docker build -t ${project}:${branch} -f docker/Dockerfile . diff --git a/scripts/docker_initbbs.sh b/scripts/docker_initbbs.sh index 2a0d577d..05b58657 100755 --- a/scripts/docker_initbbs.sh +++ b/scripts/docker_initbbs.sh @@ -17,6 +17,6 @@ docker run --rm --name ${project} -v ${BBSHOME}:/home/bbs ${GOPTTBBS_IMAGE} /opt docker run --rm --name ${project} -v ${BBSHOME}:/home/bbs ${GOPTTBBS_IMAGE} sh -c 'mkdir -p /home/bbs/bin && cp /opt/bbs/bin/* /home/bbs/bin' -docker run --name ${project} -v ${BBSHOME}:/home/bbs ${GOPTTBBS_IMAGE} sh -c 'mkdir -p /home/bbs/etc && cp /opt/bbs/etc/* /home/bbs/etc' +docker run --rm --name ${project} -v ${BBSHOME}:/home/bbs ${GOPTTBBS_IMAGE} sh -c 'mkdir -p /home/bbs/etc && cp /opt/bbs/etc/* /home/bbs/etc' -docker run --name ${project} -v ${BBSHOME}:/home/bbs ${GOPTTBBS_IMAGE} sh -c 'mkdir -p /home/bbs/wsproxy && cp -R /opt/bbs/wsproxy/* /home/bbs/wsproxy' +docker run --rm --name ${project} -v ${BBSHOME}:/home/bbs ${GOPTTBBS_IMAGE} sh -c 'mkdir -p /home/bbs/wsproxy && cp -R /opt/bbs/wsproxy/* /home/bbs/wsproxy' diff --git a/scripts/docker_run.sh b/scripts/docker_run.sh index a485fe71..a7a1d8b7 100755 --- a/scripts/docker_run.sh +++ b/scripts/docker_run.sh @@ -8,6 +8,7 @@ BBSHOME=${1:-${BBSHOME}} docker container stop ${project} docker container rm ${project} +echo "BBSHOME: ${BBSHOME}" if [ "${BBSHOME}" == "" ]; then docker run -itd --name ${project} -p 3456:3456 -p 8888:8888 -p 48763:48763 ${project}:${branch} else diff --git a/scripts/run-in-docker.sh b/scripts/run-in-docker.sh index eb9f9896..c4720bf1 100755 --- a/scripts/run-in-docker.sh +++ b/scripts/run-in-docker.sh @@ -7,11 +7,6 @@ fi port=$1 current_dir=`pwd` -homename=`echo "${current_dir}"|awk -F '\/' '{print $2}'` -if [ "${homename}" != "home" ]; then - echo "go-pttbbs in docker-dir should be with /home/[user]/go-pttbbs format" - exit 255 -fi ini_filename_prefix=`echo "${current_dir}"|awk -F '\/' '{print $3}'` ini_filename="${ini_filename_prefix}.ini" diff --git a/scripts/run.sh b/scripts/run.sh index ace4bafc..21e06c55 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -1,6 +1,6 @@ #!/bin/bash -ini_filename=02-config.run.ini +ini_filename=docs/config/02-config.run.ini package=github.com/Ptt-official-app/go-pttbbs/types commit=`git rev-parse --short HEAD` version=`git describe --tags` From f55c5e66ba6be7e264aa46eb5e1885ee3ea5e2a7 Mon Sep 17 00:00:00 2001 From: Chuan-Heng Hsiao Date: Wed, 16 Oct 2024 22:26:36 -0400 Subject: [PATCH 2/2] golangci ignore G115 --- .golangci.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.golangci.yaml b/.golangci.yaml index 560ccee2..793a2ba1 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -44,5 +44,6 @@ issues: - '`setBBottom` is unused' - '`pwcuSetByBit` is unused' - 'unused-parameter: parameter' + - G115 exclude-rules: exclude-use-default: true