Skip to content

lerry/rust-multi-ip-http-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rust-multi-ip-http-client

Rust 多本地 IP 绑定发起 HTTP 请求:将请求绑定到指定本地 IPv4,支持并发与连接复用。

Rust source-bound multi-IP HTTP requests: Bind requests to specific local IPv4s with concurrency and connection reuse.

轻量级命令行工具,使用指定本地 IPv4 地址作为出站地址,请求 https://ip.me 并打印返回的公网 IP。

Simple CLI tool to query public IPs using specific local IPv4 addresses as egress via https://ip.me.

关键词 Keywords

  • rust multi ip http
  • rust source-bound http
  • rust bind local address
  • rust per ip http
  • rust multiple interfaces
  • reqwest local_address
  • multi egress ip
  • outbound ip
  • iface public ip
  • multi-ip http client

功能 Features

  • 发现本机 IPv4 地址(过滤回环与常见虚拟网卡)

  • 使用给定 IPv4 作为本地绑定地址发起请求,打印返回的公网 IP

  • User-Agent 固定为 curl/8.7.1

  • 并发查询所有发现的 IPv4 地址

  • 使用 Rustls 进行 TLS(无需系统 OpenSSL)

  • Discover local IPv4 addresses (filters loopback and common virtual interfaces)

  • Bind a reqwest client to a given local IPv4 and call https://ip.me, print the public IP

  • Set User-Agent to curl/8.7.1

  • Concurrently query all discovered IPv4 addresses

  • TLS via Rustls (no system OpenSSL required)

工作原理 How it works

  • 通过 if-addrs 枚举网卡

  • 过滤回环与常见虚拟/桥接网段(如 docker、veth、VirtualBox)

  • 使用 ClientBuilder::local_address 绑定到指定本地 IPv4

  • 请求 https://ip.me,输出去除空白后的响应

  • Enumerates network interfaces via if-addrs

  • Filters out loopback and likely virtual/bridge ranges (e.g., docker, veth, VirtualBox)

  • Builds a reqwest client bound to a specific local IPv4 using ClientBuilder::local_address

  • Requests https://ip.me and prints the trimmed response

依赖与要求 Requirements

  • Rust 1.75+(2024 edition)

  • 无需外部 OpenSSL(启用 rustls-tls 特性)

  • Rust 1.75+ (edition 2024)

  • No external OpenSSL required (uses rustls-tls feature)

构建 Build

cargo build --release

运行 Run

cargo run --release

预期输出示例 Expected output example:

Found IPv4 addresses:
  192.168.1.10
  10.0.0.5
Found 2 IPv4 addresses

Checking public IP for each local address:
  Local: 192.168.1.10 -> Public: 203.0.113.45
  Local: 10.0.0.5 -> Public: 203.0.113.45

配置 Configuration

默认会过滤:

  • 接口名包含以下前缀:docker, br-, veth, virbr, vmnet, tun, tap, lo, dummy, bridge, vbox, vmware, utun
  • 常见虚拟化地址段:172.17.0.0/16,172.18.0.0/16–172.31.0.0/16,192.168.56.0/24

你可以在 src/main.rs 中修改这些过滤规则。

By default, discovery filters out:

  • Interface names containing: docker, br-, veth, virbr, vmnet, tun, tap, lo, dummy, bridge, vbox, vmware, utun
  • Virtualization ranges: 172.17.0.0/16, 172.18.0.0/16–172.31.0.0/16, 192.168.56.0/24

You can adjust these filters in src/main.rs.

注意事项 Notes

  • 绑定本地 IPv4 只影响源地址选择;实际对外 IP 可能仍经由 NAT。

  • 目标服务可能有频率限制;如需高频请求请在应用层做限速。

  • 客户端默认使用连接池与 keep-alive,会完整读取响应以便复用连接。

  • Binding to a local IPv4 only controls source address selection; outbound IP may still be NATed.

  • Servers may rate-limit requests; add application-level rate limiting if you query frequently.

  • The client uses connection pooling and keep-alive by default. Responses are fully read to allow reuse.

安全与隐私 Security & Privacy

  • 本仓库不包含密钥或凭证。

  • 自动扫描未发现 token、密码或嵌入式凭据。

  • 程序仅向 https://ip.me 发起请求并打印响应。

  • This repository does not contain secrets or private keys.

  • No tokens, passwords, or embedded credentials were found during an automated scan.

  • The tool performs outbound requests to https://ip.me and prints the server response.

许可 License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages