erase fingerprints (#177)
* add external modules and patches * migrate pion webrtc to vendored headlessclient, drop local pion replaces * use chrome ice credentials, one webrtc api per peer connection * send one user agent everywhere, use the vendored websocket * route the telemost joiner through headlessclient, drop the dead keylog * answer telemost dtls without a hello verify round trip * follow the headlessclient dtls 1.3 mimicry rename * follow the headless-client rename and apply the profile before the caller settings * build every webrtc api through relay/headlessapi * register chrome rtp header extensions for every pion consumer * dial vk webtransport signaling through the headless quic profile * dial dion and wb stream through the headless chrome profile * announce chrome's http/3 settings on the vk webtransport signaling * send chrome header blocks on bitrix http and livekit websocket * send chrome's webtransport connect headers on vk signaling * stop passing invented track names to the library * move wbp http paths onto the headlessclient profile * migrate to a published headlessclient * dedup go.mod
This commit is contained in:
1 parent
88a0b5f1b9
commit
a735b4176e
71 files changed
+571
-2140
No files matched your search
+7
-1
@@ -14,6 +14,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/kulikov0/headless-client"
|
||||
"whitelist-bypass/relay/common"
|
||||
)
|
||||
|
||||
@@ -132,6 +133,11 @@ func (s *Session) setBaseHeaders(req *http.Request, accessToken string) {
|
||||
req.Header.Set("Referer", Origin+"/")
|
||||
req.Header.Set("Accept", "*/*")
|
||||
req.Header.Set("Accept-Language", "en")
|
||||
for name, values := range headless.ChromeWindows.Headers(headless.DestEmpty) {
|
||||
if strings.HasPrefix(name, "Sec-Fetch-") {
|
||||
req.Header[name] = values
|
||||
}
|
||||
}
|
||||
req.Header.Set("X-Request-Id", uuid.New().String())
|
||||
for name, value := range deviceHeaders(s.Device) {
|
||||
req.Header.Set(name, value)
|
||||
@@ -168,7 +174,7 @@ func NewSession(httpClient *http.Client) (*Session, error) {
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cookiejar: %w", err)
|
||||
}
|
||||
httpClient = &http.Client{Jar: jar}
|
||||
httpClient = &http.Client{Jar: jar, Transport: headless.ChromeWindows.HTTPClient().Transport}
|
||||
} else if httpClient.Jar == nil {
|
||||
jar, err := cookiejar.New(nil)
|
||||
if err != nil {
|
||||
|
||||
+13
-26
@@ -10,10 +10,12 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
headless "github.com/kulikov0/headless-client"
|
||||
"github.com/kulikov0/headless-client/webrtc"
|
||||
"github.com/pion/rtp/codecs"
|
||||
"github.com/pion/webrtc/v4"
|
||||
|
||||
"whitelist-bypass/relay/common"
|
||||
"whitelist-bypass/relay/headlessapi"
|
||||
"whitelist-bypass/relay/tunnel"
|
||||
)
|
||||
|
||||
@@ -37,9 +39,6 @@ const (
|
||||
RoleJoiner Role = "joiner"
|
||||
)
|
||||
|
||||
// CallConfig configures a Call lifecycle. Auth must already have a valid
|
||||
// access token (caller did LoadCookiesFromFile + EnsureValidToken). Event
|
||||
// must be a usable EventInfo (CreateRoom or GetEventBySlug result).
|
||||
type CallConfig struct {
|
||||
Auth *Session
|
||||
Event *EventInfo
|
||||
@@ -49,16 +48,11 @@ type CallConfig struct {
|
||||
RecvMid string
|
||||
Role Role
|
||||
|
||||
// SettingEngine, NetDialContext, and ResolveICEHost are forwarded to Pion
|
||||
// and the WebSocket dialer. All three are no-ops if nil (desktop default).
|
||||
// They exist so the Android relay can plug in AndroidNet plus stdin-based
|
||||
// DNS resolution before the VPN starts intercepting traffic.
|
||||
SettingEngine *webrtc.SettingEngine
|
||||
NetDialContext func(ctx context.Context, network, addr string) (net.Conn, error)
|
||||
ResolveICEHost func(host string) (string, error)
|
||||
ConfigureSettingEngine func(*webrtc.SettingEngine)
|
||||
NetDialContext func(ctx context.Context, network, addr string) (net.Conn, error)
|
||||
ResolveICEHost func(host string) (string, error)
|
||||
}
|
||||
|
||||
// PeerEntry tracks one remote peer's signaling state.
|
||||
type PeerEntry struct {
|
||||
SessionID string
|
||||
UserID string
|
||||
@@ -67,12 +61,6 @@ type PeerEntry struct {
|
||||
JoinedAt time.Time
|
||||
}
|
||||
|
||||
// Call drives one full DION room session: signaling, Pion peer, VP8 send
|
||||
// track on mid=12, OnTrack reader on the bound recv mid, plus discovery and
|
||||
// subscription to other peers via conf_speakers_state and get_video_from_user.
|
||||
//
|
||||
// Lifecycle: NewCall(cfg) -> Start() -> wait OnConnected(tunnel.DataTunnel) ->
|
||||
// use tunnel via RelayBridge -> wait Done() (read-loop or ICE death) -> Close().
|
||||
type Call struct {
|
||||
cfg CallConfig
|
||||
signaling *SignalingClient
|
||||
@@ -147,10 +135,6 @@ func (c *Call) Close() {
|
||||
})
|
||||
}
|
||||
|
||||
// Start runs the full lifecycle to the point where the VP8 tunnel is up and
|
||||
// OnConnected has fired. It returns nil on success; from that point the call
|
||||
// continues in the background until ICE death or signaling read-loop end, at
|
||||
// which point Done() is closed.
|
||||
func (c *Call) Start() error {
|
||||
sessionID := uuid.New().String()
|
||||
c.mySessionID = sessionID
|
||||
@@ -218,7 +202,13 @@ func (c *Call) Start() error {
|
||||
}
|
||||
c.cfg.LogFn("[call] you_joined ice_servers=%d", len(youJoined.IceServers))
|
||||
|
||||
pionAPI := NewPionAPI(c.cfg.SettingEngine)
|
||||
pionAPI, err := headlessapi.WebRTCAPI(headlessapi.Options{
|
||||
Profile: headless.ChromeWindows,
|
||||
Configure: c.cfg.ConfigureSettingEngine,
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("build webrtc api: %w", err)
|
||||
}
|
||||
iceServers := ResolveICEServerHosts(youJoined.IceServers, c.cfg.ResolveICEHost, c.cfg.LogFn)
|
||||
peer, err := BuildPionPeer(pionAPI, iceServers)
|
||||
if err != nil {
|
||||
@@ -227,14 +217,11 @@ func (c *Call) Start() error {
|
||||
c.peer = peer
|
||||
|
||||
sendMidIndex := sendVideoMidIndex
|
||||
trackLabel := "dion-tunnel-" + sessionID
|
||||
if c.cfg.Role == RoleCreator {
|
||||
sendMidIndex = sendScreenShareMidIndex
|
||||
trackLabel = "dion-tunnel-screen-" + sessionID
|
||||
}
|
||||
track, err := webrtc.NewTrackLocalStaticSample(
|
||||
webrtc.RTPCodecCapability{MimeType: webrtc.MimeTypeVP8, ClockRate: 90000},
|
||||
"video", trackLabel,
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("NewTrackLocalStaticSample: %w", err)
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net"
|
||||
"strings"
|
||||
|
||||
"github.com/pion/webrtc/v4"
|
||||
"github.com/kulikov0/headless-client/webrtc"
|
||||
)
|
||||
|
||||
type TransceiverPlan struct {
|
||||
@@ -59,27 +59,6 @@ type PionPeer struct {
|
||||
DatachannelDescs []DataChannelDesc
|
||||
}
|
||||
|
||||
// NewPionAPI builds a Pion API with default codecs. customEngine may be nil
|
||||
// for the standalone (desktop) case; pass a configured *webrtc.SettingEngine
|
||||
// on Android to plug in AndroidNet / custom dial / ICE filters.
|
||||
func NewPionAPI(customEngine ...*webrtc.SettingEngine) *webrtc.API {
|
||||
mediaEngine := &webrtc.MediaEngine{}
|
||||
if err := mediaEngine.RegisterDefaultCodecs(); err != nil {
|
||||
panic(fmt.Errorf("dion: register default codecs: %w", err))
|
||||
}
|
||||
engine := webrtc.SettingEngine{}
|
||||
if len(customEngine) > 0 && customEngine[0] != nil {
|
||||
engine = *customEngine[0]
|
||||
}
|
||||
return webrtc.NewAPI(
|
||||
webrtc.WithMediaEngine(mediaEngine),
|
||||
webrtc.WithSettingEngine(engine),
|
||||
)
|
||||
}
|
||||
|
||||
// ResolveICEServerHosts walks each ICEServerEntry and rewrites any non-IP host
|
||||
// in its URLs via the resolver. Used on Android where Pion has no DNS access
|
||||
// and hostnames must be pre-resolved through the Java side.
|
||||
func ResolveICEServerHosts(entries []ICEServerEntry, resolveFn func(host string) (string, error), logFn func(string, ...any)) []ICEServerEntry {
|
||||
if resolveFn == nil {
|
||||
return entries
|
||||
|
||||
@@ -12,7 +12,8 @@ import (
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
headless "github.com/kulikov0/headless-client"
|
||||
"github.com/kulikov0/headless-client/websocket"
|
||||
|
||||
"whitelist-bypass/relay/common"
|
||||
)
|
||||
@@ -249,7 +250,8 @@ func DialSignaling(wssURL string, opts SignalingDialOptions) (*SignalingClient,
|
||||
}
|
||||
wssURL = wssURL + joiner + "socket_version=2.0"
|
||||
}
|
||||
dialer := websocket.Dialer{HandshakeTimeout: 10 * time.Second}
|
||||
dialer := headless.ChromeWindows.WebSocketDialer(headless.TLSOptions{DialContext: opts.NetDialContext})
|
||||
dialer.HandshakeTimeout = 10 * time.Second
|
||||
if opts.NetDialContext != nil {
|
||||
dialer.NetDialContext = opts.NetDialContext
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user