Skip to content

xtwist/cellularproxy

Repository files navigation

4G LTE Modem Proxy

Demo screenshot

This project provides a transparent proxy service that routes HTTP and SOCKS5 traffic through a 4G LTE modem (Huawei E3372). It exposes:

  • An HTTP API (Axum) to list and reboot network interfaces backed by the modem.
  • A SOCKS5 proxy server that binds outgoing connections to specific network interfaces via SO_BINDTODEVICE.
  • Prometheus metrics for monitoring.

Features

  • HTTP API (Axum) for device management:

    • GET /api/v1/devices — list available interfaces
    • POST /api/v1/devices/{id}/reboot — trigger modem reboot
  • SOCKS5 Proxy with username/password auth:

    • Username: modem
    • Password: interface ID (UUID)
    • Tunnels traffic over the chosen cellular interface
  • Interface discovery using get_if_addrs and custom filter (enx*)

  • Huawei E3372 integration via modem_huaweie337 module

  • Graceful shutdown on Ctrl+C

  • Prometheus metrics via jemalloc metrics loop


Prerequisites

  • Linux with Rust toolchain (>= 1.70)
  • Root or CAP_NET_RAW capability for SO_BINDTODEVICE
  • A Huawei E3372 LTE modem reachable at http://<modem_ip>/api
  • libc support for SO_BINDTODEVICE

Configuration & CLI Flags

Flag Env Var Default Description
--ip IP 127.0.0.1 Public IP label for logging
--ip-modem-api IP_MODEM_API 192.168.8.1 Modem API base URL
--port-api PORT_API 4444 HTTP API listening port
--port-socks5 PORT_SOCKS5 7777 SOCKS5 proxy listening port
--port-prometheus PORT_PROMETHEUS 8888 Prometheus metrics port
--prometheus-username PROMETHEUS_USERNAME "" Basic auth username for metrics
--prometheus-password PROMETHEUS_PASSWORD "" Basic auth password for metrics
--cluster CLUSTER ua-1 Cluster label for logs and metrics

Building

git clone https://github.com/your-org/proxymodem.git
cd proxymodem
cargo build --release

Running

Note: Root privileges are required to bind sockets to network interfaces.

sudo target/release/proxymodem \
  --ip 0.0.0.0 \
  --ip-modem-api 192.168.8.1 \
  --port-api 4444 \
  --port-socks5 7777 \
  --port-prometheus 8888 \
  --prometheus-username user \
  --prometheus-password pass \
  --cluster my-cluster

You should see logs indicating that API, SOCKS5, and metrics servers have started.


HTTP API Usage

  • List devices:

    curl http://localhost:4444/api/v1/devices

    Response:

    [
      {"id": "<uuid>", "name": "enx0123456789ab", "ip": "10.3.47.231"},
      ...
    ]
  • Reboot device (modem):

    curl -X POST http://localhost:4444/api/v1/devices/<uuid>/reboot

    Response:

    {"status": "success", "message": "Interface enx... restarted successfully"}

SOCKS5 Proxy Usage

# Start the client using the built-in CLI:
curl --socks5-hostname localhost:7777 http://example.com
  • Auth:

    • Username: modem
    • Password: <uuid> (interface ID returned by HTTP API)

Requests will be routed over the corresponding enx* interface.


Prometheus Metrics

Metrics are available at:

GET http://localhost:8888/metrics

Includes jemalloc allocator stats and internal proxy metrics.


Troubleshooting

  • Permission denied binding to interface:

    • Ensure you run as root or grant CAP_NET_RAW.
  • No default route found:

    • Check /proc/net/route for a line with 00000000 in the Destination column.
  • Modem API unreachable:

    • Verify --ip-modem-api address and network connectivity to the modem.

Contributing

  1. Fork the repo
  2. Create a new feature branch
  3. Implement your changes
  4. Open a Pull Request

Generated by CellularProxy.com 4G LTE Modem Proxy

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages