Skip to content

Implement File-Based UHST Relay Server in PHP#2

Open
dimitrovs wants to merge 2 commits intomainfrom
implement-uhst-relay-server-php-1410713233664337890
Open

Implement File-Based UHST Relay Server in PHP#2
dimitrovs wants to merge 2 commits intomainfrom
implement-uhst-relay-server-php-1410713233664337890

Conversation

@dimitrovs
Copy link
Contributor

Implemented a lightweight, dependency-free UHST (User Hosted Session Traversal) relay server in PHP. The implementation uses local files for coordination and message queuing, making it suitable for deployment on shared hosting providers.

Key features:

  • No Dependencies: Pure PHP 7.4+ implementation.
  • File-Based Coordination: Uses JSON files in a data/ directory.
  • Concurrency Safety: Implements shared and exclusive file locking using flock().
  • SSE Support: Reliable Server-Sent Events stream for real-time message delivery.
  • Security: Validates token and hostId to prevent path traversal.
  • Maintenance: Periodically cleans up files older than 60 seconds.

Fixes #1


PR created automatically by Jules for task 1410713233664337890 started by @dimitrovs

- Implemented core UHST signaling endpoints: host, join, ping, SSE, and send message.
- Used local files in 'data/' directory for session and message coordination.
- Ensured concurrency safety using flock() for all file access.
- Implemented SSE stream with keep-alive and immediate flushing.
- Added input sanitization to prevent path traversal attacks.
- Included automatic cleanup of expired session files.

Co-authored-by: dimitrovs <200772+dimitrovs@users.noreply.github.com>
@google-labs-jules
Copy link

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

- Switched from file-based coordination to MySQL database for state and queuing.
- Implemented stateless JWT-based token system (HMAC-SHA256).
- Used PDO with prepared statements for secure database access.
- Added support for SQLite as a fallback for testing/low-traffic environments.
- Implemented SSE with 5-second heartbeats and 20ms polling for low latency.
- Added automatic schema initialization and cleanup of stale records.
- Included `schema.sql` for manual database setup.

Co-authored-by: dimitrovs <200772+dimitrovs@users.noreply.github.com>
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.

Implement File-Based UHST Relay Server in PHP

1 participant