v2ray的搭建

1.docker-compose.yml的配置

version: "3"
services:
  v2ray:
    image: v2ray/official
    container_name: v2ray
    restart: always
    command: v2ray -config=/etc/v2ray/config.json
    ports:
      - "45367:45367"
    volumes:
      - ./data:/etc/v2ray
      - ./v2ray.config.json:/etc/v2ray/config.json:ro

2.v2ray.config.json的配置

version: "3"
services:
  v2ray:
    image: v2ray/official
    container_name: v2ray
    restart: always
    command: v2ray -config=/etc/v2ray/config.json
    ports:
      - "45367:45367"
    volumes:
      - ./data:/etc/v2ray
      - ./v2ray.config.json:/etc/v2ray/config.json:ro
[root@woterm v2ray]# 
[root@woterm v2ray]# 
[root@woterm v2ray]# cat v2ray.config.json 
{
  "inbounds": [{
    "port": 12345,
    "protocol": "vmess",
    "settings": {
      "clients": [
        {
          "id": "bda8368e-b622-4cb6-9833-dc3f988134cb",
          "level": 1,
          "alterId": 233
        }
      ]
    }
  }],
  "outbounds": [{
    "protocol": "freedom",
    "settings": {}
  },{
    "protocol": "blackhole",
    "settings": {},
    "tag": "blocked"
  }],
  "routing": {
    "rules": [
      {
        "type": "field",
        "ip": ["geoip:private"],
        "outboundTag": "blocked"
      }
    ]
  }
}

3.客户端配置【默认是Sock5代理】


4.谷歌SwitchyOmega插件的配置

cmake编译兼容xp代码

命令行中如下:
cmake -DCMAKE_GENERATOR_TOOLSET=v120_xp ../woterm && cmake –build . –config Release
在CMakeFiles.txt中编译可执行文件是如下这样:
set(CMAKE_EXE_LINKER_FLAGS “${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS,5.01”) #Win32程序

set(CMAKE_EXE_LINKER_FLAGS “${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:CONSOLE,5.01”) #Console程序。

vs2013编译兼容xp版本代码

在vs2017中需要加上_USING_V110_SDK71_,强制指定SDK的版本。
perl Configure VC-WIN32 –prefix=H:\VC_INCLUDE\OpenSSL-Win32_MSVC141_xp -D_WIN32_WINNT=0x0501 -D_USING_V110_SDK71_
在VS2013中
perl Configure VC-WIN32 –prefix=H:\VC_INCLUDE\OpenSSL-Win32_MSVC141_xp -D_WIN32_WINNT=0x0501

 这不是它的工作方式。 回到VS2012,您使用了Project + Properties,General,Platform Toolset设置并选择了v110_xp 。 这进行了几次设置更改。 作为副作用 ,您还可以定义_USING_V110_SDK71_宏。 这是准确的,其中一个设置更改是您将使用SDK版本7.1标头和库而不是版本8. 7.1是最后一个仍与XP兼容的SDK版本。  
 这对任何事情都不重要,到目前为止,您获得的最重要的变化是链接器的系统,最低要求版本设置。 使用v110_xp可确保将此设置更改为XP版本号5.01。 没有它你的目标6.00,Vista版本号。 这是一个非常重要的设置,当您告诉它您设计的程序在最新的Windows版本上运行良好时,Windows会关注它并关闭几个appcompat垫片。  
 在VS2013中它仍然可以正常工作。 选择v120_xp工具集。
That's not the way it worked. Back in VS2012, you used the Project + Properties, General, Platform Toolset setting and selected v110_xp. Which made several setting changes. As a side-effect, you'd also get the _USING_V110_SDK71_ macro defined. Which is accurate, one of the setting changes is that you'll use the SDK version 7.1 headers and libraries instead of version 8. 7.1 is the last SDK version that's still compatible with XP. 
Which isn't actually important for anything, by far the most important change that you got was the linker's System, Minimum Required Version setting. Using v110_xp ensured that this setting was changed to 5.01, the XP version number. Without it you target 6.00, the Vista version number. It is a very important setting, Windows pays attention to it and turns off several appcompat shims when you tell it that you designed your program to run well on the latest Windows versions. 
It still works the same in VS2013. Select the v120_xp toolset.

查看容器的启动参数

1.pip install runlike
2.runlike -p 容器ID

root@ubuntu:~# runlike -p 498c3ad49c46
docker run \
        --name=nginx \
        --hostname=nginx \
        --env=PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
        --env='NGINX_VERSION=1.15.12-1~stretch' \
        --env='NJS_VERSION=1.15.12.0.3.1-1~stretch' \
        --volume=/data/php/dnmp/nginx/conf.d:/etc/nginx/conf.d:ro \
        --volume=/data/php/www:/www:rw \
        --volume=/data/php/dnmp/nginx/nginx.conf:/etc/nginx/nginx.conf:ro \
        --volume=/etc/nginx/conf.d \
        --volume=/etc/nginx/nginx.conf \
        --volume=/www \
        --network=dnmp_lnmp \
        -p 443:443 \
        --expose=80 \
        --label com.docker.compose.project="dnmp" \
        --label com.docker.compose.version="1.18.0" \
        --label com.docker.compose.oneoff="False" \
        --label com.docker.compose.service="nginx" \
        --label com.docker.compose.config-hash="4ad2cd21b7c3c4d0b69776274ea51f5de602a725aa
f3ec1c14c39511051aa904" \
        --label maintainer="NGINX Docker Maintainers <docker-maint@nginx.com>" \
        --label com.docker.compose.container-number="1" \
        --detach=true \
        nginx:latest \
        nginx -g 'daemon off;'

检测域名是否过期

转https://www.jianshu.com/p/5f3e0c858ab2

#!/bin/bash
#检测域名是否过期
#作者:xuexiaobai@shell.com
#日期:20200224
#版本:v0.1
 
#当前日期时间戳,用于和域名的到期时间做比较
currentTimestamp=`date +%s`
 
#检测whois命令是否存在,不存在则安装whois包
isInstallWhois()
{
    which whois >/dev/null 2>/dev/null
    if [ $? -ne 0 ]
    then
        yum install -y whois || apt-get install whois -y
    fi
}
 
notify()
{
    expiredate=`whois $1 |grep 'Registry Expiry Date' |awk '{print $4}' |cut -d 'T' -f 1`
    #上面的$1代表域名,遍历循环出来的。
    #如果e_d的值为空,则过滤关键词'Expiration Time'
    if [ -z "$expiredate" ]
    then
        expiredate=`whois $1|grep 'Expiration Time' |awk '{print $3}'`
 
    fi
    #将域名过期的日期转化为时间戳
    expiredatestamp=`date -d $expiredate +%s`
    #计算半个月一共有多少秒
    # 15d 1296000  30d 2592000 35d 3024000 40d 3456000
    n=2592000
    timeBeforce=$[$expiredatestamp - $n] #过期时间15d以前的时间戳
    timeAfter=$[$expiredatestamp + $n] #过期时间15d以后的时间戳
    if [ $currentTimestamp -ge $timeBeforce ] && [ $currentTimestamp -lt $expiredatestamp ]
    then
        curl -X POST \
            -H 'Content-type: application/json' \
            --data '{"text":":warning:Domain '$1' will to be expired less then 15d. And domain '$1' expire date is '$expiredate' @xuexiaobai"}' \
            https://hooks.slack.com/services/*****/xxxxxxx/qqqqqqqqqqqqqqqqqqqqqq  
    fi
    if [ $currentTimestamp -ge $expiredatestamp ] 
    then
        curl -X POST \
            -H 'Content-type: application/json' \
            --data '{
                "text":":interrobang:Domain '$1' has been expired. And domain '$1' expire date is '$expiredate' @xuexiaobai"}' \
            https://hooks.slack.com/services/*****/xxxxxxx/qqqqqqqqqqqqqqqqqqqqqq
    fi
}
 
#检测上次运行的whois查询进程是否存在
#若存在,需要杀死进程,以免影响本次脚本执行
if pgrep whois &>/dev/null
then
    killall -9 whois
fi
 
isInstallWhois
 
for d in baidu.com google.com
do
  notify $d
done

容器清理

1.列举所有容器列表(docker clean)
docker ps -aq
2.停止所有容器
docker stop $(docker ps -aq)
3.删除所有容器
docker rm $(docker ps -aq)
4.清理所有容器
docker system prune -a -f

因为docker版本落后的原故,可能会导致更新版本的docker构造出来的镜像不一定完全兼容旧版本的docker,从而引发挂载目录时内部权限的错误。
移除当前版本:
rpm -qa | grep docker|xargs yum remove -y
安装最新版本:
curl -fsSL https://get.docker.com/ | sh

Win10安装的流氓

在Window10安装过程中,千万不要联网。
在Window10安装过程中,千万不要联网。
在Window10安装过程中,千万不要联网。

因为一旦联网,它就会强迫你使用microsoft的帐号登录系统。虽然是可以在登录后,再注销帐号,但可能会导致个人目录与登录帐号不一致。
只有拒绝联网后,才会出现创建脱机登录帐号,也即本地帐号。等使用本地帐号登录系统后,才配置网络。

Android编译第三方库脚本模板

#!/bin/bash
path_current=`pwd`
path_script=$(cd "$(dirname "$0")"; pwd)
 
DEFAULT_PATH=$PATH
ANDROID_NDK_HOME=~/Android/Sdk/ndk/20.1.5948944
 
declare -A qt_architectures=( ["x86_64"]="x86_64" ["x86"]="x86" ["arm64"]="arm64-v8a" ["arm"]="armeabi-v7a" )
rm -rf android
if [ ! -d "${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin" ]; then
    echo "failed to find linux-x86_64 home. please install ndk-r20+ version in ubuntu-18.04 system"
    exit 1
fi
ANDROID_TOOLCHAIN="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin"
for arch in ${!qt_architectures[@]}
do    
    case $arch in
        arm)
            ANDROID_API=16
            ;;
        x86)
            ANDROID_API=16
            ;;
        arm64)
            ANDROID_API=21
            ;;
        x86_64)
            ANDROID_API=21
            ;;
    esac
    rm -rf ${path_script}/build
 
    ANDROID_DEFINITION="-DCMAKE_FIND_ROOT_PATH:PATH=${path_script}/../openssl/android/${arch};${path_script}/../zlib/android/${arch}"
    ANDROID_DEFINITION="${ANDROID_DEFINITION} -DWITH_EXAMPLES=OFF"
    ANDROID_DEFINITION="${ANDROID_DEFINITION} -DCMAKE_BUILD_TYPE:STRING=Release"
    ANDROID_DEFINITION="${ANDROID_DEFINITION} -DANDROID_ABI:STRING=${qt_architectures[$arch]}"
    ANDROID_DEFINITION="${ANDROID_DEFINITION} -DANDROID_NATIVE_API_LEVEL:STRING=${ANDROID_API}"
    ANDROID_DEFINITION="${ANDROID_DEFINITION} -DANDROID_NDK:PATH=${ANDROID_NDK_HOME}"
    ANDROID_DEFINITION="${ANDROID_DEFINITION} -DCMAKE_CXX_COMPILER:STRING=${ANDROID_TOOLCHAIN}/clang++"
    ANDROID_DEFINITION="${ANDROID_DEFINITION} -DCMAKE_C_COMPILER:STRING=${ANDROID_TOOLCHAIN}/clang"
    ANDROID_DEFINITION="${ANDROID_DEFINITION} -DCMAKE_TOOLCHAIN_FILE:PATH=${ANDROID_NDK_HOME}/build/cmake/android.toolchain.cmake"
    mkdir -p ${path_script}/build && cd ${path_script}/build && cmake -DCMAKE_C_FLAGS="-fPIC -Wall" -DCMAKE_INSTALL_PREFIX=${path_script}/android/${arch} ${ANDROID_DEFINITION} ../libssh-0.9.3
    make clean && make && make install
done

Android添加第三方库

if(ANDROID)
    # the follow VARIABLE must be written before find_package or it will be no effective.
    # must add CACHE INTERNAL parameter. or it will failed.
    message("add the third so library to project")
    #set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android" CACHE INTERNAL "")
    set(ANDROID_EXTRA_LIBS "${LIBSSH_SOURCE_PATH}/lib/libssh.so" CACHE INTERNAL "")
    message("ANDROID_EXTRA_LIBS=${ANDROID_EXTRA_LIBS}")
endif()

The CACHE is mandatory, otherwise QtCreator won’t see the variable and it won’t use it