> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xray.cool/llms.txt
> Use this file to discover all available pages before exploring further.

# YAML插件的参数

> 该文档会简单介绍所有的数据类型以及支持的函数

## 请求参数（Request Patch）

规则中的request部分的参数说明

| 参数名 | 参数类型 | 说明 | 适用版本 |
| - | - | - | - |
| `cache` | `bool` | 当前请求是否使用缓存 | 全版本 |
| `method` | `string` | 定义请求的方法 | 全版本 |
| `path` | `string` | 定义请求的路径 | 全版本 |
| `header` | `map[string]string` | 定义请求的header | 全版本 |
| `body` | `string` | 定义请求体 | 全版本 |
| `follow_redirects` | `bool` | 定义请求是否跟随跳转 | 全版本 |
| `read_timeout` | `string` | 定义当前请求的超时时间 | 全版本 |
| `no_cookie` | `bool` | 定义当前请求是否继承之前请求的cookie | xpoc ≥ 0.1.0；xapp ≥ 0.0.2 |

## 类型（Type）

xray 支持所有CEL文档中的类型，同时还注入了几种特殊的类型，包含：

* `addrType` 连接地址信息
* `connInfoType` 连接信息，包含源地址和目的地址, 可以通过 `response.conn`
* `urlType` url 类型，可以 `request.url`、`response.url` 和 `reverse.url` 调用
* `reverseType` 反连平台类型
* `request` 扫描请求
* `response` 请求的响应，通用属性包含：`raw`

其中注入的 request 和 response 类型是随着 `transport` 对应的值进行改变的。

### TCP请求响应

其中 request 包含的字段如下：

| 变量名 | 类型 | 说明 | 适用版本 |
| - | - | - | - |
| `request.raw` | `[]byte` | 原始请求 | xray ≥ 1.8.4 |

response 包含的字段如下:

| 变量名 | 类型 | 说明 | 适用版本 |
| - | - | - | - |
| `response.conn` | `connInfoType` | 连接相关信息 | xray ≥ 1.8.4 |
| `response.raw` | `[]byte` | 原始响应 | xray ≥ 1.8.4 |

### UDP请求响应

其中 request 包含的字段如下：

| 变量名 | 类型 | 说明 | 适用版本 |
| - | - | - | - |
| `request.raw` | `[]byte` | 原始请求 | xray ≥ 1.8.4 |

response 包含的字段如下:

| 变量名 | 类型 | 说明 | 适用版本 |
| - | - | - | - |
| `response.conn` | `connInfoType` | 连接相关信息 | xray ≥ 1.8.4 |
| `response.raw` | `[]byte` | 原始响应 | xray ≥ 1.8.4 |

### HTTP请求响应

其中 request 包含的字段如下：

| 变量名 | 类型 | 说明 | 适用版本 |
| - | - | - | - |
| `request.raw` | `[]byte` | 原始请求 | xray ≥ 1.8.4 |
| `request.url` | `urlType` | 自定义类型 urlType, 请查看下方 urlType 的说明 | xray ≥ 1.8.4 |
| `request.method` | `string` | 原始请求的方法 | xray ≥ 1.8.4 |
| `request.headers` | `map[string]string` | 原始请求的HTTP头，是一个键值对（均为小写），我们可以通过`headers['server']`来获取值。如果键不存在，则获取到的值是空字符串。注意，该空字符串不能用于 `==` 以外的操作，否则不存在的时候将报错，需要先 `in` 判断下。详情参考下文常用函数章节。 | xray ≥ 1.8.4 |
| `request.content_type` | `string` | 原始请求的 content-type 头的值, 等于`request.headers["Content-Type"]` | xray ≥ 1.8.4 |
| `request.raw_header` | `[]byte` | 原始的 header 部分，需要使用字节流相关方法来判断。 | xray ≥ 1.8.4 |
| `request.body` | `[]byte` | 原始请求的 body，需要使用字节流相关方法来判断。如果是 GET， body 为空。 | xray ≥ 1.8.4 |

response 包含的字段如下:

