Skip to content

Implement Single-QR WebRTC Flow for Offline Connectivity#9

Draft
Copilot wants to merge 8 commits intomainfrom
copilot/fix-8
Draft

Implement Single-QR WebRTC Flow for Offline Connectivity#9
Copilot wants to merge 8 commits intomainfrom
copilot/fix-8

Conversation

Copy link

Copilot AI commented May 20, 2025

This PR implements a "Single-QR / no-return-trip" WebRTC flow for improved offline connectivity, following the Pion-style offline trick approach. This allows the application to work in local LAN environments without requiring Internet connectivity or return-trip signaling.

Key Features

  • WebRTC Mode: Added WebRTC data channel support using node-datachannel with ICE-lite mode
  • Single-QR Connection: The entire connection is established with just one QR code scan
  • No Return Trip: Modified WebRTC signaling to avoid client-to-server return trip
  • LAN Support: Works in offline LAN environments without STUN/TURN servers
  • Fixed Credentials: Uses session-wide fixed ICE credentials and DTLS certificate
  • Backwards Compatible: Maintains legacy WebSocket mode for compatibility

Implementation Details

  • Server generates SDP answer with ICE credentials and certificate fingerprint
  • QR code contains the complete SDP answer
  • Client patches its offer with server's ICE credentials
  • Connection is established with complementary fingerprints and shared credentials

Command Line Options

# WebRTC mode (default)
barbarcode -p 8080 -s inventory_input --rtc

# Legacy WebSocket mode
barbarcode -p 8080 -s inventory_input --ws

The WebRTC mode offers better security and reliability in offline environments where WebSockets may not be viable.

Fixes #8.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: Yukaii <4230968+Yukaii@users.noreply.github.com>
Copilot AI changed the title [WIP] “Single-QR / no-return-trip” WebRTC flow Implement Single-QR WebRTC Flow for Offline Connectivity May 20, 2025
Copilot AI requested a review from Yukaii May 20, 2025 16:51
Copilot finished work on behalf of Yukaii May 20, 2025 16:51
@Yukaii
Copy link
Owner

Yukaii commented May 20, 2025

@copilot To add a little more context. Check out #7 for my WIP on WebRTC.

The PWA client should also support reading SDP and additional credentials for connection from the printed QR code on the server. I was using a technique of cycling through a set of different QR codes that encoded JSON chunks, and scanning to recover the final data on the client. So our current command-line server also needs a TUI to achieve this. I was also patching node-libdatachannel for better logging.

@Yukaii
Copy link
Owner

Yukaii commented May 20, 2025

@copilot try again, since the changes in comment #9 (comment) not delivered

@Yukaii
Copy link
Owner

Yukaii commented May 21, 2025

@copilot try again, since the changes in comment #9 (comment) not delivered

Co-authored-by: Yukaii <4230968+Yukaii@users.noreply.github.com>
Copy link
Author

Copilot AI commented May 21, 2025

@copilot try again, since the changes in comment #9 (comment) not delivered

Implemented the TUI for cycling through QR codes with these features:

  1. Added a terminal UI for displaying multiple QR codes in sequence
  2. Created a chunking system to break large WebRTC connection data into smaller parts
  3. Client now automatically reassembles the chunks when scanned
  4. Added manual navigation and auto-cycling options in the TUI

Changes in 8a7c119.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • bin.equinox.io
    • Triggering command: node ./postinstall.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of Yukaii May 21, 2025 05:55
@Yukaii
Copy link
Owner

Yukaii commented May 21, 2025

@copilot Could you replace blessed with ink? It's more actively maintained. Also check #7 for reference

Co-authored-by: Yukaii <4230968+Yukaii@users.noreply.github.com>
Copy link
Author

Copilot AI commented May 21, 2025

@copilot Could you replace blessed with ink? It's more actively maintained. Also check #7 for reference

Replaced blessed with ink in deecef3. Created a React-based implementation that maintains the same public API for QRCycleTUI class with these features:

  • Terminal UI for displaying QR codes with auto-cycling
  • QR chunking support for larger WebRTC connection data
  • Navigation between QR chunks with keyboard controls
  • Cleaner, more modern React component architecture
  • Based on your implementation in PR try webrtc again #7

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • cdn.fwupd.org
    • Triggering command: /usr/bin/fwupdmgr refresh (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI and others added 4 commits May 21, 2025 10:19
Co-authored-by: Yukaii <4230968+Yukaii@users.noreply.github.com>
Co-authored-by: Yukaii <4230968+Yukaii@users.noreply.github.com>
Co-authored-by: Yukaii <4230968+Yukaii@users.noreply.github.com>
Co-authored-by: Yukaii <4230968+Yukaii@users.noreply.github.com>
Copilot finished work on behalf of Yukaii May 21, 2025 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

“Single-QR / no-return-trip” WebRTC flow

2 participants