这是 Potat0000/dn42-bot 的 Fork 版本,根据我自己的需求添加了部分功能。
欢迎在 Telegram 中使用 @baka_lg_bot 和我进行 Peer!
- 支持了 Docker 部署
- 支持了通过 SSH / GPG 进行 ASN 登录
- 支持了非 DN42 ASN 的自助 Peer
- 支持了
findnoc指令 - 修改了部分 whois 请求为本地拉取仓库进行遍历
- 修改了默认数据存放位置
- 修改了
login的相关逻辑以支持 Org 类的 ASN 登录 - 新增了部分参数
server/config.py:
| Config Key | Description |
|---|---|
| DIG_ADDRESS | The address of /dig |
- 支持节点审批
以下为原 README 内容:
- Tools
- Ping
- TCPing
- Traceroute
- Route
- Path
- Whois
- Dig / NSLookup
- User Manage
- Login
- Logout
- Whoami
- Peer
- New peer
- Modify peer
- Remove peer
- Peer info
- Statistics
- DN42 global ranking
- DN42 user basic info & statistics
- Peer situation of a user
- Preferred routes ranking
- Blacklist
- Block / Unblock an ASN
- Get blocked ASN list
The project is divided into two parts: server and agent, which can be deployed separately and have independent requirements.txt.
The server directory contains the code for the tg-bot server.
Config items are located at server/config.py.
| Config Key | Description |
|---|---|
| BOT_TOKEN | Token of Telegram Bot |
| CONTACT | Contact information for yourself |
| DN42_ASN | Your DN42 ASN |
| WELCOME_TEXT | The text shows at the top of /help command |
| WHOIS_ADDRESS | The address of whois server |
| DN42_ONLY | Whether the tool commands (ping, traceroute, etc.) only allow DN42 networks |
| ALLOW_NO_CLEARNET | Whether allowed to peer with someone who has no clearnet |
| ENDPOINT | Server name domain suffixes |
| API_PORT | Agent API Port |
| API_TOKEN | Agent API Token |
| SERVERS | A dict. The keys are the actual server names while the values are the display names |
| HOSTS | (Optional) A dict. The keys are contained in the SERVERS while the values are its custom hosts |
| WEBHOOK_URL | (Optional) Webhook URL to regist to Telegram. Disable webhook by set it to empty string |
| WEBHOOK_LISTEN_HOST | (Required if webhook enabled) The listen host for webhook |
| WEBHOOK_LISTEN_PORT | (Required if webhook enabled) The listen port for webhook |
| LG_DOMAIN | (Optional) URL of looking glass. Support bird-lg's URL format |
| PRIVILEGE_CODE | (Optional) Privilege code |
| SINGLE_PRIVILEGE | (Optional) Whether to disable the privilege code when a privileged user already logs in |
| CN_WHITELIST_IP | (Optional) A list of IP networks that been explicitly marked as non-Chinese-Mainland |
| SENTRY_DSN | (Optional) Sentry DSN. Leave empty to disable Sentry exception tracking |
You should implement a send_email(asn, mnt, code, email) function in config.py and do the email sending in that function. If the send meets an error, a RuntimeError should be raised, otherwise, the send will be considered successful.
Privilege code login is provided for network operators.
When logging in, you can enter the Privilege Code when selecting email to log in as a privileged user.
Privileged users can use /whoami <New AS> to directly modify their identity, unlock additional settings in /peer, remove some restrictions, and receive notifications when others create or delete peers.
The agent directory contains the code for the "agent" for tg-bot server.
Config items are located at agent/agent_config.json.
| Config Key | Description |
|---|---|
| HOST | API listen host |
| PORT | API Port |
| SECRET | API Token |
| OPEN | Whether open peer |
| MAX_PEERS | Maximum number of Peer (0 for no limit) |
| MIN_PEER_REQUIREMENT | Minimum number of peers required to peer with this node |
| NET_SUPPORT | Net supported by this agent |
| EXTRA_MSG | Extra message of this agent |
| MY_DN42_LINK_LOCAL_ADDRESS | The DN42 IPv6 Link-Local Address of this agent |
| MY_DN42_ULA_ADDRESS | The DN42 IPv6 ULA Address of this agent |
| MY_DN42_IPv4_ADDRESS | The DN42 IPv4 Address of this agent |
| MY_WG_PUBLIC_KEY | The WireGuard Public Key of this agent |
| SENTRY_DSN | Sentry DSN. Leave empty to disable Sentry exception tracking |
| BIRD_TABLE_4 | The name of the BIRD table for IPv4 |
| BIRD_TABLE_6 | The name of the BIRD table for IPv6 |
| VNSTAT_AUTO_ADD | Whether to automatically add tunnel interface to vnstat |
| VNSTAT_AUTO_REMOVE | Whether to automatically remove tunnel interface from vnstat |
NET_SUPPORT item has following subconfig items:
ipv4: Whether support IPv4ipv6: Whether support IPv6ipv4_nat: Whether the IPv4 is behind NATcn: Whether allowed to peer with Chinese Mainland
You should install a tcping command in the system. Currently, the agent only supports nodeseeker/tcping. You can modify the tcping_test() function to use other TCPing tools.
My bot is deployed at @Potat0_DN42_Bot. Welcome to peer with me!