2017年4月18日星期二

shadowsocksR ssr openwrt 编译

最新参考https://github.com/ywb94/openwrt-ssr

以下是老版编译

git clone -b shadowsocksR https://github.com/etnperlong/openwrt-shadowsocks.git package/shadowsocks-libev

更改版本号
git clone https://github.com/shadowsocksr/shadowsocksr.git
git log 获取commit id
修改commit id为最新版
bfdb71349be780a3cb365f581ef59ff0cef29b65

添加支持库

更新feeds
./scripts/feeds update -a
安装feeds(不是必须)
./scripts/feeds install -a

make menuconfig
make -j4 package/shadowsocks-libev/compile V=99

编译后清理文件
make clean

测试运行
/usr/bin/ssr-redir -c /var/etc/shadowsocksr.json -u -f /var/run/ss-redir.pid

SSR重启命令
/etc/init.d/shadowsocksr restart

openwrtx86x64配置

openwrt虚拟机分区扩展
http://blog.csdn.net/llq6llq/article/details/48655483#t1

固件下载

下载openwrt官网最新的x64固件openwrt-15.05.1-x86-64-combined-ext4.img.gz,要选择combined-ext4版本的。

固件转换

由于VMware需要的vmdk的磁盘镜像文件,而我们下载的openwrt固件却是img格式,我们需要通过qemu-img工具将其转换。

打开VMware下的ubuntu虚拟机,将下载好的openwrt-15.05-x86.img.gz中的img文件解压拷贝到ubuntu虚拟机内。

安装qemu-img:

sudo -s

apt-get install qemu-utils
将img文件转换为vmdk文件:

qemu-img convert -f raw openwrt-15.05.1-x86.img -O vmdk openwrt.vmdk
扩展磁盘

经过转换过的openwrt.vmdk的磁盘空间默认才只有60MB,明显不够用,需要先挂载到ubuntu的虚拟机里进行扩展。

在ubuntu里加载新磁盘的时候,要选择IDE类型和独立永久模式。
这里写图片描述

在新磁盘的实用工具中选择扩展,将空间改为1GB
这里写图片描述

我们这里虽然将虚拟磁盘的总空间修改了,但里面实际的分区大小是没有变化的,我们需要在ubuntu虚拟机下做后续修改。

在ubuntu终端下获取root权限

sudo -s
确定你新挂上去的磁盘文件对应的设备名是什么,我的是/dev/sda

修改磁盘分区

fdisk /dev/sda

p
查询到对应的磁盘分区表信息,里面的sda2中start信息需要记住!!!9216!!!
这里写图片描述

在fdisk中将原有第二个分区删掉

d [enter]

2 [enter]

n [enter]

p [enter]

2 [enter]

9216 [enter]

[enter]

w [enter]
这里写图片描述

使用resize2fs修改分区

resize2fs /dev/sda2
这里写图片描述

将ubuntu虚拟机关机,把openwrt.vmdk从ubuntu虚拟机中移除。

创建虚拟机

用刚才处理好的openwrt.vmdk创建虚拟机,注意硬盘需选择IDE类型。

开机后,就跟正常的openwrt玩法一样了。


界面安装
http://blog.sina.com.cn/s/blog_59b89af00101c501.html

配置网卡:
vi /etc/config/network

双网卡配置,lan口:hostonly wan口:桥接
本机手动配置成lan口的ip地址才能连接。

libpcre解决can't load library 'libpcre.so.0'错误

libpcre编译时出现错误:
打开目录/pcre/ipkg-install/usr/lib/ 找到libpcre.so.1,复制此文件改名为libpcre.so.0即可编译成功,或者创建文件链接也可以。

运行软件时提示缺少'libpcre.so.0':
openwrt系统运行创建链接命令:
ln -s /usr/lib/libpcre.so.1 /usr/lib/libpcre.so.0

debian/ubuntu/openwrt/lede编译环境

openwrt/lede编译环境

在 Debian 7(Wheezy) 编译 libev 版本需要开启 debian-backports 来安装 dh-systemd 和 init-system-helpers.
首先要在 debian 的源列表中添加 backports 源
/etc/apt/sources.list
然后在末尾出添加
deb http://ftp.debian.org/debian wheezy-backports main

在 Debian 7(Wheezy)添加nodejs源
curl -sL https://deb.nodesource.com/setup | bash -

32位(x86)请执行下列命令:
apt-get install build-essential asciidoc binutils bzip2 gawk gettext git libncurses5-dev patch unzip zlib1g-dev ccache g++ bison flex autoconf make gcc subversion libtool sphinx-common mercurial sharutils ncurses-term git-core texinfo curl debhelper dh-systemd init-system-helpers pkg-config xmlto libpcre3-dev libc-ares2 libglib2.0-dev libgsasl7 libntlm0 libssl-dev libssl-doc libv8-dev msmtp nodejs p7zip p7zip-full pkg-config gcc-multilib wget nano -y

64位(x86_64)请执行下列命令:
apt-get install build-essential asciidoc binutils bzip2 gawk gettext git libncurses5-dev patch unzip zlib1g-dev ccache g++ bison flex autoconf make gcc subversion libtool sphinx-common mercurial sharutils ncurses-term git-core texinfo curl debhelper dh-systemd init-system-helpers pkg-config xmlto libpcre3-dev libc-ares2 libglib2.0-dev libgsasl7 libntlm0 libssl-dev libssl-doc libv8-dev msmtp nodejs p7zip p7zip-full pkg-config gcc-multilib wget nano lib32gcc1 libc6-dev-i386 -y

Adobe Flash Player最新版下载 屏蔽上传

Adobe Flash Player下载地址:
https://helpx.adobe.com/flash-player/kb/archived-flash-player-versions.html
https://www.adobe.com/cn/products/flashplayer/distribution3.html
Adobe Flash Player 正式版 官方地址:

Internet Explorer (和其他支持 Internet Explorer ActiveX 控件和插件的浏览器)
https://fpdownload.macromedia.com/pub/flashplayer/latest/help/install_flash_player_ax.exe

Firefox、Mozilla、Netscape、Opera(和其他基于插件的浏览器)
https://fpdownload.macromedia.com/pub/flashplayer/latest/help/install_flash_player.exe

Chrome(基于 Pepper 的 Flash Player)

https://fpdownload.macromedia.com/pub/flashplayer/latest/help/install_flash_player_ppapi.exe

Adobe Flash Player 官方本地播放器

https://download.macromedia.com/get/flashplayer/updaters/16/flashplayer_16_sa.exe

Adobe Flash Player 官方通用卸载工具

https://download.macromedia.com/get/flashplayer/current/support/uninstall_flash_player.exe

Adobe Flash Player 版本查看
http://www.adobe.com/swf/software/flash/about/flashAbout_info_small.swf

屏蔽flash上传
win批处理:
 echo RTMFPP2PDisable=1 >> %windir%\system32\Macromed\Flash\mms.cfg
 echo AutoUpdateDisable=0 >> %windir%\system32\Macromed\Flash\mms.cfg
 echo SilentAutoUpdateEnable=1 >> %windir%\system32\Macromed\Flash\mms.cfg
 echo RTMFPP2PDisable=1 >> %windir%\syswow64\Macromed\Flash\mms.cfg
 echo AutoUpdateDisable=0 >> %windir%\syswow64\Macromed\Flash\mms.cfg
 echo SilentAutoUpdateEnable=1 >> %windir%\syswow64\Macromed\Flash\mms.cfg



chrome如何屏蔽
chrome中打开chrome://version/ 找到配置文件路径
打开文件在*UserData\Default\Pepper Data\Shockwave Flash\
建立System目录,放入内容为RTMFPP2PDisable=1的mms.cfg和RTMFPP2PDisable=1的mms.tmp,这俩配置文件均用记事本新建内容即可。
ctrl+shift+delete清除ie及浏览器缓存,关闭浏览器或电脑重启即可。

在线管理面板禁止P2P
http://www.macromedia.com/support/documentation/cn/flashplayer/help/settings_manager09.html

2017年4月17日星期一

dnsmasq配置dns解析

