logind - ptt/pttbbs GitHub Wiki

高效能登入前導程式: logind

相關須知

若您有計劃架設像 ptt/ptt2 數千~十幾萬人這樣的大站,或是有提供 websocket 安全連線的需求,

才有需要用到此程式。

套件相依性

在 Debian/Ubuntu 等 Linux 發行版, 你需要確認已經安裝 libevent-dev 套件

編譯

先重新編譯一次程式 (以確保相關編譯後的檔案, 能被利用為 logind 編譯時, 所需的檔案)

- bbs - $ cd ~/pttbbs; pmake all install

為了讓 daemon/logind/ 裡面的程式碼可以被順利編譯, 請先不要執行 pmake clean 等動作

再去 source 資料夾中的 daemon/logind/ 編譯 logind 程式:

- bbs - $ cd ~/pttbbs/daemon/logind/; pmake all install clean

相關程式即編譯完成, 但還需要將所需的設定檔, 建立並編輯好才能使用

調整設定檔: bindports.conf

首先, 將 source 資料夾裡附的範例設定檔複製到 $(BBSHOME)/etc 底下:

- bbs - $ cp ~/pttbbs/sample/etc/bindports_adv.conf ~/etc/bindports.conf

接著, 用您習慣的編輯器編輯你要用的設定檔

- bbs - $ vim ~/etc/bindports.conf
# Bind Port List
# ----------------------------------------------
# syntax: <program> <port/service> <option>
#  program: arbitary name
#  port:    numeric port number or special name.
#  option:  parameter to this connection.
# ----------------------------------------------

# mode selection for 'bbsctl start'
# ----------------------------------------------
# * current available modes: mbbsd, logind
! #bbsctl mode mbbsd

沒有使用 bbsctl 的必要的話, 可以將上面那行前面加上 # 來註解

#bbsctl mode logind

# standalone mbbsd ports
# ----------------------------------------------
# * list all ports you want mbbsd to listen here.
mbbsd 23
! #mbbsd 443
! #mbbsd 3000
! #mbbsd 3001
! #mbbsd 3002
! #mbbsd 3003
! #mbbsd 3004
! #mbbsd 3005
! #mbbsd 3006
! #mbbsd 3007
! #mbbsd 3008
! #mbbsd 3009
! #mbbsd 3010

若無需要上面那些 port 設定也直接註解掉, 但主要的 port ( mbbsd 23 ) 還是要保留.

# logind ports
# ----------------------------------------------
# * list all ports for logind to listen here.
! logind 23

logind 23 該行取消註解, 才能讓 logind 程式監聽 port 23

#logind 443
#logind 3000
#logind 3001
#logind 3002
#logind 3003
#logind 3004
#logind 3005
#logind 3006
#logind 3007
#logind 3008
#logind 3009
#logind 3010
# * bind logind to unix socket for conn forwarding.
#logind unix run/logind.connfwd.sock

# logind client setings
# ----------------------------------------------
# * if this is set, each restart logind will 
#   also invoke the client.
#
# * example (let mbbsd listen to all tunnel+ports)
! logind client bin/mbbsd -d -f etc/bindports.conf

將這行的註解取消掉

#
# * example (let one mbbsd listen to tunnel only)
#logind client bin/mbbsd -n run/logind.tunnel

# tunnel mappings
# ----------------------------------------------
# * to configure the path of tunnels
! mbbsd  tunnel run/logind.tunnel
! logind tunnel run/logind.tunnel

上面那兩行都取消註解

再用 root 權限執行 logind

-root- # /home/bbs/bin/logind

再測試看看, 應該就能登入了

另外注意 logind 顯示的進站歡迎畫面會較 mbbsd 所顯示的高一行:

左邊為 mbbsd 顯示的畫面, 右邊為 logind 顯示的畫面 左邊為 mbbsd 顯示的畫面, 右邊為 logind 顯示的畫面

⚠️ **GitHub.com Fallback** ⚠️