blob: 434b7631c9a796a5223a7249f0278d6f434e01d6 [file] [log] [blame]
// Copyright 2015 The Vanadium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package vine
error (
InvalidAddress(address string) {"en": "invalid vine address {address}, address must be of the form 'network/address/tag'"}
AddressNotReachable(address string) {"en": "address {address} not reachable"}
NoRegisteredProtocol(protocol string) {"en": "no registered protocol {protocol}"}
CantAcceptFromTag(tag string) {"en": "can't accept connection from tag {tag}"}
// Vine is the interface to a vine service that can dynamically change the network
// behavior of connection's on the vine service's process.
type Vine interface {
// SetBehaviors sets the policy that the accepting vine service's process
// will use on connections.
// behaviors is a map from server tag to the desired connection behavior.
// For example,
// client.SetBehaviors(map[PeerKey]PeerBehavior{PeerKey{"foo", "bar"}, PeerBehavior{Reachable: false}})
// will cause all vine protocol dial calls from "foo" to "bar" to fail.
SetBehaviors(behaviors map[PeerKey]PeerBehavior) error
// PeerKey is a key that represents a connection from a Dialer tag to an Acceptor tag.
type PeerKey struct{
Dialer string
Acceptor string
// PeerBehavior specifies characteristics of a connection.
type PeerBehavior struct {
// Reachable specifies whether the outgoing or incoming connection can be
// dialed or accepted.
// TODO(suharshs): Make this a user defined error which vine will return instead of a bool.
Reachable bool
// Discoverable specifies whether the Dialer can advertise a discovery packet
// to the Acceptor. This is useful for emulating neighborhoods.
// TODO(suharshs): Discoverable should always be bidirectional. It is unrealistic for
// A to discover B, but not vice versa.
Discoverable bool