Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do Not Merge: review and discuss adding tor onion transport #79

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions p2p/net/swarm/addr/addr.go
Expand Up @@ -3,6 +3,7 @@ package addrutil
import (
"fmt"

onion "github.com/david415/ipfs-onion-transport"
logging "github.com/ipfs/go-log"
ma "github.com/jbenet/go-multiaddr"
manet "github.com/jbenet/go-multiaddr-net"
Expand All @@ -21,6 +22,7 @@ var SupportedTransportStrings = []string{
"/ip6/udp/utp",
// "/ip4/udp/udt", disabled because the lib doesnt work on arm
// "/ip6/udp/udt", disabled because the lib doesnt work on arm
"/onion",
}

// SupportedTransportProtocols is the list of supported transports for the swarm.
Expand Down
20 changes: 20 additions & 0 deletions p2p/net/swarm/swarm.go
Expand Up @@ -10,6 +10,7 @@ import (
"sync"
"time"

onion "github.com/david415/ipfs-onion-transport"
peer "github.com/ipfs/go-libp2p-peer"
pstore "github.com/ipfs/go-libp2p-peerstore"
transport "github.com/ipfs/go-libp2p-transport"
Expand All @@ -30,6 +31,7 @@ import (
yamux "github.com/whyrusleeping/go-smux-yamux"
mafilter "github.com/whyrusleeping/multiaddr-filter"
context "golang.org/x/net/context"
"golang.org/x/net/proxy"
)

var log = logging.Logger("swarm2")
Expand Down Expand Up @@ -108,6 +110,23 @@ func NewSwarm(ctx context.Context, listenAddrs []ma.Multiaddr,
return mconn.WrapConn(bwc, c)
}

// POC setup for onion transport

// The Tor socks user and password can be set to random values
// to tell little-t tor to make a new circuit.
// It's probably OK to leave them blank because when connecting
// to a new onion a new tor circuit will have to be created anyway.
auth := proxy.Auth{
User: "",
Password: "",
}

// XXX FIXME: The tor control net and addr should be user specified!
// Note: for sandboxing purposes UNIX domain sockets are preferred instead of TCP.
controlNet := "tcp"
controlAddr := "127.0.0.1:9051"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this info be embedded into the multiaddr? If its an onion protocol running over tcp i'd expect to see something like /ip4/127.0.0.1/tcp/9051/onion/abcdefsasdasdasd

onionTransport := NewOnionTransport(controlNet, controlAddr, nil, &auth)

s := &Swarm{
swarm: ps.NewSwarm(PSTransport),
local: local,
Expand All @@ -118,6 +137,7 @@ func NewSwarm(ctx context.Context, listenAddrs []ma.Multiaddr,
transports: []transport.Transport{
transport.NewTCPTransport(),
transport.NewUtpTransport(),
onionTransport,
},
bwc: bwc,
fdRateLimit: make(chan struct{}, concurrentFdDials),
Expand Down