Provide Links() method in Tunnel

This commit is contained in:
Asim Aslam
2019-09-04 15:41:57 +01:00
parent 7ab3934eb7
commit d559ce9da2
4 changed files with 40 additions and 20 deletions

View File

@@ -187,30 +187,15 @@ func testBrokenTunAccept(t *testing.T, tun Tunnel, wait chan bool, wg *sync.Wait
if err := c.Recv(m); err != nil {
t.Fatal(err)
}
tun.Close()
// re-start tunnel
err = tun.Connect()
if err != nil {
t.Fatal(err)
}
defer tun.Close()
// listen on some virtual address
tl, err = tun.Listen("test-tunnel")
if err != nil {
t.Fatal(err)
// close all the links
for _, link := range tun.Links() {
link.Close()
}
// receiver ready; notify sender
wait <- true
// accept a connection
c, err = tl.Accept()
if err != nil {
t.Fatal(err)
}
// accept the message
m = new(transport.Message)
if err := c.Recv(m); err != nil {
@@ -279,6 +264,7 @@ func TestReconnectTunnel(t *testing.T) {
if err != nil {
t.Fatal(err)
}
defer tunB.Close()
// we manually override the tunnel.ReconnectTime value here
// this is so that we make the reconnects faster than the default 5s
@@ -289,6 +275,7 @@ func TestReconnectTunnel(t *testing.T) {
if err != nil {
t.Fatal(err)
}
defer tunA.Close()
wait := make(chan bool)