Commit Graph
100 Commits
Author SHA1 Message Date
sijie.sun ba86e47cc6 fix: adapt mobile ffi tun fd API 2026-06-16 20:31:22 +08:00
sijie.sun d742fa34aa refactor: simplify shared virtual nic helpers 2026-06-16 12:46:28 +08:00
sijie.sun 800c840bb5 shared-tun: preserve member ownership on mobile
Introduce shared NIC source ownership and dispatcher handling so a
single dev_name can be shared by multiple tun-enabled instances while
keeping per-member IP and route claims distinct.

Pass Android VpnService fd registration with per-instance source and
route claims. Keep the VPN address list limited to real member
addresses and allow AF_INET6 without installing hidden fd00::1.

Invalidate dispatcher flow and NAT state when source ownership changes
or a member unregisters. Avoid rewriting non-first IPv4 fragment
payloads, and adjust fragmented TCP/UDP checksums without recomputing
over partial fragment bodies.

Preserve source-owner routing for equal-prefix route conflicts, keep
ICMP echo NAT entries distinct by echo id, and retry stale flow-owner
send failures from the original packet. Only record NAT state after a
translated packet is accepted by its member.

Apply Linux IPv4 route preferred-source hints for shared routes and keep
route repair paths source-aware. Keep Darwin ifcfg access scoped to
cleanup-only paths where netns is not available.
2026-06-16 02:16:25 +08:00
sijie.sun ca17e856a6 fix: tighten shared virtual nic lifecycle
Key shared virtual NIC registry entries by both netns and device
name. Instances in different namespaces can no longer reuse the same
underlying device by accident.

Store each member's configured MTU separately and publish it as
the initial MTU claim after device creation. Later members no longer
inherit only the first member's MTU.

Shut down the dispatcher when the last current member leaves, and
invalidate the shared NIC if member cleanup fails. The registry entry
remains available for a later clean recreate.

Keep Magic DNS fake-IP routes owned by shared TUN members through
the shared backend. Stopping one member no longer removes the route
while another shared member still owns it, and Linux retained routes
are re-applied after address deletion.

Extend the shared TUN Magic DNS integration test to drop one shared
member first, verify DNS still works through the remaining member,
and then verify final cleanup after the last member exits.
2026-06-15 01:34:29 +08:00
sijie.sun d87624b353 fix: address shared tun ci failures 2026-06-14 23:14:45 +08:00
sijie.sun a7ab60e0e4 fix: support android shared tun fd groups
Android previously treated setTunFd as a single-instance update, and the
VpnService plugin could only expose one IPv4 address. That made shared
TUN members disable each other or leave only one address configured.

Group enabled Android TUN instances by shared dev_name, send the fd to
every compatible member, and only disable incompatible TUN users. Build
the Android VPN request from the whole running shared group and pass
every IPv4 address to VpnService.

The shared mobile dispatcher now owns current fd device state on a
process-level runtime. New setTunFd calls replace that state even when
the raw fd number is reused, and mobile TUN read/write/create failures
rebuild with backoff while preserving member registrations.

Protect shared member cleanup with per-registration ownership tokens, so
old async cleanup cannot unregister a recreated member or remove its
source claims. Mobile source addresses are registered in the dispatcher
without applying OS ifcfg changes, so Android-originated packets return
through the owning instance.

When one shared member stops while another remains, notify the frontend
to recalculate the VpnService config instead of leaving stale addresses
and routes. Serialize Android VpnService config recalculation so stale
async events cannot overwrite newer shared-group state.

If one shared member is not ready, rebuild from the healthy members and
retry the missing member later. If no healthy member remains, stop the
Android VPN service instead of keeping stale routes active.
2026-06-14 16:24:08 +08:00
sijie.sun 3d0d2bed9e fix: preserve macos shared tun ipv4 aliases 2026-06-14 11:38:12 +08:00
sijie.sun 7ef023fcdd test: cover shared tun dynamic proxy routes
Cover shared tun duplicate proxy CIDR failover and runtime proxy
CIDR add/remove through netns integration tests.

Start IP proxy from config patch events so a node that did not have
proxy CIDRs at startup can serve a later proxy network patch.

