knitr::opts_chunk$set(collapse=TRUE, fig.retina=2, message=FALSE, warning=FALSE)
options(width=60)

Travis-CI Build Status AppVeyor build status Coverage Status CRAN_Status_Badge

udpprobe

Send User Datagram Protocol ('UDP') Probes and Receive Responses

Description

Unfortunately (but understandably) R has no built in connection support for the user datagram protocol ('UDP'). We aim to somewhat fix that with the ability to send a lightweight probe and receive lightweight responses over 'UDP' to a target host/port. Supports Windows, macOS and Linux clients.

What's Inside The Tin

The following functions are implemented:

The core probe function:

Helpers for Ubiquity Discover Protocol probes:

Helpers for old, insecure internet services:

Installation

devtools::install_git("https://git.sr.ht/~hrbrmstr/udpprobe")
# or
devtools::install_gitlab("hrbrmstr/udpprobe")
# or
devtools::install_github("hrbrmstr/udpprobe")

Usage

library(udpprobe)

# current version
packageVersion("udpprobe")

Fun with manually crafting DNS records

What's the IP address of example.com?

c(
  0xaa, 0xaa, # id
  0x01, 0x00, # |QR|   Opcode  |AA|TC|RD|RA|   Z    |   RCODE   |
  0x00, 0x01, # QDCOUNT num of questions
  0x00, 0x00, # ANCOUNT 0 since it's only for answers
  0x00, 0x00, # NSCOUNT 0 since it's only for answers
  0x00, 0x00, # ARCOUNT 0 sicne it's only for answers
  0x07,       # start of QNAME beginning with size of "example"
  0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65,  # example
  0x03,       # size of "com" (excluding null terminator)
  0x63, 0x6f, 0x6d, 0x00,  # "com" with null terminator
  0x00, 0x01, # QTYPE ("A" == 1)
  0x00, 0x01  # QCLASS (internet == 1)
) -> dns_req

(resp <- udp_send_payload("8.8.8.8", 53, dns_req))

paste0(as.integer(tail(resp, 4)), collapse = ".")

curl::nslookup("example.com")

Live Ubiquiti Test (internet host redacted)

# the following just does:
#   udp_send_payload(Sys.getenv("UBNT_TEST_HOST"), 10001L, c(0x01, 0x00, 0x00, 0x00))
(x <- ubnt_discovery_probe(Sys.getenv("UBNT_TEST_HOST")))

parse_ubnt_discovery_response(x)

Old, indecure internet services:

cat(udp_echo("91.207.125.246", "the message you want back"), "\n")

cat(udp_qotd("119.48.167.199"), "\n")

cat(udp_daytime("195.34.89.241"), "\n")

udpprobe Metrics

cloc::cloc_pkg_md()

Code of Conduct

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.



hrbrmstr/udpprobe documentation built on May 23, 2019, 9:49 a.m.