Giter Site home page Giter Site logo

ip-over-telegram's Introduction

IP over Telegram

This is a simple program that allows you to create a connection to the Internet through Telegram servers, taking advantage of the unlimited data offerings from mobile carriers.

Building

  1. Install prerequisites

Alpine Linux:

sudo apk install gcc g++ cmake ninja gperf python3 python3-dev openssl-dev
  1. Build and install td and tuntap libraries
./build.sh
  1. Install requirements
python3 -m pip install -r requirements.txt
  1. Create config files Example of /config.client.yaml (change tdconfig.token to your phone number):
tdconfig:
  files_directory: ".td"
  token: "+15555555555"
  api_id: 94575
  api_hash: "a3406de8d171bb422bb6ddf3bbd800e2"
  database_encryption_key: "1234echobot$"
tun:
  name: "telegram_tun0"
  mtu: 1500
  ip: "10.0.0.2"

cache_size: 1
cache_flush_rate: 10
#cache_size: 0
#cache_flush_rate: 0

wrap_in_proxy: false
receive_from_user_id: 829534074
send_to_chat_id: 829534074

Copy config to config.server.yaml, but change TUN's device IP to ip: "10.0.0.1" for your internal server TUN device IP. Then rsync config to the server.

 rsync -avz -e ssh config.server.yaml user@company420:/p/ip_over_telegram

Run

  1. You should have root permissions in order to run this program.
  2. On the server:
sudo sysctl -w net.ipv4.ip_forward=1
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables --policy FORWARD ACCEPT
sudo modprobe tun
sudo python3 main.py config.server.yaml
  1. On the client:
sudo modprobe tun
sudo python3 main.py config.client.yaml
  1. Setup routes (on the client):
TELEGRAM_IP_ADDRESSES=(149.154.167.41 149.154.167.51 95.161.76.100)
DEFAULT_GATEWAY=$(ip route | grep default | awk '{print $3 " dev " $5}')

# Add Telegram IP addresses to the exception for your default gateway
for ip in $TELEGRAM_IP_ADDRESSES; do sudo ip route add $ip via $DEFAULT_GATEWAY; done

# Make IP over Telegram as default gateway
sudo ip route change default via 10.0.0.1 dev telegram_tun0
  1. Enjoy!
  2. Stop
sudo ip route change default via $DEFAULT_GATEWAY

Alternatives

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

ip-over-telegram's People

Contributors

ivanstepanovftw avatar

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.