dependency

package
v0.0.0-...-3d855e8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 23, 2018 License: BSD-2-Clause Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Request

type Request struct {
	// contains filtered or unexported fields
}

TODO revoir cet exemple !

Request struct represents a request sent to fetch the dependency tree about a domain name.

It is initialized by calling NewRequest. A request is passed to the Finder.Handle() method. The result of the Finder handling is obtained by calling the request Result() method.

import (
	"github.com/ANSSI-FR/transdep/graph"
	"github.com/ANSSI-FR/transdep/dependency"
	"github.com/ANSSI-FR/transdep/tools"
)

func example(f *dependency.Finder, domain string) *graph.Node {
	r := NewRequest(domain, false, false)
	f.Handle(r)
	result, err := r.Result()
	if err != nil {
		if err == tools.ERROR_TIMEOUT {
			fmt.Printf("Timeout during resolution of %s\n", domain)
		} else {
			fmt.Println(err)
		}
		return
	} else if result.Err != nil {
		fmt.Println(result.Err)
		return
	}
	graph := result.Result
	return graph
}

func NewRequest

func NewRequest(domain string, resolveName, includeIP bool, except tools.Exceptions) *Request
NewRequest builds a new request from a context-free perspective.

This is mainly used when making a request that is completely unrelated to any other request. Thus, it should be used by the dependency finder users to submit requests.

domain is the domain name that is requested for dependency resolution

resolveName indicates whether we are interested in following an eventual CNAME that is found at the requested domain name. False indicates that we only want the dependency tree for the parent domains of the requested name and the delegation info to that name.

includeIP indicates that on top of following the eventual CNAME, we want the IP addresses associated to the requested domain name

func NewRequestWithContext

func NewRequestWithContext(domain string, resolveName, includeIP bool, parentReq *Request, depth int) *Request
NewRequestWithContext builds a new request that is built in the context of the resolution of another request. Thus,

it is possible that loops get created, if a request is dependent on the resolution of another request which is dependent on the result of the resolution of the first request. Building a request using NewRequestWithContext will prevent this by using the DetectCycle() method whenever appropriate.

func (*Request) Depth

func (dr *Request) Depth() int

Returns the depth of the current request. This is used to detect overly long alias chains

func (*Request) DetectCycle

func (dr *Request) DetectCycle() bool

DetectCycle returns true if this request creates a dependency cycle

func (*Request) Equal

func (dr *Request) Equal(other *Request) bool

func (*Request) Exceptions

func (dr *Request) Exceptions() tools.Exceptions

func (*Request) FollowAlias

func (dr *Request) FollowAlias() bool

FollowAlias is the getter of the FollowAlias value part of the topic of this request.

func (*Request) IncludeIP

func (dr *Request) IncludeIP() bool

IncludeIP is the getter of the IncludeIP value part of the topic of this request.

func (*Request) Name

func (dr *Request) Name() string

Name is the getter of the domain name that is the topic of this request.

func (*Request) ResolveTargetName

func (dr *Request) ResolveTargetName() bool
ResolveTargetName indicates whether the requester is interested in the value of the requested name (the CNAME and

its dependency tree or the IP addresses) or if the request topic is only the dependency graph of the apex of the zone containing the requested domain name.

func (*Request) Result

func (dr *Request) Result() (graph.Node, *errors.ErrorStack)
Result returns the result that is set by SetResult().

If the result is yet to be known when this method is called, a timeout duration is waited and if there are still no result available after that period, tools.ERROR_TIMEOUT is returned as an error. The specific timeout duration may be specified if the default one is not appropriate, using the ResultWithSpecificTimeout() method, instead of calling Result()

func (*Request) ResultWithSpecificTimeout

func (dr *Request) ResultWithSpecificTimeout(dur time.Duration) (graph.Node, *errors.ErrorStack)

ResultWithSpecificTimeout usage is described in the documentation of Request.Result()

func (*Request) SetResult

func (dr *Request) SetResult(g graph.Node, err *errors.ErrorStack)

SetResult records the result of this request. This function must only be called once per request, although nothing enforces it at the moment...

func (*Request) Topic

func (dr *Request) Topic() RequestTopic

Topic is the getter of the request topic as specified during this request initialization

type RequestTopic

type RequestTopic struct {
	// contains filtered or unexported fields
}
RequestTopic is a key used to uniquely represent a request.

This may be used in order to detect request loops and circular dependencies, and to identify the topic of a dependency resolver worker.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL