Skip to main content

Python bindings for go tun2socks.

Project description

tun2socks-python

Deploy PyPI

Python bindings for tun2socks.

Install

Core Building Tools

You have to install the following tools to be able to install this package successfully.

  • go in your PATH. go 1.20.0 and above is recommended. To check go is ready, type go version. Also, if google service is blocked in your region(such as Mainland China), you have to configure your GOPROXY to be able to pull go packages. For Chinese users, refer to goproxy.cn for more information.

  • cmake in your PATH. To check cmake is ready, type cmake --version.

  • A working GNU C++ compiler(i.e. GNU C++ toolchains). To check GNU C++ compiler is ready, type g++ --version. These tools should have been installed in Linux or macOS by default. If you don't have GNU C++ toolchains(especially for Windows users) anyway:

    • For Linux users: type sudo apt update && sudo apt install g++ and that should work out fine.
    • For Windows users: install MinGW-w64 or Cygwin and make sure you have add them to PATH.

Install Package

pip install tun2socks

API

>>> import tun2socks
>>> help(tun2socks) 
Help on package tun2socks:                                                                                                                                                                                    

NAME
    tun2socks

PACKAGE CONTENTS
    tun2socks

FUNCTIONS
    startFromArgs(...) method of builtins.PyCapsule instance
        startFromArgs(device: str, networkInterface: str, logLevel: str, proxy: str, restAPI: str) -> None

        Start tun2socks with custom arguments

VERSION
    2.5.1

Source Code Modification

This repository, including the package that distributes to pypi, contains tun2socks source code that's been modified to build the binding and specific API. If without explicitly remark, the version of this package corresponds to the version of the origin source code tag, so the binding will have full features as the original go distribution will have. And due to its backward compatibility, there's no plan to generate bindings for older release of tun2socks.

To make installation of this package easier, I didn't add the original tun2socks source code as a submodule. To track what modifications have been made to the source code, you can compare it with the same version under Python binding and corresponding go repository.

Tested Platform

tun2socks-python works on all major platform with all Python version(Python 3).

Below are tested build in github actions.

Platform Python 3.8-Python 3.14
ubuntu 22.04 :heavy_check_mark:
ubuntu 24.04 :heavy_check_mark:
windows-2019 :heavy_check_mark:
windows-2022 :heavy_check_mark:
windows-2025 :heavy_check_mark:
macos-13 :heavy_check_mark:
macos-14 :heavy_check_mark:
macos-15 :heavy_check_mark:

License

The license for this project follows its original go repository tun2socks and is under MIT.

(Upstream project relicensed, see tun2socks#460)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tun2socks-2.6.0.2.tar.gz (1.2 MB view details)

Uploaded Source

File details

Details for the file tun2socks-2.6.0.2.tar.gz.

File metadata

  • Download URL: tun2socks-2.6.0.2.tar.gz
  • Upload date:
  • Size: 1.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tun2socks-2.6.0.2.tar.gz
Algorithm Hash digest
SHA256 eaca9896d67e6e07738701a2a8659728b4684b5a94937b13c322a634ad1f6068
MD5 24d9dfa0676e55fe1a923ba81a76a066
BLAKE2b-256 19504b32bf35d7bcc4f2fa4b14ccc9c4fe91312b8de64d9bf2f61ebc9e2c55fa

See more details on using hashes here.

Provenance

The following attestation bundles were made for tun2socks-2.6.0.2.tar.gz:

Publisher: deploy-pypi.yml on LorenEteval/tun2socks-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page