| 变量名 | 类型 | 说明 | 适用版本 |
| - | - | - | - |
| `response.raw` | `[]byte` | 原始响应 | xray ≥ 1.8.4 |
| `response.url` | `urlType` | 自定义类型 urlType, 请查看下方 urlType 的说明 | xray ≥ 1.8.4 |
| `response.status` | `int` | 返回包的status code | xray ≥ 1.8.4 |
| `response.raw_header` | `[]byte` | 原始的 header 部分，需要使用字节流相关方法来判断。 | xray ≥ 1.8.4 |
| `response.body` | `[]byte` | 返回包的Body，因为是一个字节流（bytes）而非字符串，后面判断的时候需要使用字节流相关的方法 | xray ≥ 1.8.4 |
| `response.body_string` | `string` | 返回包的Body，是一个字符串 | xray ≥ 1.9.1 |
| `response.headers` | `map[string]string` | 返回包的HTTP头，类似 `request.headers`。 | xray ≥ 1.8.4 |
| `response.content_type` | `string` | 返回包的content-type头的值 | xray ≥ 1.8.4 |
| `response.latency` | `int` | 响应的延迟时间，可以用于 sql 时间盲注的判断，单位毫秒 (ms) | xray ≥ 1.8.4 |
| `response.title` | `[]byte` | 返回包的Title，因为是一个字节流（bytes）而非字符串，后面判断的时候需要使用字节流相关的方法 | xray ≥ 1.8.5 |
| `response.title_string` | `string` | 返回包的Title，是一个字符串 | xray ≥ 1.8.5 |
| `response.cert` | `CERTType` | 自定义类型CERTType, 请查看下方 CERTType 的说明 | xpoc ≥ 0.0.8 |
| `response.raw_cert` | `[]byte` | 返回包的证书的原始部分，是一个字节流（bytes） | xpoc ≥ 0.0.8 |
| `response.icon_url` | `string` | 返回包中尝试提取的icon的地址，是一个字符串，为DER（Distinguished Encoding Rules）格式 | xpoc ≥ 0.0.8 |

### 基本类型（Basic types）

#### addrType

addrType 类型包含字段如下, 设变量名为 `addr`

| 变量名 | 类型 | 说明 | 适用版本 |
| - | - | - | - |
| `addr.transport` | `string` | tranport | xray ≥ 1.8.4 |
| `addr.addr` | `string` | 目的地址， 获取失败时返回空字符串，形如： `192.0.2.1:25`, `[2001:2001::1]:80` | xray ≥ 1.8.4 |
| `addr.port` | `string` | 端口号， 获取失败时返回 `""` | xray ≥ 1.8.4 |

#### connInfoType

connInfoType 类型包含字段如下, 设变量名为 `conn`

| 变量名 | 类型 | 说明 | 适用版本 |
| - | - | - | - |
| `conn.source` | `addrType` | 源地址信息 | xray ≥ 1.8.4 |
| `conn.destination` | `addrType` | 目的地址信息 | xray ≥ 1.8.4 |

#### urlType

urlType 类型包含的字段如下, 设变量名为 `url`, 以 `http://example.com:8080/a?c=d#x=y` 为例:

| 变量名 | 类型 | 说明 | 适用版本 |
| - | - | - | - |
| `url.scheme` | `string` | url 的 scheme, 示例为 `"http"` | xray ≥ 1.8.4 |
| `url.domain` | `string` | url 的域名，示例例为 `"example.com"` | xray ≥ 1.8.4 |
| `url.host` | `string` | url 的主机名，示例为 `"example.com:8080"` | xray ≥ 1.8.4 |
| `url.port` | `string` | url 的 port，注意这里也是字符串。 示例为 `"8080"` | xray ≥ 1.8.4 |
| `url.path` | `string` | url 的 path， 示例为 `"/a"` | xray ≥ 1.8.4 |
| `url.query` | `string` | url 的 query, 示例为 `"c=d"` | xray ≥ 1.8.4 |
| `url.fragment` | `string` | url 的锚点，示例为 `"x=y"` | xray ≥ 1.8.4 |

#### reverseType

reverseType 类型包含字段如下, 设变量名为 `reverse`（需要先使用 `newReverse()` 生成实例)

| 变量名 | 类型 | 说明 | 适用版本 |
| - | - | - | - |
| `reverse.url` | `urlType` | 反连平台的 url | xray ≥ 1.8.4 |
| `reverse.domain` | `string` | 反连平台的域名 | xray ≥ 1.8.4 |
| `reverse.rmi` | `urlType` | 反连平台的rmi协议url | xray ≥ 1.9.4 |
| `reverse.ip` | `string` | 反连平台的 ip 地址 | xray ≥ 1.8.4 |
| `reverse.is_domain_name_server` | `bool` | 反连平台的 domain 是否同时是 nameserver | xray ≥ 1.8.4 |
| `reverse.wait(timeout)` | `func (timeout int) bool` | 等待 timeout 秒，并返回是否在改时间内获得了信息 | xray ≥ 1.8.4 |

