{"id":17184594,"url":"https://github.com/josexy/cropstun","last_synced_at":"2025-07-15T19:11:53.790Z","repository":{"id":245695334,"uuid":"818982358","full_name":"josexy/cropstun","owner":"josexy","description":"Cropped for sing-tun library","archived":false,"fork":false,"pushed_at":"2024-11-21T08:32:48.000Z","size":685,"stargazers_count":9,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-20T18:23:02.815Z","etag":null,"topics":["go","gvisor","sing-tun","tun"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/josexy.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}},"created_at":"2024-06-23T12:43:47.000Z","updated_at":"2025-01-21T08:59:04.000Z","dependencies_parsed_at":"2024-06-23T14:27:17.366Z","dependency_job_id":"c1cf40bf-19b3-4b7f-bfec-b6c15ab473f4","html_url":"https://github.com/josexy/cropstun","commit_stats":null,"previous_names":["josexy/cropstun"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/josexy/cropstun","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/josexy%2Fcropstun","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/josexy%2Fcropstun/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/josexy%2Fcropstun/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/josexy%2Fcropstun/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/josexy","download_url":"https://codeload.github.com/josexy/cropstun/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/josexy%2Fcropstun/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265453309,"owners_count":23768109,"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":["go","gvisor","sing-tun","tun"],"created_at":"2024-10-15T00:43:43.182Z","updated_at":"2025-07-15T19:11:53.747Z","avatar_url":"https://github.com/josexy.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# cropped for sing-tun\n\nThis project is based on the [sing-tun](https://github.com/SagerNet/sing-tun) project, with a lot of cuts and streamlining. Only the `gVisor` mode has been retained and made more generic.\n\nDue to the removal of many customizations and some referenced code, it is for personal use only, and only supports Linux, macOS and Windows.\n\n## usage\n\n```shell\ngo get github.com/josexy/cropstun\n```\n\nHere is a simple example:\n\n```go\ntype myHandler struct{}\n\nfunc (*myHandler) HandleTCPConnection(conn net.Conn, info tun.Metadata) error {\n\tlog.Printf(\"tcp, src: %s, dst: %s\", info.Source, info.Destination)\n\t// do something...\n\treturn nil\n}\n\nfunc (*myHandler) HandleUDPConnection(conn net.PacketConn, info tun.Metadata) error {\n\tlog.Printf(\"udp, src: %s, dst: %s\", info.Source, info.Destination)\n\t// do something...\n\treturn nil\n}\n\nfunc main() {\n\ttunOpt := new(tun.Options)\n\ttunIf, err := tun.NewTunDevice([]netip.Prefix{netip.MustParsePrefix(\"198.18.0.1/16\")}, tunOpt)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tstack, err := tun.NewStack(tun.StackOptions{\n\t\tTun:        tunIf,\n\t\tTunOptions: tunOpt,\n\t\tHandler:    \u0026myHandler{},\n\t})\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tif err = stack.Start(); err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tinter := make(chan os.Signal, 1)\n\tsignal.Notify(inter, syscall.SIGINT)\n\t\u003c-inter\n\tstack.Close()\n\ttime.Sleep(time.Second)\n}\n```\n\n## Credits\n\n- [sing-tun](https://github.com/SagerNet/sing-tun)\n- [mihomo](https://github.com/MetaCubeX/mihomo)\n- [tun2socks](https://github.com/xjasonlyu/tun2socks)\n\n## License\n\n```\nCopyright (C) 2022 by nekohasekai \u003ccontact-sagernet@sekai.icu\u003e\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program. If not, see \u003chttp://www.gnu.org/licenses/\u003e.\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjosexy%2Fcropstun","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjosexy%2Fcropstun","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjosexy%2Fcropstun/lists"}