aboutsummaryrefslogtreecommitdiff
path: root/ssh.go
blob: 3d43a6c8e4c6aea2a745c63eced9a0526dd18236 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package main

import (
	"fmt"
	"io"
	"io/ioutil"
	"math/rand"
	"net"
	"time"
)

type empty struct{}

func sshHandler(conn net.Conn) {
	eof := make(chan empty)
	go func() {
		io.Copy(ioutil.Discard, conn)
		eof <- empty{}
	}()

	tick := time.Tick(10 * time.Second)
	for {
		select {
		case <-eof:
			return
		case <-tick:
			_, err := fmt.Fprintf(conn, "%x\r\n", rand.Uint32())
			if err != nil {
				return
			}
		}
	}
}