Total Pageviews

Monday, 7 March 2016

利用lightsword(轻剑)+level.4给未越狱ios科学上网方案,替代surge

又要提到surge了,不论作者是真的被喝茶了还是只是一种营销手段,毕竟surge已经是bye bye了,暂且不论。
之前苹果助手(pgzs.com) 里还可以下载到,前几天也是下架了,现在只能是某宝买共享账户用,土豪请无视。
这是第一个替代方案,相信以后会更多。
首先,部署服务器,第一步我们要给服务器安装Node.js并升级到5.0以上的版本,
首先登录linux vps,编译node:
# wget https://nodejs.org/dist/v0.12.7/node-v0.12.7.tar.gz
# tar zxvf  node-v0.12.7.tar.gz
# cd  node-v0.12.7
# ./configure
# make (这一步需要9分钟时间。在慢的VPS上,需要近30分钟)
# make install
这样,vps上的node环境就搭建好了。(不要编译node-v0.8.x版-https://nodejs.org/dist/v0.8.23/),
到这里你已经安装好了node.js,不过版本较低,运行node -v ,
root@ar2:~# node -v
v0.12.7

root@ar2:~#
我们需要下面两行命令来升级node.js:
npm install -g n
n stable (
自动安装最新的稳定版本)
这时你的node.js已经升级为最新的版本了。
n ls (查看所有的node版本
root@ar2:~# node -v
v5.8.0

root@ar2:~#
接下来部署lightsword,也只需两行命令:
npm install -g lightsword (此行为安装lightsword)
lsserver -f -m aes-256-cfb -p 3355 -k your_password --cluster (此行为运行lightsword)
(注:在openvz vps中,运行 lsserver -f -m aes-256-cfb -p 3355 -k your_password --cluster 这行命令后,过不多久,lsserver 程序还是会退出。所以最好是按此文http://briteming.blogspot.com/2016/01/supervisor.html,安装supervisor,然后在supervisord.conf里加上一段:
[program:lightsword]
command=lsserver -f -m aes-256-cfb -p 3355 -k your_password --cluster
autostart=true
autorestart=true
user=root


然后重启supervisor:
pkill supervisord
supervisord -c /etc/supervisor/supervisord.conf



然后编辑/etc/rc.local,在exit 0这行的上方加上:supervisord -c /etc/supervisor/supervisord.conf

在我的openvz vps上,lsserver程序运行一段时间,通常不到1小时就会退出。在我的kvm vps上,lsserver程序不会退出。从这点就可知kvm vps/xen vps好过openvz vps.严重不建议在openvz vps上搭建lightsword!
建议kvm vps/xen vps上搭建lightsword!


第一行是安装lightsword, 如果安装的时候仍然提示你的node.js版本过低,通过命令reboot重启下vps就好了.
第二行为运行该服务的命令,aes-256-cfb为加密方式,3355为端口,your_password为你的密码,更详细的可以去作者的github查看。运行完第二行,如果提示
Run as daemon
Child PID: 674
说明你已经成功启动了lightsword。接下来就可以在Appstore搜索level.4,安装iOS客户端了。别忘了切换到香港区或者美国区,大陆区搜不到的,因为软件作者很低调,也没很多人在用,所以多翻几页找找 。当然,这是收费软件,价格为1$,也当然,如果你是萌妹子可以@作者 卖个萌,兑换码什么的应该会给你一打。
安装好之后的界面是这样的:
输入你的vps的ip地址,端口,密码就可以登陆了,登陆之后,状态栏会显示VPN图标。
目前的level.4版本(0.2.3) 只支持全局代理,后续更新会内置智能规则。
(我在iphone用此法翻墙成功。不得不再次感叹中国人其实是很聪明的。碰上了共匪这个专制政府,聪明才智受到了压制而已
---------------------------
lightsword- Network Security Server based on Node.js
LightSword —— 基于 Node.js 的 SOCKS5 代理 / Apple NE 服务器。
LightSword 参考了 Shadowsocks 的协议,并用 Typescript 实现。LightSword 基于 Node.js 4.0+,因此需要首先安装 Node.js 4.0 以上版本,点击访问官方网址

Quick Start

首先安装Node.js 4.0+,安装好 Node.js 之后,即可使用 Node.js 的包管理器 npm 安装 LightSword 。目前 npmjs.org 可以访问,因此可以直接安装:
1.安装
[sudo] npm install lightsword -g
安装完成之后,即可使用客户端,服务器端,中转站端。
服务器端: lsserver, lightsword-server, lightsword
中转站端: lsbridge, lightsword-bridge
客户端: lslocal, lightsword-client
简单地说明下中转站的作用: 
由于某些不为人知的原因,访问境外IP时不时丢包非常严重,因此可以把中转站搭建在云提供商服务器上,作为中转/中继使用,具有较好的效果(在一定程度上提高了匿名性)。
2.运行
服务器:
lsserver -f
客户端:
lslocal -s server_addr -f
中转站:
lsbridge -s server_addr -f
以上配置均使用内置默认设置,详细参数请参见源码文件夹中的 README.md 文件(参见: server, client, bridge 这三个文件夹)。
经实际测试,中转服务器对 Shadowsocks 有效。理论上支持任何形式的 TCP 流量中转。
最后配置你的浏览器及其它需要上网的软件使用 LightSword 提供的 SOCKS5 代理。
默认监听地址: localhost
端口: 1080

Linux 支持

在 misc 文件夹下,已经写好了 Linux 启动脚本,你可以根据自己的实际情况,修改运行参数。并放到 init.d 目录下,再 chkconfig on 或者其它 Linux 分发版的命令激活自动运行即可。

快速安装lightsword的方法:
Ubuntu 用户
# Using Ubuntu
[sudo] apt-get update -y
[sudo] apt-get install curl -y
[sudo] curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
[sudo] apt-get install nodejs -y 
[sudo] npm install lightsword -g
Debian 用户
# Using Debian, as root
[sudo] apt-get update -y
[sudo] apt-get install curl -y
[sudo] curl -sL https://deb.nodesource.com/setup_5.x | bash -
[sudo] apt-get install nodejs -y 
[sudo] npm install lightsword -g
RHEL 6, CentOS 6 用户
# Using RHEL 6, CentOS 6
[sudo] yum update -y
[sudo] yum install curl -y
[sudo] curl -sL https://rpm.nodesource.com/setup_5.x | bash -
[sudo] yum install nodejs -y 
[sudo] npm install lightsword -g

Apple 用户

Apple 用户只需要运行服务器,即可打开iOS客户端填写配置并投入使用。如需测试 DNS 泄漏,请访问https://dnsleaktest.com
建议在运行的时候加入 --cluster 参数,以提升服务器性能和稳定性。
默认端口: 8900
默认密码: lightsword.neko
默认算法: AES-256-CFB
from https://github.com/UnsignedInt8/LightSword
-----------------------------
我的补充说明:

在linux桌面系统/mac安装lightsword,以便在linux桌面系统/mac,用lightsword翻墙

首先在你的linux桌面系统/mac的终端里安装最新版的nodejs,(在你的linux桌面系统,按上面的蓝色文字来编译nodejs并升级到最新版.在mac上,运行brew install nodejs,然后运行
npm install -g n
n stable
这样在mac上就安装了nodejs的最新版)
然后运行npm install -g lightsword 来安装lightsword.
然后在终端里运行:
lslocal -s your_vps_ip -p 3355 -l your_local_port -m aes-256-cfb -k your_password -f

(3355为在你的vps上所指定的lightsword的端口。your_local_port为你指定的某个本地端口。your_password为你的密码,需与服务器上设置的密码一致
然后设置浏览器的socks5代理为127.0.0.1,端口:your_local_port(你指定的某个本地端口),然后即可翻墙。

可把lslocal -s your_vps_ip -p 3355 -l your_local_port -m aes-256-cfb -k your_password -f保存为lslocal.sh,然后赋予lslocal.sh执行权限,以后想要翻墙时,运行./lslocal.sh ,然后设置浏览器的socks5代理为127.0.0.1,端口:your_local_port(你指定的某个本地端口),然后即可翻墙。

yudeMacBook-Air:~ brite$ lslocal -h

  Usage: lslocal [options]

  Options:

    -h, --help                  output usage information
    -V, --version               output the version number
    -s, --server <addr|domain>  Server Address
    -p, --port <number>         Server Port Number
    -l, --listenport <number>   Local Listening Port Number
    -m, --method <algorithm>    Cipher Algorithm
    -k, --password <password>   Password
    -c, --config <path>         Configuration File Path
    -a, --any                   Listen Any Connection
    -t, --timeout [number]      Timeout (second)
    -f, --fork                  Run as Daemon
    -b, --dontbypasslocal       DON'T Bypass Local Address
    -d, --daemon <command>      Daemon Control

yudeMacBook-Air:~ brite$ lslocal -s your_vps_ip -p lightsword_port_in_your_vps -l your_local_port -m aes-256-cfb -k your_password -f
Run as daemon
Child PID:  7259
yudeMacBook-Air:~ brite$
---------------------------------

Level.4(iOS) 5(OS X)

An app for protecting your iOS/OS X network traffic
LightSword is a server program written by Node.js. And to use Level.4/5, you should install LightSword on your server. It's very simple! 
1.Installing
# Using Ubuntu
[sudo] apt-get update -y
[sudo] apt-get install curl -y
[sudo] curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
[sudo] apt-get install nodejs -y
[sudo] npm install lightsword -g

# Using Debian, as root
[sudo] apt-get update -y
[sudo] apt-get install curl -y
[sudo] curl -sL https://deb.nodesource.com/setup_5.x | bash -
[sudo] apt-get install nodejs -y
[sudo] npm install lightsword -g

# Using RHEL 6, CentOS 6
[sudo] yum update -y
[sudo] yum install curl -y
[sudo] curl -sL https://rpm.nodesource.com/setup_5.x | bash -
[sudo] yum install nodejs -y
[sudo] npm install lightsword -g
2.Running 
lsserver -p 8081 -k mypassword -f --cluster
注:如果你的centos系统为centos7,因为centos7系统的防火墙对访问权限管得比较严,所以还需
开放相应的tcp端口,这里为开放tcp端口3355.命令如下:
iptables -I INPUT -p tcp -m tcp --dport 3355 -j ACCEPT
service iptables save service iptables restart
OK, your server is running. To get more information, type: 'lsserver -h' in your terminal.
Now, run Level.4/5 on your iOS/OS X device, tap 'Add Server Configuration', input your server label, address, port number, password, and save it. Switch on the connection toggle, Level.4/5 is going to protect your network traffic.
from https://github.com/UnsignedInt8/Level.4
------------------------------------------------------------------------------------------------
程序作者还制作了一个mac下的lightsword的客户端。

LightSwordX

LightSwordX is a SOCKS5 proxy client for OS X 10.10+.
It's an open-source project. To get it, you may download the source code and compile it on your Mac, or buy it from Mac App Store. 
LightSwordX has a built-in remote proxy server that is free for everyone. Of course, everyone can set up LightSword Server for self, and enjoy it by using LightSwordX or LightSword Command Line Interface.
HOW TO USE
  1. Run LightSword from Launchpad
  2. Open System Preferences - Network - Advanced - Proxies
  3. Select 'SOCKS Proxy', fill in server address and port number
  4. Click OK - Apply Settings
  5. Open Safari or Chrome, surf the Internet! 
You can buy it from Mac App Store:
Price: $0.99
Why it's not Free on Mac App Store?
LightSwordX is an open-source software, everyone can download the source code and compile it on Mac without any cost. But you may know maintenance is the most expensive part of software. No one can live without money! So, as a developer, I hope people would use and buy it. Thanks.

Features

✓ Enable mutli proxy servers simultaneously
✓ IPv6
✓ Whitelist & Blacklist
✓ Start self on system startup
✓ Traffic statistics
from https://github.com/UnsignedInt8/LightSwordX
------------------

Description

LightSword SOCKS5 Proxy Client for OS X.

With LightSword Server and LightSwordX, you can access some blocked websites in some countries, and go online more securely.

Features:

1. Multi proxy servers running simultaneously
2. IPv6 Support
3. Whitelist & Blacklist
4. Start self on system startup
5. Traffic statistics
6. One free proxy server for users

HOW TO USE:
0. Run LightSwordX, check remote proxy server enabled
1. Open System Preferences
2. Select Network
3. Click Advanced... -> Proxies
4. Select SOCKS5 Proxy
5. Fill in Proxy Server Address (eg. localhost, port: 1080, No Password Required)

Note:
LightSwordX is just a client application. Without LightSword Server, it can't work well. LightSword has a built-in remote proxy server for everyone, but the speed may slow.
LightSwordX doesn't provide cryptography level encryption for network traffic in current version.
from https://itunes.apple.com/us/app/lightswordx/id1071607364?ls=1&mt=12
--------------------

Level.5 is a network proxy client that designed for protecting your Internet traffic against network-attack (DNS hijacking, leak, sniffing, inspection, spoofing...). And, it may require you some professional knowledge to use.

Level.5 is based on OS X 10.11 Network Extension, so OS X 10.11 is required.

Features:
1. Self-defined network protocol
2. Self-implementation TCP/IPv4 stack
3. Customizable port number
4. Customizable DNS servers (GoogleDNS is the the default DNS Server)
5. Connecting to server automatically when iOS device wakes up

To use Level.5, you should install Node.js v4+ and LightSword on your server.

Installing LightSword:

# Using Ubuntu
> [sudo] apt-get update -y
> [sudo] apt-get install curl -y

> [sudo] curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
> [sudo] apt-get install -y nodejs
> [sudo] npm install lightsword -g

# Using Debian, as root
> [sudo] apt-get update -y
> [sudo] apt-get install curl -y

> [sudo] curl -sL https://deb.nodesource.com/setup_5.x | bash -
> [sudo] apt-get install -y nodejs
> [sudo] npm install lightsword -g

# Using RHEL 6, CentOS 6
> [sudo] yum update
> [sudo] yum install curl

> [sudo] curl -sL https://rpm.nodesource.com/setup_5.x | bash -
> [sudo] npm install lightsword -g

Ok, let's run LightSword:

> lsserver --port 8081 --password mylevel5 --fork --cluster

Now, run Level.5 on your Mac, then tap 'Add Server...', fill in your server's information: label (eg. My Tunnel), address (IPv4, IPv6 or domain name), port number (8081), password (mylevel5), and save it. 

Finally, click 'Connect' button, Level.5 is going to protect your network traffic.

NOTE: If your Mac can't load VPN plugin, please run this command in Terminal: pluginkit -a /Applications/Level.5.app/Contents/PlugIns/OSXPacketTunnelProvider.appex

Feedback: unsignedint8@gmail.com

from  https://itunes.apple.com/us/app/level.5/id1088733081?ls=1&mt=12 (这个可在中国区购买)
----------

how to upgrade the Node.js version


Node.js is being actively developed, and the latest stable version frequently changes. From time to time you will find a module that doesn’t work with your current version of Node and says that you need to upgrade.
Fortunately there is a very easy way of managing your node version, using the Node binary manager module ‘n’.
1: Check your current version of Node.
$node -v v0.6.12
2: Clear your npm cache
sudo npm cache clean -f  
3: Install ‘n’
sudo npm install -g n  
4: Upgrade to a later version (this step can take a while) You can specify a particular version like so:
sudo n 0.8.11  
Or you can just tell the manager to install the latest stable version like so:
sudo n stable  
5: Check the running version of Node to verify that it has worked:
$node -v v0.8.11

If the version doesn’t number output in step 5 isn’t what you were expecting, you may need to reboot.
from http://theholmesoffice.com/node-js-fundamentals-how-to-upgrade-the-node-js-version/