Originally from https://github.com/chbrown/rfc6902

Combined with this contribution from supermeng: https://github.com/chbrown/rfc6902/pull/88/files

Vendored here to avoid depending on a unpublished git repository.

# License

Copyright 2014-2021 Christopher Brown. MIT Licensed.
