Irssi

出自 Arch Linux 中文维基

Irssi 是一個基於 ncurses、模塊化的 IRC (互聯網中繼聊天 Internet Relay Chat) 客户端。

得益於健壯的社區以及官方插件的支持,使得 Irssi 客户端能夠支持 SILCICB 協議。

安裝[編輯 | 編輯原始碼]

安裝 軟件包 irssi

在 AUR 的 irssi-script 下和 Irssi's Script Repository 有一些腳本。

使用[編輯 | 編輯原始碼]

更詳細的介紹請閱讀官方文檔

注意: 這部分假定您了解 IRC 的基本知識並過去用過其他客户端。

推薦使用終端復用器,例如 tmux 或者 GNU Screen 等。它能讓用户輕鬆地斷開和重新連接一個會話,並且能夠運行如 nicklist.pl 這類依賴次要窗口的腳本。要運行 irssi ,執行:

$ irssi

參見 irssi(1)

命令[編輯 | 編輯原始碼]

Irssi 的命令以反斜槓為開始,並且大小寫不敏感。您可以輸入 /help 來獲得內建的命令列表。這份列表也能在線查閱

命令 説明
/help 列出所有命令或者解釋給定的命令。
/network 管理您的 IRC 網絡。
/server 管理您的 IRC 伺服器。
/connect 連接一個伺服器或者網絡。
/disconnect 斷開目前的伺服器連接。
ALT+(1-0,q-p,etc) 切換活動窗口。Ctrl+n 循環到下一個窗口,Ctrl+p 循環到前一個。
/window 管理 irssi 窗口。
/layout 保存或者關閉窗口配置。
/statusbar 管理狀態欄。
/set 查看或者變更設置。
/alias 管理您的別名。

設置[編輯 | 編輯原始碼]

個人設置文件應當位於 ~/.irssi/config。在 /etc/irssi.conf 有一份模板。使用 --config 參數也能使用代替的配置文件啟動 irssi。

  • 您可以使用 /save 來把當前的配置保存到配置文件中。
  • 您可以使用 /layout save 來保存當前打開的窗口的位置。

使用SASL進行身份驗證[編輯 | 編輯原始碼]

本文或本章節的語言、語法或風格需要改進。參考:Help:Style

原因:Is -ssl_capath actually needed?(在Talk:Irssi討論)

Irssi 是支持 Simple Authentication and Security Layer (SASL)進行登錄的。

你可以進行如下設置,實現以SASL的身份認證機制添加IRC聊天伺服器(如LiberaChat)

/SERVER ADD -ssl -ssl_verify -ssl_capath /etc/ssl/certs -network liberachat -port 6697 irc.libera.chat
/NETWORK ADD -sasl_mechanism plain -sasl_username username -sasl_password password liberachat
注意:
  • IRC聊天伺服器的名字是區分大小寫的,請確保伺服器的名字輸入正確
  • 如上的第一條命令,是用於添加允許 #TLS Connection的聊天伺服器
  • 如果你之前已經添加了聊天伺服器,只需輸入第二條命令即可
  • 如果你的IRC賬户的密碼中含有 $, 你必須額外再加一個 $ 作為前綴,使得Irssi將$作為正常字符進行讀取。如將密碼設置為1234$$56

如果上述操作沒問題的話,Irssi在重啟之後,你就能看到在所加入的IRC聊天伺服器的頻道內輸出SASL認證成功的信息。

啟動時自動連接到 #archlinux[編輯 | 編輯原始碼]

啟動 irssi 並輸入以下命令:

/server add -auto -network liberachat irc.libera.chat

liberachat 可以用任何喜歡的詞代替,例如常用縮寫 fn

保證 SASL 設置正確。也可以配合 -autosendcmd 命令使用 NickServ 代替 SASL,但是這可能會與您設置的自動加入頻道的設置發生衝突。如果願意的話,可以使用 SSL 證書代替給 NickServ 發送密碼認證。

/channel add -auto #archlinux liberachat
/channel add -auto #archlinux-offtopic liberachat

TLS 連接[編輯 | 編輯原始碼]

LiberaChat 是使用 6697 端口進行 SSL/TLS 連接的。 若想通過TLS連接LiberaChat IRC網絡,可以進行以下設置:

/server add -auto -tls -tls_verify -network liberachat -port 6697 irc.libera.chat

保存更改:

/save

如果配置成功,那麼你將會看到「Z」模組的設置。你應該會看到以下輸出:"Mode change (+Zi) for user 你的用户名

Client certificates[編輯 | 編輯原始碼]

LiberaChat 和 OFTC 都支持使用SSL證書進行身份認證並為其提供了相應的明文密碼的替代方案。 欲知詳情,請看LiberaChat的『使用CertFP』的指導。

要創建有效期為730天的無密碼證書(當被要求輸入詳細信息,如狀態或甚至通用名稱(CN)時,您可以填寫任何您想要的內容):

$ openssl req -newkey rsa:4096 -days 730 -x509 -keyout irssi.key -out irssi.crt -nodes 
$ cat irssi.crt irssi.key > ~/.irssi/irssi.pem
$ chmod 600 ~/.irssi/irssi.pem
$ rm irssi.crt irssi.key

接下來,找出相應的指紋:

$ openssl x509 -sha512 -fingerprint -noout -in ~/.irssi/irssi.pem | sed -e 's/^.*=//;s/://g;y/ABCDEF/abcdef/'

這將把SHA512指紋寫入至標準輸出(stdout)。 如果需要SHA1指紋, 將參數 -sha512 改為 -sha1。sed命令可用於通過刪除不需要的文本和字符來正確格式化指紋。

賦值其指紋字符串,稍後將會使用它。

