Skip to content
This repository has been archived by the owner on Sep 9, 2022. It is now read-only.

Commit

Permalink
doc: document options
Browse files Browse the repository at this point in the history
  • Loading branch information
Stebalien committed Apr 6, 2019
1 parent 0c6f4d6 commit 74ac06f
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const maxMessageSize = 4096
var RelayAcceptTimeout = time.Minute
var HopConnectTimeout = 10 * time.Second

// Relay is the relay transport and service.
type Relay struct {
host host.Host
upgrader *tptu.Upgrader
Expand All @@ -47,11 +48,22 @@ type Relay struct {
lhLk sync.Mutex
}

// RelayOpts are options for configuring the relay transport.
type RelayOpt int

var (
OptActive = RelayOpt(0)
OptHop = RelayOpt(1)
// OptActive configures the relay transport to actively establish
// outbound connections on behalf of clients. You probably don't want to
// enable this unless you know what you're doing.
OptActive = RelayOpt(0)
// OptHop configures the relay transport to accept requests to relay
// traffic on behalf of third-parties. Unless OptActive is specified,
// this will only relay traffic between peers already connected to this
// node.
OptHop = RelayOpt(1)
// OptDiscovery configures this relay transport to discover new relays
// by probing every new peer. You almost _certainly_ don't want to
// enable this.
OptDiscovery = RelayOpt(2)
)

Expand All @@ -63,6 +75,7 @@ func (e RelayError) Error() string {
return fmt.Sprintf("error opening relay circuit: %s (%d)", pb.CircuitRelay_Status_name[int32(e.Code)], e.Code)
}

// NewRelay constructs a new relay.
func NewRelay(ctx context.Context, h host.Host, upgrader *tptu.Upgrader, opts ...RelayOpt) (*Relay, error) {
r := &Relay{
upgrader: upgrader,
Expand Down

0 comments on commit 74ac06f

Please sign in to comment.