Total Pageviews

Friday 24 April 2020

利用shadowsocks-java-by-tongxiji翻墙(不稳定,不建议使用)

登陆linux vps.
首先搭建java环境:
apt-get install -y default-jdk或者openjdk-8-jdk 
(centos系统下,则yum install -y java-1.8.0-openjdk)
这样jdk环境就搭建好了。

接着是搭建maven环境:
建议这样安装Maven:
apt-get install -y maven*
(yum install -y maven*)
运行 mvn -version 命令,检验是否正确地安装了Maven.

然后,
git clone https://github.com/TongxiJi/shadowsocks-java shadowsocks-java-by-TongxiJi
cd shadowsocks-java-by-TongxiJi
nano conf/config-example-server.json
cat conf/config-example-server.json
{
  "server": "0.0.0.0",
  "port_password": {
    "4423": "mypassword"
  },
  "method": "aes-256-cfb",
  "obfs": "origin"
}

然后运行:
mvn package
(会在当前目录下,生成target目录)
cd target
rm -rf shadowsocks-netty-1.2.0.jar
(这里的shadowsocks-netty-1.2.0.jar是个无用的文件)
unzip shadowsocks-netty-1.2.0-bin.zip
(会释放出shadowsocks-netty-1.2.0目录)
cd shadowsocks-netty-1.2.0
cat conf/config-example-server.json
(发现conf/config-example-server.json的内容跟/root/shadowsocks-java-by-TongxiJi/conf/config-example-server.json的内容一模一样,说明/root/shadowsocks-java-by-TongxiJi/conf/config-example-server.json的内容被mvn程序复制至此处,无需再修改此处的conf/config-example-server.json)
java -jar shadowsocks-netty-1.2.0.jar
但是java -jar shadowsocks-netty-1.2.0.jar是运行在前台的,我们可以使用systemd把它运行为service:
nano /etc/systemd/system/shadowsocks-java-by-tongxiji.service
cat /etc/systemd/system/shadowsocks-java-by-tongxiji.service
[Unit]
After=network.target

[Service]
WorkingDirectory=/root/shadowsocks-java-by-TongxiJi/target/shadowsocks-netty-1.2.0/conf/
ExecStart=/usr/bin/java -jar /root/shadowsocks-java-by-TongxiJi/target/shadowsocks-netty-1.2.0/shadowsocks-netty-1.2.0.jar -s -conf=config-example-server.json
Restart=always

[Install]
WantedBy=multi-user.target

然后运行:
systemctl restart shadowsocks-java-by-tongxiji
systemctl enable shadowsocks-java-by-tongxiji
服务器端搭建完成。

至于客户端,兼容各大平台下的ss客户端程序。把4个参数填入即可。









No comments:

Post a Comment