| @@ -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() | ||||
|   | ||||
| @@ -8,7 +8,7 @@ import ( | ||||
|  | ||||
| var ( | ||||
| 	// DefaultAddress is default tunnel bind address | ||||
| 	DefaultAddress = ":9096" | ||||
| 	DefaultAddress = ":0" | ||||
| ) | ||||
|  | ||||
| type Option func(*Options) | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user