在irssi中,斷開與網絡的連接並為其添加客户端證書和密鑰。如果您的證書是在沒有密碼的情況下生成的,請省略-ssl_pass選項:

/disconnect liberachat
/server add -ssl_cert ~/.irssi/irssi.pem  -ssl_pass irssi.pem_password -network liberachat irc.libera.chat 6697

現在,您可以進行連接(不是重新連接哦!)以及註冊指紋了

/connect liberachat
/msg NickServ identify YOUR_PASSWORD
/msg NickServ cert add YOUR_FINGERPRINT

此時,您可以從配置文件中刪除密碼了(如果您將其保存在其中),並使用以下命令來保存配置

/save

啟用自動日誌記錄功能[編輯 | 編輯原始碼]

/SET autolog ON
/save

隱藏頻道內其他用户的狀態[編輯 | 編輯原始碼]

為了忽略所有頻道用户的加入、離開和退出顯示,請在Irssi中輸入以下內容:

/ignore * joins parts quits

查閱 smartfilter 來限制活躍用户的上線提醒

鼠標滾動[編輯 | 編輯原始碼]

為了能在Irssi下啟動鼠標滾動功能, 輸入以下命令:

 /run scriptassist
 /script install mouse.pl

欲將其在Irssi運行開始時啟用鼠標滾動功能,請輸入以下命令:

 /script autorun mouse.pl

如果以上命令不起作用, 你可以手動將mouse.pl腳本放入~/.irssi/scripts 或者 ~/.irssi/scripts/autorun,操作如下:

 /script load mouse.pl

技巧[編輯 | 編輯原始碼]

HTTP 代理[編輯 | 編輯原始碼]

要在Irssi下使用HTTP代理,需要以下命令:

/SET use_proxy ON
/SET proxy_address <Proxy host address>
/SET proxy_port <Proxy port>
/SET -clear proxy_string
/SET proxy_string_after conn %s %d
/EVAL SET proxy_string CONNECT %s:%d HTTP/1.0\n\n

然後irssi應該相應地修改其配置文件;如果不需要代理,只需將use_proxy設置為OFF。

如果代理需要密碼,請嘗試:

/SET proxy_password your_pass

否則:

/SET -clear proxy_password
注意: 如果設置了HTTP代理,那麼SSL認證將失效!

在Irssi中使用tmux來顯示頻道內的用户暱稱列表[編輯 | 編輯原始碼]

Irssi 插件 nicklist 提供了一個可顯示暱稱列表的小窗口,有兩種方法能夠實現哦:

  • 屏幕 , 它只是將列表添加到irssi的右側,但帶來的缺點是每次irssi打印一行時都會重新繪製整個窗口。
  • FIFO , 顧名思義,它將列表寫入FIFO,然後可以用例如cat~/.irssi/nicklistfifo連續讀取。利用FIFO來實現暱稱列表的表現效果會更好:
/NICKLIST FIFO

This fifo can be used in a tmux window split vertically with irssi in its left pane and the cat from above in a small one in its right. Since the pane is dependent on its creating tmux session's geometry, a subsequent session with a different one needs to recreate it (which also implies a switch in irssi windows to refill the fifo).

E.g., the following script first checks for a running irssi, presumed to have been run by a previous execution of itself. Unless found it creates a new tmux session, a window named after and running irssi and then the pane with cat. If however irssi was found it merely attaches to the session and recreates the cat pane.

#!/bin/sh

T3=$(pgrep -u "$USER" -x irssi)

irssi_nickpane() {
    tmux setw main-pane-width $(( $(tput cols) - 21));
    tmux splitw -v "cat ~/.irssi/nicklistfifo";
    tmux selectl main-vertical;
    tmux selectw -t irssi;
    tmux selectp -t 0;
}

irssi_repair() {
    tmux selectw -t irssi
    [ "$(tmux lsp | wc -l)" -gt 1 ] && tmux killp -a -t 0
    irssi_nickpane
}

if [ -z "$T3" ]; then
    tmux new-session -d -s main;
    tmux new-window -t main -n irssi irssi;
    irssi_nickpane ;
fi
    tmux attach-session -d -t main;
    irssi_repair ;
exit 0
提示:Instead of doing all this work, this plugin does all the work needed for a nice nicklist inside tmux.

Virtual hostname (vhost)[編輯 | 編輯原始碼]

A vhost can be used to change your hostname when connected to an IRC-server, commonly viewed when joining/parting or doing a whois. This is most commonly done on a server that has a static IP address. Without a vhost it would commonly look like so when doing a 'whois':

nick@123.456.78.90.isp.com

The result of a successful vhost could be like so if you have the domain example.com available:

nick@example.com

Keep in mind that not every IRC-server supports the use of vhost. This might be individually set between the servers and not the network, so if you are experiencing issues with one server try another on the same network.

Required preconfigurations[編輯 | 編輯原始碼]

Irssi supports using a vhost as long as the required configurations has been set. This includes especially that your host supports Recursive DNS Lookup (rDNS) using Pointer record (PTR). Additionally you should add an appropriate line to your /etc/hosts file.

To see if this is working, test with the 'host' DNS lookup utility included in bind like so (where ip is a normal IPv4 address):

host ip

If this returns something in the lines of this then you know that your rDNS is working.

ip.in-addr.arpa domain name pointer example.com

Enabling the vhost[編輯 | 編輯原始碼]

There are a couple of ways to connect to a server with a given hostname. One is using the 'server' command with a -host argument like so:

/server -host example.com irc.libera.chat

Another way would be to set your hostname (vhost) with the 'set' command which will save your hostname to ~/.irssi/config:

/set hostname example.com
/save
/server irc.libera.chat

更多內容[編輯 | 編輯原始碼]