diff --git a/dnslink/Makefile b/dnslink/Makefile new file mode 100644 index 0000000..eba3bf4 --- /dev/null +++ b/dnslink/Makefile @@ -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 diff --git a/dnslink/dnslink.c b/dnslink/dnslink.c index d80fe2c..a6b99a5 100644 --- a/dnslink/dnslink.c +++ b/dnslink/dnslink.c @@ -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 diff --git a/main/Makefile b/main/Makefile index 7c74a8a..256b9a9 100644 --- a/main/Makefile +++ b/main/Makefile @@ -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 \ No newline at end of file + rm -f ipfs diff --git a/main/ipfs b/main/ipfs index 388725d..223aa74 100755 Binary files a/main/ipfs and b/main/ipfs differ diff --git a/main/main.c b/main/main.c index 2fdc626..d8b9136 100644 --- a/main/main.c +++ b/main/main.c @@ -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; } } diff --git a/namesys/Makefile b/namesys/Makefile new file mode 100644 index 0000000..8dab9f6 --- /dev/null +++ b/namesys/Makefile @@ -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 diff --git a/path/Makefile b/path/Makefile new file mode 100644 index 0000000..022f82c --- /dev/null +++ b/path/Makefile @@ -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 diff --git a/util/Makefile b/util/Makefile new file mode 100644 index 0000000..559e417 --- /dev/null +++ b/util/Makefile @@ -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