Ignore NotFound for shared NIC remove-side ifcfg cleanup so member
teardown does not poison shared owner state when the OS item is
already gone.

Add dispatcher coverage for TUN read failure invalidation and member
close notification.
2026-06-14 02:37:19 +08:00
sijie.sun 69d476ad13 test: cover shared tun subnet proxy paths
Add a shared tun subnet proxy topology with shared members on both
the source and destination sides. The test exercises ICMP, TCP
subnet proxy, and UDP subnet proxy against a real netns target.

Add focused KCP and QUIC TCP proxy variants that verify the selected
TcpProxyConnect transport label. The helper waits for real proxy CIDR
reachability before running transport-specific checks to avoid racing
route installation.
2026-06-14 01:26:19 +08:00
sijie.sun cf3fcb75b5 test: cover shared tun magic dns in netns
Add an end-to-end shared tun Magic DNS test with two members
sharing one device in the same namespace. The test checks real
netns ping paths and queries the Magic DNS fake IP through dig.

Teach DnsRunner to pass the instance netns into
MagicDnsServerInstance so fake DNS route add/remove operations run
where the tun device exists. Keep the existing constructors as
wrappers so current callers stay source-compatible.
2026-06-14 01:26:19 +08:00
sijie.sun 17195a5cc4 fix: dispatch shared tun packets by source owner
Track each shared tun member's claimed IPv4 and IPv6 addresses in
the dispatcher.

When a packet arrives from the shared device, keep the existing flow
affinity lookup first, then route by source address owner before
falling back to an arbitrary member. This keeps public IPv6 auto
traffic on the member that owns the leased address while preserving
the simple local-origin fallback.

Migrate high-value shared tun coverage from the backup branch: real
member communication, no_tun isolation, proxy CIDR forwarding, and
public IPv6 auto through a shared device.
2026-06-14 01:26:19 +08:00
sijie.sun 22bcfebe3e test: cover shared nic instance selection
Add focused tests for Instance nic context creation without creating a
real tun device.

Verify empty dev_name keeps the dedicated backend, while matching
shared dev_name values reuse the same shared virtual nic and get fresh
member ids on each recreation.
2026-06-14 01:26:19 +08:00
sijie.sun 47a2fb19a6 feat: wire shared nic into instance setup
Route normal, DHCP, and mobile nic creation through one helper that
selects the shared backend when dev_name is configured.

Keep dedicated nic creation as the default for configs without a
dev_name, and keep no_tun handling in the existing callers.

Store a process-wide shared virtual nic registry behind each instance
so networks with the same dev_name attach to the same shared device.
2026-06-14 01:26:19 +08:00
sijie.sun 62e43855cb feat: support shared nic mobile fd
Create the shared virtual nic dispatcher from the mobile tun fd.

Later shared members attach through their ring tunnel and do not
consume another fd. Dedicated mobile nic creation stays unchanged.

Fix mobile no-magic-dns cfg so the mobile tun path checks without
enabling magic-dns.
2026-06-14 01:26:19 +08:00
sijie.sun 5efbf4853a feat: apply shared nic member ifcfg
Route shared nic IP and route configuration through member claims.
Repeated addresses or routes now touch the OS device only when the
first owner appears, and are removed only after the last owner leaves.

Forward NicBackend shared operations to the member claim layer.
Dynamic proxy and public IPv6 route updates now go through NicBackend,
so they use the same ownership merge behavior.

Clean member claims when shared member registration is dropped. Keep
raw ifcfg access for non-Linux platform cleanup only, and document
that this raw path does not carry the netns guard.
2026-06-14 01:26:19 +08:00
sijie.sun 3e0bde68b8 perf: bound shared nic flow eviction
Replace full flow table clears with a small FIFO order queue so overflow evicts only older flow ownership hints.

Keep lookup read-only on the packet hot path and prune stale queue entries when a shared member unregisters.
2026-06-14 01:26:19 +08:00
sijie.sun bda06ebb61 perf: speed up shared nic flow lookup
Parse shared virtual nic flow keys directly from IP payload bytes instead of building pnet packet wrappers on the dispatcher hot path.

