@@ -29,7 +29,6 @@ type Client struct {
2929 net.Conn
3030 * ssh.ServerConn
3131 Listeners map [string ]net.Listener
32- Channel ssh.NewChannel
3332 Addr string
3433 Port uint32
3534}
@@ -87,7 +86,7 @@ func (s *SSHServer) listen(addr string, domain string) error {
8786 continue
8887 }
8988
90- client := & Client {randID (), tcpConn , sshConn , make (map [string ]net.Listener ), nil , "" , 0 }
89+ client := & Client {randID (), tcpConn , sshConn , make (map [string ]net.Listener ), "" , 0 }
9190 log .Printf ("New SSH connection from %s (%s)" , sshConn .RemoteAddr (), sshConn .ClientVersion ())
9291
9392 go s .handleRequests (client , reqs )
@@ -117,7 +116,14 @@ func (s *SSHServer) Wait() error {
117116
118117func (s * SSHServer ) handleChannels (client * Client , chans <- chan ssh.NewChannel ) {
119118 for newChannel := range chans {
120- client .Channel = newChannel
119+ channelConn , _ , err := newChannel .Accept ()
120+ if err != nil {
121+ log .Printf ("Could not accept channel (%s)" , err )
122+ return
123+ }
124+
125+ generatedURL := "http://" + client .ID + "." + s .domain
126+ io .WriteString (channelConn , "[vexd] Generated URL: " + generatedURL )
121127 }
122128}
123129
@@ -141,15 +147,6 @@ func (s *SSHServer) handleRequests(client *Client, reqs <-chan *ssh.Request) {
141147 client .Listeners [bindinfo .Bound ] = listener
142148 s .clients [client .ID ] = * client
143149
144- channelConn , _ , err := client .Channel .Accept ()
145- if err != nil {
146- log .Printf ("Could not accept channel (%s)" , err )
147- return
148- }
149-
150- generatedURL := "http://" + client .ID + "." + s .domain
151- io .WriteString (channelConn , "[vexd] Generated URL: " + generatedURL )
152-
153150 go handleListener (client , bindinfo , listener )
154151 continue
155152 // client.Conn.Close()
0 commit comments