Giter Club home page Giter Club logo

dn42-bot's Introduction

Yet Another Telegram DN42 Bot

Features

  • 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

Deployment

The project is divided into two parts: server and agent, which can be deployed separately and have independent requirements.txt.

Server

The server directory contains the code for the tg-bot server.

Config

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
SERVER 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 SERVER 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
SENTRY_DSN (Optional) Sentry DSN. Leave empty to disable Sentry exception tracking

Email-sending function

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

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.

Agent

The agent directory contains the code for the "agent" for tg-bot server.

Config

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)
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

NET_SUPPORT item has following subconfig items:

  • ipv4: Whether support IPv4
  • ipv6: Whether support IPv6
  • ipv4_nat: Whether the IPv4 is behind NAT
  • cn: Whether allowed to peer with Chinese Mainland

TCPing

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.

Have a try

My bot is deployed at @Potat0_DN42_Bot. Welcome to peer with me!

dn42-bot's People

Contributors

potat0000 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

moechs

dn42-bot's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.