2017年10月4日 星期三

以 chvt 遠端切換本機 tty

切換到第 num 個 tty
$ chvt [num]
出現
Couldn't get a file descriptor referring to the console
改用
$ sudo chvt [num]

列出所有 tty
$ w

QEMU -usbdevice is deprecated

改成:

machine usb=on -device usb-tablet

以 socat 將 IPv6 特定 port 導向特定主機的 IPv4 指定 port


# socat TCP6-LISTEN:6666,fork TCP4:123.123.123.123:7777
 會將連到本機 IPv6 位址 6666 port 資料全部傳到 123.123.123.123 主機的 7777 port

2017年9月19日 星期二

用 iptables 在特定 port 做跳板(forwarding)

因為固定public IP 有限,
有時為了安全性,限制服務只開放給特定ip,
為了要給區網內其他電腦也可以直接使用這個服務,
透過區網內有固定 public IP 的主機,
連到該主機特定port 的資料會直接轉給提供服務的電腦,
從提供服務的電腦看就會是從固定 public IP 主機傳出的資料。


2017年5月12日 星期五

用 Tsung 對網站做壓力測試

需要對網站做大量連線測試,
找到這篇
How to Generate Millions of HTTP Requests
作者測試幾個工具最後找到最適用的是 Tsung
目前測試的設定檔一秒可以送出大約 2900 個 https request

2017年2月22日 星期三

type juggling of PHP function default argument


在 php 版本 7.1.2 (Archlinux)
當 default argument 是 string ,
在指定 value 成 array 時會出現和預期不同的結果。

write2DBarcode([], 'QRCODE,H', 1,2,3,4);
Illegal string offset 'position'

tcpdf.php ( http://tcpdf.org/ )

public function write2DBarcode($code, $type, $x='', $y='', $w='', $h='', $style='', $align='', $distort=false) {
        if (!isset($style['position'])) {
            $style['position'] = ''; // error line

        }
}

workaround:
write2DBarcode([], 'QRCODE,H', 1,2 ,3 ,4 , []);