2019-08-05 19:52:57 +03:00
|
|
|
// Package tunnel provides micro network tunnelling
|
|
|
|
package tunnel
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/micro/go-micro/transport"
|
|
|
|
)
|
|
|
|
|
2019-08-05 21:41:48 +03:00
|
|
|
// Status is tunnel status
|
|
|
|
type Status int
|
|
|
|
|
|
|
|
const (
|
|
|
|
// Connected means the tunnel is alive
|
|
|
|
Connected Status = iota
|
|
|
|
// Closed meands the tunnel has been disconnected
|
|
|
|
Closed
|
|
|
|
)
|
|
|
|
|
2019-08-05 19:52:57 +03:00
|
|
|
// Tunnel creates a p2p network tunnel.
|
|
|
|
type Tunnel interface {
|
2019-08-05 21:41:48 +03:00
|
|
|
// Id returns tunnel id
|
|
|
|
Id() string
|
|
|
|
// Address returns tunnel address
|
|
|
|
Address() string
|
|
|
|
// Tramsport returns tunnel transport
|
|
|
|
Transport() transport.Transport
|
2019-08-05 19:52:57 +03:00
|
|
|
// Connect connects the tunnel
|
|
|
|
Connect() error
|
|
|
|
// Close closes the tunnel
|
|
|
|
Close() error
|
2019-08-05 21:41:48 +03:00
|
|
|
// Status returns tunnel status
|
|
|
|
Status() Status
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewTunnel creates a new tunnel on top of a link
|
|
|
|
func NewTunnel(opts ...Option) Tunnel {
|
|
|
|
return newTunnel(opts...)
|
2019-08-05 19:52:57 +03:00
|
|
|
}
|