Esempio n. 1
0
File: telnet.go Progetto: beoran/woe
// Process a single byte received from the client
func (me *Telnet) ProcessByte(bin byte) bool {
	monolog.Log("TELNET", "ProcessByte %d %d", bin, me.state)
	switch me.state {
	// regular data
	case data_state:
		return me.dataStateProcessByte(bin)
		// IAC received before
	case iac_state:
		return me.iacStateProcessByte(bin)
	case will_state, wont_state, do_state, dont_state:
		return me.DoNegotiate(me.state, bin)
	// subnegotiation started, determine option to subnegotiate
	case sb_state:
		me.sb_telopt = bin
		me.state = sb_data_state
	// subnegotiation data, buffer bytes until the end request
	case sb_data_state:
		return me.sbdataStateProcessByte(bin)
	// IAC received inside a subnegotiation
	case sb_data_iac_state:
		return me.sbdataiacStateProcessByte(bin)
	default:
		//  programing error, shouldn't happen
		panic("Error in telnet state machine!")
	}
	// return false to signal compression needn't start
	return false
}
Esempio n. 2
0
File: telnet.go Progetto: beoran/woe
// Append a byte to the data buffer
func (me *Telnet) appendByte(bin byte) {
	monolog.Log("TELNET", "Appending to telnet buffer: %d %d", len(me.buffer), cap(me.buffer))
	me.buffer = append(me.buffer, bin)
}