mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-25 17:44:02 +08:00
change: remove dial ping and dns
This commit is contained in:
@@ -92,10 +92,8 @@ Available Commands:
|
||||
build build plugin for testing
|
||||
completion Generate the autocompletion script for the specified shell
|
||||
convert convert multiple source format to HttpRunner JSON/YAML/gotest/pytest cases
|
||||
dns DNS resolution for different source and record types
|
||||
help Help about any command
|
||||
ios simple utils for ios device management
|
||||
ping run integrated ping command
|
||||
pytest run API test with pytest
|
||||
run run API test with go engine
|
||||
startproject create a scaffold project
|
||||
|
||||
@@ -85,10 +85,8 @@ Available Commands:
|
||||
build build plugin for testing
|
||||
completion Generate the autocompletion script for the specified shell
|
||||
convert convert multiple source format to HttpRunner JSON/YAML/gotest/pytest cases
|
||||
dns DNS resolution for different source and record types
|
||||
help Help about any command
|
||||
ios simple utils for ios device management
|
||||
ping run integrated ping command
|
||||
pytest run API test with pytest
|
||||
run run API test with go engine
|
||||
startproject create a scaffold project
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
- refactor: merge ActionOption with DataOption
|
||||
- change: exit with AndroidShellExecError code for adb shell failure
|
||||
- change: request vedem ocr with uploading image
|
||||
- change: remove ping/dns sub commands
|
||||
|
||||
## v4.3.3 (2023-04-19)
|
||||
|
||||
|
||||
@@ -32,8 +32,6 @@ Copyright 2017 debugtalk
|
||||
* [hrp boom](hrp_boom.md) - run load test with boomer
|
||||
* [hrp build](hrp_build.md) - build plugin for testing
|
||||
* [hrp convert](hrp_convert.md) - convert multiple source format to HttpRunner JSON/YAML/gotest/pytest cases
|
||||
* [hrp dns](hrp_dns.md) - DNS resolution for different source and record types
|
||||
* [hrp ping](hrp_ping.md) - run integrated ping command
|
||||
* [hrp pytest](hrp_pytest.md) - run API test with pytest
|
||||
* [hrp run](hrp_run.md) - run API test with go engine
|
||||
* [hrp startproject](hrp_startproject.md) - create a scaffold project
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
## hrp dns
|
||||
|
||||
DNS resolution for different source and record types
|
||||
|
||||
```
|
||||
hrp dns $url [flags]
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
```
|
||||
--dns-record int DNS record type
|
||||
1: A
|
||||
28: AAAA
|
||||
5: CNAME (default 1)
|
||||
--dns-server string DNS server, only available for local DNS source
|
||||
--dns-source int DNS source type
|
||||
0: local DNS
|
||||
1: http DNS
|
||||
2: google DNS
|
||||
-h, --help help for dns
|
||||
--save-tests Save DNS resolution result as json
|
||||
```
|
||||
|
||||
### SEE ALSO
|
||||
|
||||
* [hrp](hrp.md) - Next-Generation API Testing Solution.
|
||||
|
||||
###### Auto generated by spf13/cobra on 31-May-2023
|
||||
@@ -1,23 +0,0 @@
|
||||
## hrp ping
|
||||
|
||||
run integrated ping command
|
||||
|
||||
```
|
||||
hrp ping $url [flags]
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
```
|
||||
-c, --count int Stop after sending (and receiving) N packets (default 10)
|
||||
-h, --help help for ping
|
||||
-i, --interval duration Wait N seconds between sending each packet (default 1s)
|
||||
--save-tests Save ping result as json
|
||||
-t, --timeout duration Ping exits after N seconds (default 20s)
|
||||
```
|
||||
|
||||
### SEE ALSO
|
||||
|
||||
* [hrp](hrp.md) - Next-Generation API Testing Solution.
|
||||
|
||||
###### Auto generated by spf13/cobra on 31-May-2023
|
||||
@@ -1,22 +0,0 @@
|
||||
## hrp traceroute
|
||||
|
||||
run integrated traceroute command
|
||||
|
||||
```
|
||||
hrp traceroute $url [flags]
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
```
|
||||
-h, --help help for traceroute
|
||||
-m, --max-hops int Set the max number of hops (max TTL to be reached) (default 30)
|
||||
-q, --queries int Set the number of probes per each hop (default 1)
|
||||
--save-tests Save traceroute result as json
|
||||
```
|
||||
|
||||
### SEE ALSO
|
||||
|
||||
* [hrp](hrp.md) - Next-Generation API Testing Solution.
|
||||
|
||||
###### Auto generated by spf13/cobra on 21-Oct-2022
|
||||
6
go.mod
6
go.mod
@@ -8,7 +8,6 @@ require (
|
||||
github.com/fatih/color v1.15.0
|
||||
github.com/getsentry/sentry-go v0.13.0
|
||||
github.com/go-openapi/spec v0.20.7
|
||||
github.com/go-ping/ping v1.1.0
|
||||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
|
||||
github.com/gorilla/websocket v1.5.0
|
||||
github.com/httprunner/funplugin v0.5.1
|
||||
@@ -17,7 +16,6 @@ require (
|
||||
github.com/json-iterator/go v1.1.12
|
||||
github.com/lunixbochs/struc v0.0.0-20200707160740-784aaebc1d40
|
||||
github.com/maja42/goval v1.2.1
|
||||
github.com/miekg/dns v1.1.50
|
||||
github.com/mitchellh/mapstructure v1.5.0
|
||||
github.com/olekukonko/tablewriter v0.0.5
|
||||
github.com/otiai10/gosseract/v2 v2.4.0
|
||||
@@ -50,7 +48,6 @@ require (
|
||||
github.com/go-openapi/jsonreference v0.20.0 // indirect
|
||||
github.com/go-openapi/swag v0.22.3 // indirect
|
||||
github.com/golang/protobuf v1.5.3 // indirect
|
||||
github.com/google/uuid v1.3.0 // indirect
|
||||
github.com/hashicorp/go-hclog v1.5.0 // indirect
|
||||
github.com/hashicorp/go-plugin v1.4.9 // indirect
|
||||
github.com/hashicorp/yamux v0.1.1 // indirect
|
||||
@@ -75,11 +72,8 @@ require (
|
||||
github.com/tklauser/go-sysconf v0.3.10 // indirect
|
||||
github.com/tklauser/numcpus v0.5.0 // indirect
|
||||
github.com/yusufpapurcu/wmi v1.2.2 // indirect
|
||||
golang.org/x/mod v0.8.0 // indirect
|
||||
golang.org/x/sync v0.1.0 // indirect
|
||||
golang.org/x/sys v0.7.0 // indirect
|
||||
golang.org/x/text v0.9.0 // indirect
|
||||
golang.org/x/tools v0.6.0 // indirect
|
||||
google.golang.org/appengine v1.6.7 // indirect
|
||||
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
|
||||
23
go.sum
23
go.sum
@@ -102,8 +102,6 @@ github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh
|
||||
github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ=
|
||||
github.com/go-openapi/swag v0.22.3 h1:yMBqmnQ0gyZvEb/+KzuWZOXgllrXT4SADYbvDaXHv/g=
|
||||
github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14=
|
||||
github.com/go-ping/ping v1.1.0 h1:3MCGhVX4fyEUuhsfwPrsEdQw6xspHkv5zHsiSoDFZYw=
|
||||
github.com/go-ping/ping v1.1.0/go.mod h1:xIFjORFzTxqIV/tDVGO4eDy/bLuSyawEeojSm3GfRGk=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
@@ -161,9 +159,6 @@ github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hf
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4=
|
||||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ=
|
||||
github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
|
||||
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
|
||||
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
|
||||
@@ -236,8 +231,6 @@ github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWV
|
||||
github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/miekg/dns v1.1.50 h1:DQUfb9uc6smULcREF09Uc+/Gd46YWqJd5DbpPE9xkcA=
|
||||
github.com/miekg/dns v1.1.50/go.mod h1:e3IlAVfNqAllflbibAZEWOXOQ+Ynzk/dDozDxY7XnME=
|
||||
github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU=
|
||||
github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8=
|
||||
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
|
||||
@@ -338,7 +331,6 @@ github.com/tklauser/numcpus v0.5.0/go.mod h1:OGzpTxpcIMNGYQdit2BYL1pvk/dSOaJWjKo
|
||||
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||
github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg=
|
||||
github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
|
||||
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
|
||||
@@ -384,9 +376,6 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB
|
||||
golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8=
|
||||
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
@@ -415,10 +404,7 @@ golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/
|
||||
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc=
|
||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
||||
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||
golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM=
|
||||
@@ -441,9 +427,6 @@ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJ
|
||||
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
@@ -479,10 +462,7 @@ golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
@@ -549,9 +529,6 @@ golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roY
|
||||
golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||
golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||
golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||
golang.org/x/tools v0.1.6-0.20210726203631-07bc1bf47fb2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM=
|
||||
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/dial"
|
||||
)
|
||||
|
||||
var (
|
||||
pingOptions dial.PingOptions
|
||||
dnsOptions dial.DnsOptions
|
||||
)
|
||||
|
||||
var pingCmd = &cobra.Command{
|
||||
Use: "ping $url",
|
||||
Short: "run integrated ping command",
|
||||
Args: cobra.ExactArgs(1),
|
||||
PreRun: func(cmd *cobra.Command, args []string) {
|
||||
setLogLevel(logLevel)
|
||||
},
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return dial.DoPing(&pingOptions, args)
|
||||
},
|
||||
}
|
||||
|
||||
var dnsCmd = &cobra.Command{
|
||||
Use: "dns $url",
|
||||
Short: "DNS resolution for different source and record types",
|
||||
Args: cobra.ExactArgs(1),
|
||||
PreRun: func(cmd *cobra.Command, args []string) {
|
||||
setLogLevel(logLevel)
|
||||
},
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
if dnsOptions.DnsSourceType != dial.DnsSourceTypeLocal && dnsOptions.DnsServer != "" {
|
||||
log.Warn().Msg("DNS server not supported for non-local DNS source, ignored")
|
||||
}
|
||||
if dnsOptions.DnsSourceType == dial.DnsSourceTypeHttp && dnsOptions.DnsRecordType == dial.DnsRecordTypeCNAME {
|
||||
log.Warn().Msg("CNAME record not supported for http DNS source, using default record type(A)")
|
||||
}
|
||||
return dial.DoDns(&dnsOptions, args)
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(pingCmd)
|
||||
pingCmd.Flags().IntVarP(&pingOptions.Count, "count", "c", 10, "Stop after sending (and receiving) N packets")
|
||||
pingCmd.Flags().DurationVarP(&pingOptions.Timeout, "timeout", "t", 20*time.Second, "Ping exits after N seconds")
|
||||
pingCmd.Flags().DurationVarP(&pingOptions.Interval, "interval", "i", 1*time.Second, "Wait N seconds between sending each packet")
|
||||
pingCmd.Flags().BoolVar(&pingOptions.SaveTests, "save-tests", false, "Save ping result as json")
|
||||
|
||||
rootCmd.AddCommand(dnsCmd)
|
||||
dnsCmd.Flags().IntVar(&dnsOptions.DnsSourceType, "dns-source", 0, "DNS source type\n0: local DNS\n1: http DNS\n2: google DNS")
|
||||
dnsCmd.Flags().IntVar(&dnsOptions.DnsRecordType, "dns-record", 1, "DNS record type\n1: A\n28: AAAA\n5: CNAME")
|
||||
dnsCmd.Flags().StringVar(&dnsOptions.DnsServer, "dns-server", "", "DNS server, only available for local DNS source")
|
||||
dnsCmd.Flags().BoolVar(&dnsOptions.SaveTests, "save-tests", false, "Save DNS resolution result as json")
|
||||
}
|
||||
@@ -1,250 +0,0 @@
|
||||
package dial
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/env"
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/json"
|
||||
)
|
||||
|
||||
const (
|
||||
httpDnsUrl = "https://dig.bdurl.net/q"
|
||||
googleDnsUrl = "https://dns.google/resolve"
|
||||
)
|
||||
|
||||
const (
|
||||
DnsSourceTypeLocal = iota
|
||||
DnsSourceTypeHttp
|
||||
DnsSourceTypeGoogle
|
||||
)
|
||||
|
||||
const (
|
||||
DnsRecordTypeA = 1
|
||||
DnsRecordTypeAAAA = 28
|
||||
DnsRecordTypeCNAME = 5
|
||||
)
|
||||
|
||||
var dnsHttpClient = &http.Client{
|
||||
Timeout: 5 * time.Minute,
|
||||
}
|
||||
|
||||
type DnsOptions struct {
|
||||
DnsSourceType int
|
||||
DnsRecordType int
|
||||
DnsServer string
|
||||
SaveTests bool
|
||||
}
|
||||
|
||||
type DnsResult struct {
|
||||
DnsList []string `json:"dnsList"`
|
||||
DnsSource int `json:"dnsType"`
|
||||
DnsRecordType int `json:"dnsRecordType"`
|
||||
DnsServer string `json:"dnsServer,omitempty"`
|
||||
Ttl int `json:"ttl"`
|
||||
Suc bool `json:"suc"`
|
||||
ErrMsg string `json:"errMsg"`
|
||||
}
|
||||
|
||||
type googleDnsResp struct {
|
||||
Answer []googleDnsAnswer `json:"Answer"`
|
||||
}
|
||||
|
||||
type httpDnsResp struct {
|
||||
Ips []string `json:"ips"`
|
||||
Ttl int `json:"ttl"`
|
||||
}
|
||||
|
||||
type googleDnsAnswer struct {
|
||||
Name string `json:"name"`
|
||||
Type int `json:"type"`
|
||||
TTL int `json:"TTL"`
|
||||
Data string `json:"data"`
|
||||
}
|
||||
|
||||
func ParseIP(s string) (net.IP, int) {
|
||||
ip := net.ParseIP(s)
|
||||
if ip == nil {
|
||||
return nil, 0
|
||||
}
|
||||
for i := 0; i < len(s); i++ {
|
||||
switch s[i] {
|
||||
case '.':
|
||||
return ip, 4
|
||||
case ':':
|
||||
return ip, 6
|
||||
}
|
||||
}
|
||||
return nil, 0
|
||||
}
|
||||
|
||||
func localDns(src string, dnsRecordType int, dnsServer string) (dnsResult DnsResult, err error) {
|
||||
dnsResult.DnsSource = DnsSourceTypeLocal
|
||||
dnsResult.DnsRecordType = dnsRecordType
|
||||
|
||||
if dnsServer == "" {
|
||||
config, _ := dns.ClientConfigFromFile("/etc/resolv.conf")
|
||||
dnsServer = config.Servers[0]
|
||||
} else {
|
||||
dnsResult.DnsServer = dnsServer
|
||||
}
|
||||
|
||||
_, ipType := ParseIP(dnsServer)
|
||||
if ipType == 4 {
|
||||
dnsServer += ":53"
|
||||
}
|
||||
|
||||
c := dns.Client{
|
||||
Timeout: 5 * time.Second,
|
||||
}
|
||||
m := dns.Msg{}
|
||||
|
||||
m.SetQuestion(src+".", uint16(dnsRecordType))
|
||||
r, _, err := c.Exchange(&m, dnsServer)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
for _, ans := range r.Answer {
|
||||
switch dnsRecordType {
|
||||
case DnsRecordTypeA:
|
||||
record, isType := ans.(*dns.A)
|
||||
if isType {
|
||||
dnsResult.Ttl = int(record.Hdr.Ttl)
|
||||
dnsResult.DnsList = append(dnsResult.DnsList, record.A.String())
|
||||
}
|
||||
case DnsRecordTypeAAAA:
|
||||
record, isType := ans.(*dns.AAAA)
|
||||
if isType {
|
||||
dnsResult.Ttl = int(record.Hdr.Ttl)
|
||||
dnsResult.DnsList = append(dnsResult.DnsList, record.AAAA.String())
|
||||
}
|
||||
case DnsRecordTypeCNAME:
|
||||
record, isType := ans.(*dns.CNAME)
|
||||
if isType {
|
||||
dnsResult.Ttl = int(record.Hdr.Ttl)
|
||||
dnsResult.DnsList = append(dnsResult.DnsList, record.Target)
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func httpDns(url string, dnsRecordType int) (dnsResult DnsResult, err error) {
|
||||
target := httpDnsUrl + "?host=" + url
|
||||
if dnsRecordType == DnsRecordTypeAAAA {
|
||||
target += "&aid=13&f=2"
|
||||
}
|
||||
resp, err := dnsHttpClient.Get(target)
|
||||
|
||||
dnsResult.DnsSource = DnsSourceTypeHttp
|
||||
dnsResult.DnsRecordType = dnsRecordType
|
||||
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
var buf []byte
|
||||
buf, err = ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
var result httpDnsResp
|
||||
err = json.Unmarshal(buf, &result)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
dnsResult.DnsList = result.Ips
|
||||
dnsResult.Ttl = result.Ttl
|
||||
return
|
||||
}
|
||||
|
||||
func googleDns(url string, dnsRecordType int) (dnsResult DnsResult, err error) {
|
||||
resp, err := dnsHttpClient.Get(googleDnsUrl + "?name=" + url + "&type=" + strconv.Itoa(dnsRecordType))
|
||||
|
||||
dnsResult.DnsSource = DnsSourceTypeGoogle
|
||||
dnsResult.DnsRecordType = dnsRecordType
|
||||
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
var buf []byte
|
||||
buf, err = ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
var result googleDnsResp
|
||||
err = json.Unmarshal(buf, &result)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if len(result.Answer) == 0 {
|
||||
return
|
||||
}
|
||||
for _, answer := range result.Answer {
|
||||
if answer.Type == dnsRecordType {
|
||||
dnsResult.Ttl = answer.TTL
|
||||
dnsResult.DnsList = append(dnsResult.DnsList, answer.Data)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func DoDns(dnsOptions *DnsOptions, args []string) (err error) {
|
||||
if len(args) != 1 {
|
||||
return errors.New("there should be one argument")
|
||||
}
|
||||
|
||||
var dnsResult DnsResult
|
||||
defer func() {
|
||||
if dnsOptions.SaveTests {
|
||||
dnsResultName := fmt.Sprintf("dns_result_%v.json", env.StartTimeStr)
|
||||
dnsResultPath := filepath.Join(env.RootDir, dnsResultName)
|
||||
err = builtin.Dump2JSON(dnsResult, dnsResultPath)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("save dns resolution result failed")
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
dnsTarget := args[0]
|
||||
|
||||
parsedURL, err := url.Parse(dnsTarget)
|
||||
if err == nil && parsedURL.Host != "" {
|
||||
log.Info().Msgf("parse input url %v and extract host %v", dnsTarget, parsedURL.Host)
|
||||
dnsTarget = strings.Split(parsedURL.Host, ":")[0]
|
||||
}
|
||||
log.Info().Msgf("resolve DNS for %v", dnsTarget)
|
||||
dnsRecordType := dnsOptions.DnsRecordType
|
||||
dnsServer := dnsOptions.DnsServer
|
||||
switch dnsOptions.DnsSourceType {
|
||||
case DnsSourceTypeLocal:
|
||||
dnsResult, err = localDns(dnsTarget, dnsRecordType, dnsServer)
|
||||
case DnsSourceTypeHttp:
|
||||
dnsResult, err = httpDns(dnsTarget, dnsRecordType)
|
||||
case DnsSourceTypeGoogle:
|
||||
dnsResult, err = googleDns(dnsTarget, dnsRecordType)
|
||||
}
|
||||
if err != nil {
|
||||
dnsResult.Suc = false
|
||||
dnsResult.ErrMsg = err.Error()
|
||||
log.Error().Err(err).Msgf("fail to do DNS for %s", dnsTarget)
|
||||
} else {
|
||||
dnsResult.Suc = true
|
||||
dnsResult.ErrMsg = ""
|
||||
fmt.Printf("\nDNS resolution done, result IP list: %v\n", dnsResult.DnsList)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
package dial
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/go-ping/ping"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/env"
|
||||
)
|
||||
|
||||
type PingOptions struct {
|
||||
Count int
|
||||
Timeout time.Duration
|
||||
Interval time.Duration
|
||||
SaveTests bool
|
||||
}
|
||||
|
||||
type PingResult struct {
|
||||
Suc bool `json:"suc"`
|
||||
ErrMsg string `json:"errMsg"`
|
||||
Ip string `json:"ip"`
|
||||
AvgCost int `json:"avgCost"`
|
||||
MaxCost int `json:"maxCost"`
|
||||
MinCost int `json:"minCost"`
|
||||
Lost int `json:"lost"`
|
||||
PingCount int `json:"pingCount"`
|
||||
PacketSize int `json:"packetSize"`
|
||||
ReceivePacketCount int `json:"receivePacketCount"`
|
||||
SendPacketCount int `json:"sendPacketCount"`
|
||||
SuccessCount int `json:"successCount"`
|
||||
DebugLog string `json:"debugLog"`
|
||||
}
|
||||
|
||||
func DoPing(pingOptions *PingOptions, args []string) (err error) {
|
||||
if len(args) != 1 {
|
||||
return errors.New("there should be one argument")
|
||||
}
|
||||
|
||||
var pingResult PingResult
|
||||
defer func() {
|
||||
if pingOptions.SaveTests {
|
||||
pingResultName := fmt.Sprintf("ping_result_%v.json", env.StartTimeStr)
|
||||
pingResultPath := filepath.Join(env.RootDir, pingResultName)
|
||||
err = builtin.Dump2JSON(pingResult, pingResultPath)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("save ping result failed")
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
pingTarget := args[0]
|
||||
|
||||
parsedURL, err := url.Parse(pingTarget)
|
||||
if err == nil && parsedURL.Host != "" {
|
||||
log.Info().Msgf("parse input url %v and extract host %v", pingTarget, parsedURL.Host)
|
||||
pingTarget = strings.Split(parsedURL.Host, ":")[0]
|
||||
}
|
||||
|
||||
log.Info().Msgf("ping host %v", pingTarget)
|
||||
pinger, err := ping.NewPinger(pingTarget)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msgf("fail to get pinger for %s", pingTarget)
|
||||
pingResult.Suc = false
|
||||
pingResult.ErrMsg = err.Error()
|
||||
pingResult.DebugLog = err.Error()
|
||||
return
|
||||
}
|
||||
pinger.Count = pingOptions.Count
|
||||
pinger.Timeout = pingOptions.Timeout
|
||||
pinger.Interval = pingOptions.Interval
|
||||
|
||||
pinger.OnRecv = func(pkt *ping.Packet) {
|
||||
pingResult.DebugLog += fmt.Sprintf("%d bytes from %s: icmp_seq=%d time=%v\n",
|
||||
pkt.Nbytes, pkt.IPAddr, pkt.Seq, pkt.Rtt)
|
||||
}
|
||||
pinger.OnFinish = func(stats *ping.Statistics) {
|
||||
pingResult.DebugLog += fmt.Sprintf("\n--- %s ping statistics ---\n", stats.Addr)
|
||||
pingResult.DebugLog += fmt.Sprintf("%d packets transmitted, %d packets received, %v%% packet loss\n",
|
||||
stats.PacketsSent, stats.PacketsRecv, stats.PacketLoss)
|
||||
pingResult.DebugLog += fmt.Sprintf("round-trip min/avg/max/stddev = %v/%v/%v/%v\n",
|
||||
stats.MinRtt, stats.AvgRtt, stats.MaxRtt, stats.StdDevRtt)
|
||||
}
|
||||
pingResult.DebugLog += fmt.Sprintf("PING %s (%s):\n", pinger.Addr(), pinger.IPAddr())
|
||||
|
||||
err = pinger.Run() // blocks until finished
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msgf("fail to run ping for %s", parsedURL)
|
||||
pingResult.Suc = false
|
||||
pingResult.ErrMsg = err.Error()
|
||||
pingResult.DebugLog = err.Error()
|
||||
return
|
||||
}
|
||||
fmt.Print(pingResult.DebugLog)
|
||||
stats := pinger.Statistics() // get send/receive/rtt stats
|
||||
pingResult.Ip = pinger.IPAddr().String()
|
||||
pingResult.AvgCost = int(stats.AvgRtt / time.Millisecond)
|
||||
pingResult.MaxCost = int(stats.MaxRtt / time.Millisecond)
|
||||
pingResult.MinCost = int(stats.MinRtt / time.Millisecond)
|
||||
pingResult.Lost = int(stats.PacketLoss)
|
||||
pingResult.PingCount = pingOptions.Count
|
||||
pingResult.PacketSize = pinger.Size
|
||||
pingResult.ReceivePacketCount = stats.PacketsRecv
|
||||
pingResult.SendPacketCount = stats.PacketsSent
|
||||
pingResult.SuccessCount = stats.PacketsRecv
|
||||
pingResult.Suc = true
|
||||
pingResult.ErrMsg = ""
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user