Skip to content

Commit

Permalink
Merge pull request #86 from projectdiscovery/issue-84-maintenance-stuff
Browse files Browse the repository at this point in the history
Replace docs example with link to example folder
  • Loading branch information
ehsandeep committed Jan 17, 2023
2 parents 58f5d3b + 19324f1 commit cac748a
Showing 1 changed file with 7 additions and 55 deletions.
62 changes: 7 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

}
```
fastdialer is distributed under MIT License

0 comments on commit cac748a

Please sign in to comment.