Documentation ¶
Overview ¶
Package mixnet is a generated protocol buffer package.
It is generated from these files:
mixnet.proto
It has these top-level messages:
Directive DirectoryMessage
Index ¶
- Constants
- Variables
- func GetDirectory(c net.Conn) ([]string, [][]byte, error)
- func Listen(network, laddr string, config *tls.Config, g tao.Guard, v *tao.Verifier, ...) (net.Listener, error)
- func RegisterRouter(c net.Conn, addrs []string, keys [][]byte) error
- func SocksListen(network, addr string) (net.Listener, error)
- type Circuit
- func (c *Circuit) BufferCell(cell []byte, err error)
- func (c *Circuit) Close() error
- func (c *Circuit) Decrypt(boxed []byte) ([]byte, bool)
- func (c *Circuit) Encrypt(msg []byte) []byte
- func (c *Circuit) Read(msg []byte) (int, error)
- func (c *Circuit) ReceiveDirective(d *Directive) error
- func (c *Circuit) ReceiveMessage() ([]byte, error)
- func (c *Circuit) SendDirective(d *Directive) (int, error)
- func (c *Circuit) SendMessage(msg []byte) error
- func (c *Circuit) SetKeys(peerKey, publicKey, privateKey *[32]byte)
- func (c *Circuit) Write(msg []byte) (int, error)
- type Conn
- func (c *Conn) AddCircuit(circuit *Circuit)
- func (c *Conn) DeleteCircuit(circuit *Circuit) bool
- func (c *Conn) Empty() bool
- func (c *Conn) GetCircuit(id uint64) *Circuit
- func (c *Conn) Member(id uint64) bool
- func (c *Conn) Read(msg []byte) (n int, err error)
- func (c *Conn) Write(msg []byte) (n int, err error)
- type Directive
- func (*Directive) Descriptor() ([]byte, []int)
- func (m *Directive) GetAddrs() []string
- func (m *Directive) GetError() string
- func (m *Directive) GetKey() []byte
- func (m *Directive) GetType() DirectiveType
- func (*Directive) ProtoMessage()
- func (m *Directive) Reset()
- func (m *Directive) String() string
- type DirectiveType
- type DirectoryContext
- type DirectoryMessage
- func (*DirectoryMessage) Descriptor() ([]byte, []int)
- func (m *DirectoryMessage) GetAddrs() []string
- func (m *DirectoryMessage) GetError() string
- func (m *DirectoryMessage) GetKeys() [][]byte
- func (m *DirectoryMessage) GetType() DirectoryMessageType
- func (*DirectoryMessage) ProtoMessage()
- func (m *DirectoryMessage) Reset()
- func (m *DirectoryMessage) String() string
- type DirectoryMessageType
- type ProxyContext
- func (p *ProxyContext) Accept() (net.Conn, error)
- func (p *ProxyContext) Close()
- func (p *ProxyContext) CreateCircuit(path []string, dest string) (*Circuit, uint64, error)
- func (p *ProxyContext) DestroyCircuit(id uint64) error
- func (p *ProxyContext) DialRouter(network, addr string) (*Conn, error)
- func (p *ProxyContext) GetDirectory(dirAddr string) ([]string, [][]byte, error)
- func (p *ProxyContext) HandleClient(id uint64) error
- func (p *ProxyContext) ServeClient(c net.Conn, path []string, dest string) error
- type Queue
- func (sq *Queue) Close(id uint64, msg []byte, destroy bool, conn, errConn net.Conn)
- func (sq *Queue) DoQueue(kill <-chan bool)
- func (sq *Queue) DoQueueErrorHandler(queue *Queue, kill <-chan bool)
- func (sq *Queue) Enqueue(q *Queueable)
- func (sq *Queue) EnqueueMsg(id uint64, msg []byte, conn, errConn net.Conn)
- type Queueable
- type RouterContext
- func (r *RouterContext) Accept() (*Conn, error)
- func (r *RouterContext) Close()
- func (r *RouterContext) DeleteRouter()
- func (r *RouterContext) DialRouter(network, addr string) (*Conn, error)
- func (r *RouterContext) GetDirectory(dirAddr string) ([]string, [][]byte, error)
- func (r *RouterContext) HandleErr()
- func (r *RouterContext) Register(dirAddr string) error
- func (r *RouterContext) SendError(queue *Queue, queueId, id uint64, err error, c *Conn) error
- type SocksConn
- type SocksListener
Constants ¶
const ( // CellBytes specifies the length of a cell. CellBytes = 1 << 10 // MaxMsgBytes specifies the maximum length of a message. MaxMsgBytes = 1 << 16 )
const ( // Update directory every x amount of time DefaultUpdateFrequency = 3600 * time.Second DefaultHopCount = 2 DefaultTimeout = 10 * time.Second )
const ( ID_SIZE = 8 LEN_SIZE = 8 BODY_SIZE = CellBytes - BODY - box.Overhead - 24 )
const ( ID = 0 TYPE = ID + ID_SIZE BODY = 9 )
const ( SocksVersion = 0x05 SocksMethodNoAuth = 0x00 SocksNoAcceptableMethod = 0xff SocksCmdConnect = 0x01 SocksAtypIPv4 = 0x01 SocksRepSuccess = 0x00 SocksRepFailure = 0x01 SocksRepUnsupported = 0x07 )
Codes used in the RFC standard of SOCKS version 5.
Variables ¶
var DirectiveType_name = map[int32]string{
0: "ERROR",
1: "CREATE",
2: "CREATED",
3: "DESTROY",
4: "DESTROYED",
}
var DirectiveType_value = map[string]int32{
"ERROR": 0,
"CREATE": 1,
"CREATED": 2,
"DESTROY": 3,
"DESTROYED": 4,
}
var DirectoryMessageType_name = map[int32]string{
0: "REGISTER",
1: "DELETE",
2: "LIST",
3: "DIRECTORY",
4: "DIRERROR",
}
var DirectoryMessageType_value = map[string]int32{
"REGISTER": 0,
"DELETE": 1,
"LIST": 2,
"DIRECTORY": 3,
"DIRERROR": 4,
}
Functions ¶
Types ¶
type Circuit ¶
type Circuit struct {
// contains filtered or unexported fields
}
A circuit carries cells
func NewCircuit ¶
A circuit now encrypts for the exit circuit. The key is assumed to be available through "peerKey", and publicKey and privateKey are the keys are local keys used to perform diffiehellman with peerKey. The keys are optional.
func (*Circuit) BufferCell ¶
func (*Circuit) ReceiveDirective ¶
ReceiveDirective awaits a reply from the peer and returns the directive received, e.g. in response to RouterContext.HandleProxy(). If the directive type is ERROR, return an error.
func (*Circuit) ReceiveMessage ¶
ReceiveMessage reads message cells from the router and assembles them into a messsage.
func (*Circuit) SendDirective ¶
SendDirective serializes and pads a directive to the length of a cell and sends it to the peer. A directive is signaled to the receiver by the first byte of the cell. The next few bytes encode the length of of the serialized protocol buffer. If the buffer doesn't fit in a cell, then throw an error.
func (*Circuit) SendMessage ¶
SendMessage divides a message into cells and sends each cell over the network connection. A message is signaled to the receiver by the first byte of the first cell. The next few bytes encode the total number of bytes in the message.
type Conn ¶
Conn implements the net.Conn interface. The read and write operations are overloaded to check that only cells are sent between entities in the mixnet protocol.
func (*Conn) AddCircuit ¶
func (*Conn) DeleteCircuit ¶
func (*Conn) GetCircuit ¶
type Directive ¶
type Directive struct { Type *DirectiveType `protobuf:"varint,1,req,name=type,enum=mixnet.DirectiveType" json:"type,omitempty"` // CREATE, a sequence of addresses (e.g. "192.168.1.1:7007") // comprising the circuit to be constructed over the mixnet. Each address // corresponds to a mixnet router except the last, which is the service the // proxy would like to contact. Addrs []string `protobuf:"bytes,2,rep,name=addrs" json:"addrs,omitempty"` Key []byte `protobuf:"bytes,3,opt,name=key" json:"key,omitempty"` // ERROR or FATAL, an error message. Error *string `protobuf:"bytes,4,opt,name=error" json:"error,omitempty"` XXX_unrecognized []byte `json:"-"` }
func (*Directive) Descriptor ¶
func (*Directive) GetType ¶
func (m *Directive) GetType() DirectiveType
func (*Directive) ProtoMessage ¶
func (*Directive) ProtoMessage()
type DirectiveType ¶
type DirectiveType int32
const ( DirectiveType_ERROR DirectiveType = 0 DirectiveType_CREATE DirectiveType = 1 DirectiveType_CREATED DirectiveType = 2 DirectiveType_DESTROY DirectiveType = 3 DirectiveType_DESTROYED DirectiveType = 4 )
func (DirectiveType) Enum ¶
func (x DirectiveType) Enum() *DirectiveType
func (DirectiveType) EnumDescriptor ¶
func (DirectiveType) EnumDescriptor() ([]byte, []int)
func (DirectiveType) String ¶
func (x DirectiveType) String() string
func (*DirectiveType) UnmarshalJSON ¶
func (x *DirectiveType) UnmarshalJSON(data []byte) error
type DirectoryContext ¶
type DirectoryContext struct {
// contains filtered or unexported fields
}
func NewDirectoryContext ¶
func (*DirectoryContext) Close ¶
func (dc *DirectoryContext) Close()
type DirectoryMessage ¶
type DirectoryMessage struct { Type *DirectoryMessageType `protobuf:"varint,1,req,name=type,enum=mixnet.DirectoryMessageType" json:"type,omitempty"` // Addresses to register to or delete from the directory, // or list of all available mixnets Addrs []string `protobuf:"bytes,2,rep,name=addrs" json:"addrs,omitempty"` Keys [][]byte `protobuf:"bytes,3,rep,name=keys" json:"keys,omitempty"` // Possible error message Error *string `protobuf:"bytes,4,opt,name=error" json:"error,omitempty"` XXX_unrecognized []byte `json:"-"` }
func (*DirectoryMessage) Descriptor ¶
func (*DirectoryMessage) Descriptor() ([]byte, []int)
func (*DirectoryMessage) GetAddrs ¶
func (m *DirectoryMessage) GetAddrs() []string
func (*DirectoryMessage) GetError ¶
func (m *DirectoryMessage) GetError() string
func (*DirectoryMessage) GetKeys ¶
func (m *DirectoryMessage) GetKeys() [][]byte
func (*DirectoryMessage) GetType ¶
func (m *DirectoryMessage) GetType() DirectoryMessageType
func (*DirectoryMessage) ProtoMessage ¶
func (*DirectoryMessage) ProtoMessage()
func (*DirectoryMessage) Reset ¶
func (m *DirectoryMessage) Reset()
func (*DirectoryMessage) String ¶
func (m *DirectoryMessage) String() string
type DirectoryMessageType ¶
type DirectoryMessageType int32
const ( DirectoryMessageType_REGISTER DirectoryMessageType = 0 DirectoryMessageType_DELETE DirectoryMessageType = 1 DirectoryMessageType_LIST DirectoryMessageType = 2 DirectoryMessageType_DIRECTORY DirectoryMessageType = 3 DirectoryMessageType_DIRERROR DirectoryMessageType = 4 )
func (DirectoryMessageType) Enum ¶
func (x DirectoryMessageType) Enum() *DirectoryMessageType
func (DirectoryMessageType) EnumDescriptor ¶
func (DirectoryMessageType) EnumDescriptor() ([]byte, []int)
func (DirectoryMessageType) String ¶
func (x DirectoryMessageType) String() string
func (*DirectoryMessageType) UnmarshalJSON ¶
func (x *DirectoryMessageType) UnmarshalJSON(data []byte) error
type ProxyContext ¶
type ProxyContext struct {
// contains filtered or unexported fields
}
ProxyContext stores the runtime environment for a mixnet proxy. A mixnet proxy connects to a mixnet router on behalf of a client's application.
func NewProxyContext ¶
func NewProxyContext(path, network, addr string, directories []string, hopCount int, timeout time.Duration) (*ProxyContext, error)
NewProxyContext loads a domain from a local configuration.
func (*ProxyContext) Accept ¶
func (p *ProxyContext) Accept() (net.Conn, error)
Accept waits for clients running the SOCKS5 protocol.
func (*ProxyContext) CreateCircuit ¶
CreateCircuit connects anonymously to a remote Tao-delegated mixnet router specified by path[0]. It directs the router to construct a circuit to dest. The user either provides just the exit, or the whole path
func (*ProxyContext) DestroyCircuit ¶
func (p *ProxyContext) DestroyCircuit(id uint64) error
DestroyCircuit directs the router to close the connection to the destination and destroy the circuit then closes the connection.
func (*ProxyContext) DialRouter ¶
func (p *ProxyContext) DialRouter(network, addr string) (*Conn, error)
DialRouter connects anonymously to a remote Tao-delegated mixnet router.
func (*ProxyContext) GetDirectory ¶
func (p *ProxyContext) GetDirectory(dirAddr string) ([]string, [][]byte, error)
Read the directory from a directory server TODO(kwonalbert): This is more or less a duplicate of the router get dir.. Combine them..
func (*ProxyContext) HandleClient ¶
func (p *ProxyContext) HandleClient(id uint64) error
HandleClient relays a message read from client connection c to mixnet connection d and relay reply.
func (*ProxyContext) ServeClient ¶
ServeClient creates a circuit over the mixnet and relays messages to a destination (specified by addrs[len(addrs)-1]) on behalf of the client. Read a message from the client, send it over the mixnet, wait for a reply, and forward it the client. Once an EOF is encountered (or some other error occurs), destroy the circuit.
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
The Queue structure maps a circuit identifier corresponding to a sender (in the router context) to a destination. It also maintains a message buffer for each sender. Once messages are ready on enough buffers, a batch of messages are transmitted simultaneously.
func (*Queue) Close ¶
Close creates a queueable object that sends the last msg in the circuit, closes the connection and deletes all associated resources.
func (*Queue) DoQueue ¶
DoQueue adds messages to a queue and transmits messages in batches. It also provides an interface for receiving messages from a server. Typically a message is a cell, but when the calling router is an exit point, the message length is arbitrary. A batch is transmitted when there are messages on batchSize distinct sender channels.
func (*Queue) DoQueueErrorHandler ¶
DoQueueErrorHandler handles errors produced by DoQueue by enqueing onto queue a directive containing the error message.
type Queueable ¶
type Queueable struct {
// contains filtered or unexported fields
}
The Queueable object is passed through a channel and mutates the state of the Queue in some manner; for example, it can set the destination adddress or connection of a sender, add a message or request for reply to the queue, or destroy any resources associated with the connection.
type RouterContext ¶
type RouterContext struct {
// contains filtered or unexported fields
}
RouterContext stores the runtime environment for a Tao-delegated router.
func NewRouterContext ¶
func NewRouterContext(path, network, addr string, timeout time.Duration, directories []string, batchSize int, x509Identity *pkix.Name, t tao.Tao) (r *RouterContext, err error)
NewRouterContext generates new keys, loads a local domain configuration from path and binds an anonymous listener socket to addr using network protocol. It also creates a regular listener socket for other routers to connect to. A delegation is requested from the Tao t which is nominally the parent of this hosted program.
func (*RouterContext) Accept ¶
func (r *RouterContext) Accept() (*Conn, error)
AcceptRouter Waits for connectons from other routers.
func (*RouterContext) Close ¶
func (r *RouterContext) Close()
Close releases any resources held by the hosted program.
func (*RouterContext) DeleteRouter ¶
func (r *RouterContext) DeleteRouter()
func (*RouterContext) DialRouter ¶
func (r *RouterContext) DialRouter(network, addr string) (*Conn, error)
DialRouter connects to a remote Tao-delegated mixnet router.
func (*RouterContext) GetDirectory ¶
func (r *RouterContext) GetDirectory(dirAddr string) ([]string, [][]byte, error)
Read the directory from a directory server
func (*RouterContext) HandleErr ¶
func (r *RouterContext) HandleErr()
Handle errors internal to the router When instantiating a real router (not for testing), one start this function as well to handle the errors
func (*RouterContext) Register ¶
func (r *RouterContext) Register(dirAddr string) error
Register the current router to a directory server
type SocksConn ¶
SocksConn implements the net.Conn interface and contains a destination network and address for the proxy.
func (*SocksConn) DestinationAddr ¶
DestinationAddr returns the destination address negotiated in the SOCKS protocol.
type SocksListener ¶
SocksListener implements the net.Listener interface as a SOCKS server. This program partially implements the server role in version 5 of the SOCKS protocol specified in RFC 1928. In particular, it only supports TCP clients with no authentication who request CONNECT to IPv4 addresses; neither BIND nor UDP ASSOCIATE are supported.