Skip to content

jusk9527/fastdialer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fastdialer

License Go version Release Checks GoDoc

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.

Example

An Example showing usage of fastdialer as a library is specified below:

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)

}

About

Dialer with DNS Cache + Dial History

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%