Added command ipfs dns

yamux
Jose Marcial Vieira Bisneto 2016-12-23 00:51:06 -03:00
parent 5f22be643c
commit a569159cc2
8 changed files with 114 additions and 2 deletions

18
dnslink/Makefile Normal file
View File

@ -0,0 +1,18 @@
CC = gcc
CFLAGS = -O0 -I../include -I../../c-libp2p/include -I../../c-multihash/include -I../../c-multiaddr/include -I../../c-protobuf -Wall
ifdef DEBUG
CFLAGS += -g3
endif
LFLAGS =
DEPS =
OBJS = dnslink.o
%.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
all: $(OBJS)
clean:
rm -f *.o

View File

@ -55,6 +55,35 @@ Expect these resolutions:
#include "ipfs/cid/cid.h"
#include "ipfs/path/path.h"
int ipfs_dns (int argc, char **argv)
{
int err;
char **txt, *path;
if (argc != 3) {
fprintf (stderr, "usage: ipfs dns dns.name.com\n");
return -1;
}
err = ipfs_dnslink_resolv_lookupTXT (&txt, argv[2]);
if (err) {
fprintf (stderr, "dns lookupTXT: %s\n", Err[err]);
return err;
}
err = ipfs_dnslink_parse_txt(&path, *txt);
if (err) {
fprintf (stderr, "dns parse_txt: %s\n", Err[err]);
return err;
}
free (*txt);
free (txt);
fprintf (stdout, "%s\n", path);
free (path);
return 0;
}
// ipfs_dnslink_resolve resolves the dnslink at a particular domain. It will
// recursively keep resolving until reaching the defaultDepth of Resolver. If
// the depth is reached, ipfs_dnslink_resolve will return the last value

View File

@ -1,6 +1,6 @@
CC = gcc
CFLAGS = -O0 -I../include -I../../c-libp2p/include -I../../c-multihash/include -I../../c-multiaddr/ -I../../c-protobuf -g3 -Wall
LFLAGS = -L../../c-libp2p -L../../c-multihash -L../../c-multiaddr -lp2p -lm -lmultihash -lmultiaddr -lpthread
LFLAGS = -L../../c-libp2p -L../../c-multihash -L../../c-multiaddr -lp2p -lm -lmultihash -lmultiaddr -lpthread -lresolv
DEPS = cmd/ipfs/test_init.h repo/test_repo_bootstrap_peers.h repo/test_repo_config.h repo/test_repo_identity.h cid/test_cid.h
OBJS = main.o \
../blocks/block.o ../blocks/blockstore.o \
@ -12,6 +12,9 @@ OBJS = main.o \
../flatfs/flatfs.o \
../importer/importer.o \
../importer/exporter.o \
../dnslink/dnslink.o \
../path/path.o \
../namesys/isdomain.o \
../merkledag/merkledag.o ../merkledag/node.o \
../multibase/multibase.o \
../os/utils.o \
@ -34,4 +37,4 @@ all: ipfs
clean:
rm -f *.o
rm -f ipfs
rm -f ipfs

BIN
main/ipfs

Binary file not shown.

View File

@ -4,6 +4,7 @@
#include "ipfs/repo/init.h"
#include "ipfs/importer/importer.h"
#include "ipfs/importer/exporter.h"
#include "ipfs/dnslink/dnslink.h"
void stripit(int argc, char** argv) {
char tmp[strlen(argv[argc])];
@ -24,6 +25,7 @@ void strip_quotes(int argc, char** argv) {
#define INIT 1
#define ADD 2
#define OBJECT_GET 3
#define DNS 4
/***
* Basic parsing of command line arguments to figure out where the user wants to go
@ -42,6 +44,9 @@ int parse_arguments(int argc, char** argv) {
if (strcmp("object", argv[1]) == 0 && argc > 2 && strcmp("get", argv[2]) == 0) {
return OBJECT_GET;
}
if (strcmp("dns", argv[1]) == 0) {
return DNS;
}
return -1;
}
@ -61,5 +66,8 @@ int main(int argc, char** argv) {
case (OBJECT_GET):
ipfs_exporter_object_get(argc, argv);
break;
case (DNS):
ipfs_dns(argc, argv);
break;
}
}

18
namesys/Makefile Normal file
View File

@ -0,0 +1,18 @@
CC = gcc
CFLAGS = -O0 -I../include -I../../c-libp2p/include -I../../c-multihash/include -I../../c-multiaddr/include -I../../c-protobuf -Wall
ifdef DEBUG
CFLAGS += -g3
endif
LFLAGS =
DEPS =
OBJS = base.o dns.o isdomain.o namesys.o pb.o proquint.o publisher.o routing.o
%.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
all: $(OBJS)
clean:
rm -f *.o

18
path/Makefile Normal file
View File

@ -0,0 +1,18 @@
CC = gcc
CFLAGS = -O0 -I../include -I../../c-libp2p/include -I../../c-multihash/include -I../../c-multiaddr/include -I../../c-protobuf -Wall
ifdef DEBUG
CFLAGS += -g3
endif
LFLAGS =
DEPS =
OBJS = path.o
%.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
all: $(OBJS)
clean:
rm -f *.o

18
util/Makefile Normal file
View File

@ -0,0 +1,18 @@
CC = gcc
CFLAGS = -O0 -I../include -I../../c-libp2p/include -I../../c-multihash/include -I../../c-multiaddr/include -I../../c-protobuf -Wall
ifdef DEBUG
CFLAGS += -g3
endif
LFLAGS =
DEPS =
OBJS = errs.o time.o
%.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
all: $(OBJS)
clean:
rm -f *.o