{"id":13453139,"url":"https://github.com/cretz/bine","last_synced_at":"2025-05-15T12:02:01.078Z","repository":{"id":33396105,"uuid":"132914667","full_name":"cretz/bine","owner":"cretz","description":"Go library for accessing and embedding Tor clients and servers","archived":false,"fork":false,"pushed_at":"2023-07-28T08:24:22.000Z","size":2141,"stargazers_count":778,"open_issues_count":25,"forks_count":73,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-04-14T19:59:25.210Z","etag":null,"topics":["go","tor"],"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/cretz.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}},"created_at":"2018-05-10T14:49:46.000Z","updated_at":"2025-04-09T17:44:30.000Z","dependencies_parsed_at":"2024-06-18T12:23:51.254Z","dependency_job_id":"c734e2f1-a003-41fb-8b20-df8ffa3e1e03","html_url":"https://github.com/cretz/bine","commit_stats":{"total_commits":63,"total_committers":13,"mean_commits":4.846153846153846,"dds":"0.23809523809523814","last_synced_commit":"b9d31d9c786616742e39a121b60522e803e96731"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cretz%2Fbine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cretz%2Fbine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cretz%2Fbine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cretz%2Fbine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cretz","download_url":"https://codeload.github.com/cretz/bine/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254337612,"owners_count":22054253,"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","tor"],"created_at":"2024-07-31T08:00:33.642Z","updated_at":"2025-05-15T12:02:01.018Z","avatar_url":"https://github.com/cretz.png","language":"Go","funding_links":[],"categories":["Go","Applications","Uncategorized"],"sub_categories":["Other applications","Uncategorized"],"readme":"# \u003cimg src=\"logo/bine-logo.png\" width=\"180px\"\u003e\n\n[![GoDoc](https://godoc.org/github.com/cretz/bine?status.svg)](https://godoc.org/github.com/cretz/bine)\n\nBine is a Go API for using and controlling Tor. It is similar to [Stem](https://stem.torproject.org/).\n\nFeatures:\n\n* Full support for the Tor controller API\n* Support for `net.Conn` and `net.Listen` style APIs\n* Supports statically compiled Tor to embed Tor into the binary\n* Supports v3 onion services\n* Support for embedded control socket in Tor \u003e= 0.3.5 (non-Windows)\n\nSee info below, the [API docs](http://godoc.org/github.com/cretz/bine), and the [examples](examples). The project is\nMIT licensed. The Tor docs/specs and https://github.com/yawning/bulb were great helps when building this.\n\n## Example\n\nIt is really easy to create an onion service. For example, assuming `tor` is on the `PATH`, this bit of code will show\na directory server of the current directory:\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"log\"\n\t\"net/http\"\n\t\"time\"\n\n\t\"github.com/cretz/bine/tor\"\n)\n\nfunc main() {\n\t// Start tor with default config (can set start conf's DebugWriter to os.Stdout for debug logs)\n\tfmt.Println(\"Starting and registering onion service, please wait a couple of minutes...\")\n\tt, err := tor.Start(nil, nil)\n\tif err != nil {\n\t\tlog.Panicf(\"Unable to start Tor: %v\", err)\n\t}\n\tdefer t.Close()\n\t// Wait at most a few minutes to publish the service\n\tlistenCtx, listenCancel := context.WithTimeout(context.Background(), 3*time.Minute)\n\tdefer listenCancel()\n\t// Create a v3 onion service to listen on any port but show as 80\n\tonion, err := t.Listen(listenCtx, \u0026tor.ListenConf{RemotePorts: []int{80}})\n\tif err != nil {\n\t\tlog.Panicf(\"Unable to create onion service: %v\", err)\n\t}\n\tdefer onion.Close()\n\tfmt.Printf(\"Open Tor browser and navigate to http://%v.onion\\n\", onion.ID)\n\tfmt.Println(\"Press enter to exit\")\n\t// Serve the current folder from HTTP\n\terrCh := make(chan error, 1)\n\tgo func() { errCh \u003c- http.Serve(onion, http.FileServer(http.Dir(\".\"))) }()\n\t// End when enter is pressed\n\tgo func() {\n\t\tfmt.Scanln()\n\t\terrCh \u003c- nil\n\t}()\n\tif err = \u003c-errCh; err != nil {\n\t\tlog.Panicf(\"Failed serving: %v\", err)\n\t}\n}\n```\n\nIf in `main.go` it can simply be run with `go run main.go`. Of course this uses a separate `tor` process. To embed Tor\nstatically in the binary, follow the [embedded package docs](https://godoc.org/github.com/cretz/bine/process/embedded)\nwhich will require [building Tor statically](https://github.com/cretz/tor-static). Then with\n`github.com/cretz/bine/process/embedded` imported, change the start line above to:\n\n```go\nt, err := tor.Start(nil, \u0026tor.StartConf{ProcessCreator: embedded.NewCreator()})\n```\n\nThis defaults to Tor 0.3.5.x versions but others can be used from different packages. In non-Windows environments, the\n`UseEmbeddedControlConn` field in `StartConf` can be set to `true` to use an embedded socket that does not open a\ncontrol port.\n\nTested on Windows, the original exe file is ~7MB. With Tor statically linked it comes to ~24MB, but Tor does not have to\nbe distributed separately. Of course take notice of all licenses in accompanying projects.\n\n## Testing\n\nTo test, a simple `go test ./...` from the base of the repository will work (add in a `-v` in there to see the tests).\nThe integration tests in `tests` however will be skipped. To execute those tests, `-tor` must be passed to the test.\nAlso, `tor` must be on the `PATH` or `-tor.path` must be set to the path of the `tor` executable. Even with those flags,\nonly the integration tests that do not connect to the Tor network are run. To also include the tests that use the Tor\nnetwork, add the `-tor.network` flag. For details Tor logs during any of the integration tests, use the `-tor.verbose`\nflag.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcretz%2Fbine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcretz%2Fbine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcretz%2Fbine/lists"}