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
Index ¶
- Constants
- Variables
- func SocksListen(network, addr string) (net.Listener, error)
- type Conn
- type Directive
- type DirectiveType
- type ProxyContext
- func (p *ProxyContext) Accept() (net.Conn, error)
- func (p *ProxyContext) Close()
- func (p *ProxyContext) CreateCircuit(addrs ...string) (*Conn, error)
- func (p *ProxyContext) DestroyCircuit(c *Conn) error
- func (p *ProxyContext) DialRouter(network, addr string) (*Conn, error)
- func (p *ProxyContext) HandleClient(c net.Conn, d *Conn) error
- func (p *ProxyContext) ReceiveDirective(c *Conn, d *Directive) (int, error)
- func (p *ProxyContext) ReceiveMessage(c *Conn) ([]byte, error)
- func (p *ProxyContext) SendDirective(c *Conn, d *Directive) (int, error)
- func (p *ProxyContext) SendMessage(c *Conn, msg []byte) error
- func (p *ProxyContext) ServeClient(c net.Conn, addrs ...string) error
- type Queue
- func (sq *Queue) Close(id uint64)
- func (sq *Queue) DoQueue(kill <-chan bool)
- func (sq *Queue) DoQueueErrorHandler(queue *Queue, kill <-chan bool)
- func (sq *Queue) DoQueueErrorHandlerLog(name string, kill <-chan bool)
- func (sq *Queue) Enqueue(q *Queueable)
- func (sq *Queue) EnqueueMsg(id uint64, msg []byte)
- func (sq *Queue) EnqueueMsgReply(id uint64, msg []byte, reply chan []byte)
- func (sq *Queue) EnqueueReply(id uint64, reply chan []byte)
- func (sq *Queue) SetAddr(id uint64, addr string)
- func (sq *Queue) SetConn(id uint64, c net.Conn)
- type Queueable
- type RouterContext
- 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 ( 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",
}
var DirectiveType_value = map[string]int32{
"ERROR": 0,
"CREATE": 1,
"CREATED": 2,
"DESTROY": 3,
}
Functions ¶
Types ¶
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.
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"` // ERROR or FATAL, an error message. Error *string `protobuf:"bytes,3,opt,name=error" json:"error,omitempty"` XXX_unrecognized []byte `json:"-"` }
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 )
func (DirectiveType) Enum ¶
func (x DirectiveType) Enum() *DirectiveType
func (DirectiveType) String ¶
func (x DirectiveType) String() string
func (*DirectiveType) UnmarshalJSON ¶
func (x *DirectiveType) 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, timeout time.Duration) (p *ProxyContext, err 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 ¶
func (p *ProxyContext) CreateCircuit(addrs ...string) (*Conn, error)
CreateCircuit connects anonymously to a remote Tao-delegated mixnet router specified by addrs[0]. It directs the router to construct a circuit to a particular destination over the mixnet specified by addrs[len(addrs)-1].
func (*ProxyContext) DestroyCircuit ¶
func (p *ProxyContext) DestroyCircuit(c *Conn) error
DestroyCircuit directs the router to close the connection to the destination and destroy the circuit then closes the connection. TODO(cjpatton) in order to support multi-hop circuits, this code will need to wait for a DESTROYED directive from the first hop.
func (*ProxyContext) DialRouter ¶
func (p *ProxyContext) DialRouter(network, addr string) (*Conn, error)
DialRouter connects anonymously to a remote Tao-delegated mixnet router.
func (*ProxyContext) HandleClient ¶
func (p *ProxyContext) HandleClient(c net.Conn, d *Conn) error
HandleClient relays a message read from client connection c to mixnet connection d and relay reply.
func (*ProxyContext) ReceiveDirective ¶
func (p *ProxyContext) ReceiveDirective(c *Conn, d *Directive) (int, error)
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 (*ProxyContext) ReceiveMessage ¶
func (p *ProxyContext) ReceiveMessage(c *Conn) ([]byte, error)
ReceiveMessage reads message cells from the router and assembles them into a messsage.
func (*ProxyContext) SendDirective ¶
func (p *ProxyContext) SendDirective(c *Conn, d *Directive) (int, error)
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 (*ProxyContext) SendMessage ¶
func (p *ProxyContext) SendMessage(c *Conn, msg []byte) error
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.
func (*ProxyContext) ServeClient ¶
func (p *ProxyContext) ServeClient(c net.Conn, addrs ...string) error
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 serial identifier corresponding to a sender (in the router context) to a destination. It also maintains a message buffer for each sender. Once there messages ready on enough buffers, a batch of messages are transmitted simultaneously.
func (*Queue) Close ¶
Close creates a queueable object that 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.
func (*Queue) DoQueueErrorHandlerLog ¶
DoQueueErrorHandlerLog logs errors that occur on this queue.
func (*Queue) Enqueue ¶
Enqueue inserts a queueable object into the queue. Note that this is generally unsafe to use concurrently because it doesn't make a copy of the data.
func (*Queue) EnqueueMsg ¶
EnqueueMsg copies a byte slice into a queueable object and adds it to the queue.
func (*Queue) EnqueueMsgReply ¶
EnqueueMsgReply creates a queueable object with a message and a reply channel and adds it to the queue.
func (*Queue) EnqueueReply ¶
EnqueueReply creates a queuable object with a reply channel and adds it to the queue.
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, batchSize int, timeout time.Duration, x509Identity *pkix.Name, t tao.Tao) (hp *RouterContext, err error)
NewRouterContext generates new keys, loads a local domain configuration from path and binds an anonymous listener socket to addr on network network. A delegation is requested from the Tao t which is nominally the parent of this hosted program.
func (*RouterContext) AcceptProxy ¶
func (hp *RouterContext) AcceptProxy() (*Conn, error)
AcceptProxy Waits for connectons from proxies.
func (*RouterContext) Close ¶
func (hp *RouterContext) Close()
Close releases any resources held by the hosted program.
func (*RouterContext) HandleProxy ¶
func (hp *RouterContext) HandleProxy(c *Conn) error
HandleProxy reads a directive or a message from a proxy.
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.