2018年8月28日 星期二

安裝 shadowsock server

Synology DSM6.21

#介紹
https://zh.wikipedia.org/wiki/Shadowsocks

#git位置 shadowsock python
https://github.com/dgkang/shadowsocks-python


1.先安裝 python2 or python3皆可

2.安裝 python套件包 pip  (ubuntu:apt-get install python-pip)
wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py
https://bootstrap.pypa.io/

3.pip 安裝 shadowsocks
pip install shadowsocks

4.
vi /etc/shadowsocks.json

{

    "local_address": "127.0.0.1",
    "local_port":1080,
    "port_password":{
    "6655":"nguguest",
    "8080":"nguguest"
    },
    "timeout":600,
    "method":"aes-256-cfb",
    "fast_open":false
}

其中
    "port_password":{
    "6655":"nguguest",
    "8080":"nguguest"
    },
是設定server port 對應的 password
這邊沒有設定serverIP 因為不需要

5.

*ssserver -c /etc/shadowsocks.json遇到error
RuntimeError: can not find library crypto 
自行修改/usr/lib/python2.7/ctypes/util.py
拿個發行版的來取代

*遇到Exception: libcrypto(OpenSSL) not found
參考https://ningselect.com/2018/05/01/synologyshadowsocks
修改 註解掉以下紅色四行
sudo vi /usr/lib/python2.7/site-packages/shadowsocks/crypto/util.py
 56     for name in lib_names:
 57         if os.name == "nt":
 58             paths.extend(find_library_nt(name))
 59 #        else:
 60 #            path = ctypes.util.find_library(name)
 61 #            if path:
 62 #                paths.append(path)

*
2020 update
最近重裝遇到另一個新error
TypeError: find_library() takes exactly 1 argument (3 given)
  File "/usr/lib/python2.7/site-packages/shadowsocks/crypto/openssl.py", line 41, in load_openssl
    raise Exception('libcrypto(OpenSSL) not found')
Exception: libcrypto(OpenSSL) not found

sudo -i 後進入root即可
ssserver -c /etc/shadowsocks.json -d start
(我直接sudo 不能,應該是lib path 的問題,沒有繼續trace)

6.連線試試 後臺啟動
ssserver -c /etc/shadowsocks.json -d start
ssserver -c /etc/shadowsocks.json -d stop
ssserver -c /etc/shadowsocks.json -d restart


2018年6月7日 星期四

svn 舊版安裝 (非 root)

ref.https://superuser.com/questions/929965/subversion-1-8-13-installation-without-root

http://www.cnblogs.com/xlmeng1988/p/3431321.html

cd $HOME
mkdir custom_installed
cd custom_installed
# Install apr
wget ftp://mirror.switch.ch/mirror/apache/dist//apr/apr-1.5.2.tar.gz
tar xvfz apr-1.5.2.tar.gz
cd apr-1.5.2
./configure —prefix=$HOME/custom_installed
make
make test
make install
cd ..

# Install apu
wget ftp://mirror.switch.ch/mirror/apache/dist//apr/apr-util-1.5.4.tar.gz
tar xvfz apr-util-1.5.4.tar.gz
cd apr-util-1.5.4
./configure --prefix=$HOME/custom_installed --with-apr=$HOME/custom_installed
make
make test
make install
cd ..


wget http://apache.claz.org/subversion/subversion-1.8.13.tar.gz
tar xvfz subversion-1.8.13.tar.gz
cd subversion-1.8.13
wget http://www.sqlite.org/sqlite-amalgamation-3071501.zip
unzip sqlite-amalgamation-3071501.zip
mv sqlite-amalgamation-3071501 sqlite-amalgamation
./configure --prefix=$HOME/custom_installed --with-apr=$HOME/custom_installed --with-apr-util=$HOME/custom_installed
make

make clean
./configure —prefix=$HOME/custom_installed --with-apr=$HOME/custom_installed/bin/apr-1-config --with-apr-util=$HOME/custom_installed/bin/apu-1-config



2018年2月13日 星期二

ftrace

https://www.ibm.com/developerworks/cn/linux/l-cn-ftrace1/
https://www.ibm.com/developerworks/cn/linux/l-cn-ftrace2/
https://www.ibm.com/developerworks/cn/linux/l-cn-ftrace3/index.html


http://blog.csdn.net/scarecrow_byr/article/details/17741809

https://zhuanlan.zhihu.com/p/22130013


#先關閉tracing
echo 0 > tracing_on
#清除trace
echo  1 > trace
#啟用function_graph
echo function_graph  > current_tracer
echo function1 funtion2 > set_graph_function
#開啟tracing
echo 1 > tracing_on
#不確定要不要開
echo 1 > /proc/sys/kernel/stack_tracer_enabled
echo 1 > /proc/sys/kernel/ftrace_enabled

執行function

#查看執行結果和所花費時間
cat trace

#關閉tracing
echo 0 > tracing_on

2018年1月10日 星期三

linux kernel printk

https://www.kernel.org/doc/Documentation/printk-formats.txt

16進位e自動顯示0x
pintk( " %#x " ,hex);

常用
int %d or %x
unsigned int %u or %x
long %ld or %lx
unsigned long %lu or %lx
long long %lld or %llx
unsigned long long %llu or %llx
size_t %zu or %zx
ssize_t %zd or %zx
s32 %d or %x
u32 %u or %x
s64 %lld or %llx
u64 %llu or %llx


MAC
%pM 00:01:02:03:04:05
%pMF 00-01-02-03-04-05

IPv4
%pI4 1.2.3.4
%pi4 001.002.003.004
%p[Ii]4[hnbl]
The additional ``h``, ``n``, ``b``, and ``l`` specifiers are used to specify
host, network, big or little endian order addresses respectively. Where
no specifier is provided the default network/big endian order is used.

IPv6
%pI6 0001:0002:0003:0004:0005:0006:0007:0008
%pi6 00010002000300040005000600070008
%pI6c 1:2:3:4:5:6:7:8