建议使用dnsmasq
dnsmasq配置
# 不加载本地的 /etc/hosts 文件
#no-hosts
# 指定 resolv-file 文件路径,默认/etc/resolv.conf
#resolv-file=/etc/resolv.conf
# 不读取 resolv-file 来确定上游服务器
#no-resolv
# 不缓存未知域名缓存,默认情况下dnsmasq缓存未知域名并直接返回为客户端。
no-negcache
# 重启后清空缓存
clear-on-reload
# 默认为150,即最多分配150个ip地址出去,最大1000个ip
#dhcp-lease-max=150
# 指定IP地址,可以多次指定,路由器不可开启!!!!!!!!!!!!!!!!!!!。
listen-address=127.0.0.1
#缓存大小
cache-size=80000
# 本地 hosts 文件的缓存时间,通常不要求缓存本地,这样更改hosts文件后就即时生效。
local-ttl=36000
#dns服务器
server=8.8.8.8
server=8.8.4.4
# Include all files in a directory which end in .conf
conf-dir=/etc/dnsmasq.d
# 添加读取额外的 hosts 文件路径,可以多次指定。如果指定为目录,则读取目录中的所有文件。
addn-hosts=/etc/dnsmasq.hosts.d




5、智能DNS加快解析速度。打开/etc/dnsmasq.conf文件,server=后面可以添加指定的DNS,例如国内外不同的网站使用不同的DNS。

#国内指定DNS
server=/cn/114.114.114.114
server=/taobao.com/114.114.114.114
server=/taobaocdn.com/114.114.114.114
#国外指定DNS
server=/google.com/223.5.5.5
6、server=/cn/表示所有的cn域名都使用114这个公共DNS,server=/taobao.com/表示所有的taobao.com域名都用114,223.5.5.5 是阿里云的公共DNS,你可以换成其它的。
7、屏蔽网页广告。将指广告的URL指定127这个IP,就可以将网页上讨厌的广告给去掉了。

address=/ad.youku.com/127.0.0.1
address=/ad.iqiyi.com/127.0.0.1
8、指定域名解析到特定的IP上。这个功能可以让你控制一些网站的访问,非法的DNS就经常把一些正规的网站解析到不正确IP上。

address=/freehao123.com/123.123.123.123
9、内网DNS。首先将局域网中的所有的设备的本地DNS设置为已经安装Dnsmasq的服务器IP地址。然后修改已经安装Dnsmasq的服务器Hosts文件:/etc/hosts,指定域名到特定的IP中。
10、例如想让局域网中的所有用户访问www.freehao123.com时跳转到192.168.0.2,添加:192.168.0.2 www.freehao123.com在Hosts文件中既可,整个过程也可以说是“DNS劫持”。

------------------------------------------------


2. 安装 dnsmasq

  1. 用 Homebrew 安装 dnsmasq
$ brew install dnsmasq
  1. 配置 dnsmasq
$ cp /usr/local/opt/dnsmasq/dnsmasq.conf.example /usr/local/etc/dnsmasq.conf
我的 dnsmasq 配置如下

listen-address=127.0.0.1
no-hosts
no-dhcp-interface=
cache-size=32768
server=127.0.0.1#1053
# Include all files in a directory which end in .conf
conf-dir=/usr/local/etc/dnsmasq.d


mkdir /usr/local/etc/dnsmasq.d
//创建配置目录
 
 wget -4 --no-check-certificate -O /usr/local/etc/dnsmasq.d/accelerated-domains.china.conf https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/accelerated-domains.china.conf
//为国内常用网站取消DNS加密


基于域名的泛解析配置放置在 /usr/local/etc/dnsmasq.d 中
  1. 设置 dnsmasq 自启动
复制启动配置到 /Library/LaunchDaemons
$ sudo cp -fv /usr/local/opt/dnsmasq/*.plist /Library/LaunchDaemons
设置文件权限
$ sudo chown root /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
$ sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
启动 pdnsd 服务
$ sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist

3. 配置系统 DNS

把Mac系统的DNS改为127.0.0.1。

#. dnsmasq 泛解析

DNSMASQ的泛解析规则如下
address=/baidu.com/1.1.1.1
这意味着,*.baidu.com/* 都将被引导至IP为1.1.1.1的 DNS 解析。

#. 用于国内的加速列表配置

在 GitHub 上找到了用于国内域名和 CDN 的加速配置,地址如下 dnsmasq-china-list

文本编辑软件atom

官网
https://atom.io/
常用插件
中文包
atom-simplified-chinese-menu
高亮所有和当前选中单词一样的单词,IDE标配。
highlight-selected
粘贴图片直接转成 md 文本
markdown-assistant
md 编辑器
markdown-writer
js补全插件
atom-ternjs
正则表达式图形化插件
regex-railroad-diagram

blogger添加代码框

找到主题背景-高级-添加CSS,添加以下代码然后应用保存:
CODE {
display: block; /* fixes a strange ie margin bug */
font-family: Courier New;
font-size: 8pt;
overflow:auto;
background: #f0f0f0 url(https://sites.google.com/site/klcintwimages/Code_BG.gif) left top repeat-y;
border: 1px solid #ccc;
padding: 10px 10px 10px 21px;
max-height:200px;
line-height: 1.2em;
}

