Update HTTP header attr matching config

pull/387/head
yuhan6665 2023-05-22 11:48:11 -04:00
parent 195aeba490
commit e73994d010
2 changed files with 12 additions and 16 deletions

View File

@ -69,7 +69,7 @@
"user": ["love@xray.com"],
"inboundTag": ["tag-vmess"],
"protocol": ["http", "tls", "bittorrent"],
"attrs": "attrs[':method'] == 'GET'",
"attrs": { ":method": "GET" },
"outboundTag": "direct",
"balancerTag": "balancer"
}
@ -155,19 +155,17 @@
必须开启入站代理中的 `sniffing` 选项, 才能嗅探出连接所使用的协议类型.
:::
> `attrs`: string
> `attrs`: object
一段脚本,用于检测流量的属性值。当此脚本返回真值时,此规则生效。
脚本语言为 [Starlark](https://github.com/bazelbuild/starlark),它的语法是 Python 的子集。脚本接受一个全局变量 `attrs`,其中包含了流量相关的属性。
一个 json object键名字和值皆为字符串用于检测流量的属性值。当 HTTP headers 包含所有指定的键,并且值包含指定的子字符串,则命中此规则。大小写不敏感。
目前只有 http 入站代理会设置这一属性。
示例:
- 检测 HTTP GET`"attrs[':method'] == 'GET'"`
- 检测 HTTP Path`"attrs[':path'].startswith('/test')"`
- 检测 Content Type`"attrs['accept'].index('text/html') >= 0"`
- 检测 HTTP GET`{":method": "GET"}`
- 检测 HTTP Path`{":path": "/test"}"`
- 检测 Content Type`{"accept": "text/html"}"`
> `outboundTag`: string

View File

@ -72,7 +72,7 @@ When a rule points to a load balancer, Xray selects an outbound through this loa
"user": ["love@xray.com"],
"inboundTag": ["tag-vmess"],
"protocol": ["http", "tls", "bittorrent"],
"attrs": "attrs[':method'] == 'GET'",
"attrs": { ":method": "GET" },
"outboundTag": "direct",
"balancerTag": "balancer"
}
@ -162,19 +162,17 @@ An array where each item represents a protocol. This rule will take effect when
The `sniffing` option in the inbound proxy must be enabled to detect the protocol type used by the connection.
:::
`attrs`: string
`attrs`: object
A script used to detect the attribute values of the traffic. When this script returns a truthy value, this rule takes effect.
The script language is [Starlark](https://github.com/bazelbuild/starlark), which is a subset of Python syntax. The script accepts a global variable `attrs`, which contains traffic-related attributes.
A json object with string keys and values, used to detect the HTTP headers of the traffic. It matches when all specified keys exist in the header and corresponding values are a substring of the header value, case in-sensitive.
Currently, only the inbound HTTP proxy sets this attribute.
Examples:
- Detect HTTP GET: `"attrs[':method'] == 'GET'"`
- Detect HTTP Path: `"attrs[':path'].startswith('/test')"`
- Detect Content Type: `"attrs['accept'].index('text/html') >= 0"`
- Detect HTTP GET`{":method": "GET"}`
- Detect HTTP Path`{":path": "/test"}"`
- Detect Content Type`{"accept": "text/html"}"`
> `outboundTag`: string