Update HTTP header attr matching config
parent
195aeba490
commit
e73994d010
|
@ -69,7 +69,7 @@
|
||||||
"user": ["love@xray.com"],
|
"user": ["love@xray.com"],
|
||||||
"inboundTag": ["tag-vmess"],
|
"inboundTag": ["tag-vmess"],
|
||||||
"protocol": ["http", "tls", "bittorrent"],
|
"protocol": ["http", "tls", "bittorrent"],
|
||||||
"attrs": "attrs[':method'] == 'GET'",
|
"attrs": { ":method": "GET" },
|
||||||
"outboundTag": "direct",
|
"outboundTag": "direct",
|
||||||
"balancerTag": "balancer"
|
"balancerTag": "balancer"
|
||||||
}
|
}
|
||||||
|
@ -155,19 +155,17 @@
|
||||||
必须开启入站代理中的 `sniffing` 选项, 才能嗅探出连接所使用的协议类型.
|
必须开启入站代理中的 `sniffing` 选项, 才能嗅探出连接所使用的协议类型.
|
||||||
:::
|
:::
|
||||||
|
|
||||||
> `attrs`: string
|
> `attrs`: object
|
||||||
|
|
||||||
一段脚本,用于检测流量的属性值。当此脚本返回真值时,此规则生效。
|
一个 json object,键名字和值皆为字符串,用于检测流量的属性值。当 HTTP headers 包含所有指定的键,并且值包含指定的子字符串,则命中此规则。大小写不敏感。
|
||||||
|
|
||||||
脚本语言为 [Starlark](https://github.com/bazelbuild/starlark),它的语法是 Python 的子集。脚本接受一个全局变量 `attrs`,其中包含了流量相关的属性。
|
|
||||||
|
|
||||||
目前只有 http 入站代理会设置这一属性。
|
目前只有 http 入站代理会设置这一属性。
|
||||||
|
|
||||||
示例:
|
示例:
|
||||||
|
|
||||||
- 检测 HTTP GET:`"attrs[':method'] == 'GET'"`
|
- 检测 HTTP GET:`{":method": "GET"}`
|
||||||
- 检测 HTTP Path:`"attrs[':path'].startswith('/test')"`
|
- 检测 HTTP Path:`{":path": "/test"}"`
|
||||||
- 检测 Content Type:`"attrs['accept'].index('text/html') >= 0"`
|
- 检测 Content Type:`{"accept": "text/html"}"`
|
||||||
|
|
||||||
> `outboundTag`: string
|
> `outboundTag`: string
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ When a rule points to a load balancer, Xray selects an outbound through this loa
|
||||||
"user": ["love@xray.com"],
|
"user": ["love@xray.com"],
|
||||||
"inboundTag": ["tag-vmess"],
|
"inboundTag": ["tag-vmess"],
|
||||||
"protocol": ["http", "tls", "bittorrent"],
|
"protocol": ["http", "tls", "bittorrent"],
|
||||||
"attrs": "attrs[':method'] == 'GET'",
|
"attrs": { ":method": "GET" },
|
||||||
"outboundTag": "direct",
|
"outboundTag": "direct",
|
||||||
"balancerTag": "balancer"
|
"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.
|
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.
|
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.
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
Currently, only the inbound HTTP proxy sets this attribute.
|
Currently, only the inbound HTTP proxy sets this attribute.
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
- Detect HTTP GET: `"attrs[':method'] == 'GET'"`
|
- Detect HTTP GET:`{":method": "GET"}`
|
||||||
- Detect HTTP Path: `"attrs[':path'].startswith('/test')"`
|
- Detect HTTP Path:`{":path": "/test"}"`
|
||||||
- Detect Content Type: `"attrs['accept'].index('text/html') >= 0"`
|
- Detect Content Type:`{"accept": "text/html"}"`
|
||||||
|
|
||||||
> `outboundTag`: string
|
> `outboundTag`: string
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue