mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-11 07:10:36 +00:00
7caa87862e
All #ifndef guards on headers have been removed, I think, in favor of #pragma once Headers are now included as `#include "filename"` if the included file resides in the same directory as the file including it, or any subdirectory therein. Otherwise they are included as `#include <project/top/dir/relative/path/filename>` The above does not include system/os headers.
63 lines
1.7 KiB
C++
63 lines
1.7 KiB
C++
#pragma once
|
|
|
|
#include "name.hpp"
|
|
#include "serialize.hpp"
|
|
|
|
#include <tuple>
|
|
#include <string_view>
|
|
|
|
namespace llarp::dns
|
|
{
|
|
typedef std::tuple<std::string, uint16_t, uint16_t, uint16_t, std::string> SRVTuple;
|
|
|
|
struct SRVData
|
|
{
|
|
static constexpr size_t TARGET_MAX_SIZE = 200;
|
|
|
|
std::string service_proto; // service and protocol may as well be together
|
|
|
|
uint16_t priority;
|
|
uint16_t weight;
|
|
uint16_t port;
|
|
|
|
// target string for the SRV record to point to
|
|
// options:
|
|
// empty - refer to query name
|
|
// dot - authoritative "no such service available"
|
|
// any other .loki or .snode - target is that .loki or .snode
|
|
std::string target;
|
|
|
|
// do some basic validation on the target string
|
|
// note: this is not a conclusive, regex solution,
|
|
// but rather some sanity/safety checks
|
|
bool
|
|
IsValid() const;
|
|
|
|
SRVTuple
|
|
toTuple() const;
|
|
|
|
static SRVData
|
|
fromTuple(SRVTuple tuple);
|
|
|
|
/* bind-like formatted string for SRV records in config file
|
|
*
|
|
* format:
|
|
* srv=service.proto priority weight port target
|
|
*
|
|
* exactly one space character between parts.
|
|
*
|
|
* target can be empty, in which case the space after port should
|
|
* be omitted. if this is the case, the target is
|
|
* interpreted as the .loki or .snode of the current context.
|
|
*
|
|
* if target is not empty, it must be either
|
|
* - simply a full stop (dot/period) OR
|
|
* - a name within the .loki or .snode subdomains. a target
|
|
* specified in this manner must not end with a full stop.
|
|
*/
|
|
bool
|
|
fromString(std::string_view srvString);
|
|
};
|
|
|
|
} // namespace llarp::dns
|