> 参数详情介绍：[🔎详情](/plugins/yaml/TypeFunc/exampleType/reverse)

#### Timestamp

Timestamp 类型实际是google.protobuf.Timestamp类型，为cel表达式本身自带的类型，其本身包含了非常多的方法，详情可查看：[Timestamp](/plugins/yaml/TypeFunc/exampleType/timestamp)

#### CERTType

CERTType 类型包含的字段如下, 设变量名为 `cert`，以`https://docs.xray.cool`的证书举例:

| 变量名 | 类型 | 说明 | 适用版本 |
| - | - | - | - |
| `cert.issuer` | `string` | 证书的颁发机构。用来标识颁发证书的实体或组织。示例：`CN=R3,O=Let's Encrypt,C=US` | xpoc ≥ 0.0.8 |
| `cert.subject` | `string` | 证书的主题，也就是证书持有者的身份信息。示例：`CN=xray.cool` | xpoc ≥ 0.0.8 |
| `cert.dnsnames` | `string` | 证书相关联的 DNS 名称，用于识别证书可以用于验证的服务器或域名。示例：`docs.xray.cool,download.xray.cool,poc.xray.cool,xray.cool` | xpoc ≥ 0.0.8 |
| `cert.not_after` | `Timestamp` | 证书的过期时间，用于指定证书有效期的结束日期和时间。示例：`2024-03-25 03:05:36 +0000 UTC`,此处的示例显示的是时间戳在被当成字符串输出时展示的内容 | xpoc ≥ 0.0.8 |
| `cert.not_before` | `Timestamp` | 证书的生效时间，用于指定证书有效期的开始日期和时间。示例：`2023-12-26 03:05:37 +0000 UTC`,同上 | xpoc ≥ 0.0.8 |
| `cert.serial_number` | `string` | 证书的序列号，用于唯一标识一个证书。示例：`342932071325336127920295100216553911823483` | xpoc ≥ 0.0.8 |

### 变量名约定（Variable）

在定义变量名称时，需要考虑到一些特定的名称可能会被系统进行特殊处理。因此，为了避免潜在的冲突或误解，以下表格列出了一些常见的变量名及其用途的描述和示例。当您在如Set、Payloads、Output、Detail等部分定义变量时，建议避免误用这些名称。

| 变量名 | 说明 | 示例值 |
| - | - | - |
| `version` | 用于指定版本的变量名 | `1.0.0` |
| `os_name` | 操作系统名称的变量名 | `ubuntu` |
| `os_type` | 操作系统类型的变量名 | `linux`, `windows` |
| `device_type` | 设备类型的变量名 | |
| `hostname` | 主机名称的变量名 | `server01` |

## 函数（Function）

xray 支持所有 CEL 文档中的函数，同时还新增了一些函数支持，下面列举一下常用的函数：

