3. 客户端配置
客户端通过 URI Template [TEMPLATE] 配置为使用 HTTP 上的 IP 代理. URI Template MAY 包含两个变量: "target" 和 "ipproto"; 见第 4.6 节. 定义模板时需要考虑变量的可选性, 使变量要么能自我标识, 要么可在语法中被排除.
示例如下:
https://example.org/.well-known/masque/ip/{target}/{ipproto}/
https://proxy.example.org:4443/masque/ip?t={target}&i={ipproto}
https://proxy.example.org:4443/masque/ip{?target,ipproto}
https://masque.example.org/?user=bob
图 1: URI Template 示例
以下要求适用于 URI Template:
-
URI Template MUST 是 level 3 或更低级别的模板.
-
URI Template MUST 采用绝对形式, 并且 MUST 包含非空的 scheme, authority 和 path 组件.
-
URI Template 的 path 组件 MUST 以斜杠 "/" 开头.
-
所有模板变量 MUST 位于 URI 的 path 或 query 组件中.
-
URI Template MAY 包含 "target" 和 "ipproto" 这两个变量, 也 MAY 包含其他变量. 如果包含 "target" 或 "ipproto" 变量, 其值 MUST NOT 为空. 客户端可以改用 "*" 表示通配或无偏好值; 见第 4.6 节.
-
URI Template MUST NOT 包含任何非 ASCII Unicode 字符, 并且 MUST 仅包含 0x21-0x7E 范围内的 ASCII 字符 (含端点; 注意允许百分号编码; 见 URI 第 2.1 节).
-
URI Template MUST NOT 使用 Reserved Expansion ("+" operator), Fragment Expansion ("#" operator), 带 Dot-Prefix 的 Label Expansion, 带 Slash-Prefix 的 Path Segment Expansion, 或带 Semicolon-Prefix 的 Path-Style Parameter Expansion.
客户端 SHOULD 验证上述要求; 然而, 客户端 MAY 使用缺少这种特定验证的通用 URI Template 实现. 如果客户端检测到某个 URI Template 不满足上述任一要求, 客户端 MUST 拒绝其配置并中止请求, 且不将请求发送给 IP 代理.
与 UDP 代理类似, 某些 IP 代理客户端配置只允许用户配置代理主机和代理端口. 具有此类限制的客户端 MAY 尝试使用默认模板访问 IP 代理能力, 该模板定义为: "https://$PROXY_HOST:$PROXY_PORT/.well-known/masque/ip/{target}/{ipproto}/", 其中 $PROXY_HOST 和 $PROXY_PORT 分别是配置的 IP 代理主机和端口. 如果 IP 代理部署需要与这类客户端互操作, 它们 SHOULD 在此位置提供服务.