{"id":13731636,"url":"https://github.com/nielsAD/gns","last_synced_at":"2025-05-08T05:30:27.829Z","repository":{"id":50244257,"uuid":"252948768","full_name":"nielsAD/gns","owner":"nielsAD","description":"Golang bindings for the GameNetworkingSockets library.","archived":false,"fork":false,"pushed_at":"2021-05-31T16:21:19.000Z","size":105,"stargazers_count":91,"open_issues_count":2,"forks_count":8,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-11-14T22:35:34.420Z","etag":null,"topics":["gamenetworkingsockets","go","networking","reliable-udp","udp"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nielsAD.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}},"created_at":"2020-04-04T08:39:17.000Z","updated_at":"2024-11-11T21:22:01.000Z","dependencies_parsed_at":"2022-09-14T22:54:08.514Z","dependency_job_id":null,"html_url":"https://github.com/nielsAD/gns","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nielsAD%2Fgns","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nielsAD%2Fgns/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nielsAD%2Fgns/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nielsAD%2Fgns/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nielsAD","download_url":"https://codeload.github.com/nielsAD/gns/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253008318,"owners_count":21839627,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["gamenetworkingsockets","go","networking","reliable-udp","udp"],"created_at":"2024-08-03T02:01:34.516Z","updated_at":"2025-05-08T05:30:27.801Z","avatar_url":"https://github.com/nielsAD.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"GameNetworkingSockets\n=====================\n[![build](https://github.com/nielsAD/gns/workflows/test/badge.svg)](https://github.com/nielsAD/gns/actions/)\n[![GoDoc](https://godoc.org/github.com/nielsAD/gns?status.svg)](https://godoc.org/github.com/nielsAD/gns)\n[![License: MPL 2.0](https://img.shields.io/badge/License-MPL%202.0-brightgreen.svg)](https://opensource.org/licenses/MPL-2.0)\n\nPackage gns provides golang bindings for the [GameNetworkingSockets](https://github.com/ValveSoftware/GameNetworkingSockets/) library.\n\n### GameNetworkingSockets features\n\n* Connection-oriented API (like TCP)\n* ... but message-oriented (like UDP), not stream-oriented.\n* Supports both reliable and unreliable message types\n* Messages can be larger than underlying MTU.  The protocol performs\nfragmentation, reassembly, and retransmission for reliable messages.\n* Encryption. AES-GCM-256 per packet, [Curve25519](https://cr.yp.to/ecdh.html) for\nkey exchange and cert signatures. The details for shared key derivation and\nper-packet IV are based on the [design](https://docs.google.com/document/d/1g5nIXAIkN_Y-7XJW5K45IblHd_L2f5LTaDUDwvZ5L6g/edit?usp=sharing)\nused by Google's QUIC protocol.\n* Tools for simulating loss and detailed stats measurement.\n* IPv4 + IPv6\n\n### gns features\n\n* Support for dynamic/static linking\n* API documentation available via `godoc`\n* Compatible with [net.Conn](https://golang.org/pkg/net/#Conn) and [net.Listener](https://golang.org/pkg/net/#Listener)\n\nExample\n-------\n\n```go\nfunc Example() {\n\t// GameNetworkingSockets uses a fixed transmission rate, set to 512K/s\n\tcfg := gns.ConfigMap{\n\t\tgns.ConfigSendRateMin: 512 * 1024,\n\t\tgns.ConfigSendRateMax: 512 * 1024,\n\t}\n\n\tl, err := gns.Listen(\u0026net.UDPAddr{IP: net.IP{127, 0, 0, 1}}, cfg)\n\tif err != nil {\n\t\tlog.Fatal(\"Listen: \", err)\n\t}\n\tdefer l.Close()\n\n\tgns.SetGlobalConfigValue(gns.ConfigFakePacketLagRecv, 10.0)\n\tgns.SetGlobalConfigValue(gns.ConfigFakePacketLagSend, 10.0)\n\tgns.SetGlobalConfigValue(gns.ConfigFakePacketLossRecv, 5.0)\n\tgns.SetGlobalConfigValue(gns.ConfigFakePacketLossSend, 5.0)\n\n\t// send a burst of 2MiB random bytes with 20ms lag and ~10% packet loss\n\tvar in [2 * 1024 * 1024]byte\n\trand.Read(in[:])\n\n\tgo func() {\n\t\tc, err := gns.Dial(l.Addr().(*net.UDPAddr), cfg)\n\t\tif err != nil {\n\t\t\tlog.Fatal(\"Dial: \", err)\n\t\t}\n\t\tdefer c.Close()\n\n\t\t// Linger for as long as it takes\n\t\tc.SetLinger(-1)\n\n\t\tif _, err := io.Copy(c, bytes.NewReader(in[:])); err != nil {\n\t\t\tlog.Fatal(\"Copy: \", err)\n\t\t}\n\t}()\n\n\tconn, err := l.AcceptGNS()\n\tif err != nil {\n\t\tlog.Fatal(\"Accept: \", err)\n\t}\n\tdefer conn.Close()\n\n\tout, err := ioutil.ReadAll(conn)\n\tif err != nil {\n\t\tlog.Fatal(\"Read: \", err)\n\t}\n\n\tfmt.Println(\"Compare(in, out) ==\", bytes.Compare(out, in[:]) == 0)\n\t// Output: Compare(in, out) == true\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FnielsAD%2Fgns","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FnielsAD%2Fgns","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FnielsAD%2Fgns/lists"}