Use a local HashMap for flow owner lookup and clear the bounded table on overflow instead of removing a BTreeMap entry by key order.
2026-06-14 01:26:19 +08:00
sijie.sun be0859aca6 refactor: keep shared dispatcher state local
Move shared member and flow ownership state into the dispatcher task.

Use control messages for member register and unregister events.

Keep the member table lock off the packet forwarding path.
2026-06-14 01:26:19 +08:00
sijie.sun b2f1b37336 refactor: add shared virtual nic dispatcher
Add the shared NIC dispatcher that owns the underlying VirtualNic tunnel.

Connect member ring tunnels through a private member table.

Track reverse flow ownership from packets written by a member.

Replies read from the shared device go back to the same member.

Packets without an owner fall back to any active member.

Mark the shared NIC invalid when the underlying tunnel closes or fails.

Notify members so their NicCtx can rebuild.
2026-06-14 01:26:19 +08:00
sijie.sun 583fb45939 refactor: reuse ring tunnel for shared members
Use create_ring_tunnel_pair for member-level shared NIC tunnels.

That replaces the custom packet stream and sink implementation.

Keep one side of each ring tunnel in SharedVirtualNic's member map.

Later dispatcher code can connect those endpoints to the shared device.
2026-06-14 01:26:19 +08:00
sijie.sun a343a907a9 refactor: add shared nic ctx constructor
Add a shared NicCtx constructor that obtains a SharedVirtualNicMember from the registry and wraps it in NicBackend::Shared.

Keep NicCtx::new on the dedicated backend path so existing runtime behavior does not change before the shared tunnel implementation is ready.
2026-06-14 01:26:19 +08:00
sijie.sun b1ac64f40f refactor: route nic ctx through nic backend
Replace NicCtx's direct VirtualNic field with NicBackend while keeping the constructor on the dedicated backend path.

Move existing device creation, ifcfg lookup, IP assignment, and public IPv6 updater calls through backend helpers so shared mode can be wired in a later commit without changing the dedicated flow.
2026-06-14 01:26:19 +08:00
sijie.sun 122fb9b54e refactor: add shared nic backend skeleton
Introduce SharedVirtualNicMember as the per-instance handle for a shared virtual NIC and add a registry helper to create members.

Add NicBackend so NicCtx can later choose between dedicated VirtualNic and shared member-backed tunnel creation without changing the existing dedicated path.
2026-06-14 01:26:19 +08:00
sijie.sun 09780c1698 refactor: add shared virtual nic registry
Add a small registry keyed by dev_name so shared-mode setup can reuse one SharedVirtualNic per device name.

Track invalid shared NICs through a shared flag and replace them on the next get_or_create call.
2026-06-14 01:26:19 +08:00
sijie.sun e533b48244 refactor: decouple virtual nic from global ctx
Move TUN-specific configuration into VirtualNicConfig so VirtualNic and SharedVirtualNic no longer depend on ArcGlobalCtx.

