Tor协议的层次结果经过简要分析可以大致概括为如下框图:
DIR连接…… 应用层
------------------------
AP连接,EXIT连接……
------------------
Circuit链路…… Tor协议层
------------------
OR连接……
------------------------
TLS连接 传输层
而其中的DIR,AP,EXIT,OR等连接均是对理解Tor协议非常重要的部分,所以有必要简要的介绍一下通用连接的源码文件connection.c。
0. 全局变量
// 用于检测IP地址变化的全局变量,引用处极少
// 该部分的全局变量只用于函数 client_check_address_changed
/** The last addresses that our network interface seemed to have been
* binding to. We use this as one way to detect when our IP changes.
*
* XXX024 We should really use the entire list of interfaces here.
**/
static tor_addr_t *last_interface_ipv4 = NULL;
/* DOCDOC last_interface_ipv6 */
s