Make Tor 0.3.5.x the default embedded version, fixes #24

This commit is contained in:
Chad Retz 2019-01-22 12:44:56 -06:00
parent 452e22de4f
commit f5c65d3eb0
3 changed files with 13 additions and 9 deletions

View File

@ -9,7 +9,7 @@ Features:
* Full support for the Tor controller API
* Support for `net.Conn` and `net.Listen` style APIs
* Supports statically compiled Tor to embed Tor into the binary
* Supports both V2 and V3 onion services
* Supports both v2 and v3 onion services
* Support for embedded control socket in Tor >= 0.3.5 (non-Windows)
See info below, the [API docs](http://godoc.org/github.com/cretz/bine), and the [examples](examples). The project is
@ -44,8 +44,8 @@ func main() {
// Wait at most a few minutes to publish the service
listenCtx, listenCancel := context.WithTimeout(context.Background(), 3*time.Minute)
defer listenCancel()
// Create an onion service to listen on any port but show as 80
onion, err := t.Listen(listenCtx, &tor.ListenConf{RemotePorts: []int{80}})
// Create a v3 onion service to listen on any port but show as 80
onion, err := t.Listen(listenCtx, &tor.ListenConf{Version3: true, RemotePorts: []int{80}})
if err != nil {
log.Panicf("Unable to create onion service: %v", err)
}
@ -75,6 +75,10 @@ which will require [building Tor statically](https://github.com/cretz/tor-static
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.

2
doc.go
View File

@ -6,7 +6,7 @@
//
// * Supports statically compiled Tor to embed Tor into the binary
//
// * Supports both V2 and V3 onion services
// * Supports both v2 and v3 onion services
//
// * Support for embedded control socket in Tor >= 0.3.5 (non-Windows)
//

View File

@ -13,20 +13,20 @@
// installed with gcc.exe on the PATH (i.e. the same gcc that was used to build
// the static Tor lib).
//
// The default in here is currently for Tor 0.3.3.x which uses the tor-0.3.3
// The default in here is currently for Tor 0.3.5.x which uses the tor-0.3.5
// subdirectory. A different subdirectory can be used for a different version.
// Note that the current version doesn't support
// process.Process.EmbeddedControlConn().
// Note that the current version does support
// process.Process.EmbeddedControlConn() on non-Windows.
package embedded
import (
"github.com/cretz/bine/process"
tor033 "github.com/cretz/bine/process/embedded/tor-0.3.3"
tor035 "github.com/cretz/bine/process/embedded/tor-0.3.5"
)
// NewCreator creates a process.Creator for statically-linked Tor embedded in
// the binary.
func NewCreator() process.Creator {
return tor033.NewCreator()
return tor035.NewCreator()
}