**注**：gocel 原生的正则支持使用的 golang 自带的 regex 库， 在脚本中我们使用 [regex2](https://github.com/dlclark/regexp2) 替换了自带的 regex 库

### rule 函数

**注**：只有脚本层级的 expression 才能使用这些函数

| 函数名 | 函数原型 | 说明 | 适用版本 |
| - | - | - | - |
| `rule name` | `func <rule name>() bool` | 返回这条 rule expression 执行的结果 | xray ≥ 1.8.4 |

### 字符串处理（String）

| 函数名 | 函数原型 | 说明 | 适用版本 | 详情 |
| - | - | - | - | - |
| `contains` | `func (s1 string) contains(s2 string) bool` | 判断 s1 是否包含 s2，返回 bool 类型结果 | xray ≥ 1.8.4 | [🔎](/plugins/yaml/TypeFunc/example/string/contains) |
| `icontains` | `func (s1 string) icontains(s2 string) bool` | 判断 s1 是否包含 s2，返回 bool 类型结果, 与 contains 不同的是，icontains 忽略大小写 | xray ≥ 1.8.4 | [🔎](/plugins/yaml/TypeFunc/example/string/icontains) |
| `substr` | `func substr(string, start int, length int) string` | 截取字符串 | xray ≥ 1.8.4 | [🔎](/plugins/yaml/TypeFunc/example/string/substr) |
| `replaceAll` | `func replaceAll(string, old string, new string) string` | 将 string 中的 old 替换为 new，返回替换后的 string | xray ≥ 1.8.4 | [🔎](/plugins/yaml/TypeFunc/example/string/replaceAll) |
| `printable` | `func printable(string) string` | 将 string 中的非 unicode 编码字符去掉 | xray ≥ 1.8.4 | [🔎](/plugins/yaml/TypeFunc/example/string/printable) |
| `toUintString` | `func toUintString(s1 string, direction string) string` | direction 取值为 `>`,`<`表示读取方向, 将 s1 按 direction 读取为一个整数，返回该整数的字符串形式 | xray ≥ 1.8.4 | [🔎](/plugins/yaml/TypeFunc/example/string/toUintString) |
| `startsWith` | `func (s1 string) startsWith(s2 string) bool` | 判断 s1 是否由 s2 开头 | 全版本 | [🔎](https://github.com/google/cel-spec/blob/master/tests/simple/testdata/string.textproto#L42) |
| `endsWith` | `func (s1 string) endsWith(s2 string) bool` | 判断 s1 是否由 s2 结尾 | 全版本 | [🔎](https://github.com/google/cel-spec/blob/master/tests/simple/testdata/string.textproto#L76) |
| `basename` | `func basename(s1 string) string` | 返回 URL 的最后一个路径的名称 | xray ≥ 1.9.1 | [🔎](/plugins/yaml/TypeFunc/example/string/basename) |
| `dir` | `func dir(s1 string) string` | 返回 URL 的路径 | xray ≥ 1.9.1 | [🔎](/plugins/yaml/TypeFunc/example/string/dir) |
| `upper` | `func upper(s1 string) string` | 将 string 中的小写字母转换成大写 | xray ≥ 1.9.3 | [🔎](/plugins/yaml/TypeFunc/example/string/upper) |
| `rev` | `func rev(s1 string) string` | 将 string 反向输出，主要用于验证命令执行 | xray ≥ 1.9.3 | [🔎](/plugins/yaml/TypeFunc/example/string/rev) |
| `size` | `func size(s1 string) int` | 返回 string 的长度 | 全版本 | [🔎](https://github.com/google/cel-spec/blob/master/tests/simple/testdata/string.textproto#L3) |
| `format` | `func (data string) format(align int, align_data string, prefix string, step int) string` | `format`函数主要用于格式化字符串，可以通过指定的对齐字符、前缀以及步进参数来调整字符串的显示样式 | xpoc ≥ 0.1.0；<br />xapp ≥ 0.0.2 | [🔎](/plugins/yaml/TypeFunc/example/string/format) |

### \[]byte 处理

| 函数名 | 函数原型 | 说明 | 适用版本 | 详情 |
| - | - | - | - | - |
| `bcontains` | `func (b1 bytes) bcontains(b2 bytes) bool` | 判断一个 b1 是否包含 b2，返回 bool 类型结果。与 contains 不同的是，bcontains 是字节流（bytes）的查找 | xray ≥ 1.8.4 | [🔎](./TypeFunc/example/bytes/bcontains) |
| `ibcontains` | `func (b1 bytes) ibcontains(b2 bytes) bool` | 判断 b1 是否包含 b2，返回 bool 类型结果, 与 contains 不同的是，ibcontains 是字节流（bytes）的查找, 且忽略大小写 | xray ≥ 1.8.4 | [🔎](/plugins/yaml/TypeFunc/example/bytes/ibcontains) |
| `bstartsWith` | `func (b1 bytes) bstartsWith(b2 bytes) bool` | 判断一个 b1 是否由 b2 开头，返回 bool 类型结果。与 startsWith 不同的是，bcontains 是字节流（bytes）的查找 | xray ≥ 1.8.4 | [🔎](/plugins/yaml/TypeFunc/example/bytes/bstartWith) |
| `bformat` | `func (b1 bytes) bformat(int, int, string, int) string` | 将 bytes 进行进制转换编码，可以根据输入的参数转换成对应的进制编码，并可以自定义转换格式 | xray ≥ 1.8.5 | [🔎](/plugins/yaml/TypeFunc/example/bytes/bformat) |
| `bload` | `func bload(data string, base int, align int, prefix string, step int) []byte` | `bload`函数用于将字符串数据按照特定的编码规则转换为字节序列，支持自定义的编码基数、对齐、前缀以及步进参数 | xpoc ≥ 0.1.0；<br />xapp ≥ 0.0.2 | [🔎](/plugins/yaml/TypeFunc/example/bytes/bload) |
| `size` | `func size(b1 bytes) int` | 返回 bytes 的长度 | 全版本 | [🔎](https://github.com/google/cel-spec/blob/master/tests/simple/testdata/string.textproto#L31) |

### 编码函数（Encoding）

| 函数名 | 函数原型 | 说明 | 适用版本 | 详情 |
| - | - | - | - | - |
| `base64` | `func base64(v1 string/bytes) string` | 将字符串或 bytes 进行 base64 编码 | xray ≥ 1.8.4 | [🔎](/plugins/yaml/TypeFunc/example/encode/base64) |
| `base64Decode` | `func base64Decode(v1 string/bytes) string` | 将字符串或 bytes 进行 base64 解码 | xray ≥ 1.8.4 | [🔎](/plugins/yaml/TypeFunc/example/encode/base64Decode) |
| `urlencode` | `func urlencode(v1 string/bytes) string` | 将字符串或 bytes 进行 urlencode 编码 | xray ≥ 1.8.4 | [🔎](/plugins/yaml/TypeFunc/example/encode/urlencode) |
| `urlencodeall` | `func urlencodeall(v1 string/bytes) string` | 将字符串或 bytes 进行 urlencode 编码, 结果为全字符编码 | xray ≥ 1.8.5 | [🔎](/plugins/yaml/TypeFunc/example/encode/urlencodeall) |
| `urldecode` | `func urldecode(v1 string/bytes) string` | 将字符串或 bytes 进行 urldecode 解码 | xray ≥ 1.8.4 | [🔎](/plugins/yaml/TypeFunc/example/encode/urldecode) |
| `faviconHash` | `func faviconHash(v1 string/bytes) int` | 将字符串或 bytes 进行 faviconHash 编码，参考：[iconhash](https://github.com/Becivells/iconhash) | xray ≥ 1.8.4 | [🔎](/plugins/yaml/TypeFunc/example/encode/faviconHash) |
| `htmlEscape` | `func htmlEscape(string/bytes, string, bool) string` | 将字符串或 bytes 进行 htmlEscape 编码，支持 named/numeric/hex 模式，支持全/非全字符编码 | xray ≥ 1.9.4 | [🔎](/plugins/yaml/TypeFunc/example/encode/htmlEscape) |
| `htmlUnescape` | `func htmlUnescape(string/bytes) string` | 将字符串或 bytes 进行 htmlEscape 解码，支持 named/numeric/hex 模式，支持全/非全字符编码 | xray ≥ 1.9.4 | [🔎](/plugins/yaml/TypeFunc/example/encode/htmlUnescape) |
| `hex` | `func hex(string/bytes) string` | 将字符串或 bytes 进行 hex 编码 | xray ≥ 1.9.4 | [🔎](/plugins/yaml/TypeFunc/example/encode/hex) |
| `hexDecode` | `func hexDecode(string/bytes) bytes` | 将字符串或 bytes 进行 hex 解码 | xray ≥ 1.9.4 | [🔎](/plugins/yaml/TypeFunc/example/encode/hexDecode) |

### 加密函数（Encrypt）

| 函数名 | 函数原型 | 说明 | 适用版本 | 详情 |
| - | - | - | - | - |
| `md5` | `func md5(v1 string/bytes) string` | 字符串的 md5 | xray ≥ 1.8.4 | [🔎](/plugins/yaml/TypeFunc/example/encryption/md5) |
| `sha` | `func sha(v1 string/bytes, s1 string)string` | 该函数可以将指定字符串或 bytes 进行 sha 系列计算。 | xray ≥ 1.8.4 | [🔎](/plugins/yaml/TypeFunc/example/encryption/sha) |
| `hmacSha` | `func hmacSha(v1 string/bytes, s1 string, s2 string)string` | 该函数可以将指定字符串或 bytes 进行 hmac\_sha 系列计算。 | xray ≥ 1.8.4 | [🔎](/plugins/yaml/TypeFunc/example/encryption/hmacSha) |
| `rsaEncryptPKCS1v15` | `func rsaEncryptPKCS1v15(b1 bytes, k1 string)bytes` | 该函数可以将指定数据按照PKCS1v15的填充模式进行RSA加密运算 | xpoc ≥ 0.0.8 | [🔎](/plugins/yaml/TypeFunc/example/encryption/rsaPKCS1v15) |
| `rsaDecryptPKCS1v15` | `func rsaDecryptPKCS1v15(b1 bytes, k1 string)bytes` | 该函数可以将指定数据按照PKCS1v15的填充模式进行RSA解密运算 | xpoc ≥ 0.0.8 | [🔎](/plugins/yaml/TypeFunc/example/encryption/rsaPKCS1v15) |
| `aesDecrypt` | `func aesDecrypt(d1 bytes/string, k1 bytes/string, m1 string)string` | 该函数可以对aes加密的数据进行解密 | xpoc ≥ 0.0.8 | [🔎](/plugins/yaml/TypeFunc/example/encryption/aes) |

### 随机值（Random）

| 函数名 | 函数原型 | 说明 | 适用版本 | 详情 |
| - | - | - | - | - |
| `randomInt` | `func randomInt(from, to int) int` | 两个范围内的随机数 | xray ≥ 1.8.4 | [🔎](/plugins/yaml/TypeFunc/example/random/randomInt) |
| `randomLowercase` | `func randomLowercase(n int) string` | 指定长度的小写字母组成的随机字符串 | xray ≥ 1.8.4 | [🔎](/plugins/yaml/TypeFunc/example/random/randomLowercase) |
| `uuid` | `func uuid() string` | 生成 uuid 字符串 | xpoc ≥ 0.1.0；<br />xapp ≥ 0.0.2 | [🔎](/plugins/yaml/TypeFunc/example/random/uuid) |

### 正则（Regex）

| 函数名 | 函数原型 | 说明 | 适用版本 | 详情 |
| - | - | - | - | - |
| `matches` | `func (s1 string) matches(s2 string) bool` | 使用正则表达式 s1 来匹配 s2，返回 bool 类型匹配结果 | xray ≥ 1.8.4 | [🔎](/plugins/yaml/TypeFunc/example/regex/matches) |
| `submatch` | `func (s1 string) submatch(s2 string) map[string]string` | 使用正则表达式 s1 来匹配 s2，返回 map\[string]string 类型结果，**注**：只返回具名的正则匹配结果 `(?P<name>…)` 格式 | xray ≥ 1.8.4 | [🔎](/plugins/yaml/TypeFunc/example/regex/submatch) |
| `bmatches` | `func (s1 string) bmatches(b1 bytes) bool` | 使用正则表达式 s1 来匹配 b1，返回 bool 类型匹配结果。与 matches 不同的是，bmatches 匹配的是字节流（bytes） | xray ≥ 1.8.4 | [🔎](/plugins/yaml/TypeFunc/example/regex/bmatches) |
| `bsubmatch` | `func (s1 string) bsubmatch(b1 bytes) map[string]string` | 使用正则表达式 s1 来匹配 b1，返回 map\[string]string 类型结果 **注**：只返回具名的正则匹配结果 `(?P<name>…)` 格式。与 submatch 不同的是，bsubmatch 匹配的是字节流（bytes） | xray ≥ 1.8.4 | [🔎](/plugins/yaml/TypeFunc/example/regex/bsubmatch) |

### 反连平台（Reverse）

| 函数名 | 函数原型 | 说明 | 适用版本 | 详情 |
| - | - | - | - | - |
| `newReverse` | `func newReverse() reverseType` | 返回一个 reverse 实例 | xray ≥ 1.8.4 | [🔎](/plugins/yaml/TypeFunc/exampleType/reverse) |
| `wait` | `func (reverse reverseType) wait(timeout int) bool` | 等待 timeout 秒，并返回是否在该时间内获得了信息 | xray ≥ 1.8.4 | [🔎](/plugins/yaml/TypeFunc/example/reverse/reverse) |

### 时间（Time）

| 函数名 | 函数原型 | 说明 | 适用版本 | |
| - | - | - | - | - |
| `now` | `func now() Timestamp` | 使用该函数将返回当前时间，使用 int(now())，将会获取当前时间的时间戳 | xray ≥ 1.8.5 | [🔎](/plugins/yaml/TypeFunc/example/time/now) |
| `sleep` | `func sleep(i1 int) bool` | 暂停执行等待指定的秒数 | xray ≥ 1.8.4 | [🔎](/plugins/yaml/TypeFunc/example/time/sleep) |
| `timeConvert` | `func timeConvert(int, string) string` | 该函数可以将指定时间戳转换成自定义格式的字符串 | xray ≥ 1.8.5 | [🔎](/plugins/yaml/TypeFunc/example/time/timeConvert) |

### 版本（Version）

| 函数名 | 函数原型 | 说明 | 适用版本 | 详情 |
| - | - | - | - | - |
| `versionIn` | `func versionIn(s1 string,s2 string) bool` | 判断所给出的版本是否在所限定的版本范围之内，版本格式参考: [semver](https://semver.org/) | xray ≥ 1.9.4 | [🔎](/plugins/yaml/TypeFunc/example/version/versionIn) |
| `versionLess` | `func (s1 string) versionLess(s2 string) bool` | 判断所给出的版本是否小于所给出的版本，版本格式参考: [semver](https://semver.org/) | xray ≥ 1.9.4 | [🔎](/plugins/yaml/TypeFunc/example/version/versionLess) |
| `versionGreater` | `func (s1 string) versionGreater(s2 string) bool` | 判断所给出的版本是否大于所给出的版本，版本格式参考: [semver](https://semver.org/) | xray ≥ 1.9.4 | [🔎](/plugins/yaml/TypeFunc/example/version/versionGreater) |
| `versionEqual` | `func (s1 string) versionEqual(s2 string) bool` | 判断所给出的版本是否等于所给出的版本，版本格式参考: [semver](https://semver.org/) | xray ≥ 1.9.4 | [🔎](/plugins/yaml/TypeFunc/example/version/versionEqual) |

### java 反序列化

| 函数名 | 函数原型 | 说明 | 适用版本 | 详情 |
| - | - | - | - | - |
| `javaGadget` | `func javaGadget(gadget string, payload string, type string) bytes` | 依据所给出的生成链条以及 payload 内容生成对应的 gadget 内容，第一个参数接收 gadget 类型；第二个参数为 payload 内容，为 cmd/反连 URL；第三个参数为 payload 类型 | xray ≥ 1.9.4 | [🔎](/plugins/yaml/TypeFunc/example/ysoGadget/javaGadget) |

### 压缩（Compress）

| 函数名 | 函数原型 | 说明 | 适用版本 | 详情 |
| - | - | - | - | - |
| `zipSlip` | `func zipSlip(s1 string, b1 bytes) bytes` | 该函数可以自定义生成一个zip文件 | xpoc >= 0.0.8 | [🔎](/plugins/yaml/TypeFunc/example/compress/zipSlip) |
| `gzip` | `func gzip(data string/[]byte) string` | 该函数可以对字符串或字节序列数据进行GZIP压缩。 | xpoc ≥ 0.1.0；<br />xapp ≥ 0.0.2 | [🔎](/plugins/yaml/TypeFunc/example/compress/gzip) |

### 进制转换（Base conversion）

| 函数名 | 函数原型 | 说明 | 适用版本 | 详情 |
| - | - | - | - | - |
| `decToHex` | `func decToHex(n int) string` | 该函数可以将十进制转换为十六进制 | xpoc ≥ 0.1.0；xapp ≥ 0.0.2 | [🔎](/plugins/yaml/TypeFunc/example/baseConversion/decToHex) |

### 其它（Other）

| 函数名 | 函数原型 | 说明 | 适用版本 | 详情 |
| - | - | - | - | - |
| `in` | `string in map` | map 中是否包含某个 key | xray ≥ 1.8.4 | |
| `icon`/`getIconContent` | `func (r1 response) getIconContent() bytes` | 获取response中的icon的字节流数据，如果只存储了icon的地址，则会自动访问该icon，并返回字节流 | getIconContent\[xray ≥ 1.9.3],<br />icon\[xpoc ≥ 0.1.0；xapp ≥ 0.0.2] | [🔎](/plugins/yaml/TypeFunc/example/other/getIconContent) |
| `get404Path` | `func get404Path() string` | 获取一个长度为8的随机字符串，当作404页面的路径,并保证在一次扫描中，同一个目标将只有一个404path | xpoc >= 0.0.1 | [🔎](/plugins/yaml/TypeFunc/example/http/get404path) |
| `print` | `func print(...any) bool` | 在调试场景下，使用--debug时，可以将此函数添加到expression中，打印想要的变量的值 | xpoc >= 0.1.0；<br />xapp >= 0.0.2 | [🔎](/plugins/yaml/TypeFunc/example/debug/print) |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.