func (p *LineParser) OnData(reply, endStream bool, data [][]byte) (OpType, int) {
	line, ok := getLine(data)
	line_len := len(line)

	if p.inserted {
		p.inserted = false
		return DROP, line_len
	}

	if !reply {
		log.Debugf("LineParser: Request: %s", line)
	} else {
		log.Debugf("LineParser: Response: %s", line)
	}

	if !ok {
		if line_len > 0 {
			// Partial line received, but no newline, ask for more
			return MORE, 1
		} else {
			// Nothing received, don't know if more will be coming; do nothing
			return NOP, 0
		}
	}

	if bytes.HasPrefix(line, []byte("PASS")) {
		return PASS, line_len
	}
	if bytes.HasPrefix(line, []byte("DROP")) {
		return DROP, line_len
	}
	if bytes.HasPrefix(line, []byte("INJECT")) {
		// Inject line in the reverse direction
		p.connection.Inject(!reply, []byte(line))
		// Drop the INJECT line in the current direction
		return DROP, line_len
	}
	if bytes.HasPrefix(line, []byte("INSERT")) {
		// Inject the line in the current direction
		p.connection.Inject(reply, []byte(line))
		// Drop the INJECT line in the current direction
		p.inserted = true
		return INJECT, line_len
	}

	return ERROR, int(ERROR_INVALID_FRAME_TYPE)
}
//
// Parses individual lines that must start with one of:
// "PASS" the line is passed
// "DROP" the line is dropped
// "INJECT" the line is injected in reverse direction
// "INSERT" the line is injected in current direction
//
Parses individual lines that must start with one of:
"PASS" the line is passed
"DROP" the line is dropped
"INJECT" the line is injected in reverse direction
"INSERT" the line is injected in current direction
// // Parses individual lines that must start with one of : // " PASS " the line is passed // " DROP " the line is dropped // " INJECT " the line is injected in reverse direction // " INSERT " the line is injected in current direction //
func (p *LineParser) OnData(reply, endStream bool, data [][]byte) (OpType, int) {
	line, ok := getLine(data)
	line_len := len(line)
	if p.inserted {
		p.inserted = false
		return DROP, line_len
	}
	if !reply {
		log.Debugf("LineParser: Request: %s", line)
	} else {
		log.Debugf("LineParser: Response: %s", line)
	}
	if !ok {
		if line_len > 0 {
			return MORE, 1
		} else {
			return NOP, 0
		}
	}
	if bytes.HasPrefix(line, []byte("PASS")) {
		return PASS, line_len
	}
	if bytes.HasPrefix(line, []byte("DROP")) {
		return DROP, line_len
	}
	if bytes.HasPrefix(line, []byte("INJECT")) {
		p.connection.Inject(!reply, []byte(line))
		return DROP, line_len
	}
	if bytes.HasPrefix(line, []byte("INSERT")) {
		p.connection.Inject(reply, []byte(line))
		p.inserted = true
		return INJECT, line_len
	}
	return ERROR, int(ERROR_INVALID_FRAME_TYPE)
}
func ( p * LineParser ) OnData ( reply , endStream bool , data [ ] [ ] byte ) ( OpType , int ) { line , ok := getLine ( data ) line_len := len ( line ) if p . inserted { p . inserted = false return DROP , line_len } if ! reply { log . Debugf ( " " , line ) } else { log . Debugf ( " " , line ) } if ! ok { if line_len > 0 { return MORE , 1 } else { return NOP , 0 } } if bytes . HasPrefix ( line , [ ] byte ( " " ) ) { return PASS , line_len } if bytes . HasPrefix ( line , [ ] byte ( " " ) ) { return DROP , line_len } if bytes . HasPrefix ( line , [ ] byte ( " " ) ) { p . connection . Inject ( ! reply , [ ] byte ( line ) ) return DROP , line_len } if bytes . HasPrefix ( line , [ ] byte ( " " ) ) { p . connection . Inject ( reply , [ ] byte ( line ) ) p . inserted = true return INJECT , line_len } return ERROR , int ( ERROR_INVALID_FRAME_TYPE ) }
Parses individual lines that must start with one of:
"PASS" the line is passed
"DROP" the line is dropped
"INJECT" the line is injected in reverse direction
"INSERT" the line is injected in current direction
Parses individual lines that must start with one of : " PASS " the line is passed " DROP " the line is dropped " INJECT " the line is injected in reverse direction " INSERT " the line is injected in current direction
// Partial line received, but no newline, ask for more // Nothing received, don't know if more will be coming; do nothing // Inject line in the reverse direction // Drop the INJECT line in the current direction // Inject the line in the current direction // Drop the INJECT line in the current direction