Files
tcping-go/README.md
2025-11-24 16:39:33 +08:00

53 lines
1.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Tcping GO
一个使用 Golang 写的小工具用于检测TCP端口是否开放
## 使用方法
你可以简单的测试一个域名(或 IP 地址)的某个端口是否开放,默认测试 80 端口
```shell
tcping www.qq.com
使用 www.qq.com 的 A 记录: 175.27.8.138
[1] 来自 175.27.8.138:80 的响应: 时间=29.256ms
[2] 来自 175.27.8.138:80 的响应: 时间=29.086ms
[3] 来自 175.27.8.138:80 的响应: 时间=37.761ms
[4] 来自 175.27.8.138:80 的响应: 时间=30.259ms
测试完成,成功 4/4 (100.00%)
```
也可以指定测试端口号,跟随在域名或 IP 地址后面
```shell
tcping www.qq.com 443
使用 www.qq.com 的 A 记录: 175.27.8.138
[1] 来自 175.27.8.138:443 的响应: 时间=28.835ms
[2] 来自 175.27.8.138:443 的响应: 时间=27.419ms
[3] 来自 175.27.8.138:443 的响应: 时间=44.382ms
[4] 来自 175.27.8.138:443 的响应: 时间=28.356ms
测试完成,成功 4/4 (100.00%)
```
使用 `-6` 指定使用IPv6仅对域名有效
```shell
tcping www.qq.com -6
使用 www.qq.com 的 AAAA 记录: 240e:97c:2f:1::5c
[1] 来自 [240e:97c:2f:1::5c]:80 的响应: 时间=30.795ms
[2] 来自 [240e:97c:2f:1::5c]:80 的响应: 时间=30.247ms
[3] 来自 [240e:97c:2f:1::5c]:80 的响应: 时间=30.856ms
[4] 来自 [240e:97c:2f:1::5c]:80 的响应: 时间=30.275ms
测试完成,成功 4/4 (100.00%)
```
使用 `-c` 指定测试次数默认为4次
使用 `-s` 指定超时时间默认为2秒
使用 `-t` 来启用无限次测试模式
使用 `-f` 来启用快速模式,降低两次成功测试之间的间隔时间