Keep global context side effects in NicCtx, including the Windows generated device-name writeback.
2026-06-14 01:26:19 +08:00
sijie.sun c0bd050742 add shared virtual nic 2026-06-14 01:26:19 +08:00
sijie.sun c0d2045e52 bump version to v2.4.5 2025-09-26 00:48:10 +08:00
sijie.sun d0a6c93c2c fix ipv6 packet routing and avoid route looping
properly handle ipv6 link local address and exit node.
2025-08-03 18:10:27 +08:00
sijie.sun 84bfac144c bump version to 2.4.1 2025-08-02 10:48:17 +08:00
sijie.sun e1bfec6fe2 add api_meta.js to frontend public 2025-06-19 23:40:57 +08:00
sijie.sun dde7a4dff1 bps limit should throttle kcp packet 2025-06-19 22:53:41 +08:00
sijie.sun 95b12dda5a bump rust version to v1.86 2025-05-11 20:47:29 +08:00
sijie.sun f52936a103 bump version to v2.2.3 2025-03-17 22:24:19 +08:00
sijie.sun f84ae228fc fix some tailwind style not work 2025-03-16 11:45:18 +08:00
sijie.sun 445b02b2ca do not upload to oss 2025-03-15 00:16:12 +08:00
sijie.sun bb17ffa9fc fix wireguard not respond after idle for 120s 2025-03-15 00:16:12 +08:00
sijie.sun 389ea709ce fix smoltcp not wakeup closed socket 2025-03-15 00:16:12 +08:00
sijie.sun 7397abcb94 txt connector should not rely on A record 2025-03-09 21:31:43 +08:00
sijie.sun 98d321f8ac fix kcp traffic not encrypted 2025-03-08 22:09:43 +08:00
sijie.sun e78b0ef869 test serializedly 2025-03-08 15:59:54 +08:00
sijie.sun 8d654330ac fix http_connector
1. use ipv4 first when connect to http server.
2. allow redirect to url like: http://tcp://p.com:11010
3. dns should also use long timeout
2025-03-08 15:59:54 +08:00
sijie.sun 03b55b61e7 support txt/srv record 2025-03-08 12:56:23 +08:00
sijie.sun 745e44cc87 allow using http connector for config server 2025-03-07 22:17:23 +08:00
sijie.sun 24213a874a make http connector timeout longer
http response may be slow, make its timeout longer.
2025-03-07 22:17:23 +08:00
sijie.sun 155f8a2ba2 make prost build smaller 2025-03-06 11:07:05 +08:00
sijie.sun 568dca6f9c fix memory leak 2025-03-06 11:07:05 +08:00
sijie.sun 673c34cf5a http redirector 2025-02-21 11:51:13 +08:00
sijie.sun 2050ed78d0 remove some dep 2025-02-21 11:51:13 +08:00
sijie.sun dd5b00faf4 bump version to v2.2.2 2025-02-10 08:47:18 +08:00
sijie.sun 0caec3e4da fix label translate 2025-02-09 22:01:26 +08:00
sijie.sun e48e62cac0 fix tcp proxy not close properly 2025-02-09 22:01:09 +08:00
sijie.sun 06ebda2e2f update kcp-sys to fix unexpected disconnect 2025-02-09 00:30:27 +08:00
sijie.sun 53c449b9fb fix net2net kcp proxy 2025-02-08 23:11:10 +08:00
sijie.sun 51e0fac72c improve user experience
1. add config generator to easytier-web
2. add command to show tcp/kcp proxy entries
2025-02-07 23:59:36 +08:00
sijie.sun 32b1fe0893 netlink shoud remove route only when ifidx is same 2025-02-06 19:23:00 +08:00
sijie.sun 2af3b82e32 bump version to 2.2.1 2025-02-06 16:54:49 +08:00
sijie.sun eca1231831 fix help msg of kcp 2025-02-06 16:54:49 +08:00
sijie.sun e833c2a28b improve experience of subnet/kcp proxy
1. add self to windows firewall on windows
2. android always use smoltcp
2025-02-06 16:54:49 +08:00
sijie.sun 4dca25db86 bump version to 2.0.3 2024-10-13 12:49:01 +08:00
sijie.sun ba3da97ad4 fix ipv6 direct connector not work 2024-10-03 11:56:10 +08:00
sijie.sun 984ed8f6cf fix #367
introduce my peer route id and peer id is duplicated only when peer
route id is not same.

this problem occurs because update_self may increase my peer info
version and propagate to ther nodes.
2024-09-29 23:58:33 +08:00
sijie.sun c7895963e4 rollback some parameters 2024-09-29 23:17:46 +08:00
sijie.sun a0ece6ad4d fix public server address in readme 2024-09-29 21:35:16 +08:00
sijie.sun d0a3a40a0f fix bugs
add timeout for wss try_accept

public server should show stats

use default values for flags

bump version to 2.0.0
2024-09-29 17:49:14 +08:00
sijie.sun ff5ee8a05e support forward foreign network packet between peers 2024-09-29 10:31:29 +08:00
sijie.sun e0b364d3e2 use ubuntu 24.04 apt source
github action upgraded the ubuntu-latest to 24.04

