diff --git a/.forgejo/workflows/test.yaml b/.forgejo/workflows/test.yaml index c6282d0..00a93cb 100644 --- a/.forgejo/workflows/test.yaml +++ b/.forgejo/workflows/test.yaml @@ -73,7 +73,7 @@ jobs: - name: Publish docs run: > - nix develop -c git-pages-cli https://jeff.jcollie.page/zig-websockets/ + nix develop -c git-pages-cli https://jeff.jcollie.page/zig-websocket/ --server jcollie.page --token ${{ forge.token }} --upload-dir zig-out/docs diff --git a/README.md b/README.md index ba349f1..bde7da7 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie SPDX-License-Identifier: MIT --> -# zig-websockets +# zig-websocket The WebSocket Protocol — [RFC 6455][] — for Zig servers, on top of [zig-http][]. @@ -52,14 +52,14 @@ not lose them. Everything from there on is here. ## Where this lives The repository lives in three places that carry the same history. The Forgejo -instance at is the web-visible +instance at is the web-visible one: ```console -$ git clone https://git.jcollie.dev/jeff/zig-websockets.git +$ git clone https://git.jcollie.dev/jeff/zig-websocket.git ``` -it is mirrored on Tangled at , +it is mirrored on Tangled at , and it is also on the Radicle network, where the repository's identifier is ``` @@ -72,12 +72,12 @@ seeds it. Any of the three is the whole project. ## Adding it to a project ```console -$ zig fetch --save git+https://git.jcollie.dev/jeff/zig-websockets.git +$ zig fetch --save git+https://git.jcollie.dev/jeff/zig-websocket.git ``` ```zig -const websockets = b.dependency("zig_websockets", .{}); -exe.root_module.addImport("websockets", websockets.module("websockets")); +const websocket = b.dependency("zig_websocket", .{}); +exe.root_module.addImport("websocket", websocket.module("websocket")); ``` It brings zig-http with it, since it cannot do anything without one. diff --git a/REUSE.toml b/REUSE.toml index 735faf6..3f92666 100644 --- a/REUSE.toml +++ b/REUSE.toml @@ -1,7 +1,7 @@ version = 1 -SPDX-PackageName = "zig-websockets" +SPDX-PackageName = "zig-websocket" SPDX-PackageSupplier = "Jeffrey C. Ollie " -SPDX-PackageDownloadLocation = "https://git.jcollie.dev/jeff/zig-websockets" +SPDX-PackageDownloadLocation = "https://git.jcollie.dev/jeff/zig-websocket" [[annotations]] path = ["flake.lock", "build.zig.zon", "build.zig.zon.nix"] diff --git a/build.zig b/build.zig index b10186b..6de3e72 100644 --- a/build.zig +++ b/build.zig @@ -9,20 +9,20 @@ pub fn build(b: *std.Build) void { const http = b.dependency("http", .{}); - const mod = b.addModule("websockets", .{ + const mod = b.addModule("websocket", .{ .root_source_file = b.path("src/root.zig"), .target = target, .imports = &.{.{ .name = "http", .module = http.module("http") }}, }); const exe = b.addExecutable(.{ - .name = "zig-websockets", + .name = "zig-websocket", .root_module = b.createModule(.{ .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, .imports = &.{ - .{ .name = "websockets", .module = mod }, + .{ .name = "websocket", .module = mod }, .{ .name = "http", .module = http.module("http") }, }, }), @@ -60,7 +60,7 @@ pub fn build(b: *std.Build) void { .target = target, .optimize = optimize, .imports = &.{ - .{ .name = "websockets", .module = mod }, + .{ .name = "websocket", .module = mod }, .{ .name = "http", .module = http.module("http") }, }, }); @@ -77,7 +77,7 @@ pub fn build(b: *std.Build) void { .target = target, .optimize = optimize, .imports = &.{ - .{ .name = "websockets", .module = mod }, + .{ .name = "websocket", .module = mod }, .{ .name = "http", .module = http.module("http") }, }, }); @@ -93,7 +93,7 @@ pub fn build(b: *std.Build) void { .target = target, .optimize = optimize, .imports = &.{ - .{ .name = "websockets", .module = mod }, + .{ .name = "websocket", .module = mod }, .{ .name = "http", .module = http.module("http") }, }, }); @@ -115,7 +115,7 @@ pub fn build(b: *std.Build) void { // toolchain cannot usefully run. `tools/fuzz.zig` in zig-http says why; // the short version is that the coverage table comes back empty. const fuzz_run = b.addExecutable(.{ - .name = "zig-websockets-fuzz", + .name = "zig-websocket-fuzz", .root_module = b.createModule(.{ .root_source_file = b.path("tools/fuzz.zig"), .target = b.graph.host, @@ -134,7 +134,7 @@ pub fn build(b: *std.Build) void { // -- documentation ------------------------------------------------------- - const library = b.addLibrary(.{ .name = "websockets", .root_module = mod }); + const library = b.addLibrary(.{ .name = "websocket", .root_module = mod }); const install_docs = b.addInstallDirectory(.{ .source_dir = library.getEmittedDocs(), .install_dir = .prefix, diff --git a/build.zig.zon b/build.zig.zon index d6b53ec..48c5b16 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,7 +1,7 @@ .{ - .name = .zig_websockets, + .name = .zig_websocket, .version = "0.0.0", - .fingerprint = 0x9d720e1ff620f967, + .fingerprint = 0xaf13c0d0b83756a5, .minimum_zig_version = "0.16.0", .dependencies = .{ .http = .{ diff --git a/flake.nix b/flake.nix index c4f741c..d179a2e 100644 --- a/flake.nix +++ b/flake.nix @@ -2,7 +2,7 @@ # SPDX-License-Identifier: MIT { - description = "zig-websockets"; + description = "zig-websocket"; inputs = { nixpkgs = { @@ -96,8 +96,8 @@ pkgs = makePackages system; in rec { - zig-websockets = pkgs.callPackage ./package.nix { }; - default = zig-websockets; + zig-websocket = pkgs.callPackage ./package.nix { }; + default = zig-websocket; # The dependency farm on its own, so that a workflow job which runs # `zig build` for something other than the package -- the # documentation -- can be handed it without building the package to @@ -116,11 +116,11 @@ system: let pkgs = makePackages system; - zig-websockets = pkgs.callPackage ./package.nix { }; - test = file: pkgs.testers.runNixOSTest (import file { inherit zig-websockets; }); + zig-websocket = pkgs.callPackage ./package.nix { }; + test = file: pkgs.testers.runNixOSTest (import file { inherit zig-websocket; }); in { - inherit zig-websockets; + inherit zig-websocket; interop = test ./tests/nixos/interop.nix; } ); @@ -132,7 +132,7 @@ in { default = pkgs.mkShell { - name = "zig-websockets"; + name = "zig-websocket"; nativeBuildInputs = [ (fuzzableZig pkgs) pkgs.git-pages-cli diff --git a/package.nix b/package.nix index ef924c4..bbb9896 100644 --- a/package.nix +++ b/package.nix @@ -13,7 +13,7 @@ let zigDeps = callPackage ./build.zig.zon.nix { }; in stdenv.mkDerivation (finalAttrs: { - pname = "zig-websockets"; + pname = "zig-websocket"; version = "0.0.0"; # Named rather than filtered, so that editing something outside this list -- @@ -53,9 +53,9 @@ stdenv.mkDerivation (finalAttrs: { meta = { description = "The WebSocket Protocol (RFC 6455) for Zig, on top of zig-http"; - homepage = "https://git.jcollie.dev/jeff/zig-websockets"; + homepage = "https://git.jcollie.dev/jeff/zig-websocket"; license = lib.licenses.mit; - mainProgram = "zig-websockets"; + mainProgram = "zig-websocket"; platforms = lib.platforms.unix; }; }) diff --git a/src/main.zig b/src/main.zig index c38a986..349a53d 100644 --- a/src/main.zig +++ b/src/main.zig @@ -25,10 +25,10 @@ const http = @import("http"); const Request = http.server.Request; const Response = http.server.Response; -const ws = @import("websockets"); +const ws = @import("websocket"); const usage = - \\usage: zig-websockets [--address A] [--port N] + \\usage: zig-websocket [--address A] [--port N] \\ \\ --address A The address to bind to (default 127.0.0.1). Note that \\ 0.0.0.0 is every IPv4 address and no IPv6 one, so a @@ -87,7 +87,7 @@ pub fn main(init: std.process.Init) !void { } fn fail(message: []const u8) noreturn { - std.debug.print("zig-websockets: {s}\n\n{s}", .{ message, usage }); + std.debug.print("zig-websocket: {s}\n\n{s}", .{ message, usage }); std.process.exit(2); } @@ -116,7 +116,7 @@ const Counter = struct { _ = .{ c, req }; try res.setHeader("Content-Type", "text/plain; charset=utf-8"); try res.send( - \\zig-websockets + \\zig-websocket \\ \\ GET / this \\ WS /echo says back whatever you send it diff --git a/tests/e2e.zig b/tests/e2e.zig index e4e8403..7c93e8d 100644 --- a/tests/e2e.zig +++ b/tests/e2e.zig @@ -28,7 +28,7 @@ const Request = http.server.Request; const Response = http.server.Response; const Handler = http.server.Handler; -const ws = @import("websockets"); +const ws = @import("websocket"); const gpa = testing.allocator; diff --git a/tests/fuzz.zig b/tests/fuzz.zig index 7ed1309..a7ead2d 100644 --- a/tests/fuzz.zig +++ b/tests/fuzz.zig @@ -32,7 +32,7 @@ const testing = std.testing; const Smith = std.testing.Smith; const http = @import("http"); -const ws = @import("websockets"); +const ws = @import("websocket"); /// The allocator the targets run against. /// diff --git a/tests/h2.zig b/tests/h2.zig index 3fe73b6..e2812a2 100644 --- a/tests/h2.zig +++ b/tests/h2.zig @@ -30,7 +30,7 @@ const Request = http.server.Request; const Response = http.server.Response; const Handler = http.server.Handler; -const ws = @import("websockets"); +const ws = @import("websocket"); const gpa = testing.allocator; diff --git a/tests/nixos/interop.nix b/tests/nixos/interop.nix index 235d892..6e8c5b3 100644 --- a/tests/nixos/interop.nix +++ b/tests/nixos/interop.nix @@ -21,23 +21,23 @@ # invalid UTF-8, a reserved opcode, a set reserved bit, and a message larger # than the server's buffer. -{ zig-websockets }: +{ zig-websocket }: { - name = "zig-websockets-interop"; + name = "zig-websocket-interop"; nodes = { server = { ... }: { - systemd.services.zig-websockets = { + systemd.services.zig-websocket = { wantedBy = [ "multi-user.target" ]; serviceConfig = { # `::` and not `0.0.0.0`: the test network gives each node both an # A and an AAAA record and the resolver hands out the IPv6 one # first, so a server bound to `0.0.0.0` is simply unreachable # unless the client falls back of its own accord. - ExecStart = "${zig-websockets}/bin/zig-websockets --address :: --port 8080"; + ExecStart = "${zig-websocket}/bin/zig-websocket --address :: --port 8080"; DynamicUser = true; Restart = "no"; }; @@ -70,14 +70,14 @@ in '' start_all() - server.wait_for_unit("zig-websockets.service") + server.wait_for_unit("zig-websocket.service") server.wait_for_open_port(8080) client.wait_for_unit("multi-user.target") # The plainest thing there is, and the one that proves the network # works before anything subtler is blamed for failing. body = client.succeed("curl -sS --fail http://server:8080/") - assert "zig-websockets" in body, body + assert "zig-websocket" in body, body print(client.succeed("python3 ${client}")) @@ -92,6 +92,6 @@ # And it is still there afterwards, which a server that had crashed on # one of the malformed frames above would not be. - server.succeed("systemctl is-active zig-websockets") + server.succeed("systemctl is-active zig-websocket") ''; }