{"id":47733496,"url":"https://github.com/helloh2o/lucky","last_synced_at":"2026-04-02T22:03:06.841Z","repository":{"id":40492392,"uuid":"325242210","full_name":"helloh2o/lucky","owner":"helloh2o","description":"Lucky is a simple game/application network framework, supports protobuf, JSON message protocol, data transmission based on HTTP(S), Websocket, Socket (TCP, KCP, QUIC), and supports encryption and decryption of message packets.","archived":false,"fork":false,"pushed_at":"2026-03-09T10:31:19.000Z","size":619,"stargazers_count":75,"open_issues_count":1,"forks_count":7,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-03-09T12:50:17.159Z","etag":null,"topics":["go","tcp","websocket"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/helloh2o.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":"2020-12-29T09:21:39.000Z","updated_at":"2026-03-09T08:58:08.000Z","dependencies_parsed_at":"2024-04-19T15:13:09.714Z","dependency_job_id":null,"html_url":"https://github.com/helloh2o/lucky","commit_stats":null,"previous_names":[],"tags_count":38,"template":false,"template_full_name":null,"purl":"pkg:github/helloh2o/lucky","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helloh2o%2Flucky","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helloh2o%2Flucky/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helloh2o%2Flucky/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helloh2o%2Flucky/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/helloh2o","download_url":"https://codeload.github.com/helloh2o/lucky/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helloh2o%2Flucky/sbom","scorecard":{"id":460366,"data":{"date":"2025-08-11","repo":{"name":"github.com/helloh2o/lucky","commit":"f532bddd3d512166ebcaad41d9f3e97195a136f9"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":2,"reason":"8 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GO-2024-3205 / GHSA-xhr3-wf7j-h255","Warn: Project is vulnerable to: GO-2025-3600 / GHSA-fhg8-qxh5-7q3w","Warn: Project is vulnerable to: GO-2024-3302 / GHSA-px8v-pp82-rcvr","Warn: Project is vulnerable to: GO-2024-3321 / GHSA-v778-237x-gjrc","Warn: Project is vulnerable to: GO-2025-3487 / GHSA-hcg3-q754-cr77","Warn: Project is vulnerable to: GO-2024-3333","Warn: Project is vulnerable to: GO-2025-3503 / GHSA-qxp5-gwg8-xv66","Warn: Project is vulnerable to: GO-2025-3595 / GHSA-vvgc-356p-c3xw"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-19T10:58:03.298Z","repository_id":40492392,"created_at":"2025-08-19T10:58:03.298Z","updated_at":"2025-08-19T10:58:03.298Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31317831,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T21:35:00.834Z","status":"ssl_error","status_checked_at":"2026-04-02T21:34:59.806Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["go","tcp","websocket"],"created_at":"2026-04-02T22:03:04.003Z","updated_at":"2026-04-02T22:03:06.834Z","avatar_url":"https://github.com/helloh2o.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Use Lucky to create server by simple, fast, security\n[**Github**](https://github.com/helloh2o/lucky) \u003c\u003c=\u003e\u003e [**Gitee**](https://gitee.com/helloh2o/lucky)\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/helloh2o/lucky)](https://goreportcard.com/report/github.com/helloh2o/lucky)\n\n#### [English README](https://github.com/helloh2o/lucky/blob/master/README_en.md)\n\n#### 介绍\n一个简洁安全游戏/应用网络框架，支持protobuf，JSON 消息协议，基于HTTP/HTTPS,websocket或者socket(TCP,KCP,QUIC)进行数据传输, 支持对消息包加密解密。\n\n数据包加密方式： AES128,AES192,AES256 以及Byte轻量级混淆加密。以帮助开发者朋友能高效率写出安全可靠的业务逻辑。\n\n数据包读、写、执行逻辑处理分别在各自goroutine中, 可以对单个连接恶意发包进行限制超过ConnUndoQueueSize会被忽略，不停留在缓冲区。\n\n使用者只需注册消息和消息对应的回调函数，在回调中处理具体逻辑。例如：\n```go\n    //在处理器上注册（消息码，消息体，消息执行的逻辑代码）\n\tProcessor.RegisterHandler(code.Hello, \u0026protobuf.Hello{}, logic.Hello)\n```\n\n#### 安装教程\n\ngo get github.com/helloh2o/lucky\n\n#### 使用说明\nGo version \u003e= 1.20\n\n1. 设置配置参数或保持默认\n```go\nlucky.SetConf(\u0026lucky.Data{\n\t\tConnUndoQueueSize:   100,\n\t\tConnWriteQueueSize:  100,\n\t\tFirstPackageTimeout: 5,\n\t\tConnReadTimeout:     30,\n\t\tConnWriteTimeout:    5,\n\t\tMaxDataPackageSize:  2048,\n\t\tMaxHeaderLen:        1024,\n\t})\n```\n2. 请参考example下的http, tcp, websocket, kcp, 以及kcp帧同步例子\n3. 帧同步部分还需要进一步完善，只是一个基础的实现\n4. 聊天室例子, 源码example/chatroom\n![Image text](https://raw.githubusercontent.com/helloh2o/lucky/master/examples/chatroom/demo.png)\n\n#### 欢迎参与 :)\n1. 欢迎提交PR 和 Issue\n2. 开源不易，觉得不错就给个小星星✮吧\n3. 该框架正在多个 DAU\u003e10w 商业项目中使用\n4. 新增utils.LazyQueue可对高频操作进行管理，如数据库写。\n5. 新增utils.RkPool可对任意数据进行排序，如排行榜。\n6. 新增Redis分布式锁utils.RDLockOp, 可在多进程间多协程的情景下安全操作数据\n\n#### Etcd分布式互斥锁\n```go\n\n// 初始化ETCD锁\nonProcExitRelease := etcdlock.InitDefault(\"localhost:2379\")\n// 程序异常退出时该函数释放当前进程持有的锁\n_ = onProcExitRelease \n// 获得同步锁\nop := \"lock_user_data\"\nrelease, _ := etcdlock.D().Lock(testOpKey)\n// 主动释放锁\ndefer release()\n// 同步逻辑代码\n// 安全操作\n\n```   \n\n#### Redis分布式同步锁\n```go\n// 初始化Redis\nif _, err := cache.OpenRedis(\"redis://localhost:6379/?pwd=\u0026db=0\"); err != nil {\n\tpanic(err)\n}\n// 同步操作\nop := \"lock_user_111_data\"\n// 获得同步锁\nrelease := RDLockOpWait(op)\n// 解锁!!!\ndefer release()\n// 同步逻辑代码\n// 安全操作\n\n```\n#### 快速开始\n\u003e Run as tcp server\n```go\npackage main\n\nimport (\n\t\"github.com/helloh2o/lucky\"\n\t\"github.com/helloh2o/lucky/examples/comm/msg/code\"\n\t\"github.com/helloh2o/lucky/examples/comm/protobuf\"\n\t\"github.com/helloh2o/lucky/log\"\n)\n\n// processor is protobuf processor\nvar processor = lucky.NewPBProcessor()\n\nfunc init() {\n\t//passwd := little.RandLittlePassword()\n\tpasswd := \"EyEmxIhoYUFuEc8gDTBlbN/pVOs9Nu/hLCTSjW19Oii0mKNQ9xKPoGJqu1q5Mox4zDT/+MgicJ/j5Nt2sQwK2E8rY3ORVgMUU2v2hmQBb5cP00dettGeF6wvQ36vH2CpGLX9x6RIliP8WAtZqJ0xaT7ixnxxCIr5xRZbutXl8pXqRvSa1+Z/HcuTuFHze4T1ok5A1O4Gge1n6I4ZQjgeHHSSwYs7dQI8oYWQ0MMt3rOywvsVKgUESl2cquDapXrW3PH68MoOPyk1RCe3hxvJNxB3LnLNplVLzkmbTHnZv8AJRedfUoKAJTPsAN0HVzn+XBqUvE2Dvb6nia6tZpmrsA==\"\n\tlog.Release(\"TCP Server password %v\", passwd)\n\tpwd, err := lucky.ParseLittlePassword(passwd)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tcipher := lucky.NewLittleCipher(pwd)\n\t// add encrypt cipher for processor\n\tprocessor.SetEncryptor(cipher)\n\t// register message \u0026\u0026 callback\n\tprocessor.RegisterHandler(code.Hello, \u0026protobuf.Hello{}, func(args ...interface{}) {\n\t\tmsg := args[lucky.Msg].(*protobuf.Hello)\n\t\tlog.Release(\"Message =\u003e from client:: %s\", msg.Hello)\n\t\tconn := args[lucky.Conn].(lucky.IConnection)\n\t\tconn.WriteMsg(msg)\n\t})\n}\n\nfunc main() {\n\t// run server\n\tif s, err := lucky.NewTcpServer(\"localhost:2021\", processor); err != nil {\n\t\tpanic(err)\n\t} else {\n\t\tlog.Fatal(\"%v\", s.Run())\n\t}\n}\n\n```\n\n\u003e go tcp client\n```go\npackage main\n\nimport (\n\t\"github.com/helloh2o/lucky\"\n\t\"github.com/helloh2o/lucky/examples/comm/msg/code\"\n\t\"github.com/helloh2o/lucky/examples/comm/protobuf\"\n\t\"github.com/helloh2o/lucky/log\"\n\t\"net\"\n)\n\n// processor is protobuf processor\nvar processor = lucky.NewPBProcessor()\n\nfunc init() {\n\t//passwd := lucky.RandLittlePassword()\n\tpasswd := \"EyEmxIhoYUFuEc8gDTBlbN/pVOs9Nu/hLCTSjW19Oii0mKNQ9xKPoGJqu1q5Mox4zDT/+MgicJ/j5Nt2sQwK2E8rY3ORVgMUU2v2hmQBb5cP00dettGeF6wvQ36vH2CpGLX9x6RIliP8WAtZqJ0xaT7ixnxxCIr5xRZbutXl8pXqRvSa1+Z/HcuTuFHze4T1ok5A1O4Gge1n6I4ZQjgeHHSSwYs7dQI8oYWQ0MMt3rOywvsVKgUESl2cquDapXrW3PH68MoOPyk1RCe3hxvJNxB3LnLNplVLzkmbTHnZv8AJRedfUoKAJTPsAN0HVzn+XBqUvE2Dvb6nia6tZpmrsA==\"\n\tlog.Release(\"TCP client password %v\", passwd)\n\tpwd, err := lucky.ParseLittlePassword(passwd)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tcipher := lucky.NewLittleCipher(pwd)\n\t// add encrypt cipher for processor\n\tprocessor.SetEncryptor(cipher)\n\t// register message \u0026\u0026 callback\n\tprocessor.RegisterHandler(code.Hello, \u0026protobuf.Hello{}, func(args ...interface{}) {\n\t\tmsg := args[lucky.Msg].(*protobuf.Hello)\n\t\tlog.Release(\"Message =\u003e from server:: %s\", msg.Hello)\n\t\tconn := args[lucky.Conn].(lucky.IConnection)\n\t\t_ = conn.Close()\n\t})\n}\n\nfunc main() {\n\tconn, err := net.Dial(\"tcp\", \"localhost:2021\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tic := lucky.NewTcpConn(conn, processor)\n\tic.WriteMsg(\u0026protobuf.Hello{Hello: \"hello lucky.\"})\n\tic.ReadMsg()\n}\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhelloh2o%2Flucky","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhelloh2o%2Flucky","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhelloh2o%2Flucky/lists"}