https://github.com/actions/runner-images/pull/10687
2024-09-27 11:05:52 +08:00
sijie.sun 2496cf51c3 fix connection loss when traffic is huge 2024-09-26 23:49:01 +08:00
sijie.sun 7b4a01e7fb fix ring buffer stuck when using multi thread runtime 2024-09-26 14:34:33 +08:00
sijie.sun d1e2e1db2b fix ospf foreign network info version 2024-09-23 13:42:25 +08:00
sijie.sun 783ba50c9e add cli command for global foreign network info 2024-09-23 00:03:57 +08:00
sijie.sun aca9a0e35b use ospf route to propogate foreign network info 2024-09-22 22:12:18 +08:00
sijie.sun bd60cfc2a0 add feature flag to ospf route 2024-09-21 20:54:19 +08:00
sijie.sun 06afd221d5 make ping more smart 2024-09-21 18:00:52 +08:00
sijie.sun 0171fb35a4 fix upload oss 2024-09-21 00:24:58 +08:00
sijie.sun 82f5dfd569 show nodes version correctly 2024-09-18 23:15:08 +08:00
sijie.sun 6d7edcd486 fix connect failed after setup one of sockets fails 2024-09-18 23:15:08 +08:00
sijie.sun ad4cbbea6d fix socks5 access local virtual ip 2024-08-17 23:52:05 +08:00
sijie.sun db660ee3b1 add test for socks5 server 2024-08-17 21:39:19 +08:00
sijie.sun ae54a872ce support socks5 proxy
usage: --socks5 12345

create an socks5 server on port 12345, can be used by socks5 client to access
virtual network.
2024-08-17 13:17:38 +08:00
sijie.sun 2aa686f7ad use autostart plugin and hide window when autostart 2024-08-17 02:15:15 +08:00
sijie.sun ce10bf5e60 update tauri to rc2 2024-08-17 02:15:15 +08:00
sijie.sun ff6da9bbec also setup panic handler on gui
this helps collect gui crash info.
2024-08-15 23:00:04 +08:00
sijie.sun 198c239399 set ipv6 mtu on windows
windows use different MTU for ipv4 / ipv6, we should set both.
2024-08-15 22:59:48 +08:00
sijie.sun 0fbbea963f forward foreign peer event to unbounded channel
if some events loss, may cause inconsistent foreign peer info.
2024-08-15 08:03:50 +08:00
sijie.sun 51165c54f5 smoltcp listener should bind multiple times
if smoltcp bind only once on tcp socket, it can only accept exactly
one syn packet in one round. other syn packets will be dropped and
client will receive a RST packet.
2024-08-13 23:01:34 +08:00
sijie.sun f14875aa3f bump version to v1.2.2 2024-08-13 00:46:32 +08:00
sijie.sun 6391dceb62 udpate release.yml 2024-08-13 00:46:32 +08:00
sijie.sun cca105e91d add chinese help message 2024-08-08 08:05:42 +08:00
sijie.sun 3e52490d1b update dep and bump version 2024-08-07 23:48:03 +08:00
sijie.sun d1293276ce use tun2
meh/rust-tun has bug on windows and may stuck on large traffic.
2024-08-07 15:58:23 +08:00
sijie.sun 4a5e426730 fix android route and peer conn disconn bug
1. android correctly add route
2. use mock nic ctx to consume packets
2024-08-06 22:19:30 +08:00
sijie.sun fdc2755291 fix set dev name not work on windows 2024-08-05 11:47:43 +08:00
sijie.sun b4fbcd8d80 use random ip from dns record instead of only first one 2024-08-04 23:42:33 +08:00
sijie.sun 2415cb211e run on v7 need rustc < 1.78 2024-08-04 11:07:24 +08:00
sijie.sun 5e51784803 support unicode hostname 2024-08-04 11:07:24 +08:00
sijie.sun 71d41f0a70 introduce docker image updater 2024-08-04 00:28:34 +08:00
sijie.sun 78f2804bad bump version to v1.2.0 2024-08-03 15:39:04 +08:00
sijie.sun 0da09ec605 add network whitelist for public relay node 2024-08-03 15:39:04 +08:00
sijie.sun 02b5b5f3c7 use better artifect name 2024-08-03 13:11:44 +08:00
sijie.sun 4a0adaa3f8 fix listener stop accept after failure 2024-08-03 13:11:44 +08:00