在要插入的代码前面添加:
<code><pre>

在代码后面添加:
</pre></code>

shadowsocksr ssr 服务端配置 supervisor配置

yum install python-setuptools && easy_install pip
yum install git
ubuntu/debian:
apt-get install python-pip
apt-get install git
获取源代码
执行完毕后此目录会新建一个shadowsocks目录,其中根目录的是多用户版(即数据库版),子目录中的是单用户版。
根目录即 ./shadowsocks
子目录即 ./shadowsocks/shadowsocks
服务端配置
进入根目录初始化配置(假设根目录在~/shadowsocks,如果不是,命令需要适当调整):
cd ~/shadowsocks
bash initcfg.sh
shadowsocks目录内,对userapiconfig.py里以下内容进行相应修改:
API_INTERFACE = 'mudbjson' //修改接口类型
接着,通过使用脚本mujson_mgr.py添加端口及相应的加密、协议、混淆等配置,具体方法通过执行以下命令查看该脚本的说明及提示:
python mujson_mgr.py
使用配置文件运行
如果你的ss目录是~/shadowsocks,进入这里
修改user-config.json中的server_port,password等字段,具体可参见:
https://github.com/breakwa11/shadowsocks-rss/wiki/config.json
安装libsodium
如果要使用 salsa20 或 chacha20 或 chacha20-ietf 算法,请安装 libsodium
apt-get install build-essential
wget https://github.com/jedisct1/libsodium/releases/download/1.0.10/libsodium-1.0.10.tar.gz
tar xf libsodium-1.0.10.tar.gz && cd libsodium-1.0.10
./configure && make -j2 && make install
ldconfig
user-config.json 单用户配置示例:
{
    "server":"0.0.0.0",
    "server_ipv6": "[::]",
    "local_address":"127.0.0.1",
    "local_port":1080,
    "port_password":{
        "8080":{"protocol":"auth_sha1", "password":"mima", "obfs":"http_simple", "obfs_param":""},
        "443":{"password":"mima"}
    },
    "timeout":300,
    "method":"chacha20-ietf",
    "protocol": "auth_aes128_md5",
    "protocol_param": "",
    "obfs": "tls1.2_ticket_auth",
    "obfs_param": "",
    "redirect": "apeggplfc4e.com:443",
    "dns_ipv6": true,
    "fast_open": false,
    "workers": 5
}
更新源代码
如果代码有更新可用本命令更新代码
进入shadowsocks目录
cd shadowsocks
执行
git pull
成功后重启ss服务
---------------------
supervisor 配置后台运行
supervisord.conf配置示例
; supervisor config file

[unix_http_server]
file=/var/run//supervisor.sock   ; (the path to the socket file)
chmod=0700                       ; sockef file mode (default 0700)

[supervisord]
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
childlogdir=/var/log/supervisor            ; ('AUTO' child log dir, default $TEMP)

; the below section must remain in the config file for RPC
; (supervisorctl/web interface) to work, additional interfaces may be
; added by defining them in separate rpcinterface: sections
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl=unix:///var/run//supervisor.sock ; use a unix:// URL  for a unix socket
serverurl=http://0.0.0.0:9001 ; use an http:// url to specify an inet socket
username=jun
password=junsheng

; The [include] section can just contain the "files" setting.  This
; setting can list multiple files (separated by whitespace or
; newlines).  It can also contain wildcards.  The filenames are
; interpreted as relative to this file.  Included files *cannot*
; include files themselves.

[include]
files = /etc/supervisor/conf.d/*.conf
# 如需要访问web控制界面,inet_http_server 区段修改为:
[inet_http_server]
port=0.0.0.0:9001
username=用户名
password=密码
shadowsocksr.conf配置示例
[program:shadowsocksr]
command=/usr/bin/python /shadowsocks/shadowsocks/server.py -c /shadowsocks/shadowsocks/user-config.json
autorestart=true
autostart=true
stderr_logfile=/var/log/ssrserver.err.log
stderr_logfile_maxbytes=1MB
stdout_logfile=/var/log/ssrserver.out.log
stdout_logfile_maxbytes=1MB
user=root