本文整理匯總了Golang中code/google/com/p/go/crypto/ssh.Channel.Write方法的典型用法代碼示例。如果您正苦於以下問題:Golang Channel.Write方法的具體用法?Golang Channel.Write怎麽用?Golang Channel.Write使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類code/google/com/p/go/crypto/ssh.Channel
的用法示例。
在下文中一共展示了Channel.Write方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: ServeDOSTerm
func ServeDOSTerm(channel ssh.Channel) {
go ReadSSHIn(channel)
MyID := randSeq(5)
FBIN := make(chan []byte)
FrameBufferSubscribers[MyID] = FBIN
defer delete(FrameBufferSubscribers, MyID) // Unsubscribe when dead
FB := make([]byte, 0)
for {
FB = <-FBIN
if len(FB) != 4000 {
continue
}
channel.Write([]byte("\x1B[0;0H")) // Reset the cursor to 0,0
outbound := ""
ptr := 0
for ptr < len(FB) {
outbound = outbound + VESAtoVT100(FB[ptr+1])
outbound = outbound + CorrectBadChars(FB[ptr])
ptr = ptr + 2
}
_, err := channel.Write([]byte(outbound))
if err != nil {
return
}
}
}
示例2: HandleSshRequests
func HandleSshRequests(channel ssh.Channel, in <-chan *ssh.Request, term *terminal.Terminal) {
for req := range in {
ok := false
logfile.Println("[request " + req.Type + "]: " + string(req.Payload))
switch req.Type {
case "shell":
// hacky way to get around presenting the correct prompt
channel.Write([]byte("[email protected]:/root# "))
term.SetPrompt("[email protected]:/root# ")
case "exec":
term.SetPrompt("")
fmt.Println(req)
channel.Write(RunCommand(string(req.Payload[4:])))
// close after executing their one off command
channel.Close()
}
/* this condition set and reply is needed to allow a PTY */
ok = true
req.Reply(ok, nil)
}
}