Exemplo n.º 1
0
func clientHandler(tcppipe pipe.TCPPipe) {
	defer tcppipe.Close()

	buffer := make([]byte, 65535)

	//TODO: Timeouts!
	for {
		bytesRead, err := tcppipe.ReadSource(buffer)
		if err != nil {
			continue
		}

		if module.Drop(buffer[:bytesRead]) {
			continue
		}

		if !module.Pass(buffer[:bytesRead]) {
			//TODO: This won't work when Mangle returns a different sized buffer.
			buffer = module.Mangle(buffer)
		}

		log.Println(module.PrettyPrint(buffer))

		_, err = tcppipe.WriteDestination(buffer[:bytesRead])
		if err != nil {
			continue
		}
	}
}
Exemplo n.º 2
0
func serverHandler(tcppipe pipe.TCPPipe) {
	defer tcppipe.Close()

	buffer := make([]byte, 65535)

	//TODO: Timeouts!
	for {
		bytesReadFromDestination, err := tcppipe.ReadDestination(buffer)
		if err != nil {
			continue
		}
		_, err = tcppipe.WriteSource(buffer[:bytesReadFromDestination])
		if err != nil {
			continue
		}
	}
}