Skip to contents

Tailcat addresses, private keys, and pre-shared keys are returned as character vectors with class tailcat_secret, so that printing them by accident does not reveal them. TailcatServer$address, the address element of TailcatServer$info(), the result of tailcat_address_resolve(), and the private_key and preshared_key elements of tailcat_keygen() are secrets.

print(), format(), str(), and toString() show <redacted> instead of the value, and so do printing and str() of a list that contains a secret. format() of a plain list that contains a secret redacts it in R 4.6.0 and later; earlier versions of R format list elements without consulting their class, so there it shows the value. The list returned by TailcatServer$info() has class tailcat_info and the list returned by tailcat_keygen() has class tailcat_keys, and both redact under format() in every version of R.

Everything else sees the plain string: as.character(), unclass(), paste(), paste0(), cat(), writeLines(), nchar(), and identical() on the unclassed value. A secret can be passed directly wherever this package expects an address or key, such as TailcatClient$new() and TailcatServer$new(). Subsetting a secret with [ or [[, and combining with c() when the first argument is a secret, give a secret again, so they stay redacted. Functions that drop attributes, such as unlist() on a list of secrets or c() with a plain string first, return the plain string.

Redaction only protects against accidental display. dput(), deparse(), saveRDS(), and save() necessarily include the value, as does any explicit conversion with as.character() or unclass(), so store and share secrets deliberately.

Usage

# S3 method for class 'tailcat_secret'
format(x, ...)

# S3 method for class 'tailcat_secret'
print(x, ...)

# S3 method for class 'tailcat_secret'
str(object, ...)

# S3 method for class 'tailcat_secret'
toString(x, ...)

# S3 method for class 'tailcat_secret'
x[...]

# S3 method for class 'tailcat_secret'
x[[...]]

# S3 method for class 'tailcat_secret'
c(...)

# S3 method for class 'tailcat_info'
format(x, ...)

# S3 method for class 'tailcat_info'
print(x, ...)

# S3 method for class 'tailcat_info'
str(object, ...)

Arguments

x, object

A tailcat_secret, or the tailcat_info list returned by TailcatServer$info().

...

Ignored by the display methods. For [ and [[, the index; for c(), the secrets or strings to combine.

Value

[, [[, and c() return a tailcat_secret; format() and toString() return "<redacted>" for each element of a secret; format() of a tailcat_info list returns a named character vector with its secrets redacted; print() and str() return their input invisibly.

Examples

keys = tailcat_keygen()
keys$private_key
#> <tailcat_secret> <redacted> 
str(keys)
#> List of 3 (class tailcat_keys)
#>  $ private_key  : <tailcat_secret> <redacted> 
#>  $ public_key   : chr "nodekey:7af5c1a59ca944d5674db146fa73de387ac2d2e4f2b23b71e69e441e92a06602" 
#>  $ preshared_key: <tailcat_secret> <redacted> 
nchar(keys$private_key) > 0
#> [1] TRUE