Description
Bine is a Go API for using and controlling Tor. It is similar to Stem.
bine alternatives and similar packages
Based on the "Networking" category.
Alternatively, view bine alternatives based on common mentions on social networks and blogs.
-
kcptun
A Stable & Secure Tunnel based on KCP with N:M multiplexing and FEC. Available for ARM, MIPS, 386 and AMD64。N:M 多重化と FEC を備えた KCP に基づく安定した安全なトンネル。 N:M 다중화 및 FEC를 사용하는 KCP 기반의 안정적이고 안전한 터널입니다. Un tunnel stable et sécurisé basé sur KCP avec multiplexage N:M et FEC. -
fasthttp
Fast HTTP package for Go. Tuned for high performance. Zero memory allocations in hot paths. Up to 10x faster than net/http -
gnet
🚀 gnet is a high-performance, lightweight, non-blocking, event-driven networking framework written in pure Go./ gnet 是一个高性能、轻量级、非阻塞的事件驱动 Go 网络框架。 -
Netmaker
Netmaker makes networks with WireGuard. Netmaker automates fast, secure, and distributed virtual networks. -
fortio
Fortio load testing library, command line tool, advanced echo server and web UI in go (golang). Allows to specify a set query-per-second load and record latency histograms and other useful stats. -
mqttPaho
The Paho Go Client provides an MQTT client library for connection to MQTT brokers via TCP, TLS or WebSockets. -
nbio
Pure Go 1000k+ connections solution, support tls/http1.x/websocket and basically compatible with net/http, with high-performance and low memory cost, non-blocking, event-driven, easy-to-use. -
gev
🚀Gev is a lightweight, fast non-blocking TCP network library / websocket server based on Reactor mode. Support custom protocols to quickly and easily build high-performance servers. -
gmqtt
Gmqtt is a flexible, high-performance MQTT broker library that fully implements the MQTT protocol V3.x and V5 in golang -
easytcp
:sparkles: :rocket: EasyTCP is a light-weight TCP framework written in Go (Golang), built with message router. EasyTCP helps you build a TCP server easily fast and less painful. -
peerdiscovery
Pure-Go library for cross-platform local peer discovery using UDP multicast :woman: :repeat: :woman: -
raw
Package raw enables reading and writing data at the device driver level for a network interface. MIT Licensed. -
ethernet
Package ethernet implements marshaling and unmarshaling of IEEE 802.3 Ethernet II frames and IEEE 802.1Q VLAN tags. MIT Licensed. -
buffstreams
A library to simplify writing applications using TCP sockets to stream protobuff messages
WorkOS - The modern identity platform for B2B SaaS
Do you think we are missing an alternative of bine or a related project?
Popular Comparisons
README
Bine is a Go API for using and controlling Tor. It is similar to Stem.
Features:
- Full support for the Tor controller API
- Support for
net.Conn
andnet.Listen
style APIs - Supports statically compiled Tor to embed Tor into the binary
- Supports v3 onion services
- Support for embedded control socket in Tor >= 0.3.5 (non-Windows)
See info below, the API docs, and the [examples](examples). The project is MIT licensed. The Tor docs/specs and https://github.com/yawning/bulb were great helps when building this.
Example
It is really easy to create an onion service. For example, assuming tor
is on the PATH
, this bit of code will show
a directory server of the current directory:
package main
import (
"context"
"fmt"
"log"
"net/http"
"time"
"github.com/cretz/bine/tor"
)
func main() {
// Start tor with default config (can set start conf's DebugWriter to os.Stdout for debug logs)
fmt.Println("Starting and registering onion service, please wait a couple of minutes...")
t, err := tor.Start(nil, nil)
if err != nil {
log.Panicf("Unable to start Tor: %v", err)
}
defer t.Close()
// Wait at most a few minutes to publish the service
listenCtx, listenCancel := context.WithTimeout(context.Background(), 3*time.Minute)
defer listenCancel()
// Create a v3 onion service to listen on any port but show as 80
onion, err := t.Listen(listenCtx, &tor.ListenConf{RemotePorts: []int{80}})
if err != nil {
log.Panicf("Unable to create onion service: %v", err)
}
defer onion.Close()
fmt.Printf("Open Tor browser and navigate to http://%v.onion\n", onion.ID)
fmt.Println("Press enter to exit")
// Serve the current folder from HTTP
errCh := make(chan error, 1)
go func() { errCh <- http.Serve(onion, http.FileServer(http.Dir("."))) }()
// End when enter is pressed
go func() {
fmt.Scanln()
errCh <- nil
}()
if err = <-errCh; err != nil {
log.Panicf("Failed serving: %v", err)
}
}
If in main.go
it can simply be run with go run main.go
. Of course this uses a separate tor
process. To embed Tor
statically in the binary, follow the embedded package docs
which will require building Tor statically. Then with
github.com/cretz/bine/process/embedded
imported, change the start line above to:
t, err := tor.Start(nil, &tor.StartConf{ProcessCreator: embedded.NewCreator()})
This defaults to Tor 0.3.5.x versions but others can be used from different packages. In non-Windows environments, the
UseEmbeddedControlConn
field in StartConf
can be set to true
to use an embedded socket that does not open a
control port.
Tested on Windows, the original exe file is ~7MB. With Tor statically linked it comes to ~24MB, but Tor does not have to be distributed separately. Of course take notice of all licenses in accompanying projects.
Testing
To test, a simple go test ./...
from the base of the repository will work (add in a -v
in there to see the tests).
The integration tests in tests
however will be skipped. To execute those tests, -tor
must be passed to the test.
Also, tor
must be on the PATH
or -tor.path
must be set to the path of the tor
executable. Even with those flags,
only the integration tests that do not connect to the Tor network are run. To also include the tests that use the Tor
network, add the -tor.network
flag. For details Tor logs during any of the integration tests, use the -tor.verbose
flag.
*Note that all licence references and agreements mentioned in the bine README section above
are relevant to that project's source code only.