diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fe4045c..7c042086 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +### Fixed + +- Using only WebRTC to connect to PeerBook + ## [1.8.1] - 2023/9/14 ### Fixed diff --git a/aatp/http_webrtc/lab.yaml b/aatp/http_webrtc/lab.yaml index 3e4ac83d..8c64f2d5 100644 --- a/aatp/http_webrtc/lab.yaml +++ b/aatp/http_webrtc/lab.yaml @@ -26,6 +26,8 @@ services: dockerfile: ./aatp/infra/webexec/Dockerfile args: REF: ${WEBEXEC_REF-master} + environment: + WEBEXEC_SERVER_URL: http://webexec:7777 volumes: - ./aatp/http_webrtc/webexec_conf:/conf - webexec_auth:/auth diff --git a/aatp/infra/redis/Dockerfile b/aatp/infra/redis/Dockerfile new file mode 100644 index 00000000..68908147 --- /dev/null +++ b/aatp/infra/redis/Dockerfile @@ -0,0 +1,3 @@ +FROM redis:alpine +RUN echo "appendonly no" >> /etc/redis.conf +CMD [ "redis-server", "/etc/redis.conf" ] diff --git a/aatp/infra/webexec/docker_entry.sh b/aatp/infra/webexec/docker_entry.sh index 5dfd6797..8e00b37c 100644 --- a/aatp/infra/webexec/docker_entry.sh +++ b/aatp/infra/webexec/docker_entry.sh @@ -19,7 +19,8 @@ if [[ $PEERBOOK == "1" ]] then /scripts/wait-for-it.sh -h peerbook -p 17777 fi +trap 'break' SIGTERM while true do - su - runner -c '/usr/local/bin/webexec start --debug' + su - runner -c "WEBEXEC_SERVER_URL=$WEBEXEC_SERVER_URL /usr/local/bin/webexec start --debug" done diff --git a/aatp/peerbook_webrtc/admin.spec.ts b/aatp/peerbook_webrtc/admin.spec.ts index 8ab4f1ee..888974f2 100644 --- a/aatp/peerbook_webrtc/admin.spec.ts +++ b/aatp/peerbook_webrtc/admin.spec.ts @@ -86,7 +86,7 @@ test.describe('peerbook administration', () => { await page.evaluate(async () => { terminal7.pb.close() try { - await terminal7.pb.connect("$ValidBearer") + await terminal7.pb.connect({token: "$ValidBearer"}) } catch (e) { console.log("pb.connect failed", e) if (e == "Unregistered") @@ -328,9 +328,13 @@ test.describe('peerbook administration', () => { await page.keyboard.press("Enter") await page.keyboard.type('testclient') await page.keyboard.press("Enter") - await sleep(1000) const fp = await page.evaluate(() => terminal7.getFingerprint()) - expect(await redisClient.hGet(`peer:${fp}`, "user")).toBe(uid) + let peerUID = await redisClient.hGet(`peer:${fp}`, "user") + while (!peerUID) { + await sleep(100) + peerUID = await redisClient.hGet(`peer:${fp}`, "user") + } + expect(peerUID).toBe(uid) twr = await getTWRBuffer(page) await page.screenshot({ path: '/result/4.png' }) expect(twr).toMatch(/Email sent/) @@ -346,13 +350,15 @@ test.describe('peerbook administration', () => { expect(url).toMatch(/^http:\/\/peerbook:17777\/verify/) await sleep(500) const fp = await page.evaluate(() => terminal7.getFingerprint()) - console.log("fp", fp) + console.log("new client's fp", fp) expect(await redisClient.hGet(`peer:${fp}`, "user")).toBe("123456") const verifyPage = await (await browser.newContext()).newPage() await verifyPage.goto(url) await verifyPage.screenshot({ path: '/result/6.png' }) await verifyPage.click('button[type="submit"]') - await sleep(500) + // TODO: optimize this sleep. 5 second is the max time it takes for the + // client to be logged in. We should have a retry loop instead. + await sleep(2000) const twr = await getTWRBuffer(page) await page.screenshot({ path: '/result/5.png' }) expect(twr).toMatch(/Logged in/) diff --git a/aatp/peerbook_webrtc/lab.yaml b/aatp/peerbook_webrtc/lab.yaml index 48e7de51..40bec960 100644 --- a/aatp/peerbook_webrtc/lab.yaml +++ b/aatp/peerbook_webrtc/lab.yaml @@ -30,6 +30,7 @@ services: REF: ${WEBEXEC_REF-master} environment: PEERBOOK: 1 + WEBEXEC_SERVER_URL: http://webexec:7777 depends_on: - peerbook volumes: @@ -52,8 +53,11 @@ services: PB_SMTP_HOST: smtp PB_SMTP_PORT: 1025 PB_HOME_URL: http://peerbook:17777 + WEBEXEC_SERVER_URL: http://peerbook:17777 redis: - image: "redis:alpine" + build: + context: . + dockerfile: ./aatp/infra/redis/Dockerfile revenuecat: image: "mockserver/mockserver" environment: diff --git a/aatp/ui/lab.yaml b/aatp/ui/lab.yaml index 99c15dac..7336fd8e 100644 --- a/aatp/ui/lab.yaml +++ b/aatp/ui/lab.yaml @@ -26,8 +26,46 @@ services: dockerfile: ./aatp/infra/webexec/Dockerfile args: REF: ${WEBEXEC_REF-master} + environment: + WEBEXEC_SERVER_URL: http://webexec:7777 volumes: - ./aatp/ui/webexec_conf:/conf - webexec_auth:/auth + peerbook: + build: + context: . + dockerfile: ./aatp/infra/peerbook/Dockerfile + args: + REF: ${PEERBOOK_REF-master} + expose: + - 17777 + depends_on: + - redis + - revenuecat + environment: + REDIS_HOST: redis:6379 + REVENUECAT_URL: http://revenuecat:1080 + PB_SMTP_HOST: smtp + PB_SMTP_PORT: 1025 + PB_HOME_URL: http://peerbook:17777 + WEBEXEC_SERVER_URL: http://peerbook:17777 + redis: + build: + context: . + dockerfile: ./aatp/infra/redis/Dockerfile + revenuecat: + image: "mockserver/mockserver" + environment: + MOCKSERVER_INITIALIZATION_JSON_PATH: /config/revenuecat_double.json + MOCKSERVER_LOG_LEVEL: WARN + expose: + - 1080 + volumes: + - ./aatp/peerbook_webrtc:/config + smtp: + image: jcalonso/mailhog + expose: + - 1025 + - 8025 volumes: webexec_auth: diff --git a/aatp/ui/ui.spec.ts b/aatp/ui/ui.spec.ts index 3bc0717b..8f4a95c6 100644 --- a/aatp/ui/ui.spec.ts +++ b/aatp/ui/ui.spec.ts @@ -39,6 +39,8 @@ test.describe('terminal7 UI', () => { await page.evaluate(async () => { window.terminal7.notify = (msg: string) => console.log("NOTIFY: "+msg) localStorage.setItem("CapacitorStorage.dotfile",` +[net] +peerbook = "peerbook:17777" [peerbook] insecure=true`) localStorage.setItem("CapacitorStorage.gates", JSON.stringify( @@ -82,12 +84,16 @@ insecure=true`) await page.reload({waitUntil: "networkidle"}) await page.evaluate(async () => { window.notifications = [] + while (!window.terminal7) { + await new Promise(r => setTimeout(r, 100)) + } window.terminal7.notify = (m) => window.notifications.push(m) }) await connectFirstGate(page) + await sleep(500) await page.locator('.tabbar .reset').click() await expect(page.locator('#t0')).toBeVisible() - await sleep(500) + await sleep(100) await page.keyboard.press('ArrowDown') await page.keyboard.press('Enter') await expect(page.locator('.windows-container')).toBeHidden() @@ -96,6 +102,9 @@ insecure=true`) await page.reload({waitUntil: "networkidle"}) await page.evaluate(async () => { window.notifications = [] + while (!window.terminal7) { + await new Promise(r => setTimeout(r, 100)) + } window.terminal7.notify = (m) => window.notifications.push(m) }) await connectFirstGate(page) @@ -103,8 +112,9 @@ insecure=true`) await page.screenshot({ path: `/result/2.png` }) await page.locator('.tabbar .reset').click() await expect(page.locator('#t0')).toBeVisible() - await sleep(20) + await sleep(100) await page.keyboard.press('Enter') + await sleep(100) await expect(page.locator('#t0')).toBeHidden() await expect(page.locator('.pane')).toHaveCount(1) await expect(page.locator('.windows-container')).toBeVisible() diff --git a/index.html b/index.html index 12189920..4654fdf2 100644 --- a/index.html +++ b/index.html @@ -59,6 +59,7 @@

T7