Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #76 from projectdiscovery/issue-70-docs-maintenance
Adds docs, example and more
- Loading branch information
Showing
5 changed files
with
175 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,82 @@ | ||
# Fastdialer | ||
Dialer with DNS Cache + Dial History | ||
|
||
[![License](https://img.shields.io/github/license/projectdiscovery/fastdialer)](LICENSE.md) | ||
![Go version](https://img.shields.io/github/go-mod/go-version/projectdiscovery/fastdialer?filename=go.mod) | ||
[![Release](https://img.shields.io/github/release/projectdiscovery/fastdialer)](https://github.com/projectdiscovery/fastdialer/releases/) | ||
[![Checks](https://github.com/projectdiscovery/fastdialer/actions/workflows/build-test.yml/badge.svg)](https://github.com/projectdiscovery/fastdialer/actions/workflows/build-test.yml) | ||
[![GoDoc](https://pkg.go.dev/badge/projectdiscovery/fastdialer)](https://pkg.go.dev/github.com/projectdiscovery/fastdialer/fastdialer) | ||
|
||
|
||
Fastdialer is implementation of `net.Dialer` with lot of features like DNS Cache , Dial History etc | ||
|
||
# Features | ||
|
||
- DNS Cache | ||
- Dial History | ||
- Supports Memory/Hybrid/Disk Cache. | ||
- Supports Old/New TLS and x509 versions | ||
- Supports Resolution Using Hosts File | ||
- Cross Platform and more.. | ||
|
||
For more details and documentation refer [GoDoc](https://pkg.go.dev/github.com/projectdiscovery/fastdialer/fastdialer). | ||
|
||
# Example | ||
|
||
An Example showing usage of fastdialer as a library is specified below: | ||
|
||
|
||
```go | ||
package main | ||
|
||
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) | ||
|
||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package main | ||
|
||
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) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,49 @@ | ||
module github.com/projectdiscovery/fastdialer | ||
|
||
go 1.14 | ||
go 1.18 | ||
|
||
require ( | ||
github.com/akrylysov/pogreb v0.10.1 // indirect | ||
github.com/dimchansky/utfbom v1.1.1 | ||
github.com/golang/snappy v0.0.4 // indirect | ||
github.com/kr/pretty v0.3.0 // indirect | ||
github.com/pkg/errors v0.9.1 | ||
github.com/projectdiscovery/hmap v0.0.2-0.20210917080408-0fd7bd286bfa | ||
github.com/projectdiscovery/networkpolicy v0.0.1 | ||
github.com/projectdiscovery/retryabledns v1.0.17 | ||
github.com/projectdiscovery/utils v0.0.2 | ||
github.com/rogpeppe/go-internal v1.8.0 // indirect | ||
github.com/stretchr/testify v1.8.1 | ||
github.com/ulule/deepcopier v0.0.0-20200430083143-45decc6639b6 | ||
github.com/zmap/zcrypto v0.0.0-20220803033029-557f3e4940be | ||
go.etcd.io/bbolt v1.3.6 // indirect | ||
golang.org/x/net v0.1.0 | ||
google.golang.org/protobuf v1.27.1 // indirect | ||
) | ||
|
||
require ( | ||
github.com/akrylysov/pogreb v0.10.1 // indirect | ||
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect | ||
github.com/aymerick/douceur v0.2.0 // indirect | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/golang/snappy v0.0.4 // indirect | ||
github.com/gorilla/css v1.0.0 // indirect | ||
github.com/kr/pretty v0.3.0 // indirect | ||
github.com/microcosm-cc/bluemonday v1.0.21 // indirect | ||
github.com/miekg/dns v1.1.50 // indirect | ||
github.com/pmezard/go-difflib v1.0.0 // indirect | ||
github.com/projectdiscovery/fileutil v0.0.3 // indirect | ||
github.com/projectdiscovery/iputil v0.0.2 // indirect | ||
github.com/projectdiscovery/retryablehttp-go v1.0.2 // indirect | ||
github.com/projectdiscovery/sliceutil v0.0.1 // indirect | ||
github.com/projectdiscovery/stringsutil v0.0.2 // indirect | ||
github.com/rogpeppe/go-internal v1.8.0 // indirect | ||
github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca // indirect | ||
github.com/syndtr/goleveldb v1.0.0 // indirect | ||
github.com/weppos/publicsuffix-go v0.15.1-0.20220724114530-e087fba66a37 // indirect | ||
github.com/yl2chen/cidranger v1.0.2 // indirect | ||
github.com/zmap/rc2 v0.0.0-20131011165748-24b9757f5521 // indirect | ||
go.etcd.io/bbolt v1.3.6 // indirect | ||
go.uber.org/atomic v1.10.0 // indirect | ||
go.uber.org/multierr v1.8.0 // indirect | ||
golang.org/x/crypto v0.1.0 // indirect | ||
golang.org/x/mod v0.6.0 // indirect | ||
golang.org/x/sys v0.1.0 // indirect | ||
golang.org/x/text v0.4.0 // indirect | ||
golang.org/x/tools v0.2.0 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters