'Scan \'data\' for the magic string. If found, drain it and all
the padding before it. Then open the connection.'

def _scan_for_magic(self, data):

    log_prefix = 'obfs3:_scan_for_magic()'
    assert self.other_magic_value
    chunk = data.peek()
    index = chunk.find(self.other_magic_value)
    if (index < 0):
        if (len(data) > (MAX_PADDING + HASHLEN)):
            raise Exception(('obfs3:    Too    much    padding    (%d)!' % len(data)))
        return
    index += len(self.other_magic_value)
    data.drain(index)
    self.state = ST_OPEN
    if (len(data) > 0):
        self.circuit.upstream.write(self.recv_crypto.crypt(data.read()))
