add readme

This commit is contained in:
xubiaolin 2021-11-21 16:53:20 +08:00
parent d48a353444
commit dc4e598be9
14 changed files with 113 additions and 88 deletions

8
.idea/.gitignore generated vendored
View File

@ -1,8 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -1,6 +0,0 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

4
.idea/misc.xml generated
View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8" project-jdk-type="Python SDK" />
</project>

8
.idea/modules.xml generated
View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/docker-zerotier-planet.iml" filepath="$PROJECT_DIR$/.idea/docker-zerotier-planet.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml generated
View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View File

@ -1,54 +1,39 @@
FROM centos:7 FROM alpine:latest
WORKDIR /var/lib/zerotier-one/ ADD ./run.sh /app/
COPY . /var/lib/zerotier-one/ ADD ./patch /opt/patch/
VOLUME ["/opt","/var/lib/zerotier-one"]
EXPOSE 9993
RUN curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo && \ VOLUME ["/var/lib/zerotier-one/"]
yum update -y && \
yum install git make gcc gcc-c++ python3 wget -y && \
yum install centos-release-scl -y &&\
yum install devtoolset-8 -y &&\
# 编译服务
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories &&\
apk update &&\
apk add git python3 nodejs npm make g++ linux-headers zerotier-one &&\
npm config set registry http://registry.npm.taobao.org &&\
# 安装ztncui
cd /opt && git clone https://github.com.cnpmjs.org/key-networks/ztncui.git &&\
cd ztncui/src && npm install -g node-gyp && npm install &&\
echo 'HTTP_PORT=3443' > .env&&\
echo 'NODE_ENV=production' >> .env &&\
echo 'HTTP_ALL_INTERFACES=true' >> .env &&\
# 添加补丁
cd /opt && \ cd /opt && \
git clone https://github.com.cnpmjs.org/zerotier/ZeroTierOne.git && \ git clone https://github.com.cnpmjs.org/zerotier/ZeroTierOne.git && \
cd ZeroTierOne && \
make && \
make install && \
# 配置moon
cd /var/lib/zerotier-one && \ cd /var/lib/zerotier-one && \
zerotier-idtool generate identity.public identity.secret &&\ zerotier-idtool generate identity.public identity.secret &&\
zerotier-idtool initmoon identity.public >> moon.json &&\ zerotier-idtool initmoon identity.public >> moon.json &&\
#配置ztncui cp /opt/patch/* . &&\
cd /opt &&\ python3 patch.py &&\
curl -sL https://rpm.nodesource.com/setup_10.x | bash - &&\ rm /opt/ZeroTierOne/attic/world/mkworld.cpp &&\
yum install nodejs -y &&\ cp mkworld.cpp /opt/ZeroTierOne/attic/world/ &&\
rm -rf ztncui/ &&\
git clone https://github.com.cnpmjs.org/key-networks/ztncui.git &&\
cd ztncui/src &&\
npm install -g node-gyp &&\
npm install &&\
sh -c "echo 'HTTP_PORT=3443' > .env"&&\
sh -c "echo 'NODE_ENV=production' >> .env"&&\
# 配置补丁
cd /var/lib/zerotier-one && \
python3 patch.py && \
zerotier-idtool genmoon moon.json && \
mkdir moons.d && cp ./*.moon ./moons.d &&\
rm -rf planet &&\
# 编译新的plane
cd /opt/ZeroTierOne/attic/world/ && \ cd /opt/ZeroTierOne/attic/world/ && \
sh build.sh &&\ sh build.sh &&\
mv world.bin /var/lib/zerotier-one/planet cp ./world.bin /var/lib/zerotier-one/planet
CMD [ "bash","run.sh" ]
WORKDIR /app/
CMD ["sh","./run.sh"]

View File

@ -1,4 +1,80 @@
# docker-zerotier-planet # Docker-zerotier-planet
私有部署zerotier-planet服务 私有部署zeroteir-planet服务
2021年11月21日之前更新使用教程 zerotier是一个非常好用的私有组网的软件,但是官方提供的服务器离我们比较远,搭建卫星服务器虽然也能优化部分速度,但是远没有自己行星服务器高效.
# 准备条件
- 具有公网ip的服务器
- 安装docker
# 开始
## 1.下载项目源码
```
git clone
```
## 2.修改项目中的patch/patch.json
将其中的ip地址修改为你服务器的ip地址,端口保留不变即可
## 3.在包含Dockerfile的目录下打包镜像
```
docker build -t zerotier-planet .
```
打包预计需要2-5分钟,具体需要看网络与机型
# 启动项目
```
docker run -d --name zerotier-planet -p 3443:3443 -p 9993:9993 -p 9993:9993/udp -v /var/lib/zerotier-one:/var/lib/zerotier-one --restart unless-stopped zerotier-planet
```
# 创建网络
服务器需要开放3443端口
然后访问http://ip:3443 即可进入管理后台
![ui](webui.png)
使用默认账号为admin
默认密码为 password
进入后创建一个网络可以得到一个网络ID
# 客户端配置
首先将服务器/var/lib/zerotier-one 目录下的planet文件下载到本地以备用
## linux 客户端配置
安装zerotier-one客户端
```
curl -s https://install.zerotier.com | sudo bash
```
进入/var/lib/zerotier-one目录下
删除目录下的planet文件然后把从服务器下载的planet文件替换过来
然后执行zerotier-cli join 网络ID
成功后可以在管理后台上面看到一个新增的members,此时我们需要授权,否则将无法访问。
![auth](auth.png)
其他客户端加入也是一样要进行授权操作操作
## windows 客户端配置
windows
将planet文件覆盖粘贴到C:\ProgramData\ZeroTier\One中
windows搜索服务并重启zeroiter-one
powershelladmin中执行zerotier-cli listpeers查看planet是否生效
## 安卓客户端配置
[Zerotier 非官方安卓客户端发布:支持自建 Moon 节点 - V2EX](https://www.v2ex.com/t/768628)
# 参考链接
[zerotier-虚拟局域网详解](https://www.glimmer.ltd/2021/3299983056/)
[五分钟自建 ZeroTier 的 Planet/Controller](https://v2ex.com/t/799623)

BIN
auth.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

View File

@ -1,5 +1,5 @@
{ {
"stableEndpoints": [ "stableEndpoints": [
"1.2.3.4/9993" "81.70.255.9/9993"
] ]
} }

8
run.sh
View File

@ -1,2 +1,6 @@
#!/bin/bash #!/bin/sh
cd /opt/ztncui/src && npm start echo "开始执行"
zerotier-one -d
cd /opt/ztncui/src
npm start

BIN
webui.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB