代码拉取完成,页面将自动刷新
package main
import (
"log"
"time"
"github.com/gliderlabs/ssh"
)
var (
DeadlineTimeout = 30 * time.Second
IdleTimeout = 10 * time.Second
)
func main() {
ssh.Handle(func(s ssh.Session) {
log.Println("new connection")
i := 0
for {
i += 1
log.Println("active seconds:", i)
select {
case <-time.After(time.Second):
continue
case <-s.Context().Done():
log.Println("connection closed")
return
}
}
})
log.Println("starting ssh server on port 2222...")
log.Printf("connections will only last %s\n", DeadlineTimeout)
log.Printf("and timeout after %s of no activity\n", IdleTimeout)
server := &ssh.Server{
Addr: ":2222",
MaxTimeout: DeadlineTimeout,
IdleTimeout: IdleTimeout,
}
log.Fatal(server.ListenAndServe())
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。