From 19324f142d53a81a15c57d62443e3e5997122ad7 Mon Sep 17 00:00:00 2001 From: xm1k3 Date: Tue, 17 Jan 2023 10:43:55 +0100 Subject: [PATCH] moved example to url --- README.md | 62 +++++++------------------------------------------------ 1 file changed, 7 insertions(+), 55 deletions(-) diff --git a/README.md b/README.md index c37a691..e6dc0a3 100644 --- a/README.md +++ b/README.md @@ -22,61 +22,13 @@ For more details and documentation refer [GoDoc](https://pkg.go.dev/github.com/p # Example -An Example showing usage of fastdialer as a library is specified below: +An Example showing usage of fastdialer as a library is specified [here](./example/main.go) +``` +cd example/ +go run main.go +``` -```go -package main +# License -import ( - "context" - "fmt" - "log" - - "github.com/projectdiscovery/fastdialer/fastdialer" -) - -func main() { - - // refer fastdialer/options.go for options and customization - options := fastdialer.DefaultOptions - - // Create new dialer using NewDialer(opts fastdialer.options) - fd, err := fastdialer.NewDialer(fastdialer.DefaultOptions) - if err != nil { - panic(err) - } - - // Configure Cache if required - // memory based (also support Hybrid and Disk Cache) - options.CacheType = fastdialer.Memory - options.CacheMemoryMaxItems = 100 - - ctx := context.Background() - - // To dial and create connection use - // To create connection over TLS or older versions use - // fd.DialTLS() or fd.DialZTLS() - conn, err := fd.Dial(ctx, "tcp", "www.projectdiscovery.io:80") - if err != nil || conn == nil { - log.Fatalf("couldn't connect to target: %s", err) - } else { - fmt.Println("Connected: TCP stream created with www.projectdiscovery.io:80") - } - conn.Close() - - // To look up Host/ Get DNS details use - data, err := fd.GetDNSData("www.projectdiscovery.io") - if err != nil || data == nil { - log.Fatalf("couldn't retrieve dns data: %s", err) - } - - // To Print All Type of DNS Data use - jsonData, err := data.JSON() - if err != nil { - log.Fatalf("failed to marshal json: %s", err) - } - fmt.Println(jsonData) - -} -``` \ No newline at end of file +fastdialer is distributed under MIT License \ No newline at end of file