init
This commit is contained in:
commit
cd18463a8c
9
.gitignore
vendored
Normal file
9
.gitignore
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
0_sv_learn
|
||||||
|
1_bash_learn
|
||||||
|
2_dpi
|
||||||
|
3_python_learn
|
||||||
|
4_c_re
|
||||||
|
5_vpi
|
||||||
|
sv_lab
|
||||||
|
.vscode/
|
||||||
|
me241200_zerotierApi/env/
|
11
ReadMe.md
Normal file
11
ReadMe.md
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# script work
|
||||||
|
|
||||||
|
script work是一系列自己编选的脚本合集。
|
||||||
|
|
||||||
|
## 项目列表
|
||||||
|
|
||||||
|
| 项目 | 描述 | 状态 | 备注 |
|
||||||
|
| ---------------------------------------------- | ----------------------------------------------------- | ---- | ---- |
|
||||||
|
| [me241200_zerotierApi](./me241200_zerotierApi) | 使用zerotier的api获取网络信息,生成smartdns的配置文件 | 100% | |
|
||||||
|
| | | | |
|
||||||
|
|
26
me241200_zerotierApi/ReadMe.md
Normal file
26
me241200_zerotierApi/ReadMe.md
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# zerotierApi
|
||||||
|
|
||||||
|
## 概述
|
||||||
|
|
||||||
|
使用python,调用zerotier的api,获取整个网络的节点信息。进而生成smartdns需要的配置文件。
|
||||||
|
|
||||||
|
## 快速开始
|
||||||
|
|
||||||
|
### 一、配置环境
|
||||||
|
|
||||||
|
```bash
|
||||||
|
python3 -m venv env
|
||||||
|
source ./env/bin/activate
|
||||||
|
pip install -r requirements.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
### 二、运行程序
|
||||||
|
|
||||||
|
```bash
|
||||||
|
python main.py
|
||||||
|
```
|
||||||
|
|
||||||
|
打印当前网络的节点信息,并在当前目录下产生文件`smartdns.conf`。
|
||||||
|
|
||||||
|
|
||||||
|
|
19
me241200_zerotierApi/main.py
Normal file
19
me241200_zerotierApi/main.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import requests
|
||||||
|
import json
|
||||||
|
|
||||||
|
headers={
|
||||||
|
'Authorization': 'token UPmCF82KqqqWghdlnhfUaQ4Kp24c6qth'
|
||||||
|
}
|
||||||
|
url=' https://api.zerotier.com/api/v1/network/af78bf94361850a3/member'
|
||||||
|
param = {}
|
||||||
|
response = requests.get(url=url,params=param,headers=headers) #三个参数
|
||||||
|
memberData = json.loads(response.text)
|
||||||
|
|
||||||
|
with open("smartdns.conf", '+w') as f:
|
||||||
|
f.write(f"bind [::]:53\n")
|
||||||
|
f.write(f"server 192.168.3.1\n")
|
||||||
|
f.write(f"server 223.5.5.5\n")
|
||||||
|
for i in memberData:
|
||||||
|
config=i['config']
|
||||||
|
print(f"id: {config['id']};\tname: {i['name']};\tdescription: {i['description']};\tip: {config['ipAssignments']}")
|
||||||
|
f.write(f"address /{i['name']}.fbh/{','.join(config['ipAssignments'])}\n")
|
6
me241200_zerotierApi/requirements.txt
Normal file
6
me241200_zerotierApi/requirements.txt
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
certifi==2024.8.30
|
||||||
|
charset-normalizer==2.0.12
|
||||||
|
idna==3.10
|
||||||
|
pkg-resources==0.0.0
|
||||||
|
requests==2.27.1
|
||||||
|
urllib3==1.26.20
|
12
me241200_zerotierApi/smartdns.conf
Normal file
12
me241200_zerotierApi/smartdns.conf
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
bind [::]:53
|
||||||
|
server 192.168.3.1
|
||||||
|
server 223.5.5.5
|
||||||
|
address /main.fbh/192.168.193.24
|
||||||
|
address /fby.fbh/192.168.193.102
|
||||||
|
address /home.fbh/192.168.193.224
|
||||||
|
address /bak.fbh/192.168.193.36
|
||||||
|
address /test.fbh/192.168.193.14
|
||||||
|
address /gs.fbh/192.168.193.101
|
||||||
|
address /tg.fbh/192.168.193.37
|
||||||
|
address /phone.fbh/192.168.193.193
|
||||||
|
address /nas.fbh/192.168.193.7
|
Loading…
x
Reference in New Issue
Block a user