repair ack, refactor e2e tests
This commit is contained in:
1 parent
9e5357eaa8
commit
88a0b5f1b9
42 files changed
+1732
-792
No files matched your search
@@ -6,3 +6,6 @@ prebuilts/
|
||||
cookies*.json
|
||||
relay/relay
|
||||
whitelist-experiments/
|
||||
|
||||
headless/tests/stand/.context/
|
||||
headless/tests/.env
|
||||
@@ -50,10 +50,14 @@ Traffic goes through the platform's SFU, which is on the government whitelist. T
|
||||
- `headless/vk/` - Headless VK creator: creates or joins a call via the VK HTTP API, Pion DC/VP8 tunnel, no browser
|
||||
- `headless/telemost/` - Headless Telemost (Yandex) creator with the same model
|
||||
- `headless/wbstream/` - Headless WB Stream creator (LiveKit-backed, anonymous guest tokens)
|
||||
- `headless/dion/` - Headless DION creator with the same model
|
||||
- `headless/bitrix/` - Headless Bitrix creator (adaptive DC/VP8, guest join)
|
||||
- `headless/wbstream-joiner/` - Desktop WB Stream joiner (counterpart to the creator, used for tests and Linux clients)
|
||||
- `headless/telemost-joiner/` - Desktop Telemost joiner (counterpart to the creator, used for tests and Linux clients)
|
||||
- `headless/dion-joiner/` - Desktop DION joiner (counterpart to the creator, used for tests and Linux clients)
|
||||
- `headless/bitrix-joiner/` - Desktop Bitrix joiner (counterpart to the creator, used for tests and Linux clients)
|
||||
- `headless/vk-bot/` - Standalone VK Long Poll bot that spawns headless creators on demand and replies with the join link (server-side alternative to the Electron bot)
|
||||
- `headless/tests/` - End-to-end smoke tests for each platform
|
||||
- `headless/tests/` - Live end-to-end tests (creator + joiners over a real SFU); run same-host or in a Dockerized netns stand, see [headless/tests/README.md](headless/tests/README.md)
|
||||
- `android-app/` - Android joiner: VpnService + tun2socks + headless Pion (primary path); also retains a `WebView` fallback for the legacy browser flow
|
||||
- `ios-proxy-app/` - iOS joiner: SOCKS5 + headless Pion via the gomobile xcframework
|
||||
- `creator-app/` - Electron desktop creator app: GUI front-end that can run either the legacy browser path or spawn the headless Go binaries; suitable for both interactive use and deployments
|
||||
@@ -84,6 +88,8 @@ Three forms are available; pick whichever fits the device:
|
||||
- **Linux desktop** - run a headless joiner; it exposes a SOCKS5 proxy on the given port for whatever you point at it. Useful for servers and Linux clients. Optional `--socks-user` / `--socks-pass` enable SOCKS5 username/password auth.
|
||||
- WB Stream: `headless-wbstream-joiner --room <link> --socks-port 1080 [--socks-user u --socks-pass p]`
|
||||
- Telemost: `headless-telemost-joiner --tm-link <link> --socks-port 1080 [--socks-user u --socks-pass p]`
|
||||
- DION: `headless-dion-joiner --room <link> --socks-port 1080 [--socks-user u --socks-pass p]`
|
||||
- Bitrix: `headless-bitrix-joiner --link <link> --socks-port 1080 [--socks-user u --socks-pass p]`
|
||||
|
||||
The full step-by-step (Russian) covers each platform in detail: see [docs/SETUP.md](docs/SETUP.md).
|
||||
|
||||
@@ -168,16 +174,18 @@ Pure Go creators that create calls via API without a browser. No Electron, no JS
|
||||
./build-headless.sh
|
||||
```
|
||||
|
||||
Eight binaries are produced - four creators, three Linux joiners, and the VK bot:
|
||||
Ten binaries are produced - five creators, four Linux joiners, and the VK bot:
|
||||
|
||||
```sh
|
||||
./headless/vk/headless-vk-creator --cookies cookies-vk.json
|
||||
./headless/telemost/headless-telemost-creator --cookies cookies-yandex.json
|
||||
./headless/wbstream/headless-wbstream-creator --cookies cookies-wbstream.json
|
||||
./headless/dion/headless-dion-creator --cookies cookies-dion.json
|
||||
./headless/bitrix/headless-bitrix-creator --cookies cookies-bitrix.json
|
||||
./headless/wbstream-joiner/headless-wbstream-joiner --room <link> --socks-port 1080
|
||||
./headless/dion-joiner/headless-dion-joiner --room <link> --socks-port 1080
|
||||
./headless/telemost-joiner/headless-telemost-joiner --tm-link <link> --socks-port 1080
|
||||
./headless/bitrix-joiner/headless-bitrix-joiner --link <link> --socks-port 1080
|
||||
./headless/vk-bot/headless-vk-bot --token <t> --group-id <g> --bins-dir <dir>
|
||||
```
|
||||
|
||||
|
||||
@@ -17,9 +17,11 @@ vk:headless-vk-creator \
|
||||
telemost:headless-telemost-creator \
|
||||
wbstream:headless-wbstream-creator \
|
||||
dion:headless-dion-creator \
|
||||
bitrix:headless-bitrix-creator \
|
||||
telemost-joiner:headless-telemost-joiner \
|
||||
wbstream-joiner:headless-wbstream-joiner \
|
||||
dion-joiner:headless-dion-joiner \
|
||||
bitrix-joiner:headless-bitrix-joiner \
|
||||
vk-bot:headless-vk-bot"
|
||||
|
||||
build_target() {
|
||||
|
||||
+4
-1
@@ -26,8 +26,11 @@ go -C "$ROOT/headless/wbstream-joiner" build -trimpath -ldflags="-s -w" -o headl
|
||||
echo "Building headless-telemost-joiner..."
|
||||
go -C "$ROOT/headless/telemost-joiner" build -trimpath -ldflags="-s -w" -o headless-telemost-joiner .
|
||||
|
||||
echo "Building headless-bitrix-joiner..."
|
||||
go -C "$ROOT/headless/bitrix-joiner" build -trimpath -ldflags="-s -w" -o headless-bitrix-joiner .
|
||||
|
||||
echo "Building headless-vk-bot..."
|
||||
go -C "$ROOT/headless/vk-bot" build -trimpath -ldflags="-s -w" -o headless-vk-bot .
|
||||
|
||||
echo "Done."
|
||||
ls -lh "$ROOT/headless/vk/headless-vk-creator" "$ROOT/headless/telemost/headless-telemost-creator" "$ROOT/headless/wbstream/headless-wbstream-creator" "$ROOT/headless/dion/headless-dion-creator" "$ROOT/headless/bitrix/headless-bitrix-creator" "$ROOT/headless/dion-joiner/headless-dion-joiner" "$ROOT/headless/wbstream-joiner/headless-wbstream-joiner" "$ROOT/headless/telemost-joiner/headless-telemost-joiner" "$ROOT/headless/vk-bot/headless-vk-bot"
|
||||
ls -lh "$ROOT/headless/vk/headless-vk-creator" "$ROOT/headless/telemost/headless-telemost-creator" "$ROOT/headless/wbstream/headless-wbstream-creator" "$ROOT/headless/dion/headless-dion-creator" "$ROOT/headless/bitrix/headless-bitrix-creator" "$ROOT/headless/dion-joiner/headless-dion-joiner" "$ROOT/headless/wbstream-joiner/headless-wbstream-joiner" "$ROOT/headless/telemost-joiner/headless-telemost-joiner" "$ROOT/headless/bitrix-joiner/headless-bitrix-joiner" "$ROOT/headless/vk-bot/headless-vk-bot"
|
||||
+1
-1
@@ -365,7 +365,7 @@ docker compose pull && docker compose up -d
|
||||
| `UPSTREAM_USER` | нет | - | `--upstream-user` |
|
||||
| `UPSTREAM_PASS` | нет | - | `--upstream-pass` |
|
||||
|
||||
> `cookies-dion.json` и `cookies-bitrix.json` монтируются без `:ro`, в отличие от остальных трёх: DION выдаёт одноразовый refresh-токен, а Bitrix обновляет сессию по паролю, и creator перезаписывает файл при каждом обновлении. Контейнер работает под uid 999, поэтому оба файла на хосте должны принадлежать этому uid - иначе `/dion` или `/bitrix` упадёт с `save cookies failed: ... permission denied`. VK, Telemost и WB Stream куки только читают, их менять не нужно.
|
||||
> `cookies-dion.json`, `cookies-bitrix.json` и `cookies-wbstream.json` монтируются без `:ro` - creator перезаписывает их при обновлении токена, поэтому на хосте они должны принадлежать uid 999 (иначе `save cookies failed: permission denied`). VK и Telemost только читаются.
|
||||
|
||||
> Если WebRTC-туннель не доходит через сетевой бридж Docker (UDP может отбрасываться), добавьте в `docker-compose.yml` строку `network_mode: host` под сервисом `bot`.
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
module headless-bitrix-joiner
|
||||
|
||||
go 1.26.1
|
||||
|
||||
require whitelist-bypass/relay v0.0.0
|
||||
|
||||
require (
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/gorilla/websocket v1.5.3 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.6 // indirect
|
||||
github.com/klauspost/reedsolomon v1.12.0 // indirect
|
||||
github.com/pion/datachannel v1.6.0 // indirect
|
||||
github.com/pion/dtls/v3 v3.1.2 // indirect
|
||||
github.com/pion/ice/v4 v4.2.1 // indirect
|
||||
github.com/pion/interceptor v0.1.44 // indirect
|
||||
github.com/pion/logging v0.2.4 // indirect
|
||||
github.com/pion/mdns/v2 v2.1.0 // indirect
|
||||
github.com/pion/randutil v0.1.0 // indirect
|
||||
github.com/pion/rtcp v1.2.16 // indirect
|
||||
github.com/pion/rtp v1.10.1 // indirect
|
||||
github.com/pion/sctp v1.9.2 // indirect
|
||||
github.com/pion/sdp/v3 v3.0.18 // indirect
|
||||
github.com/pion/srtp/v3 v3.0.10 // indirect
|
||||
github.com/pion/stun/v3 v3.1.1 // indirect
|
||||
github.com/pion/transport/v4 v4.0.1 // indirect
|
||||
github.com/pion/turn/v4 v4.1.4 // indirect
|
||||
github.com/pion/webrtc/v4 v4.2.9 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/quic-go/qpack v0.6.0 // indirect
|
||||
github.com/quic-go/quic-go v0.60.0 // indirect
|
||||
github.com/tjfoc/gmsm v1.4.1 // indirect
|
||||
github.com/wlynxg/anet v0.0.5 // indirect
|
||||
github.com/xtaci/kcp-go/v5 v5.6.72 // indirect
|
||||
golang.org/x/crypto v0.51.0 // indirect
|
||||
golang.org/x/net v0.55.0 // indirect
|
||||
golang.org/x/sys v0.45.0 // indirect
|
||||
golang.org/x/text v0.37.0 // indirect
|
||||
golang.org/x/time v0.14.0 // indirect
|
||||
)
|
||||
|
||||
replace whitelist-bypass/relay => ../../relay
|
||||
@@ -0,0 +1,148 @@
|
||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
||||
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
||||
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
||||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
|
||||
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/klauspost/cpuid/v2 v2.2.6 h1:ndNyv040zDGIDh8thGkXYjnFtiN02M1PVVF+JE/48xc=
|
||||
github.com/klauspost/cpuid/v2 v2.2.6/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
|
||||
github.com/klauspost/reedsolomon v1.12.0 h1:I5FEp3xSwVCcEh3F5A7dofEfhXdF/bWhQWPH+XwBFno=
|
||||
github.com/klauspost/reedsolomon v1.12.0/go.mod h1:EPLZJeh4l27pUGC3aXOjheaoh1I9yut7xTURiW3LQ9Y=
|
||||
github.com/pion/datachannel v1.6.0 h1:XecBlj+cvsxhAMZWFfFcPyUaDZtd7IJvrXqlXD/53i0=
|
||||
github.com/pion/datachannel v1.6.0/go.mod h1:ur+wzYF8mWdC+Mkis5Thosk+u/VOL287apDNEbFpsIk=
|
||||
github.com/pion/dtls/v3 v3.1.2 h1:gqEdOUXLtCGW+afsBLO0LtDD8GnuBBjEy6HRtyofZTc=
|
||||
github.com/pion/dtls/v3 v3.1.2/go.mod h1:Hw/igcX4pdY69z1Hgv5x7wJFrUkdgHwAn/Q/uo7YHRo=
|
||||
github.com/pion/ice/v4 v4.2.1 h1:XPRYXaLiFq3LFDG7a7bMrmr3mFr27G/gtXN3v/TVfxY=
|
||||
github.com/pion/ice/v4 v4.2.1/go.mod h1:2quLV1S5v1tAx3VvAJaH//KGitRXvo4RKlX6D3tnN+c=
|
||||
github.com/pion/interceptor v0.1.44 h1:sNlZwM8dWXU9JQAkJh8xrarC0Etn8Oolcniukmuy0/I=
|
||||
github.com/pion/interceptor v0.1.44/go.mod h1:4atVlBkcgXuUP+ykQF0qOCGU2j7pQzX2ofvPRFsY5RY=
|
||||
github.com/pion/logging v0.2.4 h1:tTew+7cmQ+Mc1pTBLKH2puKsOvhm32dROumOZ655zB8=
|
||||
github.com/pion/logging v0.2.4/go.mod h1:DffhXTKYdNZU+KtJ5pyQDjvOAh/GsNSyv1lbkFbe3so=
|
||||
github.com/pion/mdns/v2 v2.1.0 h1:3IJ9+Xio6tWYjhN6WwuY142P/1jA0D5ERaIqawg/fOY=
|
||||
github.com/pion/mdns/v2 v2.1.0/go.mod h1:pcez23GdynwcfRU1977qKU0mDxSeucttSHbCSfFOd9A=
|
||||
github.com/pion/randutil v0.1.0 h1:CFG1UdESneORglEsnimhUjf33Rwjubwj6xfiOXBa3mA=
|
||||
github.com/pion/randutil v0.1.0/go.mod h1:XcJrSMMbbMRhASFVOlj/5hQial/Y8oH/HVo7TBZq+j8=
|
||||
github.com/pion/rtcp v1.2.16 h1:fk1B1dNW4hsI78XUCljZJlC4kZOPk67mNRuQ0fcEkSo=
|
||||
github.com/pion/rtcp v1.2.16/go.mod h1:/as7VKfYbs5NIb4h6muQ35kQF/J0ZVNz2Z3xKoCBYOo=
|
||||
github.com/pion/rtp v1.10.1 h1:xP1prZcCTUuhO2c83XtxyOHJteISg6o8iPsE2acaMtA=
|
||||
github.com/pion/rtp v1.10.1/go.mod h1:rF5nS1GqbR7H/TCpKwylzeq6yDM+MM6k+On5EgeThEM=
|
||||
github.com/pion/sctp v1.9.2 h1:HxsOzEV9pWoeggv7T5kewVkstFNcGvhMPx0GvUOUQXo=
|
||||
github.com/pion/sctp v1.9.2/go.mod h1:OTOlsQ5EDQ6mQ0z4MUGXt2CgQmKyafBEXhUVqLRB6G8=
|
||||
github.com/pion/sdp/v3 v3.0.18 h1:l0bAXazKHpepazVdp+tPYnrsy9dfh7ZbT8DxesH5ZnI=
|
||||
github.com/pion/sdp/v3 v3.0.18/go.mod h1:ZREGo6A9ZygQ9XkqAj5xYCQtQpif0i6Pa81HOiAdqQ8=
|
||||
github.com/pion/srtp/v3 v3.0.10 h1:tFirkpBb3XccP5VEXLi50GqXhv5SKPxqrdlhDCJlZrQ=
|
||||
github.com/pion/srtp/v3 v3.0.10/go.mod h1:3mOTIB0cq9qlbn59V4ozvv9ClW/BSEbRp4cY0VtaR7M=
|
||||
github.com/pion/stun/v3 v3.1.1 h1:CkQxveJ4xGQjulGSROXbXq94TAWu8gIX2dT+ePhUkqw=
|
||||
github.com/pion/stun/v3 v3.1.1/go.mod h1:qC1DfmcCTQjl9PBaMa5wSn3x9IPmKxSdcCsxBcDBndM=
|
||||
github.com/pion/transport/v3 v3.1.1 h1:Tr684+fnnKlhPceU+ICdrw6KKkTms+5qHMgw6bIkYOM=
|
||||
github.com/pion/transport/v3 v3.1.1/go.mod h1:+c2eewC5WJQHiAA46fkMMzoYZSuGzA/7E2FPrOYHctQ=
|
||||
github.com/pion/transport/v4 v4.0.1 h1:sdROELU6BZ63Ab7FrOLn13M6YdJLY20wldXW2Cu2k8o=
|
||||
github.com/pion/transport/v4 v4.0.1/go.mod h1:nEuEA4AD5lPdcIegQDpVLgNoDGreqM/YqmEx3ovP4jM=
|
||||
github.com/pion/turn/v4 v4.1.4 h1:EU11yMXKIsK43FhcUnjLlrhE4nboHZq+TXBIi3QpcxQ=
|
||||
github.com/pion/turn/v4 v4.1.4/go.mod h1:ES1DXVFKnOhuDkqn9hn5VJlSWmZPaRJLyBXoOeO/BmQ=
|
||||
github.com/pion/webrtc/v4 v4.2.9 h1:DZIh1HAhPIL3RvwEDFsmL5hfPSLEpxsQk9/Jir2vkJE=
|
||||
github.com/pion/webrtc/v4 v4.2.9/go.mod h1:9EmLZve0H76eTzf8v2FmchZ6tcBXtDgpfTEu+drW6SY=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/quic-go/go-ossfuzz-seeds v0.1.0 h1:APacT+iIaNF6fd8AGEiN3bT/Jtkd2jz4v4TzM7MFjy0=
|
||||
github.com/quic-go/go-ossfuzz-seeds v0.1.0/go.mod h1:3IOHRbJIc+L6YKMwfDtJAM9Vj9k0YY4muhuyUYk5tbk=
|
||||
github.com/quic-go/qpack v0.6.0 h1:g7W+BMYynC1LbYLSqRt8PBg5Tgwxn214ZZR34VIOjz8=
|
||||
github.com/quic-go/qpack v0.6.0/go.mod h1:lUpLKChi8njB4ty2bFLX2x4gzDqXwUpaO1DP9qMDZII=
|
||||
github.com/quic-go/quic-go v0.60.0 h1:xcQioE8OM66UQLeUMHltK1CCcOu3JbVB4JAQdDQSB+0=
|
||||
github.com/quic-go/quic-go v0.60.0/go.mod h1:wpKpjmPpftl30sL6pFh7REVpjbcCVy4zt2vDyK1TuJk=
|
||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||
github.com/tjfoc/gmsm v1.4.1 h1:aMe1GlZb+0bLjn+cKTPEvvn9oUEBlJitaZiiBwsbgho=
|
||||
github.com/tjfoc/gmsm v1.4.1/go.mod h1:j4INPkHWMrhJb38G+J6W4Tw0AbuN8Thu3PbdVYhVcTE=
|
||||
github.com/wlynxg/anet v0.0.5 h1:J3VJGi1gvo0JwZ/P1/Yc/8p63SoW98B5dHkYDmpgvvU=
|
||||
github.com/wlynxg/anet v0.0.5/go.mod h1:eay5PRQr7fIVAMbTbchTnO9gG65Hg/uYGdc7mguHxoA=
|
||||
github.com/xtaci/kcp-go/v5 v5.6.72 h1:FLaQPalgpufJYQRk0OK+gErEhXGLUPjv6FSRPrFR8Lk=
|
||||
github.com/xtaci/kcp-go/v5 v5.6.72/go.mod h1:9O3D8WR+cyyUjGiTILYfg17vn72otWuXK2AFfqIe6CM=
|
||||
github.com/xtaci/lossyconn v0.0.0-20190602105132-8df528c0c9ae h1:J0GxkO96kL4WF+AIT3M4mfUVinOCPgf2uUWYFUzN0sM=
|
||||
github.com/xtaci/lossyconn v0.0.0-20190602105132-8df528c0c9ae/go.mod h1:gXtu8J62kEgmN++bm9BVICuT/e8yiLI2KFobd/TRFsE=
|
||||
go.uber.org/mock v0.5.2 h1:LbtPTcP8A5k9WPXj54PPPbjcI4Y6lhyOZXn+VS7wNko=
|
||||
go.uber.org/mock v0.5.2/go.mod h1:wLlUxC2vVTPTaE3UD51E0BGOAElKrILxhVSDYQLld5o=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20201012173705-84dcc777aaee/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.51.0 h1:IBPXwPfKxY7cWQZ38ZCIRPI50YLeevDLlLnyC5wRGTI=
|
||||
golang.org/x/crypto v0.51.0/go.mod h1:8AdwkbraGNABw2kOX6YFPs3WM22XqI4EXEd8g+x7Oc8=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.55.0 h1:bcvxaJn3e1U6InsFWt1JUq1aSjnRxLzT2rtD2KfkDF8=
|
||||
golang.org/x/net v0.55.0/go.mod h1:L5U2KuzuOe1lY7Z+aWVIKK6qEeJXnXV9yzGA+WCHJww=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.45.0 h1:dO4czNzziLiiXplLQgBCEpCvXQ3dnkn0SdaZSYdQ+FY=
|
||||
golang.org/x/sys v0.45.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.37.0 h1:Cqjiwd9eSg8e0QAkyCaQTNHFIIzWtidPahFWR83rTrc=
|
||||
golang.org/x/text v0.37.0/go.mod h1:a5sjxXGs9hsn/AJVwuElvCAo9v8QYLzvavO5z2PiM38=
|
||||
golang.org/x/time v0.14.0 h1:MRx4UaLrDotUKUdCIqzPC48t1Y9hANFKIRpNx+Te8PI=
|
||||
golang.org/x/time v0.14.0/go.mod h1:eL/Oa2bBBK0TkX57Fyni+NgnyQQN4LitPmob2Hjnqw4=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
|
||||
google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
||||
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
@@ -0,0 +1,123 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
"os"
|
||||
"os/signal"
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"whitelist-bypass/relay/common"
|
||||
joiner "whitelist-bypass/relay/pion/headless-joiner-common"
|
||||
"whitelist-bypass/relay/tunnel"
|
||||
)
|
||||
|
||||
type cliStatusEmitter struct{}
|
||||
|
||||
func (cliStatusEmitter) EmitStatus(status string) { log.Printf("[status] %s", status) }
|
||||
func (cliStatusEmitter) EmitStatusError(msg string) { log.Printf("[status] ERROR: %s", msg) }
|
||||
|
||||
func resolveHostname(hostname string) (string, error) {
|
||||
if ip := net.ParseIP(hostname); ip != nil {
|
||||
return hostname, nil
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
if ips, err := net.DefaultResolver.LookupIP(ctx, "ip4", hostname); err == nil && len(ips) > 0 {
|
||||
return ips[0].String(), nil
|
||||
}
|
||||
if ips, err := net.DefaultResolver.LookupIP(ctx, "ip6", hostname); err == nil && len(ips) > 0 {
|
||||
return ips[0].String(), nil
|
||||
}
|
||||
return "", fmt.Errorf("no IPs for %s", hostname)
|
||||
}
|
||||
|
||||
func main() {
|
||||
common.MaybePrintVersion()
|
||||
link := flag.String("link", "", "Bitrix conference link https://portal/video/CODE (required)")
|
||||
displayName := flag.String("name", "Joiner", "display name in the conference")
|
||||
socksHost := flag.String("socks-host", common.SocksLocalhostIP, "SOCKS5 listen address (use 0.0.0.0 to expose on LAN)")
|
||||
socksPort := flag.Int("socks-port", 1080, "SOCKS5 listen port")
|
||||
socksUser := flag.String("socks-user", "", "SOCKS5 username (optional)")
|
||||
socksPass := flag.String("socks-pass", "", "SOCKS5 password (optional)")
|
||||
resources := flag.String("resources", "default", "resource mode: moderate, default, unlimited")
|
||||
tunnelMode := flag.String("tunnel-mode", "video", "tunnel mode: video, dc")
|
||||
vp8FPS := flag.Int("vp8-fps", 24, "VP8 frame rate (video mode only)")
|
||||
vp8Batch := flag.Int("vp8-batch", 30, "VP8 batch multiplier (video mode only)")
|
||||
dualTrack := flag.Bool("dual-track", false, "request a second screenshare download track for 2x recv throughput (video mode only)")
|
||||
reliable := flag.Bool("reliable", false, "wrap the video tunnel with KCP reliability (video mode only)")
|
||||
debugFlag := flag.Bool("debug", false, "verbose debug logging")
|
||||
flag.Parse()
|
||||
common.Debug = *debugFlag
|
||||
|
||||
if *link == "" {
|
||||
log.Fatal("--link is required")
|
||||
}
|
||||
|
||||
var memLimit int64
|
||||
switch *resources {
|
||||
case "moderate":
|
||||
memLimit = 64 << 20
|
||||
case "default":
|
||||
memLimit = 128 << 20
|
||||
case "unlimited":
|
||||
memLimit = 256 << 20
|
||||
default:
|
||||
log.Fatalf("[config] unknown resources mode: %s", *resources)
|
||||
}
|
||||
if memLimit > 0 {
|
||||
debug.SetMemoryLimit(memLimit)
|
||||
}
|
||||
|
||||
inner := joiner.NewBitrixHeadlessJoiner(log.Printf, resolveHostname, cliStatusEmitter{}, nil)
|
||||
inner.OnConnected = func(tun tunnel.DataTunnel) {
|
||||
readBuf := common.VP8BufSize
|
||||
switch tun.(type) {
|
||||
case *tunnel.DCTunnel, *tunnel.MultiTrackKCPTunnel:
|
||||
readBuf = common.DCBufSize
|
||||
}
|
||||
bridge := tunnel.NewRelayBridgeWithAuth(tun, "joiner", readBuf, log.Printf, *socksUser, *socksPass)
|
||||
bridge.SetOnConfigAck(inner.MarkConfigAcked)
|
||||
bridge.MarkReady()
|
||||
addr := fmt.Sprintf("%s:%d", *socksHost, *socksPort)
|
||||
go func() {
|
||||
if err := bridge.ListenSOCKS(addr); err != nil {
|
||||
log.Printf("socks listen: %v", err)
|
||||
}
|
||||
}()
|
||||
fmt.Printf("\n TUNNEL CONNECTED mode=%s\n socks5 -> %s\n\n", *tunnelMode, addr)
|
||||
}
|
||||
|
||||
params, _ := json.Marshal(struct {
|
||||
JoinLink string `json:"joinLink"`
|
||||
DisplayName string `json:"displayName"`
|
||||
TunnelMode string `json:"tunnelMode"`
|
||||
VP8FPS int `json:"vp8Fps"`
|
||||
VP8Batch int `json:"vp8Batch"`
|
||||
Reliable bool `json:"reliable"`
|
||||
DualTrack bool `json:"dualTrack"`
|
||||
}{
|
||||
JoinLink: strings.TrimSpace(*link),
|
||||
DisplayName: *displayName,
|
||||
TunnelMode: *tunnelMode,
|
||||
VP8FPS: *vp8FPS,
|
||||
VP8Batch: *vp8Batch,
|
||||
Reliable: *reliable,
|
||||
DualTrack: *dualTrack,
|
||||
})
|
||||
|
||||
go inner.RunWithParams(string(params))
|
||||
|
||||
sig := make(chan os.Signal, 1)
|
||||
signal.Notify(sig, os.Interrupt, syscall.SIGTERM)
|
||||
<-sig
|
||||
log.Printf("[main] shutting down")
|
||||
inner.Close()
|
||||
}
|
||||
@@ -160,6 +160,30 @@ func main() {
|
||||
}
|
||||
defer sig.Close()
|
||||
|
||||
selfID, sidErr := c.SelfUserID()
|
||||
if sidErr != nil {
|
||||
log.Printf("[bx] self user id unavailable, kick disabled: %v", sidErr)
|
||||
}
|
||||
if selfID != "" {
|
||||
if pc, perr := c.PullConfig(); perr != nil {
|
||||
log.Printf("[bx] pull config failed, kick disabled: %v", perr)
|
||||
} else {
|
||||
km := bitrix.NewKickManager(c.KickUser, selfID, log.Printf)
|
||||
pull := bitrix.NewPullClient(pc, userAgent, portal, log.Printf)
|
||||
pull.SetOnUsersAnswered(func(ids []string) {
|
||||
for _, id := range ids {
|
||||
km.OnUserJoined(id)
|
||||
}
|
||||
})
|
||||
defer pull.Close()
|
||||
go func() {
|
||||
if err := pull.Run(); err != nil {
|
||||
log.Printf("[bx] subws2 pull ended: %v", err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
ms, err := bitrix.NewMediaSession(bitrix.MediaParams{
|
||||
Signal: sig,
|
||||
Alias: alias,
|
||||
|
||||
@@ -14,7 +14,7 @@ services:
|
||||
# don't use, or remove the corresponding line.
|
||||
- ./cookies-vk.json:/data/cookies-vk.json:ro
|
||||
- ./cookies-yandex.json:/data/cookies-yandex.json:ro
|
||||
- ./cookies-wbstream.json:/data/cookies-wbstream.json:ro
|
||||
- ./cookies-wbstream.json:/data/cookies-wbstream.json
|
||||
- ./cookies-dion.json:/data/cookies-dion.json
|
||||
- ./cookies-bitrix.json:/data/cookies-bitrix.json
|
||||
# Per-session creator logs persist here.
|
||||
|
||||
@@ -986,6 +986,11 @@ func main() {
|
||||
cookieStr = strings.TrimSpace(line)
|
||||
}
|
||||
|
||||
if common.CookieValue(cookieStr, "Session_id") == "" {
|
||||
common.EmitAuthError(common.AuthErrorSessionExpired)
|
||||
log.Fatalf("[auth] cookies missing Session_id; log into Yandex and re-export via creator-app's 'Export Cookies' button")
|
||||
}
|
||||
|
||||
log.Println("[config] Fetching live config from Telemost bundle...")
|
||||
cfg, err := fetchConfig()
|
||||
if err != nil {
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
# e2e room reuse. Copy to .env and fill with existing conference links.
|
||||
# Empty room = platform is SKIPPED (harness refuses to create a new call).
|
||||
# To allow creating fresh rooms per run, set ALLOW_NEW_ROOMS=1.
|
||||
|
||||
ROOM_TELEMOST=""
|
||||
ROOM_WBSTREAM=""
|
||||
ROOM_DION=""
|
||||
ROOM_BITRIX=""
|
||||
|
||||
ALLOW_NEW_ROOMS=0
|
||||
@@ -0,0 +1,77 @@
|
||||
# headless e2e tests
|
||||
|
||||
End-to-end tests for the headless creators and joiners.
|
||||
|
||||
Each run starts one creator per platform and keeps it running. Joiners then
|
||||
connect to that creator one at a time, using different parameters. This tests how
|
||||
the creator adapts when joiner parameters change.
|
||||
|
||||
Each test sends a unique string through the joiner's SOCKS5 proxy, over the
|
||||
tunnel, to a listener on the creator side. The test passes if the string arrives.
|
||||
No external network is used.
|
||||
|
||||
## Platforms and scenarios
|
||||
|
||||
Platforms: telemost, wbstream, dion, bitrix. VK is not supported because it has no
|
||||
headless SOCKS joiner. A platform skips the scenarios it does not support. For
|
||||
example, dion supports only connect and kick.
|
||||
|
||||
| Scenario | Joiner |
|
||||
|----------|--------|
|
||||
| connect | Default video tunnel. |
|
||||
| dc | `--tunnel-mode dc`. |
|
||||
| kcp | `--reliable` (KCP). |
|
||||
| dual | `--dual-track`. |
|
||||
| kick | Two joiners. The first is expected to be kicked. |
|
||||
|
||||
## Rooms
|
||||
|
||||
Copy `.env.example` to `.env`. Set `ROOM_<PLATFORM>` to an existing conference link
|
||||
for each platform you want to test.
|
||||
|
||||
If a room is empty, the harness skips that platform. It does not create a new
|
||||
conference. To create new conferences, set `ALLOW_NEW_ROOMS=1`.
|
||||
|
||||
## Cookies
|
||||
|
||||
Each platform reads `cookies-<platform>.json` from the repository root. Export
|
||||
these from the desktop creator app. If a cookie file is missing, the harness skips
|
||||
that platform.
|
||||
|
||||
## Run in Docker
|
||||
|
||||
The creator and joiner run in separate network namespaces so their WebRTC ICE does
|
||||
not collide. This requires Docker.
|
||||
|
||||
cd headless/tests/stand
|
||||
./stand.sh build
|
||||
./stand.sh run
|
||||
./stand.sh run bitrix dc kick
|
||||
./stand.sh sh
|
||||
|
||||
`build` cross-compiles the Linux binaries and builds the image. `run` runs the
|
||||
tests; with no arguments it runs every supported platform and scenario. `run`
|
||||
mounts the cookie files from the repository root, so refreshed tokens are written
|
||||
back to them. `sh` opens a shell in the container.
|
||||
|
||||
## Run on the host
|
||||
|
||||
./build-headless.sh
|
||||
./headless/tests/run.sh
|
||||
./headless/tests/run.sh bitrix
|
||||
|
||||
Run `build-headless.sh` from the repository root first. Same-host WebRTC video can
|
||||
fail because the creator and joiner share an IP address. Use the Docker method for
|
||||
the video scenarios.
|
||||
|
||||
## Environment variables
|
||||
|
||||
| Variable | Description |
|
||||
|----------|-------------|
|
||||
| `FAIL_FAST` | Stop at the first failure. Default `1`. Set to `0` to run all tests. |
|
||||
| `CREATE_TIMEOUT` | Seconds to wait for the creator to start. |
|
||||
| `CONNECT_TIMEOUT` | Seconds to wait for a joiner's SOCKS port. |
|
||||
| `PROBE_TIMEOUT` | Seconds to wait for tunnel traffic. |
|
||||
| `KICK_TIMEOUT` | Seconds to wait for a kick to take effect. |
|
||||
| `PORT_BASE` | First local port to allocate. |
|
||||
| `COOKIES_DIR` | Directory that holds the cookie files. |
|
||||
@@ -0,0 +1,182 @@
|
||||
set -u
|
||||
|
||||
PASS_N=0
|
||||
FAIL_N=0
|
||||
SKIP_N=0
|
||||
RESULTS=""
|
||||
FAIL_FAST="${FAIL_FAST:-1}"
|
||||
ABORT_RUN=0
|
||||
CHILD_PIDS=""
|
||||
JOINER_PIDS=""
|
||||
SINK_PID=""
|
||||
SINK_PORT=""
|
||||
SINK_FILE=""
|
||||
SINK_WRAP="${SINK_WRAP:-}"
|
||||
SINK_BIND="${SINK_BIND:-127.0.0.1}"
|
||||
SINK_TARGET="${SINK_TARGET:-127.0.0.1}"
|
||||
PROBE_HOST="${PROBE_HOST:-127.0.0.1}"
|
||||
PORT_CURSOR="${PORT_BASE:-21080}"
|
||||
|
||||
PROBE_CAP=""
|
||||
if command -v timeout >/dev/null 2>&1; then
|
||||
PROBE_CAP="timeout 5"
|
||||
elif command -v gtimeout >/dev/null 2>&1; then
|
||||
PROBE_CAP="gtimeout 5"
|
||||
fi
|
||||
ALLOC_PORT=""
|
||||
PROBE_SEQ=0
|
||||
|
||||
log() { printf '%s\n' "$*" >&2; }
|
||||
|
||||
die() {
|
||||
log "FATAL: $*"
|
||||
exit 2
|
||||
}
|
||||
|
||||
require_bin() {
|
||||
[ -x "$1" ] || die "missing binary $1 (run ./build-headless.sh)"
|
||||
}
|
||||
|
||||
require_cmd() {
|
||||
command -v "$1" >/dev/null 2>&1 || die "missing command $1"
|
||||
}
|
||||
|
||||
track_pid() { CHILD_PIDS="$CHILD_PIDS $1"; }
|
||||
|
||||
proc_alive() { kill -0 "$1" 2>/dev/null; }
|
||||
|
||||
track_joiner() { JOINER_PIDS="$JOINER_PIDS $1"; }
|
||||
|
||||
alloc_port() {
|
||||
while nc -z 127.0.0.1 "$PORT_CURSOR" 2>/dev/null; do
|
||||
PORT_CURSOR=$((PORT_CURSOR + 1))
|
||||
done
|
||||
ALLOC_PORT="$PORT_CURSOR"
|
||||
PORT_CURSOR=$((PORT_CURSOR + 1))
|
||||
}
|
||||
|
||||
start_sink() {
|
||||
alloc_port
|
||||
SINK_PORT="$ALLOC_PORT"
|
||||
SINK_FILE=$(mktemp -t e2e-sink.XXXXXX)
|
||||
$SINK_WRAP ncat -l -k "$SINK_BIND" "$SINK_PORT" >"$SINK_FILE" 2>/dev/null &
|
||||
SINK_PID=$!
|
||||
track_pid "$SINK_PID"
|
||||
sleep 1
|
||||
}
|
||||
|
||||
stop_sink() {
|
||||
[ -n "$SINK_PID" ] && kill "$SINK_PID" 2>/dev/null
|
||||
SINK_PID=""
|
||||
}
|
||||
|
||||
kill_joiners() {
|
||||
for _p in $JOINER_PIDS; do kill "$_p" 2>/dev/null; done
|
||||
for _p in $JOINER_PIDS; do wait "$_p" 2>/dev/null; done
|
||||
JOINER_PIDS=""
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
stop_sink
|
||||
for _p in $CHILD_PIDS; do kill "$_p" 2>/dev/null; done
|
||||
wait 2>/dev/null
|
||||
}
|
||||
|
||||
now() { date +%s; }
|
||||
|
||||
wait_join_link() {
|
||||
_lf="$1"
|
||||
_to="$2"
|
||||
_pid="${3:-}"
|
||||
_end=$(($(now) + _to))
|
||||
while [ "$(now)" -lt "$_end" ]; do
|
||||
_l=$(grep -m1 "join_link:" "$_lf" 2>/dev/null | sed 's/.*join_link:[[:space:]]*//')
|
||||
if [ -n "$_l" ]; then
|
||||
echo "$_l"
|
||||
return 0
|
||||
fi
|
||||
if [ -n "$_pid" ] && ! proc_alive "$_pid"; then
|
||||
return 1
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
wait_log_re() {
|
||||
_lf="$1"
|
||||
_re="$2"
|
||||
_to="$3"
|
||||
_pid="${4:-}"
|
||||
_end=$(($(now) + _to))
|
||||
while [ "$(now)" -lt "$_end" ]; do
|
||||
grep -qE "$_re" "$_lf" 2>/dev/null && return 0
|
||||
if [ -n "$_pid" ] && ! proc_alive "$_pid"; then
|
||||
return 1
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
wait_socks() {
|
||||
_port="$1"
|
||||
_to="$2"
|
||||
_end=$(($(now) + _to))
|
||||
while [ "$(now)" -lt "$_end" ]; do
|
||||
nc -z "$PROBE_HOST" "$_port" 2>/dev/null && return 0
|
||||
sleep 1
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
probe_once() {
|
||||
_sp="$1"
|
||||
_nonce="ping-$_sp-$PROBE_SEQ"
|
||||
PROBE_SEQ=$((PROBE_SEQ + 1))
|
||||
printf '%s\n' "$_nonce" | $PROBE_CAP ncat --send-only -w 4 --proxy "$PROBE_HOST:$_sp" --proxy-type socks5 "$SINK_TARGET" "$SINK_PORT" >/dev/null 2>&1
|
||||
sleep 1
|
||||
grep -q "$_nonce" "$SINK_FILE" 2>/dev/null
|
||||
}
|
||||
|
||||
probe_ready() {
|
||||
_sp="$1"
|
||||
_to="$2"
|
||||
_end=$(($(now) + _to))
|
||||
while [ "$(now)" -lt "$_end" ]; do
|
||||
probe_once "$_sp" && return 0
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
probe_dies() {
|
||||
_sp="$1"
|
||||
_to="$2"
|
||||
_end=$(($(now) + _to))
|
||||
while [ "$(now)" -lt "$_end" ]; do
|
||||
probe_once "$_sp" || return 0
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
record() {
|
||||
case "$1" in
|
||||
PASS) PASS_N=$((PASS_N + 1)) ;;
|
||||
FAIL)
|
||||
FAIL_N=$((FAIL_N + 1))
|
||||
[ "$FAIL_FAST" = "1" ] && ABORT_RUN=1
|
||||
;;
|
||||
SKIP) SKIP_N=$((SKIP_N + 1)) ;;
|
||||
esac
|
||||
RESULTS="$RESULTS
|
||||
$1 $2"
|
||||
}
|
||||
|
||||
summary() {
|
||||
log ""
|
||||
log "=== summary ==="
|
||||
printf '%s\n' "$RESULTS" | sed '/^[[:space:]]*$/d' >&2
|
||||
log ""
|
||||
log "passed=$PASS_N failed=$FAIL_N skipped=$SKIP_N"
|
||||
[ "$FAIL_N" -eq 0 ]
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
set -u
|
||||
|
||||
cookies_path() {
|
||||
_p="$1"
|
||||
case "$_p" in
|
||||
telemost) _f="cookies-yandex.json" ;;
|
||||
wbstream) _f="cookies-wbstream.json" ;;
|
||||
dion) _f="cookies-dion.json" ;;
|
||||
bitrix) _f="cookies-bitrix.json" ;;
|
||||
*) _f="cookies-$_p.json" ;;
|
||||
esac
|
||||
_envname=$(printf 'COOKIES_%s' "$(echo "$_p" | tr 'a-z' 'A-Z')")
|
||||
eval "_override=\${$_envname:-}"
|
||||
if [ -n "$_override" ]; then
|
||||
echo "$_override"
|
||||
else
|
||||
echo "${COOKIES_DIR:-$E2E_ROOT}/$_f"
|
||||
fi
|
||||
}
|
||||
|
||||
room_value() {
|
||||
_envname=$(printf 'ROOM_%s' "$(echo "$1" | tr 'a-z' 'A-Z')")
|
||||
eval "_v=\${$_envname:-}"
|
||||
echo "$_v"
|
||||
}
|
||||
|
||||
pf_select() {
|
||||
PF_NAME="$1"
|
||||
case "$1" in
|
||||
telemost)
|
||||
PF_CREATOR="$HEADLESS/telemost/headless-telemost-creator"
|
||||
PF_JOINER="$HEADLESS/telemost-joiner/headless-telemost-joiner"
|
||||
PF_LINK_FLAG="--tm-link"
|
||||
PF_CREATOR_ROOM_FLAG="--tm-link"
|
||||
PF_READY_RE="\[tm-ws\] Connected"
|
||||
PF_CAPS="connect kcp dual kick"
|
||||
;;
|
||||
wbstream)
|
||||
PF_CREATOR="$HEADLESS/wbstream/headless-wbstream-creator"
|
||||
PF_JOINER="$HEADLESS/wbstream-joiner/headless-wbstream-joiner"
|
||||
PF_LINK_FLAG="--room"
|
||||
PF_CREATOR_ROOM_FLAG="--room"
|
||||
PF_READY_RE="pub PC state: connected"
|
||||
PF_CAPS="connect dc kcp dual kick"
|
||||
;;
|
||||
dion)
|
||||
PF_CREATOR="$HEADLESS/dion/headless-dion-creator"
|
||||
PF_JOINER="$HEADLESS/dion-joiner/headless-dion-joiner"
|
||||
PF_LINK_FLAG="--room"
|
||||
PF_CREATOR_ROOM_FLAG="--room"
|
||||
PF_READY_RE="\[ice\] connected"
|
||||
PF_CAPS="connect kick"
|
||||
;;
|
||||
bitrix)
|
||||
PF_CREATOR="$HEADLESS/bitrix/headless-bitrix-creator"
|
||||
PF_JOINER="$HEADLESS/bitrix-joiner/headless-bitrix-joiner"
|
||||
PF_LINK_FLAG="--link"
|
||||
PF_CREATOR_ROOM_FLAG="--room"
|
||||
PF_READY_RE="pub PC state: connected"
|
||||
PF_CAPS="connect dc kcp dual kick"
|
||||
;;
|
||||
*)
|
||||
die "unknown platform: $1"
|
||||
;;
|
||||
esac
|
||||
PF_COOKIES=$(cookies_path "$1")
|
||||
PF_ROOM=$(room_value "$1")
|
||||
}
|
||||
|
||||
pf_variant_flags() {
|
||||
case "$1" in
|
||||
dc) echo "--tunnel-mode dc" ;;
|
||||
kcp) echo "--reliable" ;;
|
||||
dual) echo "--dual-track" ;;
|
||||
*) echo "" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
pf_has_cap() {
|
||||
for _c in $PF_CAPS; do
|
||||
[ "$_c" = "$1" ] && return 0
|
||||
done
|
||||
return 1
|
||||
}
|
||||
Executable
+92
@@ -0,0 +1,92 @@
|
||||
#!/bin/sh
|
||||
set -u
|
||||
|
||||
DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
E2E_ROOT="$(cd "$DIR/../.." && pwd)"
|
||||
HEADLESS="$E2E_ROOT/headless"
|
||||
|
||||
[ -f "$DIR/.env" ] && . "$DIR/.env"
|
||||
|
||||
. "$DIR/lib.sh"
|
||||
. "$DIR/platforms.sh"
|
||||
. "$DIR/scenarios.sh"
|
||||
|
||||
CREATE_TIMEOUT="${CREATE_TIMEOUT:-45}"
|
||||
CONNECT_TIMEOUT="${CONNECT_TIMEOUT:-45}"
|
||||
PROBE_TIMEOUT="${PROBE_TIMEOUT:-20}"
|
||||
KICK_TIMEOUT="${KICK_TIMEOUT:-30}"
|
||||
|
||||
ALL_PLATFORMS="telemost wbstream dion bitrix"
|
||||
ALL_SCENARIOS="connect dc kcp dual kick"
|
||||
|
||||
usage() {
|
||||
cat >&2 <<EOF
|
||||
Usage: $0 [platform...] [scenario...]
|
||||
|
||||
Live end-to-end harness: brings up a headless creator, connects one or more
|
||||
headless joiners, and proves each tunnel by echoing a nonce through the joiner's
|
||||
SOCKS5 to a local sink (no external network, no rate limits).
|
||||
|
||||
Platforms: $ALL_PLATFORMS
|
||||
Scenarios: $ALL_SCENARIOS
|
||||
connect one joiner, default video tunnel
|
||||
dc one joiner, --tunnel-mode dc
|
||||
kcp one joiner, --reliable (KCP)
|
||||
dual one joiner, --dual-track
|
||||
kick two joiners on one room, expect the first to be kicked
|
||||
|
||||
No args runs every applicable scenario on every platform. Unsupported
|
||||
platform/scenario pairs are skipped.
|
||||
|
||||
Cookies: COOKIES_DIR (default repo root) holds cookies-<platform>.json, or set
|
||||
COOKIES_<PLATFORM> to a explicit path. Missing cookies skip that platform.
|
||||
|
||||
Env: CREATE_TIMEOUT CONNECT_TIMEOUT PROBE_TIMEOUT KICK_TIMEOUT PORT_BASE
|
||||
|
||||
Examples:
|
||||
$0
|
||||
$0 bitrix
|
||||
$0 wbstream dc kick
|
||||
EOF
|
||||
}
|
||||
|
||||
RUN_PLATFORMS=""
|
||||
RUN_SCENARIOS=""
|
||||
|
||||
for _arg in "$@"; do
|
||||
case "$_arg" in
|
||||
-h | --help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
telemost | wbstream | dion | bitrix)
|
||||
RUN_PLATFORMS="$RUN_PLATFORMS $_arg"
|
||||
;;
|
||||
connect | dc | kcp | dual | kick)
|
||||
RUN_SCENARIOS="$RUN_SCENARIOS $_arg"
|
||||
;;
|
||||
*)
|
||||
log "unknown argument: $_arg"
|
||||
usage
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
[ -n "$RUN_PLATFORMS" ] || RUN_PLATFORMS="$ALL_PLATFORMS"
|
||||
[ -n "$RUN_SCENARIOS" ] || RUN_SCENARIOS="$ALL_SCENARIOS"
|
||||
|
||||
require_cmd nc
|
||||
require_cmd ncat
|
||||
|
||||
trap cleanup EXIT INT TERM
|
||||
|
||||
start_sink
|
||||
log "sink on 127.0.0.1:$SINK_PORT"
|
||||
|
||||
for _pf in $RUN_PLATFORMS; do
|
||||
run_platform "$_pf"
|
||||
[ "$ABORT_RUN" = "1" ] && break
|
||||
done
|
||||
|
||||
summary
|
||||
@@ -0,0 +1,188 @@
|
||||
set -u
|
||||
|
||||
CREATOR_WRAP="${CREATOR_WRAP:-}"
|
||||
JOINER_WRAP="${JOINER_WRAP:-}"
|
||||
JOINER_SOCKS_HOST="${JOINER_SOCKS_HOST:-127.0.0.1}"
|
||||
|
||||
run_platform() {
|
||||
pf_select "$1"
|
||||
require_bin "$PF_CREATOR"
|
||||
require_bin "$PF_JOINER"
|
||||
if [ ! -f "$PF_COOKIES" ]; then
|
||||
log "=== $1 SKIP (cookies not found at $PF_COOKIES) ==="
|
||||
record SKIP "$1 (cookies missing)"
|
||||
return
|
||||
fi
|
||||
if [ -z "$PF_ROOM" ] && [ "${ALLOW_NEW_ROOMS:-0}" != "1" ]; then
|
||||
log "=== $1 SKIP (no ROOM_$(echo "$1" | tr 'a-z' 'A-Z') set; refusing to create a new room. Set it in .env or pass ALLOW_NEW_ROOMS=1) ==="
|
||||
record SKIP "$1 (no room)"
|
||||
return
|
||||
fi
|
||||
if ! start_creator; then
|
||||
record FAIL "$1 (creator)"
|
||||
return
|
||||
fi
|
||||
for _s in $RUN_SCENARIOS; do
|
||||
if ! proc_alive "$CREATOR_PID"; then
|
||||
log "=== $1 ABORT: creator died mid-run ==="
|
||||
record FAIL "$1 (creator died)"
|
||||
break
|
||||
fi
|
||||
case "$_s" in
|
||||
connect) sc_connect ;;
|
||||
dc) sc_params dc ;;
|
||||
kcp) sc_params kcp ;;
|
||||
dual) sc_params dual ;;
|
||||
kick) sc_kick ;;
|
||||
esac
|
||||
kill_joiners
|
||||
[ "$ABORT_RUN" = "1" ] && {
|
||||
log "=== $1 ABORT: scenario failed (fail-fast); stopping ==="
|
||||
break
|
||||
}
|
||||
sleep 1
|
||||
done
|
||||
stop_creator
|
||||
}
|
||||
|
||||
start_creator() {
|
||||
CREATOR_LOG=$(mktemp -t e2e-creator.XXXXXX)
|
||||
_room_args=""
|
||||
if [ -n "$PF_ROOM" ]; then
|
||||
_room_args="$PF_CREATOR_ROOM_FLAG $PF_ROOM"
|
||||
log " reusing room: $PF_ROOM"
|
||||
fi
|
||||
$CREATOR_WRAP "$PF_CREATOR" --cookies "$PF_COOKIES" $_room_args --allow-private-dst >"$CREATOR_LOG" 2>&1 &
|
||||
CREATOR_PID=$!
|
||||
track_pid "$CREATOR_PID"
|
||||
if ! JOIN_LINK=$(wait_join_link "$CREATOR_LOG" "$CREATE_TIMEOUT" "$CREATOR_PID"); then
|
||||
if proc_alive "$CREATOR_PID"; then
|
||||
log " creator did not print join_link in ${CREATE_TIMEOUT}s"
|
||||
else
|
||||
log " creator exited before join_link (fatal)"
|
||||
fi
|
||||
tail -15 "$CREATOR_LOG" >&2
|
||||
return 1
|
||||
fi
|
||||
log " join_link=$JOIN_LINK"
|
||||
if ! wait_log_re "$CREATOR_LOG" "$PF_READY_RE" "$CREATE_TIMEOUT" "$CREATOR_PID"; then
|
||||
if proc_alive "$CREATOR_PID"; then
|
||||
log " creator did not reach ready state ($PF_READY_RE) in ${CREATE_TIMEOUT}s"
|
||||
else
|
||||
log " creator exited before ready state (fatal)"
|
||||
fi
|
||||
tail -15 "$CREATOR_LOG" >&2
|
||||
return 1
|
||||
fi
|
||||
log " creator up on SFU, room stays for all scenarios"
|
||||
sleep 1
|
||||
return 0
|
||||
}
|
||||
|
||||
stop_creator() {
|
||||
[ -n "${CREATOR_PID:-}" ] && kill "$CREATOR_PID" 2>/dev/null
|
||||
CREATOR_PID=""
|
||||
}
|
||||
|
||||
dump_logs() {
|
||||
log " --- creator tail ---"
|
||||
tail -20 "$CREATOR_LOG" >&2
|
||||
log " --- joiner tail ---"
|
||||
tail -20 "$JOINER_LOG" >&2
|
||||
}
|
||||
|
||||
dump_kick_logs() {
|
||||
log " --- creator kick events ---"
|
||||
grep -nE '\[kick\]|kicked previous|active call guest|kick failed|usersAnswered|kicked stale peer|kick_one' "$CREATOR_LOG" 2>/dev/null | tail -20 >&2
|
||||
log " --- joiner A kick-watch ---"
|
||||
grep -nE 'subws2|pull config|kick-detect|kicked from|shutting down|chatUserLeave|you_kicked|server kicked' "$_log_a" 2>/dev/null | tail -20 >&2
|
||||
}
|
||||
|
||||
start_joiner() {
|
||||
_variant="$1"
|
||||
alloc_port
|
||||
JOINER_PORT="$ALLOC_PORT"
|
||||
JOINER_LOG=$(mktemp -t e2e-joiner.XXXXXX)
|
||||
_flags=$(pf_variant_flags "$_variant")
|
||||
$JOINER_WRAP "$PF_JOINER" "$PF_LINK_FLAG" "$JOIN_LINK" --socks-host "$JOINER_SOCKS_HOST" --socks-port "$JOINER_PORT" $_flags >"$JOINER_LOG" 2>&1 &
|
||||
JOINER_PID=$!
|
||||
track_pid "$JOINER_PID"
|
||||
track_joiner "$JOINER_PID"
|
||||
}
|
||||
|
||||
joiner_up() {
|
||||
wait_socks "$1" "$CONNECT_TIMEOUT" && probe_ready "$1" "$PROBE_TIMEOUT"
|
||||
}
|
||||
|
||||
sc_connect() {
|
||||
_name="$PF_NAME/connect"
|
||||
log "=== $_name ==="
|
||||
start_joiner connect
|
||||
if joiner_up "$JOINER_PORT"; then
|
||||
record PASS "$_name"
|
||||
else
|
||||
log " joiner did not carry traffic"
|
||||
dump_logs
|
||||
record FAIL "$_name"
|
||||
fi
|
||||
}
|
||||
|
||||
sc_params() {
|
||||
_variant="$1"
|
||||
_name="$PF_NAME/params:$_variant"
|
||||
if ! pf_has_cap "$_variant"; then
|
||||
log "=== $_name SKIP (unsupported) ==="
|
||||
record SKIP "$_name"
|
||||
return
|
||||
fi
|
||||
log "=== $_name ==="
|
||||
start_joiner "$_variant"
|
||||
if joiner_up "$JOINER_PORT"; then
|
||||
record PASS "$_name"
|
||||
else
|
||||
log " joiner did not carry traffic"
|
||||
dump_logs
|
||||
record FAIL "$_name"
|
||||
fi
|
||||
}
|
||||
|
||||
sc_kick() {
|
||||
_name="$PF_NAME/kick"
|
||||
if ! pf_has_cap kick; then
|
||||
log "=== $_name SKIP ==="
|
||||
record SKIP "$_name"
|
||||
return
|
||||
fi
|
||||
log "=== $_name ==="
|
||||
_kv=connect
|
||||
pf_has_cap dc && _kv=dc
|
||||
start_joiner "$_kv"
|
||||
_port_a="$JOINER_PORT"
|
||||
_log_a="$JOINER_LOG"
|
||||
if ! joiner_up "$_port_a"; then
|
||||
log " joiner A never carried traffic; tail:"
|
||||
tail -15 "$_log_a" >&2
|
||||
dump_kick_logs
|
||||
record FAIL "$_name (A up)"
|
||||
return
|
||||
fi
|
||||
log " joiner A up on $_port_a, joining second joiner"
|
||||
start_joiner "$_kv"
|
||||
_port_b="$JOINER_PORT"
|
||||
_log_b="$JOINER_LOG"
|
||||
if ! joiner_up "$_port_b"; then
|
||||
log " joiner B never carried traffic; tail:"
|
||||
tail -15 "$_log_b" >&2
|
||||
dump_kick_logs
|
||||
record FAIL "$_name (B up)"
|
||||
return
|
||||
fi
|
||||
log " joiner B up on $_port_b, expecting A to be kicked"
|
||||
if probe_dies "$_port_a" "$KICK_TIMEOUT" && probe_once "$_port_b"; then
|
||||
record PASS "$_name"
|
||||
else
|
||||
log " expected A kicked while B holds the tunnel"
|
||||
dump_kick_logs
|
||||
record FAIL "$_name"
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
FROM debian:bookworm-slim
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
iproute2 iptables ncat ca-certificates procps \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY work /work
|
||||
RUN chmod +x /work/headless/*/headless-* \
|
||||
/work/headless/tests/*.sh \
|
||||
/work/headless/tests/stand/*.sh
|
||||
|
||||
CMD ["sleep", "infinity"]
|
||||
Executable
+68
@@ -0,0 +1,68 @@
|
||||
#!/bin/sh
|
||||
set -u
|
||||
|
||||
DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
E2E_ROOT="${E2E_ROOT:-/work}"
|
||||
HEADLESS="$E2E_ROOT/headless"
|
||||
E2E_DIR="$HEADLESS/tests"
|
||||
|
||||
[ -f "$E2E_DIR/.env" ] && . "$E2E_DIR/.env"
|
||||
|
||||
. "$E2E_DIR/lib.sh"
|
||||
. "$E2E_DIR/platforms.sh"
|
||||
. "$E2E_DIR/scenarios.sh"
|
||||
. "$DIR/netns.sh"
|
||||
|
||||
CREATE_TIMEOUT="${CREATE_TIMEOUT:-45}"
|
||||
CONNECT_TIMEOUT="${CONNECT_TIMEOUT:-45}"
|
||||
PROBE_TIMEOUT="${PROBE_TIMEOUT:-25}"
|
||||
KICK_TIMEOUT="${KICK_TIMEOUT:-30}"
|
||||
|
||||
ALL_PLATFORMS="telemost wbstream dion bitrix"
|
||||
ALL_SCENARIOS="connect dc kcp dual kick"
|
||||
|
||||
RUN_PLATFORMS=""
|
||||
RUN_SCENARIOS=""
|
||||
for _arg in "$@"; do
|
||||
case "$_arg" in
|
||||
telemost | wbstream | dion | bitrix) RUN_PLATFORMS="$RUN_PLATFORMS $_arg" ;;
|
||||
connect | dc | kcp | dual | kick) RUN_SCENARIOS="$RUN_SCENARIOS $_arg" ;;
|
||||
*)
|
||||
log "unknown argument: $_arg"
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
[ -n "$RUN_PLATFORMS" ] || RUN_PLATFORMS="$ALL_PLATFORMS"
|
||||
[ -n "$RUN_SCENARIOS" ] || RUN_SCENARIOS="$ALL_SCENARIOS"
|
||||
|
||||
require_cmd nc
|
||||
require_cmd ncat
|
||||
require_cmd ip
|
||||
require_cmd iptables
|
||||
|
||||
CREATOR_WRAP="ip netns exec creator"
|
||||
JOINER_WRAP="ip netns exec joiner"
|
||||
JOINER_SOCKS_HOST="0.0.0.0"
|
||||
PROBE_HOST="10.201.2.2"
|
||||
SINK_WRAP="ip netns exec creator"
|
||||
SINK_BIND="127.0.0.1"
|
||||
SINK_TARGET="127.0.0.1"
|
||||
|
||||
cleanup_all() {
|
||||
cleanup
|
||||
teardown_ns
|
||||
}
|
||||
trap cleanup_all EXIT INT TERM
|
||||
|
||||
setup_ns creator 1
|
||||
setup_ns joiner 2
|
||||
start_sink
|
||||
log "netns creator=10.201.1.2 joiner=10.201.2.2 sink=creator:$SINK_PORT"
|
||||
|
||||
for _pf in $RUN_PLATFORMS; do
|
||||
run_platform "$_pf"
|
||||
[ "$ABORT_RUN" = "1" ] && break
|
||||
done
|
||||
|
||||
summary
|
||||
@@ -0,0 +1,37 @@
|
||||
set -u
|
||||
|
||||
NETNS_CREATED=""
|
||||
|
||||
setup_ns() {
|
||||
_name="$1"
|
||||
_sub="$2"
|
||||
_gw="10.201.$_sub.1"
|
||||
_addr="10.201.$_sub.2"
|
||||
ip netns add "$_name"
|
||||
ip link add "veth-$_name" type veth peer name "peer-$_name"
|
||||
ip link set "peer-$_name" netns "$_name"
|
||||
ip addr add "$_gw/30" dev "veth-$_name"
|
||||
ip link set "veth-$_name" up
|
||||
ip netns exec "$_name" ip link set "peer-$_name" name eth0
|
||||
ip netns exec "$_name" ip link set lo up
|
||||
ip netns exec "$_name" ip addr add "$_addr/30" dev eth0
|
||||
ip netns exec "$_name" ip link set eth0 up
|
||||
ip netns exec "$_name" ip route add default via "$_gw"
|
||||
iptables -t nat -A POSTROUTING -s "$_addr/32" -j MASQUERADE
|
||||
mkdir -p "/etc/netns/$_name"
|
||||
_ns=$(grep '^nameserver' /etc/resolv.conf | grep -v ' 127\.' || true)
|
||||
[ -n "$_ns" ] || _ns="nameserver 1.1.1.1"
|
||||
printf '%s\n' "$_ns" >"/etc/netns/$_name/resolv.conf"
|
||||
NETNS_CREATED="$NETNS_CREATED $_name:$_addr"
|
||||
}
|
||||
|
||||
teardown_ns() {
|
||||
for _entry in $NETNS_CREATED; do
|
||||
_name="${_entry%%:*}"
|
||||
_addr="${_entry#*:}"
|
||||
iptables -t nat -D POSTROUTING -s "$_addr/32" -j MASQUERADE 2>/dev/null
|
||||
ip netns delete "$_name" 2>/dev/null
|
||||
rm -rf "/etc/netns/$_name"
|
||||
done
|
||||
NETNS_CREATED=""
|
||||
}
|
||||
Executable
+89
@@ -0,0 +1,89 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
REPO="$(cd "$DIR/../../.." && pwd)"
|
||||
E2E="$REPO/headless/tests"
|
||||
CTX="$DIR/.context"
|
||||
IMAGE=wlb-e2e-stand
|
||||
|
||||
COMPONENTS="\
|
||||
telemost/headless-telemost-creator \
|
||||
wbstream/headless-wbstream-creator \
|
||||
dion/headless-dion-creator \
|
||||
bitrix/headless-bitrix-creator \
|
||||
telemost-joiner/headless-telemost-joiner \
|
||||
wbstream-joiner/headless-wbstream-joiner \
|
||||
dion-joiner/headless-dion-joiner \
|
||||
bitrix-joiner/headless-bitrix-joiner"
|
||||
|
||||
usage() {
|
||||
cat >&2 <<EOF
|
||||
Usage: stand.sh build | run [platform...] [scenario...] | sh
|
||||
|
||||
Dockerized live e2e: each of creator and joiner runs in its own network
|
||||
namespace (distinct IP), so same-host WebRTC ICE does not collide. Traffic is
|
||||
proved by echoing a nonce through the joiner's SOCKS5 to a sink on the creator's
|
||||
loopback - no external network, no rate limits.
|
||||
|
||||
build cross-build linux binaries, stage cookies, docker build
|
||||
run run the netns harness in a privileged container
|
||||
sh drop into a shell in the container for debugging
|
||||
|
||||
Platforms: telemost wbstream dion bitrix (VK has no headless SOCKS joiner)
|
||||
Scenarios: connect dc kcp dual kick
|
||||
|
||||
Cookies are taken from cookies-<platform>.json at the repo root at build time.
|
||||
Rebuild after refreshing cookies. Examples:
|
||||
stand.sh build
|
||||
stand.sh run
|
||||
stand.sh run bitrix dc kick
|
||||
EOF
|
||||
exit 1
|
||||
}
|
||||
|
||||
build_context() {
|
||||
arch=$(docker version --format '{{.Server.Arch}}' 2>/dev/null || echo arm64)
|
||||
rm -rf "$CTX"
|
||||
mkdir -p "$CTX/work/headless/tests/stand"
|
||||
for spec in $COMPONENTS; do
|
||||
d="${spec%%/*}"
|
||||
b="${spec##*/}"
|
||||
mkdir -p "$CTX/work/headless/$d"
|
||||
echo "building $b (linux/$arch)..."
|
||||
GOOS=linux GOARCH="$arch" CGO_ENABLED=0 \
|
||||
go -C "$REPO/headless/$d" build -trimpath -ldflags="-s -w" -o "$CTX/work/headless/$d/$b" .
|
||||
done
|
||||
cp "$E2E/lib.sh" "$E2E/platforms.sh" "$E2E/scenarios.sh" "$CTX/work/headless/tests/"
|
||||
[ -f "$E2E/.env" ] && cp "$E2E/.env" "$CTX/work/headless/tests/"
|
||||
cp "$DIR/netns.sh" "$DIR/netns-run.sh" "$CTX/work/headless/tests/stand/"
|
||||
cp "$DIR/Dockerfile" "$CTX/Dockerfile"
|
||||
}
|
||||
|
||||
case "${1:-}" in
|
||||
build)
|
||||
build_context
|
||||
docker build -t "$IMAGE" "$CTX"
|
||||
echo "built $IMAGE"
|
||||
;;
|
||||
run)
|
||||
shift
|
||||
cookie_mounts=""
|
||||
for c in vk yandex wbstream dion bitrix; do
|
||||
f="$REPO/cookies-$c.json"
|
||||
[ -f "$f" ] && cookie_mounts="$cookie_mounts -v $f:/cookies/cookies-$c.json"
|
||||
done
|
||||
docker run --rm --cap-add=NET_ADMIN --cap-add=SYS_ADMIN \
|
||||
-e FAIL_FAST="${FAIL_FAST:-1}" \
|
||||
-e COOKIES_DIR=/cookies \
|
||||
$cookie_mounts \
|
||||
"$IMAGE" /work/headless/tests/stand/netns-run.sh "$@"
|
||||
;;
|
||||
sh)
|
||||
docker run --rm -it --cap-add=NET_ADMIN --cap-add=SYS_ADMIN \
|
||||
"$IMAGE" /bin/bash
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
@@ -1,93 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Smoke test for headless-telemost-creator -tm-link: create a conference,
|
||||
# then a second creator joins the same conference URI.
|
||||
#
|
||||
# Usage: ./test-telemost-join-existing.sh <path-to-cookies.json>
|
||||
|
||||
set -u
|
||||
|
||||
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||
CREATOR="$ROOT/headless/telemost/headless-telemost-creator"
|
||||
if [ $# -lt 1 ]; then
|
||||
echo "Usage: $0 <path-to-cookies.json>" >&2
|
||||
exit 2
|
||||
fi
|
||||
COOKIES="$1"
|
||||
SETTLE_TIMEOUT=30
|
||||
|
||||
[ -x "$CREATOR" ] || { echo "FAIL: $CREATOR not built, run ./build-headless.sh" >&2; exit 2; }
|
||||
[ -f "$COOKIES" ] || { echo "FAIL: cookies not found at: $COOKIES" >&2; exit 2; }
|
||||
echo "cookies: $COOKIES"
|
||||
|
||||
PHASE1_LOG=$(mktemp -t tm-create.XXXXXX.log)
|
||||
PHASE2_LOG=$(mktemp -t tm-join.XXXXXX.log)
|
||||
P1_PID=""
|
||||
P2_PID=""
|
||||
|
||||
cleanup() {
|
||||
[ -n "$P2_PID" ] && kill "$P2_PID" 2>/dev/null
|
||||
[ -n "$P1_PID" ] && kill "$P1_PID" 2>/dev/null
|
||||
wait 2>/dev/null
|
||||
}
|
||||
trap cleanup EXIT INT TERM
|
||||
|
||||
echo "=== phase 1: create conference ==="
|
||||
"$CREATOR" -cookies "$COOKIES" > "$PHASE1_LOG" 2>&1 &
|
||||
P1_PID=$!
|
||||
|
||||
waited=0
|
||||
JOIN_LINK=""
|
||||
while [ "$waited" -lt "$SETTLE_TIMEOUT" ]; do
|
||||
JOIN_LINK=$(grep -m1 -oE "https://telemost\.yandex\.[a-z]+/j/[A-Za-z0-9_-]+" "$PHASE1_LOG" | head -1)
|
||||
[ -n "$JOIN_LINK" ] && break
|
||||
if ! kill -0 "$P1_PID" 2>/dev/null; then
|
||||
echo "FAIL: phase 1 process died" >&2
|
||||
tail -20 "$PHASE1_LOG" >&2
|
||||
exit 1
|
||||
fi
|
||||
sleep 1
|
||||
waited=$((waited + 1))
|
||||
done
|
||||
|
||||
if [ -z "$JOIN_LINK" ]; then
|
||||
echo "FAIL: phase 1 did not print join_link within ${SETTLE_TIMEOUT}s" >&2
|
||||
tail -20 "$PHASE1_LOG" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "phase 1 join_link: $JOIN_LINK"
|
||||
|
||||
sleep 3
|
||||
|
||||
echo ""
|
||||
echo "=== phase 2: join existing conference via -tm-link ==="
|
||||
"$CREATOR" -cookies "$COOKIES" -tm-link "$JOIN_LINK" > "$PHASE2_LOG" 2>&1 &
|
||||
P2_PID=$!
|
||||
|
||||
waited=0
|
||||
while [ "$waited" -lt "$SETTLE_TIMEOUT" ]; do
|
||||
if grep -q "media_server=" "$PHASE2_LOG"; then
|
||||
break
|
||||
fi
|
||||
if grep -qE "Failed to join existing conference|empty conference URI" "$PHASE2_LOG"; then
|
||||
break
|
||||
fi
|
||||
if ! kill -0 "$P2_PID" 2>/dev/null; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
waited=$((waited + 1))
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "--- phase 2 log tail ---"
|
||||
tail -25 "$PHASE2_LOG"
|
||||
|
||||
if grep -q "media_server=" "$PHASE2_LOG" && grep -q "Joining existing conference" "$PHASE2_LOG"; then
|
||||
echo ""
|
||||
echo "PASS: phase 2 joined the existing conference"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "FAIL: phase 2 did not reach media_server stage" >&2
|
||||
exit 1
|
||||
@@ -1,93 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Smoke test: headless-telemost-creator creates a conference, headless-telemost-joiner
|
||||
# joins it via -tm-link and exposes a SOCKS5 listener.
|
||||
#
|
||||
# Usage: ./test-telemost-joiner.sh <path-to-cookies.json>
|
||||
|
||||
set -u
|
||||
|
||||
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||
CREATOR="$ROOT/headless/telemost/headless-telemost-creator"
|
||||
JOINER="$ROOT/headless/telemost-joiner/headless-telemost-joiner"
|
||||
SOCKS_PORT=11080
|
||||
SETTLE_TIMEOUT=45
|
||||
|
||||
if [ $# -lt 1 ]; then
|
||||
echo "Usage: $0 <path-to-cookies.json>" >&2
|
||||
exit 2
|
||||
fi
|
||||
COOKIES="$1"
|
||||
|
||||
[ -x "$CREATOR" ] || { echo "FAIL: $CREATOR not built (run ./build-headless.sh)" >&2; exit 2; }
|
||||
[ -x "$JOINER" ] || { echo "FAIL: $JOINER not built (run ./build-headless.sh)" >&2; exit 2; }
|
||||
[ -f "$COOKIES" ] || { echo "FAIL: cookies not found at: $COOKIES" >&2; exit 2; }
|
||||
|
||||
PHASE1_LOG=$(mktemp -t tm-create.XXXXXX.log)
|
||||
PHASE2_LOG=$(mktemp -t tm-joiner.XXXXXX.log)
|
||||
P1_PID=""
|
||||
P2_PID=""
|
||||
|
||||
cleanup() {
|
||||
[ -n "$P2_PID" ] && kill "$P2_PID" 2>/dev/null
|
||||
[ -n "$P1_PID" ] && kill "$P1_PID" 2>/dev/null
|
||||
wait 2>/dev/null
|
||||
}
|
||||
trap cleanup EXIT INT TERM
|
||||
|
||||
echo "=== phase 1: create conference ==="
|
||||
"$CREATOR" -cookies "$COOKIES" > "$PHASE1_LOG" 2>&1 &
|
||||
P1_PID=$!
|
||||
|
||||
waited=0
|
||||
JOIN_LINK=""
|
||||
while [ "$waited" -lt "$SETTLE_TIMEOUT" ]; do
|
||||
JOIN_LINK=$(grep -m1 -oE "https://telemost\.yandex\.[a-z]+/j/[A-Za-z0-9_-]+" "$PHASE1_LOG" | head -1)
|
||||
[ -n "$JOIN_LINK" ] && break
|
||||
if ! kill -0 "$P1_PID" 2>/dev/null; then
|
||||
echo "FAIL: phase 1 process died" >&2
|
||||
tail -20 "$PHASE1_LOG" >&2
|
||||
exit 1
|
||||
fi
|
||||
sleep 1
|
||||
waited=$((waited + 1))
|
||||
done
|
||||
|
||||
if [ -z "$JOIN_LINK" ]; then
|
||||
echo "FAIL: phase 1 did not print join_link within ${SETTLE_TIMEOUT}s" >&2
|
||||
tail -20 "$PHASE1_LOG" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "phase 1 join_link: $JOIN_LINK"
|
||||
|
||||
sleep 3
|
||||
|
||||
echo ""
|
||||
echo "=== phase 2: join via headless-telemost-joiner ==="
|
||||
"$JOINER" -tm-link "$JOIN_LINK" -socks-port "$SOCKS_PORT" > "$PHASE2_LOG" 2>&1 &
|
||||
P2_PID=$!
|
||||
|
||||
waited=0
|
||||
while [ "$waited" -lt "$SETTLE_TIMEOUT" ]; do
|
||||
if grep -q "TUNNEL CONNECTED" "$PHASE2_LOG"; then
|
||||
break
|
||||
fi
|
||||
if ! kill -0 "$P2_PID" 2>/dev/null; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
waited=$((waited + 1))
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "--- phase 2 log tail ---"
|
||||
tail -25 "$PHASE2_LOG"
|
||||
|
||||
if grep -q "TUNNEL CONNECTED" "$PHASE2_LOG" && grep -q "socks5 -> 127.0.0.1:${SOCKS_PORT}" "$PHASE2_LOG"; then
|
||||
echo ""
|
||||
echo "PASS: joiner reached TUNNEL CONNECTED on socks port ${SOCKS_PORT}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "FAIL: joiner did not reach TUNNEL CONNECTED within ${SETTLE_TIMEOUT}s" >&2
|
||||
exit 1
|
||||
@@ -1,116 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -u
|
||||
|
||||
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||
CREATOR="$ROOT/headless/telemost/headless-telemost-creator"
|
||||
JOINER="$ROOT/headless/telemost-joiner/headless-telemost-joiner"
|
||||
|
||||
RATES="${RATES:-0 62500 125000 250000 625000}"
|
||||
PHASE_SECS="${PHASE_SECS:-100}"
|
||||
SOCKS_PORT="${SOCKS_PORT:-11080}"
|
||||
SINK_PORT="${SINK_PORT:-19099}"
|
||||
SETTLE_TIMEOUT="${SETTLE_TIMEOUT:-60}"
|
||||
|
||||
if [ $# -lt 2 ]; then
|
||||
echo "Usage: $0 <cookies.json> <telemost-join-link>" >&2
|
||||
exit 2
|
||||
fi
|
||||
COOKIES="$1"
|
||||
TM_LINK="$2"
|
||||
|
||||
[ -x "$CREATOR" ] || { echo "FAIL: $CREATOR not built (run ./build-headless.sh)" >&2; exit 2; }
|
||||
[ -x "$JOINER" ] || { echo "FAIL: $JOINER not built (run ./build-headless.sh)" >&2; exit 2; }
|
||||
[ -f "$COOKIES" ] || { echo "FAIL: cookies not found: $COOKIES" >&2; exit 2; }
|
||||
command -v ncat >/dev/null 2>&1 || { echo "FAIL: ncat not found (brew install nmap)" >&2; exit 2; }
|
||||
|
||||
CREATOR_LOG=$(mktemp -t tm-reap-creator.XXXXXX.log)
|
||||
JOINER_LOG=$(mktemp -t tm-reap-joiner.XXXXXX.log)
|
||||
C_PID=""; J_PID=""; SINK_PID=""
|
||||
|
||||
cleanup() {
|
||||
[ -n "$SINK_PID" ] && kill "$SINK_PID" 2>/dev/null
|
||||
[ -n "$J_PID" ] && kill "$J_PID" 2>/dev/null
|
||||
[ -n "$C_PID" ] && kill "$C_PID" 2>/dev/null
|
||||
wait 2>/dev/null
|
||||
}
|
||||
trap cleanup EXIT INT TERM
|
||||
|
||||
echo "room: $TM_LINK"
|
||||
echo "rates: $RATES phase: ${PHASE_SECS}s socks: $SOCKS_PORT sink: $SINK_PORT"
|
||||
|
||||
echo "=== creator joins named room ==="
|
||||
"$CREATOR" -cookies "$COOKIES" -tm-link "$TM_LINK" > "$CREATOR_LOG" 2>&1 &
|
||||
C_PID=$!
|
||||
|
||||
echo "=== joiner joins named room, exposes SOCKS5 ==="
|
||||
"$JOINER" -tm-link "$TM_LINK" -socks-port "$SOCKS_PORT" > "$JOINER_LOG" 2>&1 &
|
||||
J_PID=$!
|
||||
|
||||
waited=0
|
||||
while [ "$waited" -lt "$SETTLE_TIMEOUT" ]; do
|
||||
grep -q "TUNNEL CONNECTED" "$JOINER_LOG" && break
|
||||
kill -0 "$C_PID" 2>/dev/null || { echo "FAIL: creator died" >&2; tail -20 "$CREATOR_LOG" >&2; exit 1; }
|
||||
kill -0 "$J_PID" 2>/dev/null || { echo "FAIL: joiner died" >&2; tail -20 "$JOINER_LOG" >&2; exit 1; }
|
||||
sleep 1; waited=$((waited + 1))
|
||||
done
|
||||
grep -q "TUNNEL CONNECTED" "$JOINER_LOG" || { echo "FAIL: no TUNNEL CONNECTED in ${SETTLE_TIMEOUT}s" >&2; tail -25 "$JOINER_LOG" >&2; exit 1; }
|
||||
echo "tunnel up."
|
||||
|
||||
# discard sink reached through the tunnel egress; creator and joiner share this host's loopback
|
||||
ncat -k -l --recv-only 127.0.0.1 "$SINK_PORT" > /dev/null 2>&1 &
|
||||
SINK_PID=$!
|
||||
sleep 1
|
||||
|
||||
# emit ~rate bytes/sec into stdout for dur seconds, in 10 chunks/sec (coarse token bucket, no pv dep)
|
||||
pump_rate() {
|
||||
rate=$1; dur=$2
|
||||
[ "$rate" -le 0 ] && { sleep "$dur"; return; }
|
||||
chunk=$((rate / 10)); [ "$chunk" -lt 1 ] && chunk=1
|
||||
end=$(( $(date +%s) + dur ))
|
||||
while [ "$(date +%s)" -lt "$end" ]; do
|
||||
dd if=/dev/zero bs="$chunk" count=1 2>/dev/null
|
||||
sleep 0.1
|
||||
done
|
||||
}
|
||||
|
||||
# count reap markers currently in both logs
|
||||
reap_count() {
|
||||
c1=$(grep -cE "\[bind\] UNBOUND|forcing reconnect: slot binding killed" "$JOINER_LOG" 2>/dev/null || echo 0)
|
||||
c2=$(grep -cE "\[bind\] UNBOUND|forcing reconnect: slot binding killed" "$CREATOR_LOG" 2>/dev/null || echo 0)
|
||||
echo $((c1 + c2))
|
||||
}
|
||||
|
||||
echo ""
|
||||
echo "=== reap sweep ==="
|
||||
printf "%-10s %-14s %-12s\n" "rate_Bps" "first_reap_s" "reaps_in_phase"
|
||||
RESULTS=""
|
||||
for RATE in $RATES; do
|
||||
base=$(reap_count)
|
||||
start=$(date +%s)
|
||||
# drive the load in the background so we can poll for the reap during the phase
|
||||
( pump_rate "$RATE" "$PHASE_SECS" | ncat --proxy 127.0.0.1:"$SOCKS_PORT" --proxy-type socks5 127.0.0.1 "$SINK_PORT" ) >/dev/null 2>&1 &
|
||||
LOAD_PID=$!
|
||||
first_reap="-"
|
||||
while kill -0 "$LOAD_PID" 2>/dev/null; do
|
||||
if [ "$first_reap" = "-" ] && [ "$(reap_count)" -gt "$base" ]; then
|
||||
first_reap=$(( $(date +%s) - start ))
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
wait "$LOAD_PID" 2>/dev/null
|
||||
# one final check after the phase ends
|
||||
if [ "$first_reap" = "-" ] && [ "$(reap_count)" -gt "$base" ]; then
|
||||
first_reap=$(( $(date +%s) - start ))
|
||||
fi
|
||||
total=$(( $(reap_count) - base ))
|
||||
printf "%-10s %-14s %-12s\n" "$RATE" "$first_reap" "$total"
|
||||
RESULTS="$RESULTS$RATE=$first_reap,${total} "
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "--- joiner reap lines ---"
|
||||
grep -nE "\[bind\] (BOUND|UNBOUND)|forcing reconnect" "$JOINER_LOG" | tail -20
|
||||
echo ""
|
||||
echo "summary (rate_Bps=first_reap_s,reaps): $RESULTS"
|
||||
echo "logs: creator=$CREATOR_LOG joiner=$JOINER_LOG"
|
||||
@@ -1,149 +0,0 @@
|
||||
#!/bin/sh
|
||||
# End-to-end test for creator --upstream-socks, on Telemost.
|
||||
#
|
||||
# A telemost creator JOINS an existing conference (your call link, never created
|
||||
# here) and a telemost joiner joins the same conference to form the tunnel. We run
|
||||
# the pair twice - once with direct egress, once with -upstream-socks - and assert
|
||||
# the joiner's public egress IP CHANGES. A changed IP proves the joiner's traffic
|
||||
# left through the upstream SOCKS5 (your VPN client -> VPS) instead of this host.
|
||||
#
|
||||
# Needs: a real upstream SOCKS5 proxy whose exit IP differs from this machine
|
||||
# (an actual VPN client pointing at a VPS), plus Yandex cookies and a live call link.
|
||||
#
|
||||
# Usage:
|
||||
# UPSTREAM_SOCKS=127.0.0.1:1080 ./test-upstream-socks.sh <cookies-yandex.json> <tm-link>
|
||||
# UPSTREAM_SOCKS=127.0.0.1:1080 UPSTREAM_USER=u UPSTREAM_PASS=p \
|
||||
# ./test-upstream-socks.sh <cookies-yandex.json> https://telemost.yandex.ru/j/<id>
|
||||
|
||||
set -u
|
||||
|
||||
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||
CREATOR="$ROOT/headless/telemost/headless-telemost-creator"
|
||||
JOINER="$ROOT/headless/telemost-joiner/headless-telemost-joiner"
|
||||
SOCKS_PORT=11080
|
||||
IP_URL="https://api.ipify.org"
|
||||
SETTLE_TIMEOUT=45
|
||||
PROBE_TIMEOUT=15
|
||||
|
||||
if [ $# -lt 2 ]; then
|
||||
echo "Usage: UPSTREAM_SOCKS=host:port $0 <cookies-yandex.json> <tm-link>" >&2
|
||||
exit 2
|
||||
fi
|
||||
COOKIES="$1"
|
||||
TM_LINK="$2"
|
||||
|
||||
if [ -z "${UPSTREAM_SOCKS:-}" ]; then
|
||||
echo "FAIL: set UPSTREAM_SOCKS=host:port (a real SOCKS5 proxy / VPN client whose exit IP differs from this host)" >&2
|
||||
exit 2
|
||||
fi
|
||||
[ -x "$CREATOR" ] || { echo "FAIL: missing $CREATOR (run ./build-headless.sh first)" >&2; exit 2; }
|
||||
[ -x "$JOINER" ] || { echo "FAIL: missing $JOINER (run ./build-headless.sh first)" >&2; exit 2; }
|
||||
[ -f "$COOKIES" ] || { echo "FAIL: cookies not found at: $COOKIES" >&2; exit 2; }
|
||||
echo "cookies=$COOKIES tm-link=$TM_LINK upstream=$UPSTREAM_SOCKS"
|
||||
|
||||
CREATOR_PID=""
|
||||
JOINER_PID=""
|
||||
kill_pair() {
|
||||
[ -n "$JOINER_PID" ] && kill "$JOINER_PID" 2>/dev/null
|
||||
[ -n "$CREATOR_PID" ] && kill "$CREATOR_PID" 2>/dev/null
|
||||
wait 2>/dev/null
|
||||
JOINER_PID=""
|
||||
CREATOR_PID=""
|
||||
}
|
||||
trap kill_pair EXIT INT TERM
|
||||
|
||||
# run_chain <label> [extra creator args...] -> prints the joiner's egress IP on stdout
|
||||
run_chain() {
|
||||
label="$1"
|
||||
shift
|
||||
clog=$(mktemp -t up-c.XXXXXX.log)
|
||||
jlog=$(mktemp -t up-j.XXXXXX.log)
|
||||
|
||||
"$CREATOR" -cookies "$COOKIES" -tm-link "$TM_LINK" "$@" >"$clog" 2>&1 &
|
||||
CREATOR_PID=$!
|
||||
|
||||
w=0
|
||||
while [ "$w" -lt "$SETTLE_TIMEOUT" ]; do
|
||||
grep -q "media_server=" "$clog" && break
|
||||
if ! kill -0 "$CREATOR_PID" 2>/dev/null; then
|
||||
echo "FAIL[$label]: creator died before joining the conference" >&2
|
||||
tail -20 "$clog" >&2
|
||||
kill_pair
|
||||
return 1
|
||||
fi
|
||||
sleep 1
|
||||
w=$((w + 1))
|
||||
done
|
||||
if ! grep -q "media_server=" "$clog"; then
|
||||
echo "FAIL[$label]: creator did not join the conference in ${SETTLE_TIMEOUT}s" >&2
|
||||
tail -20 "$clog" >&2
|
||||
kill_pair
|
||||
return 1
|
||||
fi
|
||||
sleep 3
|
||||
|
||||
"$JOINER" -tm-link "$TM_LINK" -socks-port "$SOCKS_PORT" >"$jlog" 2>&1 &
|
||||
JOINER_PID=$!
|
||||
|
||||
w=0
|
||||
while [ "$w" -lt "$SETTLE_TIMEOUT" ]; do
|
||||
grep -q "TUNNEL CONNECTED" "$jlog" && break
|
||||
if ! kill -0 "$JOINER_PID" 2>/dev/null; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
w=$((w + 1))
|
||||
done
|
||||
if ! grep -q "TUNNEL CONNECTED" "$jlog"; then
|
||||
echo "FAIL[$label]: joiner never reached TUNNEL CONNECTED in ${SETTLE_TIMEOUT}s" >&2
|
||||
tail -20 "$jlog" >&2
|
||||
kill_pair
|
||||
return 1
|
||||
fi
|
||||
|
||||
w=0
|
||||
while [ "$w" -lt 10 ]; do
|
||||
nc -z 127.0.0.1 "$SOCKS_PORT" 2>/dev/null && break
|
||||
sleep 1
|
||||
w=$((w + 1))
|
||||
done
|
||||
|
||||
ip=$(curl --socks5-hostname "127.0.0.1:$SOCKS_PORT" -m "$PROBE_TIMEOUT" -s "$IP_URL")
|
||||
kill_pair
|
||||
echo "$ip"
|
||||
}
|
||||
|
||||
echo "=== baseline: direct egress ==="
|
||||
DIRECT_IP=$(run_chain direct) || exit 1
|
||||
echo "direct_ip=$DIRECT_IP"
|
||||
|
||||
# Let the fixed SOCKS port free up before the second pair.
|
||||
sleep 2
|
||||
|
||||
echo "=== upstream: -upstream-socks $UPSTREAM_SOCKS ==="
|
||||
set -- -upstream-socks "$UPSTREAM_SOCKS"
|
||||
[ -n "${UPSTREAM_USER:-}" ] && set -- "$@" -upstream-user "$UPSTREAM_USER"
|
||||
[ -n "${UPSTREAM_PASS:-}" ] && set -- "$@" -upstream-pass "$UPSTREAM_PASS"
|
||||
UPSTREAM_IP=$(run_chain upstream "$@") || exit 1
|
||||
echo "upstream_ip=$UPSTREAM_IP"
|
||||
|
||||
case "$DIRECT_IP" in
|
||||
*.*) ;;
|
||||
*)
|
||||
echo "FAIL: no direct egress IP (baseline chain broken)" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
case "$UPSTREAM_IP" in
|
||||
*.*) ;;
|
||||
*)
|
||||
echo "FAIL: no egress IP via upstream - is $UPSTREAM_SOCKS reachable and does its SOCKS5 inbound work?" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
if [ "$DIRECT_IP" = "$UPSTREAM_IP" ]; then
|
||||
echo "FAIL: egress IP unchanged ($UPSTREAM_IP) - joiner traffic did NOT go through the upstream" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "PASS: egress moved from $DIRECT_IP (this host) to $UPSTREAM_IP (via $UPSTREAM_SOCKS)"
|
||||
@@ -1,93 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Smoke test for -vk-link: create a call, then join it via the new flag.
|
||||
#
|
||||
# Usage: ./test-vk-join-existing.sh <path-to-cookies.json>
|
||||
|
||||
set -u
|
||||
|
||||
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||
CREATOR="$ROOT/headless/vk/headless-vk-creator"
|
||||
if [ $# -lt 1 ]; then
|
||||
echo "Usage: $0 <path-to-cookies.json>" >&2
|
||||
exit 2
|
||||
fi
|
||||
COOKIES="$1"
|
||||
SETTLE_TIMEOUT=25
|
||||
|
||||
[ -x "$CREATOR" ] || { echo "FAIL: $CREATOR not built, run ./build-headless.sh" >&2; exit 2; }
|
||||
[ -f "$COOKIES" ] || { echo "FAIL: cookies not found at: $COOKIES" >&2; exit 2; }
|
||||
echo "cookies: $COOKIES"
|
||||
|
||||
PHASE1_LOG=$(mktemp -t vk-create.XXXXXX.log)
|
||||
PHASE2_LOG=$(mktemp -t vk-join.XXXXXX.log)
|
||||
P1_PID=""
|
||||
P2_PID=""
|
||||
|
||||
cleanup() {
|
||||
[ -n "$P2_PID" ] && kill "$P2_PID" 2>/dev/null
|
||||
[ -n "$P1_PID" ] && kill "$P1_PID" 2>/dev/null
|
||||
wait 2>/dev/null
|
||||
}
|
||||
trap cleanup EXIT INT TERM
|
||||
|
||||
echo "=== phase 1: create call ==="
|
||||
"$CREATOR" -cookies "$COOKIES" > "$PHASE1_LOG" 2>&1 &
|
||||
P1_PID=$!
|
||||
|
||||
waited=0
|
||||
JOIN_LINK=""
|
||||
while [ "$waited" -lt "$SETTLE_TIMEOUT" ]; do
|
||||
JOIN_LINK=$(grep -m1 -oE "https://vk\.com/call/join/[A-Za-z0-9_-]+" "$PHASE1_LOG")
|
||||
[ -n "$JOIN_LINK" ] && break
|
||||
if ! kill -0 "$P1_PID" 2>/dev/null; then
|
||||
echo "FAIL: phase 1 process died" >&2
|
||||
tail -20 "$PHASE1_LOG" >&2
|
||||
exit 1
|
||||
fi
|
||||
sleep 1
|
||||
waited=$((waited + 1))
|
||||
done
|
||||
|
||||
if [ -z "$JOIN_LINK" ]; then
|
||||
echo "FAIL: phase 1 did not print join_link within ${SETTLE_TIMEOUT}s" >&2
|
||||
tail -20 "$PHASE1_LOG" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "phase 1 join_link: $JOIN_LINK"
|
||||
|
||||
# Wait a beat so the call is fully joined on VK's side before phase 2 starts.
|
||||
sleep 3
|
||||
|
||||
echo ""
|
||||
echo "=== phase 2: join existing call via -vk-link ==="
|
||||
"$CREATOR" -cookies "$COOKIES" -vk-link "$JOIN_LINK" > "$PHASE2_LOG" 2>&1 &
|
||||
P2_PID=$!
|
||||
|
||||
waited=0
|
||||
while [ "$waited" -lt "$SETTLE_TIMEOUT" ]; do
|
||||
if grep -q "vk-ws] Connected" "$PHASE2_LOG"; then
|
||||
break
|
||||
fi
|
||||
if grep -qE "Failed to join existing call|empty WS endpoint|empty session_key" "$PHASE2_LOG"; then
|
||||
break
|
||||
fi
|
||||
if ! kill -0 "$P2_PID" 2>/dev/null; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
waited=$((waited + 1))
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "--- phase 2 log tail ---"
|
||||
tail -25 "$PHASE2_LOG"
|
||||
|
||||
if grep -q "vk-ws] Connected" "$PHASE2_LOG"; then
|
||||
echo ""
|
||||
echo "PASS: phase 2 joined the existing call (got vk-ws connection)"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "FAIL: phase 2 did not reach vk-ws connection" >&2
|
||||
exit 1
|
||||
@@ -1,87 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Smoke test for headless-wbstream-creator -room: create a room, then a second
|
||||
# creator joins the same room id.
|
||||
|
||||
set -u
|
||||
|
||||
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||
CREATOR="$ROOT/headless/wbstream/headless-wbstream-creator"
|
||||
SETTLE_TIMEOUT=25
|
||||
|
||||
[ -x "$CREATOR" ] || { echo "FAIL: $CREATOR not built (run ./build-headless.sh)" >&2; exit 2; }
|
||||
|
||||
PHASE1_LOG=$(mktemp -t wb-create.XXXXXX.log)
|
||||
PHASE2_LOG=$(mktemp -t wb-join.XXXXXX.log)
|
||||
P1_PID=""
|
||||
P2_PID=""
|
||||
|
||||
cleanup() {
|
||||
[ -n "$P2_PID" ] && kill "$P2_PID" 2>/dev/null
|
||||
[ -n "$P1_PID" ] && kill "$P1_PID" 2>/dev/null
|
||||
wait 2>/dev/null
|
||||
}
|
||||
trap cleanup EXIT INT TERM
|
||||
|
||||
echo "=== phase 1: create room ==="
|
||||
"$CREATOR" > "$PHASE1_LOG" 2>&1 &
|
||||
P1_PID=$!
|
||||
|
||||
waited=0
|
||||
JOIN_LINK=""
|
||||
while [ "$waited" -lt "$SETTLE_TIMEOUT" ]; do
|
||||
JOIN_LINK=$(grep -m1 -oE "wbstream://[A-Za-z0-9-]+" "$PHASE1_LOG" | head -1)
|
||||
[ -n "$JOIN_LINK" ] && break
|
||||
if ! kill -0 "$P1_PID" 2>/dev/null; then
|
||||
echo "FAIL: phase 1 process died" >&2
|
||||
tail -20 "$PHASE1_LOG" >&2
|
||||
exit 1
|
||||
fi
|
||||
sleep 1
|
||||
waited=$((waited + 1))
|
||||
done
|
||||
|
||||
if [ -z "$JOIN_LINK" ]; then
|
||||
echo "FAIL: phase 1 did not print join_link within ${SETTLE_TIMEOUT}s" >&2
|
||||
tail -20 "$PHASE1_LOG" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "phase 1 join_link: $JOIN_LINK"
|
||||
|
||||
sleep 3
|
||||
|
||||
echo ""
|
||||
echo "=== phase 2: join existing room via -room ==="
|
||||
"$CREATOR" -room "$JOIN_LINK" > "$PHASE2_LOG" 2>&1 &
|
||||
P2_PID=$!
|
||||
|
||||
waited=0
|
||||
while [ "$waited" -lt "$SETTLE_TIMEOUT" ]; do
|
||||
if grep -q "\[lk\] join: room=" "$PHASE2_LOG"; then
|
||||
break
|
||||
fi
|
||||
if grep -qE "Failed to|register guest|create room" "$PHASE2_LOG" | grep -qiE "error|failed"; then
|
||||
break
|
||||
fi
|
||||
if ! kill -0 "$P2_PID" 2>/dev/null; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
waited=$((waited + 1))
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "--- phase 2 log tail ---"
|
||||
tail -25 "$PHASE2_LOG"
|
||||
|
||||
phase2_room=$(grep -m1 -oE "room=[a-f0-9-]+" "$PHASE2_LOG" | head -1 | cut -d= -f2)
|
||||
expected_room=$(echo "$JOIN_LINK" | sed 's|wbstream://||')
|
||||
|
||||
if [ "$phase2_room" = "$expected_room" ]; then
|
||||
echo ""
|
||||
echo "PASS: phase 2 joined room $phase2_room"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "FAIL: phase 2 did not join the expected room (got '$phase2_room', wanted '$expected_room')" >&2
|
||||
exit 1
|
||||
@@ -1,135 +0,0 @@
|
||||
#!/bin/sh
|
||||
# End-to-end smoke test: spawn a wbstream creator + joiner pair, route curl
|
||||
# through the joiner's SOCKS5 and verify the response arrives.
|
||||
#
|
||||
# Usage:
|
||||
# ./test-wbstream.sh [video|dc] # default: video
|
||||
|
||||
set -u
|
||||
|
||||
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||
CREATOR="$ROOT/headless/wbstream/headless-wbstream-creator"
|
||||
JOINER="$ROOT/headless/wbstream-joiner/headless-wbstream-joiner"
|
||||
COOKIES="${WBSTREAM_COOKIES:-$ROOT/cookies-wbstream.json}"
|
||||
SOCKS_PORT=11080
|
||||
TARGET_URL="https://api.ipify.org"
|
||||
PROBE_TIMEOUT=15
|
||||
SETTLE_TIMEOUT=20
|
||||
|
||||
mode_arg="${1:-video}"
|
||||
case "$mode_arg" in
|
||||
video|dc) ;;
|
||||
*)
|
||||
echo "Unknown mode: $mode_arg (expected video or dc)" >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
|
||||
CREATOR_LOG=$(mktemp -t wb-c.XXXXXX.log)
|
||||
JOINER_LOG=$(mktemp -t wb-j.XXXXXX.log)
|
||||
CREATOR_PID=""
|
||||
JOINER_PID=""
|
||||
|
||||
cleanup() {
|
||||
[ -n "$JOINER_PID" ] && kill "$JOINER_PID" 2>/dev/null
|
||||
[ -n "$CREATOR_PID" ] && kill "$CREATOR_PID" 2>/dev/null
|
||||
wait 2>/dev/null
|
||||
}
|
||||
trap cleanup EXIT INT TERM
|
||||
|
||||
require_bin() {
|
||||
if [ ! -x "$1" ]; then
|
||||
echo "FAIL: missing binary $1" >&2
|
||||
echo "Run ./build-headless.sh first." >&2
|
||||
exit 2
|
||||
fi
|
||||
}
|
||||
|
||||
require_bin "$CREATOR"
|
||||
require_bin "$JOINER"
|
||||
|
||||
if [ ! -f "$COOKIES" ]; then
|
||||
echo "FAIL: cookies file not found at $COOKIES" >&2
|
||||
echo "Set WBSTREAM_COOKIES or place cookies-wbstream.json at repo root." >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
echo "=== mode=$mode_arg ==="
|
||||
|
||||
"$CREATOR" --cookies "$COOKIES" > "$CREATOR_LOG" 2>&1 &
|
||||
CREATOR_PID=$!
|
||||
|
||||
waited=0
|
||||
JOIN_LINK=""
|
||||
while [ "$waited" -lt "$SETTLE_TIMEOUT" ]; do
|
||||
JOIN_LINK=$(grep -m1 "join_link:" "$CREATOR_LOG" | awk '{print $2}')
|
||||
[ -n "$JOIN_LINK" ] && break
|
||||
sleep 1
|
||||
waited=$((waited + 1))
|
||||
done
|
||||
|
||||
if [ -z "$JOIN_LINK" ]; then
|
||||
echo "FAIL: creator did not print a join_link within ${SETTLE_TIMEOUT}s" >&2
|
||||
tail -20 "$CREATOR_LOG" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "join_link=$JOIN_LINK"
|
||||
|
||||
"$JOINER" --room "$JOIN_LINK" --socks-port "$SOCKS_PORT" --tunnel-mode "$mode_arg" \
|
||||
> "$JOINER_LOG" 2>&1 &
|
||||
JOINER_PID=$!
|
||||
|
||||
waited=0
|
||||
while [ "$waited" -lt "$SETTLE_TIMEOUT" ]; do
|
||||
if grep -q "TUNNEL CONNECTED" "$JOINER_LOG"; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
waited=$((waited + 1))
|
||||
done
|
||||
|
||||
if ! grep -q "TUNNEL CONNECTED" "$JOINER_LOG"; then
|
||||
echo "FAIL: joiner did not reach TUNNEL CONNECTED within ${SETTLE_TIMEOUT}s" >&2
|
||||
tail -20 "$JOINER_LOG" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# SOCKS listener starts in a goroutine after TUNNEL CONNECTED prints; poll.
|
||||
waited=0
|
||||
while [ "$waited" -lt 10 ]; do
|
||||
if nc -z 127.0.0.1 "$SOCKS_PORT" 2>/dev/null; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
waited=$((waited + 1))
|
||||
done
|
||||
if ! nc -z 127.0.0.1 "$SOCKS_PORT" 2>/dev/null; then
|
||||
echo "FAIL: SOCKS5 port $SOCKS_PORT never opened" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
response=$(curl --socks5 "127.0.0.1:$SOCKS_PORT" -m "$PROBE_TIMEOUT" -sv "$TARGET_URL" 2>&1)
|
||||
if ! echo "$response" | grep -q "HTTP/.* 200"; then
|
||||
echo "FAIL: SOCKS5 request did not return HTTP 200" >&2
|
||||
echo "--- curl output ---" >&2
|
||||
echo "$response" >&2
|
||||
echo "--- joiner log tail ---" >&2
|
||||
tail -30 "$JOINER_LOG" >&2
|
||||
echo "--- creator log tail ---" >&2
|
||||
tail -30 "$CREATOR_LOG" >&2
|
||||
exit 1
|
||||
fi
|
||||
response=$(echo "$response" | tail -1)
|
||||
echo "remote_ip=$response"
|
||||
|
||||
speed=$(curl --socks5 "127.0.0.1:$SOCKS_PORT" -m 30 -s -o /dev/null \
|
||||
-w "%{speed_download}" \
|
||||
"https://speed.cloudflare.com/__down?bytes=10485760")
|
||||
if [ -z "$speed" ] || [ "$speed" = "0" ]; then
|
||||
echo "FAIL: throughput probe returned 0 B/s" >&2
|
||||
exit 1
|
||||
fi
|
||||
mbps=$(awk -v b="$speed" 'BEGIN { printf "%.2f", b * 8 / 1000000 }')
|
||||
echo "throughput=${mbps} Mbps"
|
||||
|
||||
echo "PASS: mode=$mode_arg"
|
||||
@@ -69,11 +69,24 @@ func main() {
|
||||
log.Fatalf("[auth] cookies file is missing __wb_device_id; re-export via creator-app's 'Export Cookies' button")
|
||||
}
|
||||
cookieHeader := common.FilterCookies(rawCookies, wbstream.WBStreamCookieAllowlist)
|
||||
bearer, err := wbstream.RefreshAccessToken(nil, cookieHeader, deviceID)
|
||||
persistCookies := func(rotated map[string]string) {
|
||||
if len(rotated) == 0 {
|
||||
return
|
||||
}
|
||||
if werr := common.UpdateCookieFile(*cookiesPath, rotated); werr != nil {
|
||||
log.Printf("[auth] warn: persist rotated cookies: %v", werr)
|
||||
return
|
||||
}
|
||||
rawCookies = common.LoadCookies(*cookiesPath)
|
||||
cookieHeader = common.FilterCookies(rawCookies, wbstream.WBStreamCookieAllowlist)
|
||||
log.Printf("[auth] persisted %d rotated cookie(s)", len(rotated))
|
||||
}
|
||||
bearer, rotated, err := wbstream.RefreshAccessToken(nil, cookieHeader, deviceID)
|
||||
if err != nil {
|
||||
common.EmitAuthErrorFor(err)
|
||||
log.Fatalf("[auth] slide-v3 refresh: %v", err)
|
||||
}
|
||||
persistCookies(rotated)
|
||||
log.Printf("[auth] bearer refreshed (len=%d)", len(bearer))
|
||||
requestedRoom := wbstream.ParseRoomID(*roomFlag)
|
||||
roomID, roomToken, accessToken, serverURL, err := wbstream.AuthAsLoggedIn(nil, cookieHeader, bearer, requestedRoom, *displayName)
|
||||
@@ -163,13 +176,14 @@ func main() {
|
||||
}
|
||||
time.Sleep(3 * time.Second)
|
||||
|
||||
newBearer, refreshErr := wbstream.RefreshAccessToken(nil, cookieHeader, deviceID)
|
||||
newBearer, rotated, refreshErr := wbstream.RefreshAccessToken(nil, cookieHeader, deviceID)
|
||||
if refreshErr != nil {
|
||||
log.Printf("[rejoin] slide-v3 refresh failed: %v, retrying in 5s", refreshErr)
|
||||
time.Sleep(5 * time.Second)
|
||||
continue
|
||||
}
|
||||
bearer = newBearer
|
||||
persistCookies(rotated)
|
||||
_, newRoomToken, newAccessToken, newServerURL, err := wbstream.AuthAsLoggedIn(nil, cookieHeader, bearer, roomID, *displayName)
|
||||
if err != nil {
|
||||
log.Printf("[rejoin] auth failed: %v, retrying in 5s", err)
|
||||
|
||||
+149
-7
@@ -39,13 +39,16 @@ type Client struct {
|
||||
HTTP *http.Client
|
||||
LogFn func(string, ...any)
|
||||
|
||||
portal string
|
||||
sessid string
|
||||
userAgent string
|
||||
instanceID string
|
||||
email string
|
||||
password string
|
||||
credsPath string
|
||||
portal string
|
||||
sessid string
|
||||
userAgent string
|
||||
instanceID string
|
||||
email string
|
||||
password string
|
||||
credsPath string
|
||||
chatID string
|
||||
conferenceID string
|
||||
selfUserID string
|
||||
}
|
||||
|
||||
type JoinResult struct {
|
||||
@@ -69,6 +72,13 @@ type callInfo struct {
|
||||
GuestLink string
|
||||
}
|
||||
|
||||
type PullConfigResult struct {
|
||||
WebSocket string
|
||||
ChannelID string
|
||||
Hostname string
|
||||
Revision int
|
||||
}
|
||||
|
||||
type slbRequest struct {
|
||||
UserToken string `json:"userToken"`
|
||||
IsOneToOne bool `json:"isOneToOne"`
|
||||
@@ -115,6 +125,8 @@ func (c *Client) JoinAsGuest(alias, displayName string) (JoinResult, error) {
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
c.chatID = conf.ChatID
|
||||
c.conferenceID = conf.ConferenceID
|
||||
userToken, err := c.registerGuest(conf, displayName)
|
||||
if err != nil {
|
||||
return res, err
|
||||
@@ -134,6 +146,7 @@ func (c *Client) JoinAsHost(alias string) (JoinResult, error) {
|
||||
return res, err
|
||||
}
|
||||
c.LogFn("[host] conference chatId=%s conferenceId=%s", conf.ChatID, conf.ConferenceID)
|
||||
c.chatID = conf.ChatID
|
||||
callToken, userToken, err := c.getCallToken(conf.ChatID)
|
||||
if err != nil {
|
||||
return res, err
|
||||
@@ -154,6 +167,7 @@ func (c *Client) CreateAndJoin() (JoinResult, string, error) {
|
||||
if err != nil {
|
||||
return res, "", err
|
||||
}
|
||||
c.chatID = info.ChatID
|
||||
guestLink := info.GuestLink
|
||||
if guestLink == "" {
|
||||
guestLink, err = c.getGuestLink(info.ChatID)
|
||||
@@ -216,6 +230,15 @@ func (c *Client) restForm(action string, form url.Values) ([]byte, int, error) {
|
||||
return c.do("POST", endpoint, "application/x-www-form-urlencoded", strings.NewReader(form.Encode()))
|
||||
}
|
||||
|
||||
func (c *Client) restFormAuthed(action string, form url.Values) ([]byte, int, error) {
|
||||
endpoint := c.portal + "/rest/" + action + ".json"
|
||||
if c.sessid != "" {
|
||||
form.Set("sessid", c.sessid)
|
||||
endpoint += "?sessid=" + url.QueryEscape(c.sessid)
|
||||
}
|
||||
return c.do("POST", endpoint, "application/x-www-form-urlencoded", strings.NewReader(form.Encode()))
|
||||
}
|
||||
|
||||
func (c *Client) ajaxAction(action string, form url.Values) ([]byte, int, error) {
|
||||
endpoint := c.portal + "/bitrix/services/main/ajax.php?action=" + action
|
||||
if c.sessid != "" {
|
||||
@@ -426,6 +449,125 @@ func (c *Client) createRoom() (callInfo, error) {
|
||||
return info, nil
|
||||
}
|
||||
|
||||
func (c *Client) KickUser(userID string) error {
|
||||
if c.chatID == "" {
|
||||
return fmt.Errorf("kick: no active chatId")
|
||||
}
|
||||
if userID == "" {
|
||||
return fmt.Errorf("kick: empty userId")
|
||||
}
|
||||
form := url.Values{}
|
||||
form.Set("chatId", c.chatID)
|
||||
form.Set("userId", userID)
|
||||
body, status, err := c.withRelogin(func() ([]byte, int, error) {
|
||||
return c.ajaxAction("im.v2.Chat.deleteUser", form)
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var out struct {
|
||||
Status string `json:"status"`
|
||||
Errors []struct {
|
||||
Code json.Number `json:"code"`
|
||||
Message string `json:"message"`
|
||||
} `json:"errors"`
|
||||
}
|
||||
if err := json.Unmarshal(body, &out); err != nil {
|
||||
return fmt.Errorf("kick: %w (status %d, body %s)", err, status, common.BodySnippet(body))
|
||||
}
|
||||
if len(out.Errors) > 0 {
|
||||
return fmt.Errorf("kick: chatId=%s userId=%s rejected (status %d, %s %s)", c.chatID, userID, status, out.Errors[0].Code.String(), out.Errors[0].Message)
|
||||
}
|
||||
c.LogFn("[kick] removed userId=%s from chatId=%s", userID, c.chatID)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Client) SelfUserID() (string, error) {
|
||||
if c.selfUserID != "" {
|
||||
return c.selfUserID, nil
|
||||
}
|
||||
id, err := c.currentUserID()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
c.selfUserID = id
|
||||
return id, nil
|
||||
}
|
||||
|
||||
func (c *Client) callHash() string {
|
||||
if c.HTTP == nil || c.HTTP.Jar == nil {
|
||||
return ""
|
||||
}
|
||||
u, err := url.Parse(c.portal)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
for _, ck := range c.HTTP.Jar.Cookies(u) {
|
||||
if ck.Name == "BITRIX_CALL_HASH" {
|
||||
return ck.Value
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (c *Client) PullConfig() (PullConfigResult, error) {
|
||||
var pc PullConfigResult
|
||||
form := url.Values{}
|
||||
form.Set("CACHE", "N")
|
||||
var body []byte
|
||||
var status int
|
||||
var err error
|
||||
if hash := c.callHash(); hash != "" {
|
||||
form.Set("call_auth_id", hash)
|
||||
form.Set("videoconf_id", c.conferenceID)
|
||||
form.Set("call_chat_id", c.chatID)
|
||||
body, status, err = c.restForm("pull.config.get", form)
|
||||
} else {
|
||||
body, status, err = c.withRelogin(func() ([]byte, int, error) {
|
||||
return c.restFormAuthed("pull.config.get", form)
|
||||
})
|
||||
}
|
||||
if err != nil {
|
||||
return pc, err
|
||||
}
|
||||
var out struct {
|
||||
Result struct {
|
||||
Server struct {
|
||||
WebSocket string `json:"websocket"`
|
||||
} `json:"server"`
|
||||
API struct {
|
||||
RevisionWeb int `json:"revision_web"`
|
||||
} `json:"api"`
|
||||
Channels struct {
|
||||
Shared struct {
|
||||
ID string `json:"id"`
|
||||
} `json:"shared"`
|
||||
Private struct {
|
||||
ID string `json:"id"`
|
||||
} `json:"private"`
|
||||
} `json:"channels"`
|
||||
} `json:"result"`
|
||||
Error string `json:"error"`
|
||||
}
|
||||
if err := json.Unmarshal(body, &out); err != nil {
|
||||
return pc, fmt.Errorf("pull config: %w (status %d, body %s)", err, status, common.BodySnippet(body))
|
||||
}
|
||||
if out.Result.Server.WebSocket == "" || out.Result.Channels.Private.ID == "" {
|
||||
return pc, fmt.Errorf("pull config: missing websocket/channel (status %d, body %s)", status, common.BodySnippet(body))
|
||||
}
|
||||
pc.WebSocket = out.Result.Server.WebSocket
|
||||
pc.ChannelID = out.Result.Channels.Private.ID
|
||||
if out.Result.Channels.Shared.ID != "" {
|
||||
pc.ChannelID += "/" + out.Result.Channels.Shared.ID
|
||||
}
|
||||
pc.Revision = out.Result.API.RevisionWeb
|
||||
pc.Hostname = c.portal
|
||||
if u, perr := url.Parse(c.portal); perr == nil && u.Host != "" {
|
||||
pc.Hostname = u.Host
|
||||
}
|
||||
return pc, nil
|
||||
}
|
||||
|
||||
func (c *Client) getGuestLink(chatID string) (string, error) {
|
||||
form := url.Values{}
|
||||
form.Set("chatId", chatID)
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package bitrix
|
||||
|
||||
import "sync"
|
||||
|
||||
type KickManager struct {
|
||||
kick func(userID string) error
|
||||
selfID string
|
||||
logFn func(string, ...any)
|
||||
|
||||
mu sync.Mutex
|
||||
active string
|
||||
}
|
||||
|
||||
func NewKickManager(kick func(userID string) error, selfID string, logFn func(string, ...any)) *KickManager {
|
||||
return &KickManager{kick: kick, selfID: selfID, logFn: logFn}
|
||||
}
|
||||
|
||||
func (m *KickManager) OnUserJoined(userID string) {
|
||||
if userID == "" || userID == m.selfID {
|
||||
return
|
||||
}
|
||||
m.mu.Lock()
|
||||
old := m.active
|
||||
if old == userID {
|
||||
m.mu.Unlock()
|
||||
return
|
||||
}
|
||||
m.active = userID
|
||||
m.mu.Unlock()
|
||||
|
||||
if old == "" {
|
||||
m.logFn("[bx] active call guest userId=%s", userID)
|
||||
return
|
||||
}
|
||||
if err := m.kick(old); err != nil {
|
||||
m.logFn("[bx] kick failed userId=%s: %v", old, err)
|
||||
return
|
||||
}
|
||||
m.logFn("[bx] kicked previous guest userId=%s, new active=%s", old, userID)
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
package bitrix
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
|
||||
"whitelist-bypass/relay/common"
|
||||
)
|
||||
|
||||
const (
|
||||
pullWireVarint = 0
|
||||
pullWireFixed64 = 1
|
||||
pullWireBytes = 2
|
||||
pullWireFixed32 = 5
|
||||
pullMaxDepth = 8
|
||||
)
|
||||
|
||||
type PullClient struct {
|
||||
cfg PullConfigResult
|
||||
ua string
|
||||
origin string
|
||||
logFn func(string, ...any)
|
||||
|
||||
mu sync.Mutex
|
||||
ws *websocket.Conn
|
||||
closed bool
|
||||
|
||||
onUsersAnswered func([]string)
|
||||
onUserLeave func(string)
|
||||
}
|
||||
|
||||
func NewPullClient(cfg PullConfigResult, ua, origin string, logFn func(string, ...any)) *PullClient {
|
||||
return &PullClient{cfg: cfg, ua: ua, origin: origin, logFn: logFn}
|
||||
}
|
||||
|
||||
func (p *PullClient) SetOnUsersAnswered(fn func([]string)) { p.onUsersAnswered = fn }
|
||||
|
||||
func (p *PullClient) SetOnUserLeave(fn func(string)) { p.onUserLeave = fn }
|
||||
|
||||
func (p *PullClient) dialURL() string {
|
||||
q := url.Values{}
|
||||
q.Set("CHANNEL_ID", p.cfg.ChannelID)
|
||||
q.Set("binaryMode", "true")
|
||||
if p.cfg.Hostname != "" {
|
||||
q.Set("hostname", p.cfg.Hostname)
|
||||
}
|
||||
if p.cfg.Revision > 0 {
|
||||
q.Set("revision", fmt.Sprintf("%d", p.cfg.Revision))
|
||||
}
|
||||
sep := "?"
|
||||
if strings.Contains(p.cfg.WebSocket, "?") {
|
||||
sep = "&"
|
||||
}
|
||||
return p.cfg.WebSocket + sep + q.Encode()
|
||||
}
|
||||
|
||||
func (p *PullClient) connect() error {
|
||||
headers := http.Header{}
|
||||
if p.ua != "" {
|
||||
headers.Set("User-Agent", p.ua)
|
||||
}
|
||||
if p.origin != "" {
|
||||
headers.Set("Origin", p.origin)
|
||||
}
|
||||
conn, resp, err := websocket.DefaultDialer.Dial(p.dialURL(), headers)
|
||||
if err != nil {
|
||||
if resp != nil {
|
||||
return fmt.Errorf("subws2 dial: %w, status %d", err, resp.StatusCode)
|
||||
}
|
||||
return fmt.Errorf("subws2 dial: %w", err)
|
||||
}
|
||||
p.mu.Lock()
|
||||
p.ws = conn
|
||||
p.mu.Unlock()
|
||||
p.logFn("[bx] subws2 connected")
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *PullClient) Run() error {
|
||||
if err := p.connect(); err != nil {
|
||||
return err
|
||||
}
|
||||
for {
|
||||
p.mu.Lock()
|
||||
ws := p.ws
|
||||
closed := p.closed
|
||||
p.mu.Unlock()
|
||||
if closed || ws == nil {
|
||||
return nil
|
||||
}
|
||||
_, data, err := ws.ReadMessage()
|
||||
if err != nil {
|
||||
p.mu.Lock()
|
||||
closed = p.closed
|
||||
p.mu.Unlock()
|
||||
if closed {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("subws2 read: %w", err)
|
||||
}
|
||||
p.handleFrame(data)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *PullClient) Close() {
|
||||
p.mu.Lock()
|
||||
p.closed = true
|
||||
ws := p.ws
|
||||
p.ws = nil
|
||||
p.mu.Unlock()
|
||||
if ws != nil {
|
||||
common.CloseWS(ws)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *PullClient) handleFrame(frame []byte) {
|
||||
for _, body := range extractPullBodies(frame) {
|
||||
var msg struct {
|
||||
ModuleID string `json:"module_id"`
|
||||
Command string `json:"command"`
|
||||
Params struct {
|
||||
Senders []struct {
|
||||
SenderID json.Number `json:"senderId"`
|
||||
} `json:"senders"`
|
||||
UserID json.Number `json:"userId"`
|
||||
} `json:"params"`
|
||||
}
|
||||
if err := json.Unmarshal(body, &msg); err != nil {
|
||||
continue
|
||||
}
|
||||
switch {
|
||||
case msg.ModuleID == "call" && strings.Contains(msg.Command, "usersAnswered"):
|
||||
var ids []string
|
||||
for _, s := range msg.Params.Senders {
|
||||
if id := s.SenderID.String(); id != "" {
|
||||
ids = append(ids, id)
|
||||
}
|
||||
}
|
||||
if len(ids) > 0 && p.onUsersAnswered != nil {
|
||||
p.onUsersAnswered(ids)
|
||||
}
|
||||
case msg.ModuleID == "im" && msg.Command == "chatUserLeave":
|
||||
if uid := msg.Params.UserID.String(); uid != "" && p.onUserLeave != nil {
|
||||
p.onUserLeave(uid)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func extractPullBodies(buf []byte) [][]byte {
|
||||
return collectPullBodies(buf, nil, 0)
|
||||
}
|
||||
|
||||
func collectPullBodies(buf []byte, out [][]byte, depth int) [][]byte {
|
||||
if depth > pullMaxDepth {
|
||||
return out
|
||||
}
|
||||
for len(buf) > 0 {
|
||||
value, rest, ok := nextPullField(buf)
|
||||
if !ok {
|
||||
return out
|
||||
}
|
||||
buf = rest
|
||||
switch {
|
||||
case len(value) == 0:
|
||||
case value[0] == '{':
|
||||
out = append(out, value)
|
||||
default:
|
||||
out = collectPullBodies(value, out, depth+1)
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func nextPullField(buf []byte) (value, rest []byte, ok bool) {
|
||||
tag, n := binary.Uvarint(buf)
|
||||
if n <= 0 {
|
||||
return nil, nil, false
|
||||
}
|
||||
buf = buf[n:]
|
||||
switch tag & 7 {
|
||||
case pullWireVarint:
|
||||
_, m := binary.Uvarint(buf)
|
||||
if m <= 0 {
|
||||
return nil, nil, false
|
||||
}
|
||||
return nil, buf[m:], true
|
||||
case pullWireFixed64:
|
||||
return skipPullFixed(buf, 8)
|
||||
case pullWireFixed32:
|
||||
return skipPullFixed(buf, 4)
|
||||
case pullWireBytes:
|
||||
l, m := binary.Uvarint(buf)
|
||||
if m <= 0 || l > uint64(len(buf)-m) {
|
||||
return nil, nil, false
|
||||
}
|
||||
end := m + int(l)
|
||||
return buf[m:end], buf[end:], true
|
||||
}
|
||||
return nil, nil, false
|
||||
}
|
||||
|
||||
func skipPullFixed(buf []byte, size int) (value, rest []byte, ok bool) {
|
||||
if len(buf) < size {
|
||||
return nil, nil, false
|
||||
}
|
||||
return nil, buf[size:], true
|
||||
}
|
||||
@@ -115,6 +115,8 @@ func (s *Signal) SetOnDataChannel(fn func(*webrtc.DataChannel)) {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Signal) LocalUserID() string { return s.lk.Join().LocalUserID }
|
||||
|
||||
func (s *Signal) PubReliableDC() *webrtc.DataChannel {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
@@ -39,6 +39,38 @@ func LoadCookies(path string) string {
|
||||
return strings.Join(parts, "; ")
|
||||
}
|
||||
|
||||
func UpdateCookieFile(path string, updates map[string]string) error {
|
||||
if len(updates) == 0 {
|
||||
return nil
|
||||
}
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var raw []map[string]any
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
return err
|
||||
}
|
||||
seen := make(map[string]bool, len(updates))
|
||||
for _, c := range raw {
|
||||
name, _ := c["name"].(string)
|
||||
if v, ok := updates[name]; ok {
|
||||
c["value"] = v
|
||||
seen[name] = true
|
||||
}
|
||||
}
|
||||
for name, v := range updates {
|
||||
if !seen[name] {
|
||||
raw = append(raw, map[string]any{"name": name, "value": v})
|
||||
}
|
||||
}
|
||||
out, err := json.MarshalIndent(raw, "", " ")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return os.WriteFile(path, out, 0o600)
|
||||
}
|
||||
|
||||
func CookieValue(cookieHeader, name string) string {
|
||||
for _, part := range strings.Split(cookieHeader, ";") {
|
||||
part = strings.TrimSpace(part)
|
||||
|
||||
@@ -92,6 +92,7 @@ type Call struct {
|
||||
|
||||
OnConnected func(tunnel.DataTunnel)
|
||||
OnPeerRestart func()
|
||||
OnKicked func()
|
||||
OnRemoteSDP func(sdp string)
|
||||
|
||||
done chan struct{}
|
||||
@@ -186,6 +187,13 @@ func (c *Call) Start() error {
|
||||
default:
|
||||
}
|
||||
}
|
||||
signaling.OnKicked = func() {
|
||||
c.cfg.LogFn("[call] server kicked us, tearing down")
|
||||
if c.OnKicked != nil {
|
||||
c.OnKicked()
|
||||
}
|
||||
c.Close()
|
||||
}
|
||||
signaling.OnSpeakerJoined = c.handleSpeakerJoined
|
||||
signaling.OnSpeakerDisconnected = c.handleSpeakerDisconnected
|
||||
signaling.OnSpeakerCamStateChanged = c.handleSpeakerCamStateChanged
|
||||
|
||||
@@ -229,6 +229,7 @@ type SignalingClient struct {
|
||||
OnGetVideoFromUserResponse func(resp GetVideoFromUserResponse, errCode int, errMessage string)
|
||||
OnGetScreenSharingFromUserResponse func(resp GetScreenSharingFromUserResponse, errCode int, errMessage string)
|
||||
OnHeartbeat func()
|
||||
OnKicked func()
|
||||
OnUnknown func(method string, params json.RawMessage)
|
||||
OnDataChannelMessage func(method string, params json.RawMessage)
|
||||
}
|
||||
@@ -652,6 +653,11 @@ func (c *SignalingClient) dispatch(frame Frame) {
|
||||
if c.OnHeartbeat != nil {
|
||||
c.OnHeartbeat()
|
||||
}
|
||||
case MethodServerYouKicked:
|
||||
c.logFn("dion: server:you_kicked")
|
||||
if c.OnKicked != nil {
|
||||
c.OnKicked()
|
||||
}
|
||||
case MethodServerGetVideoFromUser:
|
||||
var resp GetVideoFromUserResponse
|
||||
_ = json.Unmarshal(frame.Params, &resp)
|
||||
|
||||
@@ -183,8 +183,9 @@ type jsonJoin struct {
|
||||
PingInterval int32 `json:"pingInterval"`
|
||||
ICEServers []jsonICEServer `json:"iceServers"`
|
||||
Local struct {
|
||||
SID string `json:"sid"`
|
||||
Name string `json:"name"`
|
||||
SID string `json:"sid"`
|
||||
Name string `json:"name"`
|
||||
UserID string `json:"userId"`
|
||||
} `json:"localParticipant"`
|
||||
}
|
||||
|
||||
@@ -231,6 +232,7 @@ func (JSONCodec) Decode(data []byte) (Event, error) {
|
||||
RoomName: ji.RoomID,
|
||||
ParticipantSID: ji.Local.SID,
|
||||
ParticipantID: ji.Local.Name,
|
||||
LocalUserID: ji.Local.UserID,
|
||||
PingIntervalSec: ji.PingInterval,
|
||||
}
|
||||
for _, is := range ji.ICEServers {
|
||||
|
||||
@@ -183,6 +183,7 @@ type joinResponse struct {
|
||||
RoomName string
|
||||
ParticipantSID string
|
||||
ParticipantID string
|
||||
LocalUserID string
|
||||
ServerVersion string
|
||||
ServerRegion string
|
||||
ICEServers []iceServer
|
||||
|
||||
@@ -40,6 +40,7 @@ type BitrixHeadlessJoiner struct {
|
||||
sessMu sync.Mutex
|
||||
sig *bitrix.Signal
|
||||
ms *bitrix.MediaSession
|
||||
pull *bitrix.PullClient
|
||||
|
||||
closeMu sync.Mutex
|
||||
closed bool
|
||||
@@ -235,6 +236,8 @@ func (j *BitrixHeadlessJoiner) runOnce() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
j.startKickWatch(c, sig, userAgent)
|
||||
|
||||
if err := ms.Start(); err != nil {
|
||||
sig.Close()
|
||||
return fmt.Errorf("media start: %w", err)
|
||||
@@ -279,13 +282,47 @@ func (j *BitrixHeadlessJoiner) setSession(sig *bitrix.Signal, ms *bitrix.MediaSe
|
||||
j.sessMu.Unlock()
|
||||
}
|
||||
|
||||
func (j *BitrixHeadlessJoiner) startKickWatch(c *bitrix.Client, sig *bitrix.Signal, userAgent string) {
|
||||
selfID := sig.LocalUserID()
|
||||
if selfID == "" {
|
||||
j.logFn("bitrix-joiner: self userId unknown, kick-detect disabled")
|
||||
return
|
||||
}
|
||||
pc, err := c.PullConfig()
|
||||
if err != nil {
|
||||
j.logFn("bitrix-joiner: pull config failed, kick-detect disabled: %s", common.MaskError(err))
|
||||
return
|
||||
}
|
||||
pull := bitrix.NewPullClient(pc, userAgent, j.portal, j.logFn)
|
||||
pull.SetOnUserLeave(func(uid string) {
|
||||
if uid != selfID {
|
||||
return
|
||||
}
|
||||
j.logFn("bitrix-joiner: kicked from conference (userId=%s), shutting down", uid)
|
||||
go j.Close()
|
||||
})
|
||||
j.sessMu.Lock()
|
||||
j.pull = pull
|
||||
j.sessMu.Unlock()
|
||||
go func() {
|
||||
if err := pull.Run(); err != nil {
|
||||
j.logFn("bitrix-joiner: subws2 pull ended: %s", common.MaskError(err))
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func (j *BitrixHeadlessJoiner) resetSessionState() {
|
||||
j.sessMu.Lock()
|
||||
sig := j.sig
|
||||
ms := j.ms
|
||||
pull := j.pull
|
||||
j.sig = nil
|
||||
j.ms = nil
|
||||
j.pull = nil
|
||||
j.sessMu.Unlock()
|
||||
if pull != nil {
|
||||
pull.Close()
|
||||
}
|
||||
if ms != nil {
|
||||
ms.Stop()
|
||||
}
|
||||
|
||||
@@ -130,6 +130,10 @@ func (j *DionHeadlessJoiner) runOnce(httpClient *http.Client, slug, displayName
|
||||
j.OnConnected(tun)
|
||||
}
|
||||
}
|
||||
call.OnKicked = func() {
|
||||
j.logFn("dion-joiner: kicked from conference, shutting down")
|
||||
go j.Close()
|
||||
}
|
||||
|
||||
j.mu.Lock()
|
||||
if j.closed {
|
||||
|
||||
@@ -14,9 +14,9 @@ import (
|
||||
const (
|
||||
defaultVP8FPS = 24
|
||||
defaultVP8Batch = 30
|
||||
keepaliveIdlePeriod = 5 * time.Second
|
||||
keepaliveIdleMin = 3 * time.Second
|
||||
keepaliveIdleMax = 8 * time.Second
|
||||
keepaliveIdlePeriod = 100 * time.Millisecond
|
||||
keepaliveIdleMin = 60 * time.Millisecond
|
||||
keepaliveIdleMax = 200 * time.Millisecond
|
||||
keepalivePadMax = 176
|
||||
sendQueueDepth = 128
|
||||
|
||||
|
||||
+13
-7
@@ -267,10 +267,10 @@ func newRequestID() string {
|
||||
return fmt.Sprintf("%x-%x-%x-%x-%x", b[0:4], b[4:6], b[6:8], b[8:10], b[10:16])
|
||||
}
|
||||
|
||||
func RefreshAccessToken(client *http.Client, cookieHeader, deviceID string) (string, error) {
|
||||
func RefreshAccessToken(client *http.Client, cookieHeader, deviceID string) (string, map[string]string, error) {
|
||||
req, err := http.NewRequest(http.MethodPost, "https://auth-stream.wb.ru/v2/auth/slide-v3", bytes.NewReader(nil))
|
||||
if err != nil {
|
||||
return "", err
|
||||
return "", nil, err
|
||||
}
|
||||
if deviceID == "" {
|
||||
deviceID = newRequestID()
|
||||
@@ -289,21 +289,27 @@ func RefreshAccessToken(client *http.Client, cookieHeader, deviceID string) (str
|
||||
}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
return "", nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
rotated := make(map[string]string)
|
||||
for _, ck := range resp.Cookies() {
|
||||
if ck.Value != "" {
|
||||
rotated[ck.Name] = ck.Value
|
||||
}
|
||||
}
|
||||
raw, _ := io.ReadAll(resp.Body)
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return "", fmt.Errorf("slide-v3: status %d: %s", resp.StatusCode, string(raw))
|
||||
return "", nil, fmt.Errorf("slide-v3: status %d: %s", resp.StatusCode, string(raw))
|
||||
}
|
||||
var r slideV3Response
|
||||
if err := json.Unmarshal(raw, &r); err != nil {
|
||||
return "", fmt.Errorf("slide-v3 decode: %w", err)
|
||||
return "", nil, fmt.Errorf("slide-v3 decode: %w", err)
|
||||
}
|
||||
if r.Payload.AccessToken == "" {
|
||||
return "", fmt.Errorf("slide-v3: empty access_token in response: %s", string(raw))
|
||||
return "", nil, fmt.Errorf("slide-v3: empty access_token in response: %s", string(raw))
|
||||
}
|
||||
return r.Payload.AccessToken, nil
|
||||
return r.Payload.AccessToken, rotated, nil
|
||||
}
|
||||
|
||||
func joinAndGetDetails(client *http.Client, accessToken, roomID, displayName string) (string, string, string, string, error) {
|
||||
|
||||
Reference in new issue
Block a user