Skip to content

Conversation

lixmal
Copy link
Collaborator

@lixmal lixmal commented Aug 29, 2025

Describe your changes

Issue ticket number and link

Stack

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)

By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.

Documentation

Select exactly one:

  • I added/updated documentation for this change
  • Documentation is not needed for this change (explain why)

Docs PR URL (required if "docs added" is checked)

Paste the PR link from https://github.com/netbirdio/docs here:

https://github.com/netbirdio/docs/pull/__

@lixmal lixmal changed the title Add wasm client [client] Add wasm client Aug 29, 2025
@lixmal lixmal changed the title [client] Add wasm client [client,relay] Add wasm client Aug 29, 2025
@lixmal lixmal changed the title [client,relay] Add wasm client [client] Add wasm client Sep 1, 2025
@lixmal lixmal marked this pull request as ready for review September 1, 2025 17:48
@Copilot Copilot AI review requested due to automatic review settings September 1, 2025 17:48
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds WebAssembly (WASM) client support to NetBird, enabling NetBird to run in browser environments. The implementation provides browser-compatible networking through WebSocket proxies and userspace networking.

  • Platform-specific build configurations to enable/disable features based on WASM constraints
  • WASM-specific networking implementations using WebSocket transport for gRPC and relay connections
  • Browser-compatible SSH, RDP and HTTP proxy functionality for connecting to NetBird network resources

Reviewed Changes

Copilot reviewed 56 out of 58 changed files in this pull request and generated 13 comments.

Show a summary per file
File Description
util/wsproxy/constants.go Defines WebSocket proxy constants and error types
util/wsproxy/client/dialer_js.go WASM WebSocket dialer for gRPC connections
util/grpc/dialer_*.go Platform-specific gRPC dialers (WASM vs generic)
client/wasm/* WASM client implementation with SSH, RDP, HTTP proxy support
client/embed/embed.go Enhanced embedded client with JWT authentication
Various platform-specific files Build tag constraints to separate WASM from non-WASM implementations

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@@ -38,8 +38,7 @@ func (c *Conn) Read(b []byte) (n int, err error) {
}

func (c *Conn) Write(b []byte) (n int, err error) {
err = c.Conn.Write(c.ctx, websocket.MessageBinary, b)
return 0, err
return 0, c.Conn.Write(c.ctx, websocket.MessageBinary, b)
Copy link
Preview

Copilot AI Sep 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function signature expects to return (int, error) but is returning (0, error). This doesn't indicate how many bytes were written. Should return len(b) on successful write.

Suggested change
return 0, c.Conn.Write(c.ctx, websocket.MessageBinary, b)
err = c.Conn.Write(c.ctx, websocket.MessageBinary, b)
if err != nil {
return 0, err
}
return len(b), nil

Copilot uses AI. Check for mistakes.

Copy link

sonarqubecloud bot commented Sep 3, 2025

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.

1 participant