Title: | Check if a Remote Computer is Up |
---|---|
Description: | Check if a remote computer is up. It can either just call the system ping command, or check a specified TCP port. |
Authors: | Gábor Csárdi [aut, cre], Posit Software, PBC [cph, fnd] |
Maintainer: | Gábor Csárdi <[email protected]> |
License: | MIT + file LICENSE |
Version: | 2.0.4 |
Built: | 2024-11-28 06:55:01 UTC |
Source: | CRAN |
If the test page, returns "Success" that means that the computer is connected to the Internet.
apple_captive_test()
apple_captive_test()
Note that this function will fail if the computer is offline. Use
is_online()
to check if the computer is online.
apple_captive_test()
apple_captive_test()
Check if the computer is online. It does three tries:
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()
.
If any of these are successful, it returns TRUE
.
is_online(timeout = 1)
is_online(timeout = 1)
timeout |
Timeout for the queries. (Note: it is currently not used for the DNS query.) |
Possible values:
TRUE
Yes, online.
FALSE
No, not online.
is_online()
is_online()
It can use a DNS query to opendns.com, if method == "dns"
, or
an HTTPS query to icanhazip.com, see https://github.com/major/icanhaz.
The DNS query is much faster, the HTTPS query is secure.
my_ip(method = c("dns", "https"))
my_ip(method = c("dns", "https"))
method |
Whether to use a DNS or HTTPS query. |
Computer's public IP address as a string.
my_ip() my_ip(method = "https")
my_ip() my_ip(method = "https")
Perform a DNS query for a domain. It supports custom name servers, and querying DNS records of certain class and type.
nsl(domain, server = NULL, type = 1L, class = 1L)
nsl(domain, server = NULL, type = 1L, class = 1L)
domain |
Domain to query. |
server |
Custom name server IP address, to use. Note that this must be an IP address currently. E.g. 8.8.8.8 is Google's DNS server. |
type |
Record type to query, an integer scalar. 1L is an A record, 28L is an AAAA record, etc. See e.g. https://en.wikipedia.org/wiki/List_of_DNS_record_types for the record types. |
class |
Query class. This is usually 1L, i.e. "Internet". See e.g. https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-2 for all DNS classes. |
A list of two entries currently, additional entries might be added later:
answer
: a data frame of DNS records, with columns:
name
, class
, type
, ttl
, data
. data
is a list column and
contains the IP(6) address for A and AAAA records, but it contains
other data, e.g. host name for CNAME, for other records. If pingr
could not parse a record (it only parses the most common records
types: A, AAAA, NA, PTR, CNAME, TXT, MX, SOA), then the data of
the record is included as a raw vector.
flags
: a named logical vector of flags aa
, tc
, rd
, ra
,
ad
, cd
. See the RFC (https://www.ietf.org/rfc/rfc1035.txt) for
these. On Windows they are all set to NA currently.
nsl("r-project.org") nsl("google.com", type = 28L)
nsl("r-project.org") nsl("google.com", type = 28L)
This is the classic ping, using ICMP packages. Only the system administrator can send ICMP packages, so we call out to the system's ping utility.
ping( destination, continuous = FALSE, verbose = continuous, count = 3L, timeout = 1 )
ping( destination, continuous = FALSE, verbose = continuous, count = 3L, timeout = 1 )
destination |
Host name or IP address. |
continuous |
Logical, whether to keep pinging until the user interrupts. |
verbose |
Whether to print progress on the screen while pinging. |
count |
Number of pings to perform. |
timeout |
Timeout for a ping response. |
Vector of response times. NA
means no response, in
milliseconds. Currently NA
s are always at the end of the vector,
and not in their correct position.
ping("8.8.8.8") ping("r-project.org")
ping("8.8.8.8") ping("r-project.org")
Check if a port of a server is active, measure response time
is_up()
checks if a web server is up.
ping_port( destination, port = 80L, continuous = FALSE, verbose = continuous, count = 3L, timeout = 1 ) is_up( destination, port = 80, timeout = 0.5, fail_on_dns_error = FALSE, check_online = TRUE )
ping_port( destination, port = 80L, continuous = FALSE, verbose = continuous, count = 3L, timeout = 1 ) is_up( destination, port = 80, timeout = 0.5, fail_on_dns_error = FALSE, check_online = TRUE )
destination |
Host name or IP address. |
port |
Port. |
continuous |
Logical, whether to keep pinging until the user interrupts. |
verbose |
Whether to print progress on the screen while pinging. |
count |
Number of pings to perform. |
timeout |
Timeout, in seconds. How long to wait for a ping to succeed. |
fail_on_dns_error |
If |
check_online |
Whether to check first if the computer is online.
Otherwise it is possible that the computer is behind a proxy, that
hijacks the HTTP connection to |
Vector of response times, in milliseconds.
NA
means no response within the timeout.
ping_port("r-project.org") is_up("google.com") is_up("google.com", timeout = 0.01)
ping_port("r-project.org") is_up("google.com") is_up("google.com", timeout = 0.01)