Some changes at namesys.

This commit is contained in:
Jose Marcial Vieira Bisneto 2016-12-23 00:28:30 -03:00
parent da4b1f86f4
commit 049078effc
2 changed files with 9 additions and 4 deletions

View file

@ -59,10 +59,11 @@
typedef struct s_DNSResolver { typedef struct s_DNSResolver {
// TODO // TODO
int (*lookupTXT) (char ***, char *);
} DNSResolver; } DNSResolver;
int ipfs_dns_resolver_resolve_once (DNSResolver *r, char **path, char *name); int ipfs_dns_resolver_resolve_once (char **path, char *name);
int ipfs_dns_work_domain (int output, DNSResolver *r, char *name); int ipfs_dns_work_domain (int output, DNSResolver *r, char *name);
int ipfs_dns_parse_entry (char **Path, char *txt); int ipfs_dns_parse_entry (char **path, char *txt);
int ipfs_dns_try_parse_dns_link (char **Path, char *txt); int ipfs_dns_try_parse_dns_link(char **path, char *txt);
#endif //NAMESYS_H #endif //NAMESYS_H

View file

@ -4,6 +4,7 @@
#include "ipfs/cid/cid.h" #include "ipfs/cid/cid.h"
#include "ipfs/path/path.h" #include "ipfs/path/path.h"
#include "ipfs/namesys/namesys.h" #include "ipfs/namesys/namesys.h"
#include "ipfs/dnslink/dnslink.h"
/* mpns (a multi-protocol NameSystem) implements generic IPFS naming. /* mpns (a multi-protocol NameSystem) implements generic IPFS naming.
* *
@ -31,7 +32,7 @@ func NewNameSystem(r routing.ValueStore, ds ds.Datastore, cachesize int) NameSys
} }
}*/ }*/
const DefaultResolverCacheTTL = time.Minute; const DefaultResolverCacheTTL = 60;
// ipfs_namesys_resolve implements Resolver. // ipfs_namesys_resolve implements Resolver.
int ipfs_namesys_resolve(char **path, char *name) int ipfs_namesys_resolve(char **path, char *name)
@ -94,11 +95,14 @@ int ipfs_namesys_resolve_once (char **path, char *name)
char *ptr = NULL; char *ptr = NULL;
char **segs; char **segs;
int i, err = 0; int i, err = 0;
struct DNSResolver dnsr;
if (!name) { // NULL pointer. if (!name) { // NULL pointer.
return ErrNULLPointer; return ErrNULLPointer;
} }
dnsr.lookupTXT = ipfs_dnslink_resolv_lookupTXT;
if (memcmp (name, ipns_prefix, strlen(ipns_prefix)) == 0) { // prefix missing. if (memcmp (name, ipns_prefix, strlen(ipns_prefix)) == 0) { // prefix missing.
i = strlen(name) + sizeof(ipns_prefix); i = strlen(name) + sizeof(ipns_prefix);
ptr = malloc(i); ptr = malloc(i);