1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-12-24 10:07:04 +02:00

Add tunnel address

This commit is contained in:
Asim Aslam 2019-08-21 12:55:10 +01:00
parent 86f0c06fac
commit c2d85a6e1f
3 changed files with 14 additions and 1 deletions

View File

@ -521,6 +521,17 @@ func (t *tun) close() error {
return t.listener.Close()
}
func (t *tun) Address() string {
t.RLock()
defer t.RUnlock()
if !t.connected {
return t.options.Address
}
return t.listener.Addr()
}
// Close the tunnel
func (t *tun) Close() error {
t.Lock()

View File

@ -8,7 +8,7 @@ import (
var (
// DefaultAddress is default tunnel bind address
DefaultAddress = ":9096"
DefaultAddress = ":0"
)
type Option func(*Options)

View File

@ -11,6 +11,8 @@ import (
// the address being requested.
type Tunnel interface {
Init(opts ...Option) error
// Address the tunnel is listening on
Address() string
// Connect connects the tunnel
Connect() error
// Close closes the tunnel