mirror of
https://github.com/aljazceru/kata-containers.git
synced 2025-12-26 18:44:47 +01:00
To include the grpc yamux dialer. Included kata agent git log: e37feac protocol: client: enable builtin yamux client support a862fea agent: Fix container creation rollback 9602e11 vendor: Update libcontainer vendoring 92f87a1 agent: Rollback properly when container creation fails 128f87d mount: Correct error message with mount failure. 7a182a4 device: VmPath can be empty if an Id is provided 0275654 ci: lib: allow override of tests_repo 205a4d7 github: Add issue template 103aacd announce: Add total memory e277ec6 announce: Add device and storage handlers 5d7463f announce: Add standard fields when running as PID 1 4655950 agent: Add announce function 5e6c385 CI: Require pullapprove ack for protocol changes 5d40027 tests: Skip more tests if non-root 4ba8499 tests: Use root skip function 9a2da30 tests: Move helper function ae2be84 device: Add validation and debug 9e7b27c mount: Log params and validate Signed-off-by: Peng Tao <bergwolf@gmail.com>
61 lines
1.2 KiB
Go
61 lines
1.2 KiB
Go
package yamux
|
|
|
|
import (
|
|
"fmt"
|
|
"net"
|
|
)
|
|
|
|
// 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) Network() string {
|
|
return "yamux"
|
|
}
|
|
|
|
func (y *yamuxAddr) String() string {
|
|
return fmt.Sprintf("yamux:%s", y.Addr)
|
|
}
|
|
|
|
// Addr is used to get the address of the listener.
|
|
func (s *Session) Addr() net.Addr {
|
|
return s.LocalAddr()
|
|
}
|
|
|
|
// LocalAddr is used to get the local address of the
|
|
// underlying connection.
|
|
func (s *Session) LocalAddr() net.Addr {
|
|
addr, ok := s.conn.(hasAddr)
|
|
if !ok {
|
|
return &yamuxAddr{"local"}
|
|
}
|
|
return addr.LocalAddr()
|
|
}
|
|
|
|
// RemoteAddr is used to get the address of remote end
|
|
// of the underlying connection
|
|
func (s *Session) RemoteAddr() net.Addr {
|
|
addr, ok := s.conn.(hasAddr)
|
|
if !ok {
|
|
return &yamuxAddr{"remote"}
|
|
}
|
|
return addr.RemoteAddr()
|
|
}
|
|
|
|
// LocalAddr returns the local address
|
|
func (s *Stream) LocalAddr() net.Addr {
|
|
return s.session.LocalAddr()
|
|
}
|
|
|
|
// LocalAddr returns the remote address
|
|
func (s *Stream) RemoteAddr() net.Addr {
|
|
return s.session.RemoteAddr()
|
|
}
|