package yamux

import (
	
	
)

// hasAddr is used to get the address from the underlying connection
type hasAddr interface {
	LocalAddr() net.Addr
	RemoteAddr() net.Addr
}

// yamuxAddr is used when we cannot get the underlying address
type yamuxAddr struct {
	Addr string
}

func (*yamuxAddr) () string {
	return "yamux"
}

func ( *yamuxAddr) () string {
	return fmt.Sprintf("yamux:%s", .Addr)
}

// Addr is used to get the address of the listener.
func ( *Session) () net.Addr {
	return .LocalAddr()
}

// LocalAddr is used to get the local address of the
// underlying connection.
func ( *Session) () net.Addr {
	,  := .conn.(hasAddr)
	if ! {
		return &yamuxAddr{"local"}
	}
	return .LocalAddr()
}

// RemoteAddr is used to get the address of remote end
// of the underlying connection
func ( *Session) () net.Addr {
	,  := .conn.(hasAddr)
	if ! {
		return &yamuxAddr{"remote"}
	}
	return .RemoteAddr()
}

// LocalAddr returns the local address
func ( *Stream) () net.Addr {
	return .session.LocalAddr()
}

// RemoteAddr returns the remote address
func ( *Stream) () net.Addr {
	return .session.RemoteAddr()
}