2016-11-23 20:19:16 +00:00
|
|
|
#ifndef NAMESYS_H
|
|
|
|
#define NAMESYS_H
|
|
|
|
|
|
|
|
#define DefaultDepthLimit 32
|
|
|
|
|
2016-11-24 22:49:26 +00:00
|
|
|
#ifdef NAMESYS_C
|
|
|
|
char *ErrNamesys[] = {
|
|
|
|
NULL,
|
|
|
|
"ErrAllocFailed",
|
|
|
|
"ErrNULLPointer",
|
2016-11-27 13:57:28 +00:00
|
|
|
"ErrPipe",
|
|
|
|
"ErrPoll",
|
2016-11-24 22:49:26 +00:00
|
|
|
"Could not publish name."
|
|
|
|
"Could not resolve name.",
|
|
|
|
"Could not resolve name (recursion limit exceeded).",
|
|
|
|
"expired record",
|
|
|
|
"unrecognized validity type",
|
2016-11-27 13:57:28 +00:00
|
|
|
"not a valid proquint string",
|
|
|
|
"not a valid domain name",
|
|
|
|
"not a valid dnslink entry"
|
2016-11-24 22:49:26 +00:00
|
|
|
};
|
|
|
|
#else
|
|
|
|
extern char *ErrNamesys;
|
|
|
|
#endif // NAMESYS_C
|
2016-11-23 20:19:16 +00:00
|
|
|
|
|
|
|
enum {
|
|
|
|
ErrAllocFailed = 1,
|
|
|
|
ErrNULLPointer,
|
2016-11-27 13:57:28 +00:00
|
|
|
ErrPipe,
|
|
|
|
ErrPoll,
|
2016-11-23 20:19:16 +00:00
|
|
|
ErrPublishFailed,
|
|
|
|
ErrResolveFailed,
|
|
|
|
ErrResolveRecursion,
|
|
|
|
ErrExpiredRecord,
|
2016-11-24 10:52:15 +00:00
|
|
|
ErrUnrecognizedValidity,
|
2016-11-27 13:57:28 +00:00
|
|
|
ErrInvalidProquint,
|
|
|
|
ErrInvalidDomain,
|
|
|
|
ErrInvalidDNSLink
|
2016-11-23 20:19:16 +00:00
|
|
|
} NamesysErrs;
|
|
|
|
|
|
|
|
typedef struct s_resolvers {
|
|
|
|
char *protocol;
|
|
|
|
int (*func)(char**, char*);
|
|
|
|
} resolvers;
|
|
|
|
|
2016-12-01 22:25:16 +00:00
|
|
|
// Resolver provides path resolution to IPFS
|
|
|
|
// It has a pointer to a DAGService, which is uses to resolve nodes.
|
|
|
|
// TODO: now that this is more modular, try to unify this code with the
|
|
|
|
// the resolvers in namesys
|
2016-11-24 10:52:15 +00:00
|
|
|
typedef struct s_resolver {
|
2016-12-01 22:25:16 +00:00
|
|
|
//DAGService DAG;
|
|
|
|
//NodeLink *lnk;
|
2016-11-24 10:52:15 +00:00
|
|
|
// resolveOnce looks up a name once (without recursion).
|
|
|
|
int (*resolveOnce) (char **, char *);
|
|
|
|
} resolver;
|
|
|
|
|
2016-11-23 20:19:16 +00:00
|
|
|
//TODO ciPrivKey from c-libp2p-crypto
|
|
|
|
typedef void* ciPrivKey;
|
|
|
|
|
|
|
|
typedef struct s_publishers {
|
|
|
|
char *protocol;
|
|
|
|
int (*func) (ciPrivKey, char*);
|
|
|
|
int (*func_eol) (ciPrivKey, char*, time_t);
|
|
|
|
} publishers;
|
|
|
|
|
|
|
|
typedef struct s_mpns {
|
|
|
|
resolvers *resolver;
|
|
|
|
publishers *Publisher;
|
|
|
|
} mpns;
|
2016-11-24 10:52:15 +00:00
|
|
|
|
2016-11-24 22:52:19 +00:00
|
|
|
typedef struct s_tlds {
|
|
|
|
char *str;
|
|
|
|
int condition;
|
|
|
|
} tlds;
|
|
|
|
|
2016-11-24 10:52:15 +00:00
|
|
|
int resolve (resolver *r, char **p, char *str, int depth, char **prefixes);
|
|
|
|
int Resolve(char **path, char *name);
|
|
|
|
int ResolveN(char **path, char *name, int depth);
|
|
|
|
int resolveOnce (char **path, char *name);
|
|
|
|
int Publish (char *proto, ciPrivKey name, char *value);
|
|
|
|
int PublishWithEOL (char *proto, ciPrivKey name, char *value, time_t eol);
|
2016-11-24 12:50:05 +00:00
|
|
|
|
2016-12-01 22:32:29 +00:00
|
|
|
int ProquintIsProquint(char *str);
|
|
|
|
char *ProquintEncode(char *buf, int size);
|
|
|
|
char *ProquintDecode(char *str);
|
2016-11-24 12:50:05 +00:00
|
|
|
int ProquintResolveOnce (char **p, char *name);
|
2016-11-24 22:52:19 +00:00
|
|
|
|
|
|
|
int domainMatchString (char *d);
|
|
|
|
int IsICANNTLD(char *s);
|
|
|
|
int IsExtendedTLD (char *s);
|
|
|
|
int IsTLD (char *s);
|
|
|
|
int IsDomain (char *s);
|
2016-11-27 13:57:28 +00:00
|
|
|
|
2016-11-29 23:35:55 +00:00
|
|
|
typedef struct s_DNSResolver {
|
|
|
|
// TODO
|
|
|
|
} DNSResolver;
|
|
|
|
|
2016-11-27 13:57:28 +00:00
|
|
|
int DNSResolverResolveOnce (DNSResolver *r, char **path, char *name);
|
|
|
|
int workDomain (int output, DNSResolver *r, char *name);
|
|
|
|
int parseEntry (char **Path, char *txt);
|
|
|
|
int tryParseDnsLink (char **Path, char *txt);
|
2016-11-23 20:19:16 +00:00
|
|
|
#endif //NAMESYS_H
|