func dial(handler serverType, t *testing.T) *Client {
	c1, c2, err := netPipe()
	if err != nil {
		t.Fatalf("netPipe: %v", err)
	}

	go func() {
		defer c1.Close()
		conf := ServerConfig{
			NoClientAuth: true,
		}
		conf.AddHostKey(testSigners["rsa"])

		conn, chans, reqs, err := NewServerConn(c1, &conf)
		if err != nil {
			t.Fatalf("Unable to handshake: %v", err)
		}
		go DiscardRequests(reqs)

		for newCh := range chans {
			if newCh.ChannelType() != "session" {
				newCh.Reject(UnknownChannelType, "unknown channel type")
				continue
			}

			ch, inReqs, err := newCh.Accept()
			if err != nil {
				t.Errorf("Accept: %v", err)
				continue
			}
			go func() {
				handler(ch, inReqs, t)
			}()
		}
		if err := conn.Wait(); err != io.EOF {
			t.Logf("server exit reason: %v", err)
		}
	}()

	config := &ClientConfig{
		User:            "testuser",
		HostKeyCallback: InsecureIgnoreHostKey(),
	}

	conn, chans, reqs, err := NewClientConn(c2, "", config)
	if err != nil {
		t.Fatalf("unable to dial remote side: %v", err)
	}

	return NewClient(conn, chans, reqs)
}
// dial constructs a new test server and returns a *ClientConn.
dial constructs a new test server and returns a *ClientConn.
// dial constructs a new test server and returns a * ClientConn .
func dial(handler serverType, t *testing.T) *Client {
	c1, c2, err := netPipe()
	if err != nil {
		t.Fatalf("netPipe: %v", err)
	}
	go func() {
		defer c1.Close()
		conf := ServerConfig{
			NoClientAuth: true,
		}
		conf.AddHostKey(testSigners["rsa"])
		conn, chans, reqs, err := NewServerConn(c1, &conf)
		if err != nil {
			t.Fatalf("Unable to handshake: %v", err)
		}
		go DiscardRequests(reqs)
		for newCh := range chans {
			if newCh.ChannelType() != "session" {
				newCh.Reject(UnknownChannelType, "unknown channel type")
				continue
			}
			ch, inReqs, err := newCh.Accept()
			if err != nil {
				t.Errorf("Accept: %v", err)
				continue
			}
			go func() {
				handler(ch, inReqs, t)
			}()
		}
		if err := conn.Wait(); err != io.EOF {
			t.Logf("server exit reason: %v", err)
		}
	}()
	config := &ClientConfig{
		User:            "testuser",
		HostKeyCallback: InsecureIgnoreHostKey(),
	}
	conn, chans, reqs, err := NewClientConn(c2, "", config)
	if err != nil {
		t.Fatalf("unable to dial remote side: %v", err)
	}
	return NewClient(conn, chans, reqs)
}
func dial ( handler serverType , t * testing . T ) * Client { c1 , c2 , err := netPipe ( ) if err != nil { t . Fatalf ( " " , err ) } go func ( ) { defer c1 . Close ( ) conf := ServerConfig { NoClientAuth : true , } conf . AddHostKey ( testSigners [ " " ] ) conn , chans , reqs , err := NewServerConn ( c1 , & conf ) if err != nil { t . Fatalf ( " " , err ) } go DiscardRequests ( reqs ) for newCh := range chans { if newCh . ChannelType ( ) != " " { newCh . Reject ( UnknownChannelType , " " ) continue } ch , inReqs , err := newCh . Accept ( ) if err != nil { t . Errorf ( " " , err ) continue } go func ( ) { handler ( ch , inReqs , t ) } ( ) } if err := conn . Wait ( ) ; err != io . EOF { t . Logf ( " " , err ) } } ( ) config := & ClientConfig { User : " " , HostKeyCallback : InsecureIgnoreHostKey ( ) , } conn , chans , reqs , err := NewClientConn ( c2 , " " , config ) if err != nil { t . Fatalf ( " " , err ) } return NewClient ( conn , chans , reqs ) }
dial constructs a new test server and returns a *ClientConn.
dial constructs a new test server and returns a * ClientConn .