diff --git a/src/bun.js/api/bun/socket.zig b/src/bun.js/api/bun/socket.zig index 4280f785fa..383e0061eb 100644 --- a/src/bun.js/api/bun/socket.zig +++ b/src/bun.js/api/bun/socket.zig @@ -1057,13 +1057,13 @@ pub const Listener = struct { } const vm = globalObject.bunVM(); - const socket_config = SocketConfig.fromJS(vm, opts, globalObject, exception) orelse { + var socket_config: SocketConfig = SocketConfig.fromJS(vm, opts, globalObject, exception) orelse { return .zero; }; var hostname_or_unix = socket_config.hostname_or_unix; const port = socket_config.port; - var ssl = socket_config.ssl; + var ssl = if (socket_config.ssl) |*ssl_config| ssl_config else null; var handlers = socket_config.handlers; var default_data = socket_config.default_data; @@ -1178,8 +1178,8 @@ pub const Listener = struct { } } - const ctx_opts: uws.us_bun_socket_context_options_t = if (ssl != null) - JSC.API.ServerConfig.SSLConfig.asUSockets(&ssl.?) + const ctx_opts: uws.us_bun_socket_context_options_t = if (ssl) |ssl_config| + JSC.API.ServerConfig.SSLConfig.asUSockets(ssl_config) else .{}; @@ -3996,7 +3996,7 @@ pub const WindowsNamedPipeContext = if (Environment.isWindows) struct { return this; } - pub fn open(globalThis: *JSC.JSGlobalObject, fd: bun.FileDescriptor, ssl_config: ?JSC.API.ServerConfig.SSLConfig, socket: SocketType) !*uws.WindowsNamedPipe { + pub fn open(globalThis: *JSC.JSGlobalObject, fd: bun.FileDescriptor, ssl_config: ?*const JSC.API.ServerConfig.SSLConfig, socket: SocketType) !*uws.WindowsNamedPipe { // TODO: reuse the same context for multiple connections when possibles const this = WindowsNamedPipeContext.create(globalThis, socket); @@ -4017,7 +4017,7 @@ pub const WindowsNamedPipeContext = if (Environment.isWindows) struct { return &this.named_pipe; } - pub fn connect(globalThis: *JSC.JSGlobalObject, path: []const u8, ssl_config: ?JSC.API.ServerConfig.SSLConfig, socket: SocketType) !*uws.WindowsNamedPipe { + pub fn connect(globalThis: *JSC.JSGlobalObject, path: []const u8, ssl_config: ?*const JSC.API.ServerConfig.SSLConfig, socket: SocketType) !*uws.WindowsNamedPipe { // TODO: reuse the same context for multiple connections when possibles const this = WindowsNamedPipeContext.create(globalThis, socket); diff --git a/src/deps/uws.zig b/src/deps/uws.zig index 908879d75e..76e09504f1 100644 --- a/src/deps/uws.zig +++ b/src/deps/uws.zig @@ -857,11 +857,11 @@ pub const WindowsNamedPipe = if (Environment.isWindows) struct { } return .{ .result = {} }; } - pub fn open(this: *WindowsNamedPipe, fd: bun.FileDescriptor, ssl_options: ?JSC.API.ServerConfig.SSLConfig) JSC.Maybe(void) { + pub fn open(this: *WindowsNamedPipe, fd: bun.FileDescriptor, ssl_options: ?*const JSC.API.ServerConfig.SSLConfig) JSC.Maybe(void) { bun.assert(this.pipe != null); this.flags.disconnected = true; - if (ssl_options) |*tls| { + if (ssl_options) |tls| { this.flags.is_ssl = true; this.wrapper = WrapperType.init(tls, true, .{ .ctx = this, @@ -893,13 +893,13 @@ pub const WindowsNamedPipe = if (Environment.isWindows) struct { return .{ .result = {} }; } - pub fn connect(this: *WindowsNamedPipe, path: []const u8, ssl_options: ?JSC.API.ServerConfig.SSLConfig) JSC.Maybe(void) { + pub fn connect(this: *WindowsNamedPipe, path: []const u8, ssl_options: ?*const JSC.API.ServerConfig.SSLConfig) JSC.Maybe(void) { bun.assert(this.pipe != null); this.flags.disconnected = true; // ref because we are connecting _ = this.pipe.?.ref(); - if (ssl_options) |*tls| { + if (ssl_options) |tls| { this.flags.is_ssl = true; this.wrapper = WrapperType.init(tls, true, .{ .ctx = this, @@ -925,7 +925,7 @@ pub const WindowsNamedPipe = if (Environment.isWindows) struct { this.connect_req.data = this; return this.pipe.?.connect(&this.connect_req, path, this, onConnect); } - pub fn startTLS(this: *WindowsNamedPipe, ssl_options: JSC.API.ServerConfig.SSLConfig, is_client: bool) !void { + pub fn startTLS(this: *WindowsNamedPipe, ssl_options: *const JSC.API.ServerConfig.SSLConfig, is_client: bool) !void { this.flags.is_ssl = true; if (this.start(is_client)) { this.wrapper = try WrapperType.init(ssl_options, is_client, .{