Skip to content

Commit

Permalink
Rebuild README, redocument
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborcsardi committed Nov 3, 2023
1 parent f9a36c9 commit a13114b
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 50 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Suggests:
Imports:
processx,
utils
RoxygenNote: 7.1.0.9000
Roxygen: list(packages = "roxygenlabs", markdown = TRUE)
RoxygenNote: 7.2.3
Roxygen: list(markdown = TRUE)
Encoding: UTF-8
Config/Needs/website: tidyverse/tidytemplate
124 changes: 79 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,103 +14,137 @@ up and some other related tools.

## ICMP ping

The `ping()` function does ICMP ping, via the systems `ping` utility:
The `ping()` function does ICMP ping, via the system's `ping` utility:

``` r

```r
library(pingr)
```

```
#>
#> Attaching package: 'pingr'
```

```
#> The following object is masked from 'package:utils':
#>
#> nsl
```

```r
ping("127.0.0.1")
```

#> [1] 0.046 0.058 0.053
```
#> [1] 0.076 0.236 0.226
```

By default it sends three packets and measures the time it receives and answer.
It waits between sending out the packets, so if you want a really quick check,
you can just send a single packet:

By default it sends three packets and measures the time it receives and
answer. It waits between sending out the packets, so if you want a
really quick check, you can just send a single packet:

``` r
```r
ping("127.0.0.1", count = 1)
```

#> [1] 0.067
```
#> [1] 0.125
```

If a machine is down (or it does not exist), then `NA` is returned
instead of the roundtrip time:
If a machine is down (or it does not exist), then `NA` is returned instead
of the roundtrip time:

``` r

```r
ping("192.0.2.1", count = 1)
```

#> [1] NA
```
#> [1] NA
```

## TCP ping

With TCP ping we can check if a machine is listeing on a TCP port,
e.g. if google’s search web server is up and running:
With TCP ping we can check if a machine is listeing on a TCP port, e.g. if
google's search web server is up and running:


``` r
```r
ping_port("www.google.com", port = 80, count = 1)
```

#> [1] 12.676
```
#> [1] 19.825
```

## Query the public IP address of the computer

`my_ip()` queries the public IP of the computer, either via DNS or
HTTPS:
`my_ip()` queries the public IP of the computer, either via DNS or HTTPS:

``` r

```r
my_ip()
```

#> [1] "81.133.85.232"
```
#> [1] "83.50.96.133"
```

## Check if the computer is online

`is_online()` checks if the computer is online. It makes three tries:

- Queries myip.opendns.com on OpenDNS, see `my_ip()`.
- Retrieves icanhazip.com via HTTPS, see `my_ip()`.
- Retrieve Apple’s Captive Portal test page, see
`apple_captive_test()`.
* Queries myip.opendns.com on OpenDNS, see `my_ip()`.
* Retrieves icanhazip.com via HTTPS, see `my_ip()`.
* Retrieve Apple's Captive Portal test page, see `apple_captive_test()`.

If any of these are successful, it returns `TRUE`.

``` r

```r
is_online()
```

#> [1] TRUE
```
#> [1] TRUE
```

## DNS queries

The package also contains a function to perform DNS queries. This is a
more portable and more functional version of the `utils::nsl()`
function:
more portable and more functional version of the `utils::nsl()` function:

``` r

```r
nsl("www.r-project.org", type = 1L)
```

#> $answer
#> name class type ttl data
#> 1 www.r-project.org 1 5 900 cran.wu-wien.ac.at
#> 2 cran.wu-wien.ac.at 1 1 300 137.208.57.37
#>
#> $flags
#> aa tc rd ra ad cd
#> FALSE FALSE TRUE TRUE FALSE FALSE
```
#> $answer
#> name class type ttl data
#> 1 www.r-project.org 1 5 4235 cran.wu-wien.ac.at
#> 2 cran.wu-wien.ac.at 1 1 300 137.208.57.37
#>
#> $flags
#> aa tc rd ra ad cd
#> FALSE FALSE TRUE TRUE FALSE FALSE
```

``` r
```r
nsl("google.com", type = 28L)
```

#> $answer
#> name class type ttl data
#> 1 google.com 1 28 110 2a00:1450:4009:81a::200e
#>
#> $flags
#> aa tc rd ra ad cd
#> FALSE FALSE TRUE TRUE FALSE FALSE
```
#> $answer
#> name class type ttl data
#> 1 google.com 1 28 216 2a00:1450:4003:80f::200e
#>
#> $flags
#> aa tc rd ra ad cd
#> FALSE FALSE TRUE TRUE FALSE FALSE
```

## License

Expand Down
5 changes: 2 additions & 3 deletions man/pingr-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a13114b

Please sign in to comment.