|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
|
Translation changed |
|
The detection function above is suitably generic and targeted in focus that it may be used as a building block to create higher level abstractions. Our goal is to create a ['stream algorithm]: a function which is invoked with a stream, that reads or writes (or both) to achieve a purpose. In this case, to detect the TLS client handshake. Stream algorithms may be synchronous or asynchronous. Because synchronous algorithms are easier to write, we start there. Then we build the asynchronous version, trying to model it similarly to make reasoning about it easier.上述检测函数足够通用,且目标明确,可以作为基础模块来构建更高级的抽象。接下来要创建一个流算法:该算法接收一个流作为参数,通过执行读写操作来达到特定目的,这里就是检测 TLS 客户端握手。流算法可以是同步的,也可以是异步的。同步算法更容易编写,因此先实现同步版本,再在此基础上构建异步版本,并尽量让两者风格相似,便于理解。