Merge pull request #687 from micro/tunnel

Add tunnel address
This commit is contained in:
Asim Aslam 2019-08-21 13:01:28 +01:00 committed by GitHub
commit f787cc0ee0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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