tor

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 24, 2024 License: Apache-2.0, MIT Imports: 19 Imported by: 0

README

go-libp2p-tor-transport

Go tor transport is a go-libp2p transport targeting mainly *nix platform.

WIP

This transport is in very early stages (PoC) many of features enumerated here are just targets.

You can follow the process of the 1.0 here.

Usage :

import (
  "context"

  tor "berty.tech/go-libp2p-tor-transport"
  config "berty.tech/go-libp2p-tor-transport/config"
  libp2p "github.com/libp2p/go-libp2p"
)

func main() {
  builder, err := tor.NewBuilder( // Create a builder
    config.EnableEmbeded,         // Use the embeded tor instance.
  )
  c(err)
  host, err := libp2p.New(        // Create a libp2p node
    context.Background(),
    libp2p.Transport(builder),    // Use the builder to create a transport instance (you can't reuse the same builder after that).
  )
  c(err)
}

func c(err error) { // Used to check error in this example, replace by whatever you want.
  if err != nil {
    panic(err)
  }
}
With config :
import (
  "context"
  "time"

  tor "berty.tech/go-libp2p-tor-transport"
  config "berty.tech/go-libp2p-tor-transport/config"
  libp2p "github.com/libp2p/go-libp2p"
)

func main() {
  builder, err := tor.NewBuilder(        // NewBuilder can accept some `config.Configurator`
    config.AllowTcpDial,                 // Some Configurator are already ready to use.
    config.SetSetupTimeout(time.Minute), // Some require a parameter, in this case it's a function that will return a Configurator.
    config.SetBinaryPath("/usr/bin/tor"),
  )
  // Evrything else is as previously shown.
  c(err)
  hostWithConfig, err := libp2p.New(
    context.Background(),
    libp2p.Transport(builder),
  )
  c(err)
}

func c(err error) {
  if err != nil {
    panic(err)
  }
}

Support

This transport target *nix (Linux, OSX, IOS, Android, ...), it also can be built for windows but many of the attack reduction mesures will not be present (on windows potentialy un encrypted traffic will transit through the loopback, also some tor control port are gonna be exposed.).

Tor Provider Compatibility

You can use 3 different provider :

  • Embeded, this transport naturaly include a tor build, nothing to do.
  • External node, the transport will connect to an already running tor node (usefull for server, can increase annonymity by running a relay at the same time blocking SCA attacks).
  • File Path, you can give a path to a tor node executable, the transport will start the node and setup it.

Running Mode

  • Compatibility, this will create tunnels only 1 or 0 long, this disable privacy protection but allows to connect or be contacted by annonym nodes at a much lower cost (you can also use that to go around your nat) default.
  • Annonymity, this will works like you expect 3 hop tunnels, in combination with a correct configuration of your libp2p node you will be able to also dial non annonym nodes through an exit relay.

Documentation

Index

Constants

View Source
const NopMaddr2Str = "/onion/aaaaaaaaaaaaaaaa:1"

nopMaddr is an empty maddr used as filler when needed.

View Source
const NopMaddr3Str = "/onion3/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:1"

Variables

View Source
var NopMaddr2, _ = ma.NewMultiaddr(NopMaddr2Str)
View Source
var NopMaddr3, _ = ma.NewMultiaddr(NopMaddr3Str)

Functions

func NewBuilder

func NewBuilder(cs ...config.Configurator) (func(tpt.Upgrader) tpt.Transport, error)

func ProviderVersion

func ProviderVersion() string

ProviderVersion return the version of the embeded tor node.

Types

This section is empty.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL