Add tunnel address
This commit is contained in:
		| @@ -521,6 +521,17 @@ func (t *tun) close() error { | |||||||
| 	return t.listener.Close() | 	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 | // Close the tunnel | ||||||
| func (t *tun) Close() error { | func (t *tun) Close() error { | ||||||
| 	t.Lock() | 	t.Lock() | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ import ( | |||||||
|  |  | ||||||
| var ( | var ( | ||||||
| 	// DefaultAddress is default tunnel bind address | 	// DefaultAddress is default tunnel bind address | ||||||
| 	DefaultAddress = ":9096" | 	DefaultAddress = ":0" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| type Option func(*Options) | type Option func(*Options) | ||||||
|   | |||||||
| @@ -11,6 +11,8 @@ import ( | |||||||
| // the address being requested. | // the address being requested. | ||||||
| type Tunnel interface { | type Tunnel interface { | ||||||
| 	Init(opts ...Option) error | 	Init(opts ...Option) error | ||||||
|  | 	// Address the tunnel is listening on | ||||||
|  | 	Address() string | ||||||
| 	// Connect connects the tunnel | 	// Connect connects the tunnel | ||||||
| 	Connect() error | 	Connect() error | ||||||
| 	// Close closes the tunnel | 	// Close closes the tunnel | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user