nameresolve

package
v0.7.10 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDuplicateNameResolve = errors.New("Each name must resolve to a unique set of rules - duplciate found")
View Source
var ErrUnableToParse = errors.New("Unable to parse url")

Functions

func GetProtoHostPort

func GetProtoHostPort(name string) (proto, host, port string, err error)

func IsIp4

func IsIp4(s string) bool

func NoWild

func NoWild(host string) (rv string)

remove leading *. from host pattern to get domain name for IP lookup

Types

type CacheIP

type CacheIP struct {
	Data map[string]CacheIPData
	// contains filtered or unexported fields
}
var CIp CacheIP

func (*CacheIP) CachedLookupIP

func (cc *CacheIP) CachedLookupIP(host string) (ip []net.IP, err error)

type CacheIPData

type CacheIPData struct {
	IP []net.IP

	When time.Time // When saved
	// contains filtered or unexported fields
}

IPs, err := net.LookupIP(host) // xyzzy - fast enough - need to cache?

type IpToHostPort

type IpToHostPort struct {
	Host    string
	Port    string
	Proto   string
	IPAddr  string
	Handler http.Handler
	Id      int
}

type NameResolve

type NameResolve struct {
	IpLookup  map[string]map[string]*IpToHostPort //
	RawLookup map[string]*IpToHostPort
	Debug1    bool //
	Debug2    bool // Use In: func GetProtoHostPort(name string) (proto, host, port string, err error)
	Debug3    bool //
	Debug4    bool //
	Debug5    bool //
	// contains filtered or unexported fields
}

func NewNameResolve

func NewNameResolve() *NameResolve

func (*NameResolve) AddDefault

func (nr *NameResolve) AddDefault(proto, port string, hdlr http.Handler, id int) (e error)

func (*NameResolve) AddName

func (nr *NameResolve) AddName(namePattern string, hdlr http.Handler, id int, addrIfNone string) (e error)

func (*NameResolve) GetHandler

func (nr *NameResolve) GetHandler(name string) (rv *IpToHostPort, ok bool)

This is the name matcher for HTTP requests - it returns the correct handler. This means that if we are to dynamically configure - then this is the place to do it - We could use the "Id" to re-lookup (index) the handler from a table and pull it out Every time - that alone would lead to all new connections are based on new config.

name may be bob.test1.com - and match to bob.test1.com, if not look for *.test1.com, then *.*.com, then *.com

func (*NameResolve) GetRawTopHandler

func (nr *NameResolve) GetRawTopHandler(listen string) (Handler http.Handler, err error)

p1, err := bot.GetRawTopHandler ( listen );

func (*NameResolve) ServeHTTP

func (nr *NameResolve) ServeHTTP(www http.ResponseWriter, req *http.Request)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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