{"id":28736457,"url":"https://github.com/eikarna/gotops","last_synced_at":"2025-06-16T01:39:05.579Z","repository":{"id":236289627,"uuid":"792310462","full_name":"eikarna/gotops","owner":"eikarna","description":"ENet binding in Go for Growtopia Private Server using cgo. Based on codecat/go-enet.","archived":false,"fork":false,"pushed_at":"2025-03-22T04:49:53.000Z","size":93,"stargazers_count":10,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-09T01:28:04.298Z","etag":null,"topics":["enet","go","golang","growtopia","growtopiaprivateserver","gtps","ubisoft","udp-server"],"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/eikarna.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"License.txt","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},"funding":{"github":["codecat"]}},"created_at":"2024-04-26T12:06:40.000Z","updated_at":"2025-03-22T04:44:59.000Z","dependencies_parsed_at":"2024-04-26T13:30:03.164Z","dependency_job_id":"06e8ab4a-1f64-40ef-be75-6363cf31c8f0","html_url":"https://github.com/eikarna/gotops","commit_stats":null,"previous_names":["eikarna/gotps"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/eikarna/gotops","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eikarna%2Fgotops","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eikarna%2Fgotops/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eikarna%2Fgotops/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eikarna%2Fgotops/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eikarna","download_url":"https://codeload.github.com/eikarna/gotops/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eikarna%2Fgotops/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260082584,"owners_count":22956307,"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":["enet","go","golang","growtopia","growtopiaprivateserver","gtps","ubisoft","udp-server"],"created_at":"2025-06-16T01:39:01.109Z","updated_at":"2025-06-16T01:39:05.564Z","avatar_url":"https://github.com/eikarna.png","language":"Go","funding_links":["https://github.com/sponsors/codecat"],"categories":[],"sub_categories":[],"readme":"# GotoPS\nEnet bindings in Go for Growtopia Private Server using cgo. Based on [codecat/go-enet](https://github.com/codecat/go-enet)\n\n\u003e [!TIP]\n\u003e Want to see an example of a server that uses this library? Look at [gotps](https://github.com/eikarna/gotps).\n\n## Installation\nFirst, you might need to build enet from enet/ directory and install it as library:\n\n* **Windows**: Build the enet dynamic library (.dll) with Code::Blocks. (Tested with: TDM-GCC 10.3.0 installed, Windows 11 Intel Core I7-6700HQ).\n```sh\ngit clone --recurse-submodules https://github.com/eikarna/gotops\ncd gotops/enet\n\"C:\\Program Files\\CodeBlocks\\codeblocks.exe\" /na /nd enet_dll.cbp\n```\nIf you got error message: 'IP_TTL' undeclared (first use in this function), just add `#include \u003cWs2tcpip.h\u003e` to the top of win32.c.\n\n#### REMEMBER TO BUILD TARGET \"Release\" ONLY.\n\nGot Any Error again? just try to fix it by yourself.\n\nAfter successfully build, you must copy build output files (include: libenet.a, libenet.dll, libenet.def) to your root project. And then you can use this go module without any problem.\n* **Linux**: Install the enet library with make.\n```sh\ngit clone --recurse-submodules https://github.com/eikarna/gotops\ncd gotops/enet\nautoreconf -vfi\n./configure \u0026\u0026 make \u0026\u0026 sudo make install\n```\n* **Termux**: Same as Linux, but after run `autoreconf -vfi`:\n```sh\n./configure\nmake\nmake prefix=/data/data/com.termux/files/usr libdir=/data/data/com.termux/files/usr/lib install\n```\nIf you got warning message: `libtool: warning: remember to run 'libtool --finish /usr/local/lib'`, just run:\n```sh\nlibtool --finish /data/data/com.termux/files/usr/lib\n```\n* **MacOS**: Install the enet package with brew: `brew install enet`\n\n```sh\n$ go get github.com/eikarna/gotops\n```\n\n## Usage\n```go\nimport \"github.com/eikarna/gotops\"\n```\n\nThe API is mostly the same as the C API, except it's more object-oriented.\n\n## Server example\nThis is a basic server example that responds to packets `\"ping\"` and `\"bye\"`.\n\n```go\npackage main\n\nimport (\n\t\"github.com/eikarna/gotops\"\n\t\"github.com/codecat/go-libs/log\"\n)\n\nfunc main() {\n\t// Initialize enet\n\tenet.Initialize()\n\n\t// Create a host listening on 0.0.0.0:17091\n\thost, err := enet.NewHost(enet.NewListenAddress(17091), 1024, 1, 0, 0)\n\tif err != nil {\n\t\tlog.Error(\"Couldn't create host: %s\", err.Error())\n\t\treturn\n\t}\n\n\t// The event loop\n\tfor true {\n\t\t// Wait until the next event\n\t\tev := host.Service(1000)\n\n\t\t// Do nothing if we didn't get any event\n\t\tif ev.GetType() == enet.EventNone {\n\t\t\tcontinue\n\t\t}\n\n\t\tswitch ev.GetType() {\n\t\tcase enet.EventConnect: // A new peer has connected\n\t\t\tlog.Info(\"New peer connected: %s\", ev.GetPeer().GetAddress())\n\n\t\tcase enet.EventDisconnect: // A connected peer has disconnected\n\t\t\tlog.Info(\"Peer disconnected: %s\", ev.GetPeer().GetAddress())\n\n\t\tcase enet.EventReceive: // A peer sent us some data\n\t\t\t// Get the packet\n\t\t\tpacket := ev.GetPacket()\n\n\t\t\t// We must destroy the packet when we're done with it\n\t\t\tdefer packet.Destroy()\n\n\t\t\t// Get the bytes in the packet\n\t\t\tpacketBytes := packet.GetData()\n\n\t\t\t// Respond \"pong\" to \"ping\"\n\t\t\tif string(packetBytes) == \"ping\" {\n\t\t\t\tev.GetPeer().SendString(\"pong\", ev.GetChannelID(), enet.PacketFlagReliable)\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// Disconnect the peer if they say \"bye\"\n\t\t\tif string(packetBytes) == \"bye\" {\n\t\t\t\tlog.Info(\"Bye!\")\n\t\t\t\tev.GetPeer().Disconnect(0)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t}\n\n\t// Destroy the host when we're done with it\n\thost.Destroy()\n\n\t// Uninitialize enet\n\tenet.Deinitialize()\n}\n```\n\n## Client example\nThis is a basic client example that sends a ping to the server every second that there is no event.\n\n```go\npackage main\n\nimport (\n\t\"github.com/eikarna/gotops\"\n\t\"github.com/codecat/go-libs/log\"\n)\n\nfunc main() {\n\t// Initialize enet\n\tenet.Initialize()\n\n\t// Create a client host\n\tclient, err := enet.NewHost(nil, 1, 1, 0, 0)\n\tif err != nil {\n\t\tlog.Error(\"Couldn't create host: %s\", err.Error())\n\t\treturn\n\t}\n\n\t// Connect the client host to the server\n\tpeer, err := client.Connect(enet.NewAddress(\"127.0.0.1\", 17091), 1, 0)\n\tif err != nil {\n\t\tlog.Error(\"Couldn't connect: %s\", err.Error())\n\t\treturn\n\t}\n\n\t// The event loop\n\tfor true {\n\t\t// Wait until the next event\n\t\tev := client.Service(1000)\n\n\t\t// Send a ping if we didn't get any event\n\t\tif ev.GetType() == enet.EventNone {\n\t\t\tpeer.SendString(\"ping\", 0, enet.PacketFlagReliable)\n\t\t\tcontinue\n\t\t}\n\n\t\tswitch ev.GetType() {\n\t\tcase enet.EventConnect: // We connected to the server\n\t\t\tlog.Info(\"Connected to the server!\")\n\n\t\tcase enet.EventDisconnect: // We disconnected from the server\n\t\t\tlog.Info(\"Lost connection to the server!\")\n\n\t\tcase enet.EventReceive: // The server sent us data\n\t\t\tpacket := ev.GetPacket()\n\t\t\tlog.Info(\"Received %d bytes from server\", len(packet.GetData()))\n\t\t\tpacket.Destroy()\n\t\t}\n\t}\n\n\t// Destroy the host when we're done with it\n\tclient.Destroy()\n\n\t// Uninitialize enet\n\tenet.Deinitialize()\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feikarna%2Fgotops","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feikarna%2Fgotops","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feikarna%2Fgotops/lists"}