{"id":51829470,"url":"https://github.com/asciimoth/batchudp","last_synced_at":"2026-07-22T13:04:24.073Z","repository":{"id":354135401,"uuid":"1221592851","full_name":"asciimoth/batchudp","owner":"asciimoth","description":"UDP transport package extracted from wireguard-go/conn","archived":false,"fork":false,"pushed_at":"2026-06-25T15:52:53.000Z","size":1873,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-06-25T17:23:17.441Z","etag":null,"topics":["batching","golang","gonnect","networking-library","udp"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/asciimoth.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-26T12:30:32.000Z","updated_at":"2026-06-25T15:52:53.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/asciimoth/batchudp","commit_stats":null,"previous_names":["asciimoth/batchudp"],"tags_count":41,"template":false,"template_full_name":null,"purl":"pkg:github/asciimoth/batchudp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asciimoth%2Fbatchudp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asciimoth%2Fbatchudp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asciimoth%2Fbatchudp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asciimoth%2Fbatchudp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asciimoth","download_url":"https://codeload.github.com/asciimoth/batchudp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asciimoth%2Fbatchudp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35762225,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-07-20T02:08:10.276Z","status":"online","status_checked_at":"2026-07-22T02:00:06.236Z","response_time":124,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["batching","golang","gonnect","networking-library","udp"],"created_at":"2026-07-22T13:04:23.593Z","updated_at":"2026-07-22T13:04:24.065Z","avatar_url":"https://github.com/asciimoth.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BatchUDP\n\n`batchudp` is a small UDP transport package extracted from `wireguard-go/conn`.\nIt is for applications that want the WireGuard-style `Bind` API without pulling\nin the rest of `wireguard-go`.\n\nIt opens IPv4 and IPv6 UDP sockets on the same port, exposes per-family receive\nfunctions, and hides platform-specific details such as batch I/O, sticky source\naddress handling, and Linux UDP GSO/GRO support.\n\n\u003e [!IMPORTANT]\n\u003e This project contains code extracted from the original\n\u003e [wireguard-go](https://git.zx2c4.com/wireguard-go) project\n\u003e with some modifications.\n\u003e All credit goes to the original wireguard-go authors.\n\n## Usage\n\n```go\npackage main\n\nimport (\n\t\"log\"\n\n\tconn \"github.com/asciimoth/batchudp\"\n\t\"github.com/asciimoth/gonnect/native\"\n)\n\nfunc main() {\n\tnetwork := (\u0026native.Config{}).Build()\n\tdefer network.Down()\n\n\tbind := conn.NewDefaultBind(network)\n\trecvFns, port, err := bind.Open(0)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tdefer bind.Close()\n\n\tpeer, err := bind.ParseEndpoint(\"127.0.0.1:9000\")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tif err := bind.Send([][]byte{[]byte(\"ping\")}, peer); err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tpackets := make([][]byte, bind.BatchSize())\n\tsizes := make([]int, bind.BatchSize())\n\teps := make([]conn.Endpoint, bind.BatchSize())\n\tfor i := range packets {\n\t\tpackets[i] = make([]byte, 2048)\n\t}\n\n\tn, err := recvFns[0](packets, sizes, eps)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tlog.Printf(\"listening on %d, received %d packet(s)\", port, n)\n}\n```\n\nFor a larger end-to-end example, see [`examples/udp_pingpong`](examples/udp_pingpong).\n\n## Migration From `wireguard-go/conn`\n\nMost of the public `Bind`, `Endpoint`, and `ReceiveFunc` shape is intentionally\nsimilar, so send/receive code usually moves over with little change.\n\nThe main differences are:\n\n- `NewDefaultBind` and `NewStdNetBind` require a `gonnect.Network`.\n- `NewStdNetBindWithOptions` and `NewDefaultBindWithOptions` let callers opt\n  into IPv6-first opens, single-family fallback for networks that cannot\n  expose both UDP families, or an explicit positive\n  `StdNetBindOptions.BatchSize`.\n  Smaller batches reduce retained per-bind message allocation, while larger\n  batches can improve throughput under load by reducing syscall overhead.\n- Network lifecycle is explicit. When using `gonnect/native`, call\n  `network.Down()` when the network should be torn down.\n- If you start from an existing `gonnect.PacketConn` on Linux, use\n  `TryUpgradeToBatchingConn` to opt into batched reads and writes.\n\nTypical constructor migration:\n\n```go\n// wireguard-go/conn\nbind := conn.NewDefaultBind()\n```\n\n```go\n// batchudp\nnetwork := (\u0026native.Config{}).Build()\nbind := conn.NewDefaultBind(network)\ndefer network.Down()\n```\n\nIf your old code only depended on the `Bind` interface after construction, the\nrest of the call sites should usually keep the same structure:\n`Open`, `ParseEndpoint`, `Send`, `BatchSize`, and the returned `ReceiveFunc`\nvalues all work the same way.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasciimoth%2Fbatchudp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasciimoth%2Fbatchudp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasciimoth%2Fbatchudp/lists"}