Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
60 lines (46 sloc) 1.07 KB
package relay
import (
pb ""
ma ""
manet ""
var _ manet.Listener = (*RelayListener)(nil)
type RelayListener Relay
func (l *RelayListener) Relay() *Relay {
return (*Relay)(l)
func (r *Relay) Listener() *RelayListener {
// TODO: Only allow one!
return (*RelayListener)(r)
func (l *RelayListener) Accept() (manet.Conn, error) {
select {
case c := <-l.incoming:
err := l.Relay().writeResponse(, pb.CircuitRelay_SUCCESS)
if err != nil {
log.Debugf("error writing relay response: %s", err.Error())
return nil, err
// TODO: Pretty print.
log.Infof("accepted relay connection: %q", c)
return c, nil
case <-l.ctx.Done():
return nil, l.ctx.Err()
func (l *RelayListener) Addr() net.Addr {
return &NetAddr{
Relay: "any",
Remote: "any",
func (l *RelayListener) Multiaddr() ma.Multiaddr {
return circuitAddr
func (l *RelayListener) Close() error {
// TODO: noop?
return nil
You can’t perform that action at this time.