Skip to content

Conversation

Jovis7
Copy link

@Jovis7 Jovis7 commented Jun 26, 2025

This PR adds unbounded to sing-box as an endpoint, that can be configured to run as 3 different roles:

  • client: as a sing-box outbound, that takes TCP/UDP traffic and sends it over the unbounded network (TCP/UDP over QUIC over WebRTC)
  • peer: as a sing-box inbound, that receives TCP/UDP traffic (from QUIC over WebRTC) and sends it over to sing-box
  • both: as both an inbound and outbound at the same time

See more details in the ticket #2035 about implementation details and decisions.

This is part of #2035 and depends on other 2 PRs to be merged first.

Jovis7 added 2 commits June 26, 2025 22:23
The unbounded endpoint can be configured (role) to run as an inbound (peer),
and outbound (client), or as both at the same time.

When running as inbound, it builds a WebRTC peer connection with another
unbounded endpoint running as client role, receiving TCP/UDP requests
over QUIC and routes to singbox.

When running as outbound, it builds a WebRTC peer connection with
another unbounded endpoint running as peer role, receiving TCP/UDP
requests from singbox and hands over through the unbouned QUIC layer to
the peer.

For TCP it uses QUIC streams and for UDP it uses QUIC datagram.
UDP packet chunking
Heartbeat from QUIC datagram from both client/server
@Jovis7 Jovis7 requested a review from Copilot June 27, 2025 01:42
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR integrates the Unbounded transport into sing-box as a new “unbounded” endpoint, enabling it to operate in client, peer, or dual roles over QUIC and WebRTC.

  • Adds UDPOverQUICHandler to multiplex UDP traffic over QUIC datagrams, with session management and keep-alive.
  • Implements Endpoint in endpoint.go to configure and run Unbounded as outbound (client), inbound (peer), or both.
  • Registers the new protocol, updates options, constants, and dependencies (go.mod).

Reviewed Changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
protocol/unbounded/udp.go Implements UDP-over-QUIC handling, sessions, and routing
protocol/unbounded/endpoint.go Defines the Unbounded Endpoint adapter with client/peer logic
protocol/unbounded/doc.go Adds basic package documentation
protocol/register.go Registers Unbounded endpoint in the registry
option/unbounded.go Defines configuration options for the Unbounded endpoint
go.mod Bumps Go version and adds Unbounded-related dependencies
constant/proxy.go Adds the TypeUnbounded constant
Comments suppressed due to low confidence (2)

option/unbounded.go:6

  • The WebRTCTag option is never used in Endpoint; the code generates its own UUID tags instead. If you intend to allow users to set this, wire it through createClientOptions and createPeerOptions, or remove the unused field.
	WebRTCTag  string `json:"webrtc_tag"` // might need to separate this tag for inbound (peer) and outbound (client)

protocol/unbounded/endpoint.go:205

  • The Role field accepts any string at runtime but only supports client, peer, or both. Add explicit validation and return an error for unsupported values to fail fast on misconfiguration.
	switch options.Role {

Jovis7 added 2 commits June 27, 2025 12:11
This points to unmerged PRs:
quicwrapper: jovis/2035-support-singbox-pr
unbounded: jovis/2035-support-singbox-pr

And this one updates to latest main:
telemetry: current main

Also use github.com/sagernet/sing instead of lantern's because of building with these tags will fail:
❯ go build -tags with_utls,with_quic

.../global/pkg/mod/github.com/getlantern/[email protected]/route/route.go:527:39: undefined: M.IsDomainName
.../global/pkg/mod/github.com/getlantern/[email protected]/route/route.go:625:41: undefined: M.IsDomainName
@Jovis7 Jovis7 force-pushed the jovis/2035-add-unbounded-ep-pr branch from dafad42 to b60638d Compare June 27, 2025 02:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant