id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
130,700
coredns/coredns
plugin/ready/list.go
Ready
func (l *list) Ready() (bool, string) { l.RLock() defer l.RUnlock() ok := true s := []string{} for i, r := range l.rs { if r == nil { continue } if !r.Ready() { ok = false s = append(s, l.names[i]) } else { // if ok, this plugin is ready and will not be queried anymore. l.rs[i] = nil } } ...
go
func (l *list) Ready() (bool, string) { l.RLock() defer l.RUnlock() ok := true s := []string{} for i, r := range l.rs { if r == nil { continue } if !r.Ready() { ok = false s = append(s, l.names[i]) } else { // if ok, this plugin is ready and will not be queried anymore. l.rs[i] = nil } } ...
[ "func", "(", "l", "*", "list", ")", "Ready", "(", ")", "(", "bool", ",", "string", ")", "{", "l", ".", "RLock", "(", ")", "\n", "defer", "l", ".", "RUnlock", "(", ")", "\n", "ok", ":=", "true", "\n", "s", ":=", "[", "]", "string", "{", "}",...
// Ready return true when all plugins ready, if the returned value is false the string // contains a comma separated list of plugins that are not ready.
[ "Ready", "return", "true", "when", "all", "plugins", "ready", "if", "the", "returned", "value", "is", "false", "the", "string", "contains", "a", "comma", "separated", "list", "of", "plugins", "that", "are", "not", "ready", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/ready/list.go#L26-L48
130,701
coredns/coredns
plugin/dnssec/dnssec.go
New
func New(zones []string, keys []*DNSKEY, splitkeys bool, next plugin.Handler, c *cache.Cache) Dnssec { return Dnssec{Next: next, zones: zones, keys: keys, splitkeys: splitkeys, cache: c, inflight: new(singleflight.Group), } }
go
func New(zones []string, keys []*DNSKEY, splitkeys bool, next plugin.Handler, c *cache.Cache) Dnssec { return Dnssec{Next: next, zones: zones, keys: keys, splitkeys: splitkeys, cache: c, inflight: new(singleflight.Group), } }
[ "func", "New", "(", "zones", "[", "]", "string", ",", "keys", "[", "]", "*", "DNSKEY", ",", "splitkeys", "bool", ",", "next", "plugin", ".", "Handler", ",", "c", "*", "cache", ".", "Cache", ")", "Dnssec", "{", "return", "Dnssec", "{", "Next", ":", ...
// New returns a new Dnssec.
[ "New", "returns", "a", "new", "Dnssec", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/dnssec/dnssec.go#L29-L37
130,702
coredns/coredns
plugin/file/lookup.go
additionalProcessing
func (z *Zone) additionalProcessing(ctx context.Context, state request.Request, elem *tree.Elem, rrs []dns.RR) ([]dns.RR, []dns.RR, []dns.RR, Result) { qtype := state.QType() do := state.Do() if do { sigs := elem.Types(dns.TypeRRSIG) sigs = signatureForSubType(sigs, dns.TypeCNAME) if len(sigs) > 0 { rrs =...
go
func (z *Zone) additionalProcessing(ctx context.Context, state request.Request, elem *tree.Elem, rrs []dns.RR) ([]dns.RR, []dns.RR, []dns.RR, Result) { qtype := state.QType() do := state.Do() if do { sigs := elem.Types(dns.TypeRRSIG) sigs = signatureForSubType(sigs, dns.TypeCNAME) if len(sigs) > 0 { rrs =...
[ "func", "(", "z", "*", "Zone", ")", "additionalProcessing", "(", "ctx", "context", ".", "Context", ",", "state", "request", ".", "Request", ",", "elem", "*", "tree", ".", "Elem", ",", "rrs", "[", "]", "dns", ".", "RR", ")", "(", "[", "]", "dns", ...
// aditionalProcessing adds signatures and tries to resolve CNAMEs that point to external names.
[ "aditionalProcessing", "adds", "signatures", "and", "tries", "to", "resolve", "CNAMEs", "that", "point", "to", "external", "names", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/file/lookup.go#L301-L364
130,703
coredns/coredns
plugin/file/lookup.go
signatureForSubType
func signatureForSubType(rrs []dns.RR, subtype uint16) []dns.RR { sigs := []dns.RR{} for _, sig := range rrs { if s, ok := sig.(*dns.RRSIG); ok { if s.TypeCovered == subtype { sigs = append(sigs, s) } } } return sigs }
go
func signatureForSubType(rrs []dns.RR, subtype uint16) []dns.RR { sigs := []dns.RR{} for _, sig := range rrs { if s, ok := sig.(*dns.RRSIG); ok { if s.TypeCovered == subtype { sigs = append(sigs, s) } } } return sigs }
[ "func", "signatureForSubType", "(", "rrs", "[", "]", "dns", ".", "RR", ",", "subtype", "uint16", ")", "[", "]", "dns", ".", "RR", "{", "sigs", ":=", "[", "]", "dns", ".", "RR", "{", "}", "\n", "for", "_", ",", "sig", ":=", "range", "rrs", "{", ...
// signatureForSubType range through the signature and return the correct ones for the subtype.
[ "signatureForSubType", "range", "through", "the", "signature", "and", "return", "the", "correct", "ones", "for", "the", "subtype", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/file/lookup.go#L388-L398
130,704
coredns/coredns
plugin/file/lookup.go
Glue
func (z *Zone) Glue(nsrrs []dns.RR, do bool) []dns.RR { glue := []dns.RR{} for _, rr := range nsrrs { if ns, ok := rr.(*dns.NS); ok && dns.IsSubDomain(ns.Header().Name, ns.Ns) { glue = append(glue, z.searchGlue(ns.Ns, do)...) } } return glue }
go
func (z *Zone) Glue(nsrrs []dns.RR, do bool) []dns.RR { glue := []dns.RR{} for _, rr := range nsrrs { if ns, ok := rr.(*dns.NS); ok && dns.IsSubDomain(ns.Header().Name, ns.Ns) { glue = append(glue, z.searchGlue(ns.Ns, do)...) } } return glue }
[ "func", "(", "z", "*", "Zone", ")", "Glue", "(", "nsrrs", "[", "]", "dns", ".", "RR", ",", "do", "bool", ")", "[", "]", "dns", ".", "RR", "{", "glue", ":=", "[", "]", "dns", ".", "RR", "{", "}", "\n", "for", "_", ",", "rr", ":=", "range",...
// Glue returns any potential glue records for nsrrs.
[ "Glue", "returns", "any", "potential", "glue", "records", "for", "nsrrs", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/file/lookup.go#L401-L409
130,705
coredns/coredns
plugin/file/lookup.go
searchGlue
func (z *Zone) searchGlue(name string, do bool) []dns.RR { glue := []dns.RR{} // A if elem, found := z.Tree.Search(name); found { glue = append(glue, elem.Types(dns.TypeA)...) if do { sigs := elem.Types(dns.TypeRRSIG) sigs = signatureForSubType(sigs, dns.TypeA) glue = append(glue, sigs...) } } // ...
go
func (z *Zone) searchGlue(name string, do bool) []dns.RR { glue := []dns.RR{} // A if elem, found := z.Tree.Search(name); found { glue = append(glue, elem.Types(dns.TypeA)...) if do { sigs := elem.Types(dns.TypeRRSIG) sigs = signatureForSubType(sigs, dns.TypeA) glue = append(glue, sigs...) } } // ...
[ "func", "(", "z", "*", "Zone", ")", "searchGlue", "(", "name", "string", ",", "do", "bool", ")", "[", "]", "dns", ".", "RR", "{", "glue", ":=", "[", "]", "dns", ".", "RR", "{", "}", "\n\n", "// A", "if", "elem", ",", "found", ":=", "z", ".", ...
// searchGlue looks up A and AAAA for name.
[ "searchGlue", "looks", "up", "A", "and", "AAAA", "for", "name", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/file/lookup.go#L412-L435
130,706
coredns/coredns
plugin/rewrite/fuzz.go
Fuzz
func Fuzz(data []byte) int { c := caddy.NewTestController("dns", "rewrite edns0 subnet set 24 56") rules, err := rewriteParse(c) if err != nil { return 0 } r := Rewrite{Rules: rules} return fuzz.Do(r, data) }
go
func Fuzz(data []byte) int { c := caddy.NewTestController("dns", "rewrite edns0 subnet set 24 56") rules, err := rewriteParse(c) if err != nil { return 0 } r := Rewrite{Rules: rules} return fuzz.Do(r, data) }
[ "func", "Fuzz", "(", "data", "[", "]", "byte", ")", "int", "{", "c", ":=", "caddy", ".", "NewTestController", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "rules", ",", "err", ":=", "rewriteParse", "(", "c", ")", "\n", "if", "err", "!=", "nil", ...
// Fuzz fuzzes rewrite.
[ "Fuzz", "fuzzes", "rewrite", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/rewrite/fuzz.go#L12-L21
130,707
coredns/coredns
plugin/etcd/msg/path.go
Domain
func Domain(s string) string { l := strings.Split(s, "/") // start with 1, to strip /skydns for i, j := 1, len(l)-1; i < j; i, j = i+1, j-1 { l[i], l[j] = l[j], l[i] } return dnsutil.Join(l[1 : len(l)-1]...) }
go
func Domain(s string) string { l := strings.Split(s, "/") // start with 1, to strip /skydns for i, j := 1, len(l)-1; i < j; i, j = i+1, j-1 { l[i], l[j] = l[j], l[i] } return dnsutil.Join(l[1 : len(l)-1]...) }
[ "func", "Domain", "(", "s", "string", ")", "string", "{", "l", ":=", "strings", ".", "Split", "(", "s", ",", "\"", "\"", ")", "\n", "// start with 1, to strip /skydns", "for", "i", ",", "j", ":=", "1", ",", "len", "(", "l", ")", "-", "1", ";", "i...
// Domain is the opposite of Path.
[ "Domain", "is", "the", "opposite", "of", "Path", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/etcd/msg/path.go#L23-L30
130,708
coredns/coredns
core/dnsserver/server.go
NewServer
func NewServer(addr string, group []*Config) (*Server, error) { s := &Server{ Addr: addr, zones: make(map[string]*Config), graceTimeout: 5 * time.Second, } // We have to bound our wg with one increment // to prevent a "race condition" that is hard-coded // into sync.WaitGroup.Wait() - basica...
go
func NewServer(addr string, group []*Config) (*Server, error) { s := &Server{ Addr: addr, zones: make(map[string]*Config), graceTimeout: 5 * time.Second, } // We have to bound our wg with one increment // to prevent a "race condition" that is hard-coded // into sync.WaitGroup.Wait() - basica...
[ "func", "NewServer", "(", "addr", "string", ",", "group", "[", "]", "*", "Config", ")", "(", "*", "Server", ",", "error", ")", "{", "s", ":=", "&", "Server", "{", "Addr", ":", "addr", ",", "zones", ":", "make", "(", "map", "[", "string", "]", "...
// NewServer returns a new CoreDNS server and compiles all plugins in to it. By default CH class // queries are blocked unless queries from enableChaos are loaded.
[ "NewServer", "returns", "a", "new", "CoreDNS", "server", "and", "compiles", "all", "plugins", "in", "to", "it", ".", "By", "default", "CH", "class", "queries", "are", "blocked", "unless", "queries", "from", "enableChaos", "are", "loaded", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/core/dnsserver/server.go#L46-L94
130,709
coredns/coredns
core/dnsserver/server.go
ServePacket
func (s *Server) ServePacket(p net.PacketConn) error { s.m.Lock() s.server[udp] = &dns.Server{PacketConn: p, Net: "udp", Handler: dns.HandlerFunc(func(w dns.ResponseWriter, r *dns.Msg) { ctx := context.WithValue(context.Background(), Key{}, s) s.ServeDNS(ctx, w, r) })} s.m.Unlock() return s.server[udp].Activa...
go
func (s *Server) ServePacket(p net.PacketConn) error { s.m.Lock() s.server[udp] = &dns.Server{PacketConn: p, Net: "udp", Handler: dns.HandlerFunc(func(w dns.ResponseWriter, r *dns.Msg) { ctx := context.WithValue(context.Background(), Key{}, s) s.ServeDNS(ctx, w, r) })} s.m.Unlock() return s.server[udp].Activa...
[ "func", "(", "s", "*", "Server", ")", "ServePacket", "(", "p", "net", ".", "PacketConn", ")", "error", "{", "s", ".", "m", ".", "Lock", "(", ")", "\n", "s", ".", "server", "[", "udp", "]", "=", "&", "dns", ".", "Server", "{", "PacketConn", ":",...
// ServePacket starts the server with an existing packetconn. It blocks until the server stops. // This implements caddy.UDPServer interface.
[ "ServePacket", "starts", "the", "server", "with", "an", "existing", "packetconn", ".", "It", "blocks", "until", "the", "server", "stops", ".", "This", "implements", "caddy", ".", "UDPServer", "interface", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/core/dnsserver/server.go#L111-L120
130,710
coredns/coredns
core/dnsserver/server.go
Tracer
func (s *Server) Tracer() ot.Tracer { if s.trace == nil { return nil } return s.trace.Tracer() }
go
func (s *Server) Tracer() ot.Tracer { if s.trace == nil { return nil } return s.trace.Tracer() }
[ "func", "(", "s", "*", "Server", ")", "Tracer", "(", ")", "ot", ".", "Tracer", "{", "if", "s", ".", "trace", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "return", "s", ".", "trace", ".", "Tracer", "(", ")", "\n", "}" ]
// Tracer returns the tracer in the server if defined.
[ "Tracer", "returns", "the", "tracer", "in", "the", "server", "if", "defined", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/core/dnsserver/server.go#L308-L314
130,711
coredns/coredns
core/dnsserver/server.go
errorFunc
func errorFunc(server string, w dns.ResponseWriter, r *dns.Msg, rc int) { state := request.Request{W: w, Req: r} answer := new(dns.Msg) answer.SetRcode(r, rc) state.SizeAndDo(answer) w.WriteMsg(answer) }
go
func errorFunc(server string, w dns.ResponseWriter, r *dns.Msg, rc int) { state := request.Request{W: w, Req: r} answer := new(dns.Msg) answer.SetRcode(r, rc) state.SizeAndDo(answer) w.WriteMsg(answer) }
[ "func", "errorFunc", "(", "server", "string", ",", "w", "dns", ".", "ResponseWriter", ",", "r", "*", "dns", ".", "Msg", ",", "rc", "int", ")", "{", "state", ":=", "request", ".", "Request", "{", "W", ":", "w", ",", "Req", ":", "r", "}", "\n\n", ...
// errorFunc responds to an DNS request with an error.
[ "errorFunc", "responds", "to", "an", "DNS", "request", "with", "an", "error", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/core/dnsserver/server.go#L317-L325
130,712
coredns/coredns
plugin/cache/freq/freq.go
Update
func (f *Freq) Update(d time.Duration, now time.Time) int { earliest := now.Add(-1 * d) f.Lock() defer f.Unlock() if f.last.Before(earliest) { f.last = now f.hits = 1 return f.hits } f.last = now f.hits++ return f.hits }
go
func (f *Freq) Update(d time.Duration, now time.Time) int { earliest := now.Add(-1 * d) f.Lock() defer f.Unlock() if f.last.Before(earliest) { f.last = now f.hits = 1 return f.hits } f.last = now f.hits++ return f.hits }
[ "func", "(", "f", "*", "Freq", ")", "Update", "(", "d", "time", ".", "Duration", ",", "now", "time", ".", "Time", ")", "int", "{", "earliest", ":=", "now", ".", "Add", "(", "-", "1", "*", "d", ")", "\n", "f", ".", "Lock", "(", ")", "\n", "d...
// Update updates the number of hits. Last time seen will be set to now. // If the last time we've seen this entity is within now - d, we increment hits, otherwise // we reset hits to 1. It returns the number of hits.
[ "Update", "updates", "the", "number", "of", "hits", ".", "Last", "time", "seen", "will", "be", "set", "to", "now", ".", "If", "the", "last", "time", "we", "ve", "seen", "this", "entity", "is", "within", "now", "-", "d", "we", "increment", "hits", "ot...
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/cache/freq/freq.go#L28-L40
130,713
coredns/coredns
plugin/cache/freq/freq.go
Hits
func (f *Freq) Hits() int { f.RLock() defer f.RUnlock() return f.hits }
go
func (f *Freq) Hits() int { f.RLock() defer f.RUnlock() return f.hits }
[ "func", "(", "f", "*", "Freq", ")", "Hits", "(", ")", "int", "{", "f", ".", "RLock", "(", ")", "\n", "defer", "f", ".", "RUnlock", "(", ")", "\n", "return", "f", ".", "hits", "\n", "}" ]
// Hits returns the number of hits that we have seen, according to the updates we have done to f.
[ "Hits", "returns", "the", "number", "of", "hits", "that", "we", "have", "seen", "according", "to", "the", "updates", "we", "have", "done", "to", "f", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/cache/freq/freq.go#L43-L47
130,714
coredns/coredns
plugin/cache/freq/freq.go
Reset
func (f *Freq) Reset(t time.Time, hits int) { f.Lock() defer f.Unlock() f.last = t f.hits = hits }
go
func (f *Freq) Reset(t time.Time, hits int) { f.Lock() defer f.Unlock() f.last = t f.hits = hits }
[ "func", "(", "f", "*", "Freq", ")", "Reset", "(", "t", "time", ".", "Time", ",", "hits", "int", ")", "{", "f", ".", "Lock", "(", ")", "\n", "defer", "f", ".", "Unlock", "(", ")", "\n", "f", ".", "last", "=", "t", "\n", "f", ".", "hits", "...
// Reset resets f to time t and hits to hits.
[ "Reset", "resets", "f", "to", "time", "t", "and", "hits", "to", "hits", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/cache/freq/freq.go#L50-L55
130,715
coredns/coredns
plugin/grpc/proxy.go
newProxy
func newProxy(addr string, tlsConfig *tls.Config) (*Proxy, error) { p := &Proxy{ addr: addr, } if tlsConfig != nil { p.dialOpts = append(p.dialOpts, grpc.WithTransportCredentials(credentials.NewTLS(tlsConfig))) } else { p.dialOpts = append(p.dialOpts, grpc.WithInsecure()) } conn, err := grpc.Dial(p.addr, ...
go
func newProxy(addr string, tlsConfig *tls.Config) (*Proxy, error) { p := &Proxy{ addr: addr, } if tlsConfig != nil { p.dialOpts = append(p.dialOpts, grpc.WithTransportCredentials(credentials.NewTLS(tlsConfig))) } else { p.dialOpts = append(p.dialOpts, grpc.WithInsecure()) } conn, err := grpc.Dial(p.addr, ...
[ "func", "newProxy", "(", "addr", "string", ",", "tlsConfig", "*", "tls", ".", "Config", ")", "(", "*", "Proxy", ",", "error", ")", "{", "p", ":=", "&", "Proxy", "{", "addr", ":", "addr", ",", "}", "\n\n", "if", "tlsConfig", "!=", "nil", "{", "p",...
// newProxy returns a new proxy.
[ "newProxy", "returns", "a", "new", "proxy", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/grpc/proxy.go#L28-L46
130,716
coredns/coredns
plugin/grpc/proxy.go
query
func (p *Proxy) query(ctx context.Context, req *dns.Msg) (*dns.Msg, error) { start := time.Now() msg, err := req.Pack() if err != nil { return nil, err } reply, err := p.client.Query(ctx, &pb.DnsPacket{Msg: msg}) if err != nil { // if not found message, return empty message with NXDomain code if status.Co...
go
func (p *Proxy) query(ctx context.Context, req *dns.Msg) (*dns.Msg, error) { start := time.Now() msg, err := req.Pack() if err != nil { return nil, err } reply, err := p.client.Query(ctx, &pb.DnsPacket{Msg: msg}) if err != nil { // if not found message, return empty message with NXDomain code if status.Co...
[ "func", "(", "p", "*", "Proxy", ")", "query", "(", "ctx", "context", ".", "Context", ",", "req", "*", "dns", ".", "Msg", ")", "(", "*", "dns", ".", "Msg", ",", "error", ")", "{", "start", ":=", "time", ".", "Now", "(", ")", "\n\n", "msg", ","...
// query sends the request and waits for a response.
[ "query", "sends", "the", "request", "and", "waits", "for", "a", "response", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/grpc/proxy.go#L49-L81
130,717
coredns/coredns
plugin/file/secondary.go
shouldTransfer
func (z *Zone) shouldTransfer() (bool, error) { c := new(dns.Client) c.Net = "tcp" // do this query over TCP to minimize spoofing m := new(dns.Msg) m.SetQuestion(z.origin, dns.TypeSOA) var Err error serial := -1 Transfer: for _, tr := range z.TransferFrom { Err = nil ret, _, err := c.Exchange(m, tr) if e...
go
func (z *Zone) shouldTransfer() (bool, error) { c := new(dns.Client) c.Net = "tcp" // do this query over TCP to minimize spoofing m := new(dns.Msg) m.SetQuestion(z.origin, dns.TypeSOA) var Err error serial := -1 Transfer: for _, tr := range z.TransferFrom { Err = nil ret, _, err := c.Exchange(m, tr) if e...
[ "func", "(", "z", "*", "Zone", ")", "shouldTransfer", "(", ")", "(", "bool", ",", "error", ")", "{", "c", ":=", "new", "(", "dns", ".", "Client", ")", "\n", "c", ".", "Net", "=", "\"", "\"", "// do this query over TCP to minimize spoofing", "\n", "m", ...
// shouldTransfer checks the primaries of zone, retrieves the SOA record, checks the current serial // and the remote serial and will return true if the remote one is higher than the locally configured one.
[ "shouldTransfer", "checks", "the", "primaries", "of", "zone", "retrieves", "the", "SOA", "record", "checks", "the", "current", "serial", "and", "the", "remote", "serial", "and", "will", "return", "true", "if", "the", "remote", "one", "is", "higher", "than", ...
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/file/secondary.go#L63-L94
130,718
coredns/coredns
plugin/file/secondary.go
less
func less(a, b uint32) bool { if a < b { return (b - a) <= MaxSerialIncrement } return (a - b) > MaxSerialIncrement }
go
func less(a, b uint32) bool { if a < b { return (b - a) <= MaxSerialIncrement } return (a - b) > MaxSerialIncrement }
[ "func", "less", "(", "a", ",", "b", "uint32", ")", "bool", "{", "if", "a", "<", "b", "{", "return", "(", "b", "-", "a", ")", "<=", "MaxSerialIncrement", "\n", "}", "\n", "return", "(", "a", "-", "b", ")", ">", "MaxSerialIncrement", "\n", "}" ]
// less return true of a is smaller than b when taking RFC 1982 serial arithmetic into account.
[ "less", "return", "true", "of", "a", "is", "smaller", "than", "b", "when", "taking", "RFC", "1982", "serial", "arithmetic", "into", "account", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/file/secondary.go#L97-L102
130,719
coredns/coredns
plugin/file/tree/elem.go
newElem
func newElem(rr dns.RR) *Elem { e := Elem{m: make(map[uint16][]dns.RR)} e.m[rr.Header().Rrtype] = []dns.RR{rr} return &e }
go
func newElem(rr dns.RR) *Elem { e := Elem{m: make(map[uint16][]dns.RR)} e.m[rr.Header().Rrtype] = []dns.RR{rr} return &e }
[ "func", "newElem", "(", "rr", "dns", ".", "RR", ")", "*", "Elem", "{", "e", ":=", "Elem", "{", "m", ":", "make", "(", "map", "[", "uint16", "]", "[", "]", "dns", ".", "RR", ")", "}", "\n", "e", ".", "m", "[", "rr", ".", "Header", "(", ")"...
// newElem returns a new elem.
[ "newElem", "returns", "a", "new", "elem", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/file/tree/elem.go#L12-L16
130,720
coredns/coredns
plugin/file/tree/elem.go
All
func (e *Elem) All() []dns.RR { list := []dns.RR{} for _, rrs := range e.m { list = append(list, rrs...) } return list }
go
func (e *Elem) All() []dns.RR { list := []dns.RR{} for _, rrs := range e.m { list = append(list, rrs...) } return list }
[ "func", "(", "e", "*", "Elem", ")", "All", "(", ")", "[", "]", "dns", ".", "RR", "{", "list", ":=", "[", "]", "dns", ".", "RR", "{", "}", "\n", "for", "_", ",", "rrs", ":=", "range", "e", ".", "m", "{", "list", "=", "append", "(", "list",...
// All returns all RRs from e, regardless of type.
[ "All", "returns", "all", "RRs", "from", "e", "regardless", "of", "type", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/file/tree/elem.go#L35-L41
130,721
coredns/coredns
plugin/file/tree/elem.go
Name
func (e *Elem) Name() string { if e.name != "" { return e.name } for _, rrs := range e.m { e.name = rrs[0].Header().Name return e.name } return "" }
go
func (e *Elem) Name() string { if e.name != "" { return e.name } for _, rrs := range e.m { e.name = rrs[0].Header().Name return e.name } return "" }
[ "func", "(", "e", "*", "Elem", ")", "Name", "(", ")", "string", "{", "if", "e", ".", "name", "!=", "\"", "\"", "{", "return", "e", ".", "name", "\n", "}", "\n", "for", "_", ",", "rrs", ":=", "range", "e", ".", "m", "{", "e", ".", "name", ...
// Name returns the name for this node.
[ "Name", "returns", "the", "name", "for", "this", "node", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/file/tree/elem.go#L44-L53
130,722
coredns/coredns
plugin/file/tree/elem.go
Insert
func (e *Elem) Insert(rr dns.RR) { t := rr.Header().Rrtype if e.m == nil { e.m = make(map[uint16][]dns.RR) e.m[t] = []dns.RR{rr} return } rrs, ok := e.m[t] if !ok { e.m[t] = []dns.RR{rr} return } for _, er := range rrs { if equalRdata(er, rr) { return } } rrs = append(rrs, rr) e.m[t] = rrs }
go
func (e *Elem) Insert(rr dns.RR) { t := rr.Header().Rrtype if e.m == nil { e.m = make(map[uint16][]dns.RR) e.m[t] = []dns.RR{rr} return } rrs, ok := e.m[t] if !ok { e.m[t] = []dns.RR{rr} return } for _, er := range rrs { if equalRdata(er, rr) { return } } rrs = append(rrs, rr) e.m[t] = rrs }
[ "func", "(", "e", "*", "Elem", ")", "Insert", "(", "rr", "dns", ".", "RR", ")", "{", "t", ":=", "rr", ".", "Header", "(", ")", ".", "Rrtype", "\n", "if", "e", ".", "m", "==", "nil", "{", "e", ".", "m", "=", "make", "(", "map", "[", "uint1...
// Insert inserts rr into e. If rr is equal to existing rrs this is a noop.
[ "Insert", "inserts", "rr", "into", "e", ".", "If", "rr", "is", "equal", "to", "existing", "rrs", "this", "is", "a", "noop", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/file/tree/elem.go#L62-L82
130,723
coredns/coredns
plugin/file/tree/elem.go
Delete
func (e *Elem) Delete(rr dns.RR) (empty bool) { if e.m == nil { return true } t := rr.Header().Rrtype rrs, ok := e.m[t] if !ok { return } for i, er := range rrs { if equalRdata(er, rr) { rrs = removeFromSlice(rrs, i) e.m[t] = rrs empty = len(rrs) == 0 if empty { delete(e.m, t) } ret...
go
func (e *Elem) Delete(rr dns.RR) (empty bool) { if e.m == nil { return true } t := rr.Header().Rrtype rrs, ok := e.m[t] if !ok { return } for i, er := range rrs { if equalRdata(er, rr) { rrs = removeFromSlice(rrs, i) e.m[t] = rrs empty = len(rrs) == 0 if empty { delete(e.m, t) } ret...
[ "func", "(", "e", "*", "Elem", ")", "Delete", "(", "rr", "dns", ".", "RR", ")", "(", "empty", "bool", ")", "{", "if", "e", ".", "m", "==", "nil", "{", "return", "true", "\n", "}", "\n\n", "t", ":=", "rr", ".", "Header", "(", ")", ".", "Rrty...
// Delete removes rr from e. When e is empty after the removal the returned bool is true.
[ "Delete", "removes", "rr", "from", "e", ".", "When", "e", "is", "empty", "after", "the", "removal", "the", "returned", "bool", "is", "true", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/file/tree/elem.go#L85-L108
130,724
coredns/coredns
plugin/file/tree/elem.go
equalRdata
func equalRdata(a, b dns.RR) bool { switch x := a.(type) { // TODO(miek): more types, i.e. all types. + tests for this. case *dns.A: return x.A.Equal(b.(*dns.A).A) case *dns.AAAA: return x.AAAA.Equal(b.(*dns.AAAA).AAAA) case *dns.MX: if x.Mx == b.(*dns.MX).Mx && x.Preference == b.(*dns.MX).Preference { re...
go
func equalRdata(a, b dns.RR) bool { switch x := a.(type) { // TODO(miek): more types, i.e. all types. + tests for this. case *dns.A: return x.A.Equal(b.(*dns.A).A) case *dns.AAAA: return x.AAAA.Equal(b.(*dns.AAAA).AAAA) case *dns.MX: if x.Mx == b.(*dns.MX).Mx && x.Preference == b.(*dns.MX).Preference { re...
[ "func", "equalRdata", "(", "a", ",", "b", "dns", ".", "RR", ")", "bool", "{", "switch", "x", ":=", "a", ".", "(", "type", ")", "{", "// TODO(miek): more types, i.e. all types. + tests for this.", "case", "*", "dns", ".", "A", ":", "return", "x", ".", "A"...
// Assuming the same type and name this will check if the rdata is equal as well.
[ "Assuming", "the", "same", "type", "and", "name", "this", "will", "check", "if", "the", "rdata", "is", "equal", "as", "well", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/file/tree/elem.go#L114-L127
130,725
coredns/coredns
plugin/file/tree/elem.go
removeFromSlice
func removeFromSlice(rrs []dns.RR, i int) []dns.RR { if i >= len(rrs) { return rrs } rrs = append(rrs[:i], rrs[i+1:]...) return rrs }
go
func removeFromSlice(rrs []dns.RR, i int) []dns.RR { if i >= len(rrs) { return rrs } rrs = append(rrs[:i], rrs[i+1:]...) return rrs }
[ "func", "removeFromSlice", "(", "rrs", "[", "]", "dns", ".", "RR", ",", "i", "int", ")", "[", "]", "dns", ".", "RR", "{", "if", "i", ">=", "len", "(", "rrs", ")", "{", "return", "rrs", "\n", "}", "\n", "rrs", "=", "append", "(", "rrs", "[", ...
// removeFromSlice removes index i from the slice.
[ "removeFromSlice", "removes", "index", "i", "from", "the", "slice", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/file/tree/elem.go#L130-L136
130,726
coredns/coredns
plugin/erratic/ready.go
Ready
func (e *Erratic) Ready() bool { q := atomic.LoadUint64(&e.q) if q >= 3 && q < 5 { return true } return false }
go
func (e *Erratic) Ready() bool { q := atomic.LoadUint64(&e.q) if q >= 3 && q < 5 { return true } return false }
[ "func", "(", "e", "*", "Erratic", ")", "Ready", "(", ")", "bool", "{", "q", ":=", "atomic", ".", "LoadUint64", "(", "&", "e", ".", "q", ")", "\n", "if", "q", ">=", "3", "&&", "q", "<", "5", "{", "return", "true", "\n", "}", "\n", "return", ...
// Ready returns true if the number of received queries is in the range [3, 5). All other values return false. // To aid in testing we want to this flip between ready and not ready.
[ "Ready", "returns", "true", "if", "the", "number", "of", "received", "queries", "is", "in", "the", "range", "[", "3", "5", ")", ".", "All", "other", "values", "return", "false", ".", "To", "aid", "in", "testing", "we", "want", "to", "this", "flip", "...
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/erratic/ready.go#L7-L13
130,727
coredns/coredns
plugin/pkg/edns/edns.go
SupportedOption
func SupportedOption(option uint16) bool { sup.RLock() _, ok := sup.m[option] sup.RUnlock() return ok }
go
func SupportedOption(option uint16) bool { sup.RLock() _, ok := sup.m[option] sup.RUnlock() return ok }
[ "func", "SupportedOption", "(", "option", "uint16", ")", "bool", "{", "sup", ".", "RLock", "(", ")", "\n", "_", ",", "ok", ":=", "sup", ".", "m", "[", "option", "]", "\n", "sup", ".", "RUnlock", "(", ")", "\n", "return", "ok", "\n", "}" ]
// SupportedOption returns true if the option code is supported as an extra EDNS0 option.
[ "SupportedOption", "returns", "true", "if", "the", "option", "code", "is", "supported", "as", "an", "extra", "EDNS0", "option", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/pkg/edns/edns.go#L30-L35
130,728
coredns/coredns
plugin/pkg/edns/edns.go
Size
func Size(proto string, size int) int { if proto == "tcp" { return dns.MaxMsgSize } if size < dns.MinMsgSize { return dns.MinMsgSize } return size }
go
func Size(proto string, size int) int { if proto == "tcp" { return dns.MaxMsgSize } if size < dns.MinMsgSize { return dns.MinMsgSize } return size }
[ "func", "Size", "(", "proto", "string", ",", "size", "int", ")", "int", "{", "if", "proto", "==", "\"", "\"", "{", "return", "dns", ".", "MaxMsgSize", "\n", "}", "\n", "if", "size", "<", "dns", ".", "MinMsgSize", "{", "return", "dns", ".", "MinMsgS...
// Size returns a normalized size based on proto.
[ "Size", "returns", "a", "normalized", "size", "based", "on", "proto", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/pkg/edns/edns.go#L66-L74
130,729
coredns/coredns
plugin/file/closest.go
ClosestEncloser
func (z *Zone) ClosestEncloser(qname string) (*tree.Elem, bool) { offset, end := dns.NextLabel(qname, 0) for !end { elem, _ := z.Tree.Search(qname) if elem != nil { return elem, true } qname = qname[offset:] offset, end = dns.NextLabel(qname, offset) } return z.Tree.Search(z.origin) }
go
func (z *Zone) ClosestEncloser(qname string) (*tree.Elem, bool) { offset, end := dns.NextLabel(qname, 0) for !end { elem, _ := z.Tree.Search(qname) if elem != nil { return elem, true } qname = qname[offset:] offset, end = dns.NextLabel(qname, offset) } return z.Tree.Search(z.origin) }
[ "func", "(", "z", "*", "Zone", ")", "ClosestEncloser", "(", "qname", "string", ")", "(", "*", "tree", ".", "Elem", ",", "bool", ")", "{", "offset", ",", "end", ":=", "dns", ".", "NextLabel", "(", "qname", ",", "0", ")", "\n", "for", "!", "end", ...
// ClosestEncloser returns the closest encloser for qname.
[ "ClosestEncloser", "returns", "the", "closest", "encloser", "for", "qname", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/file/closest.go#L10-L24
130,730
coredns/coredns
plugin/kubernetes/object/endpoint.go
CopyWithoutSubsets
func (e *Endpoints) CopyWithoutSubsets() *Endpoints { e1 := &Endpoints{ Version: e.Version, Name: e.Name, Namespace: e.Namespace, Index: e.Index, IndexIP: make([]string, len(e.IndexIP)), } copy(e1.IndexIP, e.IndexIP) return e1 }
go
func (e *Endpoints) CopyWithoutSubsets() *Endpoints { e1 := &Endpoints{ Version: e.Version, Name: e.Name, Namespace: e.Namespace, Index: e.Index, IndexIP: make([]string, len(e.IndexIP)), } copy(e1.IndexIP, e.IndexIP) return e1 }
[ "func", "(", "e", "*", "Endpoints", ")", "CopyWithoutSubsets", "(", ")", "*", "Endpoints", "{", "e1", ":=", "&", "Endpoints", "{", "Version", ":", "e", ".", "Version", ",", "Name", ":", "e", ".", "Name", ",", "Namespace", ":", "e", ".", "Namespace", ...
// CopyWithoutSubsets copies e, without the subsets.
[ "CopyWithoutSubsets", "copies", "e", "without", "the", "subsets", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/kubernetes/object/endpoint.go#L101-L111
130,731
coredns/coredns
plugin/pkg/fuzz/do.go
Do
func Do(p plugin.Handler, data []byte) int { ctx := context.TODO() ret := 1 r := new(dns.Msg) if err := r.Unpack(data); err != nil { ret = 0 } if _, err := p.ServeDNS(ctx, &test.ResponseWriter{}, r); err != nil { ret = 1 } return ret }
go
func Do(p plugin.Handler, data []byte) int { ctx := context.TODO() ret := 1 r := new(dns.Msg) if err := r.Unpack(data); err != nil { ret = 0 } if _, err := p.ServeDNS(ctx, &test.ResponseWriter{}, r); err != nil { ret = 1 } return ret }
[ "func", "Do", "(", "p", "plugin", ".", "Handler", ",", "data", "[", "]", "byte", ")", "int", "{", "ctx", ":=", "context", ".", "TODO", "(", ")", "\n", "ret", ":=", "1", "\n", "r", ":=", "new", "(", "dns", ".", "Msg", ")", "\n", "if", "err", ...
// Do will fuzz p - used by gofuzz. See Maefile.fuzz for comments and context.
[ "Do", "will", "fuzz", "p", "-", "used", "by", "gofuzz", ".", "See", "Maefile", ".", "fuzz", "for", "comments", "and", "context", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/pkg/fuzz/do.go#L14-L27
130,732
coredns/coredns
plugin/autopath/cname.go
cnamer
func cnamer(m *dns.Msg, original string) { for _, a := range m.Answer { if strings.EqualFold(original, a.Header().Name) { continue } m.Answer = append(m.Answer, nil) copy(m.Answer[1:], m.Answer) m.Answer[0] = &dns.CNAME{ Hdr: dns.RR_Header{Name: original, Rrtype: dns.TypeCNAME, Class: dns.ClassINET,...
go
func cnamer(m *dns.Msg, original string) { for _, a := range m.Answer { if strings.EqualFold(original, a.Header().Name) { continue } m.Answer = append(m.Answer, nil) copy(m.Answer[1:], m.Answer) m.Answer[0] = &dns.CNAME{ Hdr: dns.RR_Header{Name: original, Rrtype: dns.TypeCNAME, Class: dns.ClassINET,...
[ "func", "cnamer", "(", "m", "*", "dns", ".", "Msg", ",", "original", "string", ")", "{", "for", "_", ",", "a", ":=", "range", "m", ".", "Answer", "{", "if", "strings", ".", "EqualFold", "(", "original", ",", "a", ".", "Header", "(", ")", ".", "...
// cnamer will prefix the answer section with a cname that points from original qname to the // name of the first RR. It will also update the question section and put original in there.
[ "cnamer", "will", "prefix", "the", "answer", "section", "with", "a", "cname", "that", "points", "from", "original", "qname", "to", "the", "name", "of", "the", "first", "RR", ".", "It", "will", "also", "update", "the", "question", "section", "and", "put", ...
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/autopath/cname.go#L11-L25
130,733
coredns/coredns
plugin/k8s_external/apex.go
serveApex
func (e *External) serveApex(state request.Request) (int, error) { m := new(dns.Msg) m.SetReply(state.Req) switch state.QType() { case dns.TypeSOA: m.Answer = []dns.RR{e.soa(state)} case dns.TypeNS: m.Answer = []dns.RR{e.ns(state)} addr := e.externalAddrFunc(state) for _, rr := range addr { rr.Header()...
go
func (e *External) serveApex(state request.Request) (int, error) { m := new(dns.Msg) m.SetReply(state.Req) switch state.QType() { case dns.TypeSOA: m.Answer = []dns.RR{e.soa(state)} case dns.TypeNS: m.Answer = []dns.RR{e.ns(state)} addr := e.externalAddrFunc(state) for _, rr := range addr { rr.Header()...
[ "func", "(", "e", "*", "External", ")", "serveApex", "(", "state", "request", ".", "Request", ")", "(", "int", ",", "error", ")", "{", "m", ":=", "new", "(", "dns", ".", "Msg", ")", "\n", "m", ".", "SetReply", "(", "state", ".", "Req", ")", "\n...
// serveApex serves request that hit the zone' apex. A reply is written back to the client.
[ "serveApex", "serves", "request", "that", "hit", "the", "zone", "apex", ".", "A", "reply", "is", "written", "back", "to", "the", "client", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/k8s_external/apex.go#L11-L32
130,734
coredns/coredns
plugin/k8s_external/apex.go
serveSubApex
func (e *External) serveSubApex(state request.Request) (int, error) { base, _ := dnsutil.TrimZone(state.Name(), state.Zone) m := new(dns.Msg) m.SetReply(state.Req) // base is either dns. of ns1.dns (or another name), if it's longer return nxdomain switch labels := dns.CountLabel(base); labels { default: m.Set...
go
func (e *External) serveSubApex(state request.Request) (int, error) { base, _ := dnsutil.TrimZone(state.Name(), state.Zone) m := new(dns.Msg) m.SetReply(state.Req) // base is either dns. of ns1.dns (or another name), if it's longer return nxdomain switch labels := dns.CountLabel(base); labels { default: m.Set...
[ "func", "(", "e", "*", "External", ")", "serveSubApex", "(", "state", "request", ".", "Request", ")", "(", "int", ",", "error", ")", "{", "base", ",", "_", ":=", "dnsutil", ".", "TrimZone", "(", "state", ".", "Name", "(", ")", ",", "state", ".", ...
// serveSubApex serves requests that hit the zones fake 'dns' subdomain where our nameservers live.
[ "serveSubApex", "serves", "requests", "that", "hit", "the", "zones", "fake", "dns", "subdomain", "where", "our", "nameservers", "live", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/k8s_external/apex.go#L35-L88
130,735
coredns/coredns
coremain/run.go
showVersion
func showVersion() { fmt.Print(versionString()) fmt.Print(releaseString()) if devBuild && gitShortStat != "" { fmt.Printf("%s\n%s\n", gitShortStat, gitFilesModified) } }
go
func showVersion() { fmt.Print(versionString()) fmt.Print(releaseString()) if devBuild && gitShortStat != "" { fmt.Printf("%s\n%s\n", gitShortStat, gitFilesModified) } }
[ "func", "showVersion", "(", ")", "{", "fmt", ".", "Print", "(", "versionString", "(", ")", ")", "\n", "fmt", ".", "Print", "(", "releaseString", "(", ")", ")", "\n", "if", "devBuild", "&&", "gitShortStat", "!=", "\"", "\"", "{", "fmt", ".", "Printf",...
// showVersion prints the version that is starting.
[ "showVersion", "prints", "the", "version", "that", "is", "starting", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/coremain/run.go#L159-L165
130,736
coredns/coredns
plugin/normalize.go
Matches
func (z Zones) Matches(qname string) string { zone := "" for _, zname := range z { if dns.IsSubDomain(zname, qname) { // We want the *longest* matching zone, otherwise we may end up in a parent if len(zname) > len(zone) { zone = zname } } } return zone }
go
func (z Zones) Matches(qname string) string { zone := "" for _, zname := range z { if dns.IsSubDomain(zname, qname) { // We want the *longest* matching zone, otherwise we may end up in a parent if len(zname) > len(zone) { zone = zname } } } return zone }
[ "func", "(", "z", "Zones", ")", "Matches", "(", "qname", "string", ")", "string", "{", "zone", ":=", "\"", "\"", "\n", "for", "_", ",", "zname", ":=", "range", "z", "{", "if", "dns", ".", "IsSubDomain", "(", "zname", ",", "qname", ")", "{", "// W...
// Matches checks if qname is a subdomain of any of the zones in z. The match // will return the most specific zones that matches. The empty string // signals a not found condition.
[ "Matches", "checks", "if", "qname", "is", "a", "subdomain", "of", "any", "of", "the", "zones", "in", "z", ".", "The", "match", "will", "return", "the", "most", "specific", "zones", "that", "matches", ".", "The", "empty", "string", "signals", "a", "not", ...
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/normalize.go#L21-L32
130,737
coredns/coredns
plugin/normalize.go
Normalize
func (z Zones) Normalize() { for i := range z { z[i] = Name(z[i]).Normalize() } }
go
func (z Zones) Normalize() { for i := range z { z[i] = Name(z[i]).Normalize() } }
[ "func", "(", "z", "Zones", ")", "Normalize", "(", ")", "{", "for", "i", ":=", "range", "z", "{", "z", "[", "i", "]", "=", "Name", "(", "z", "[", "i", "]", ")", ".", "Normalize", "(", ")", "\n", "}", "\n", "}" ]
// Normalize fully qualifies all zones in z. The zones in Z must be domain names, without // a port or protocol prefix.
[ "Normalize", "fully", "qualifies", "all", "zones", "in", "z", ".", "The", "zones", "in", "Z", "must", "be", "domain", "names", "without", "a", "port", "or", "protocol", "prefix", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/normalize.go#L36-L40
130,738
coredns/coredns
plugin/rewrite/ttl.go
newTtlRule
func newTtlRule(nextAction string, args ...string) (Rule, error) { if len(args) < 2 { return nil, fmt.Errorf("too few (%d) arguments for a ttl rule", len(args)) } var s string if len(args) == 2 { s = args[1] } if len(args) == 3 { s = args[2] } ttl, valid := isValidTtl(s) if valid == false { return nil,...
go
func newTtlRule(nextAction string, args ...string) (Rule, error) { if len(args) < 2 { return nil, fmt.Errorf("too few (%d) arguments for a ttl rule", len(args)) } var s string if len(args) == 2 { s = args[1] } if len(args) == 3 { s = args[2] } ttl, valid := isValidTtl(s) if valid == false { return nil,...
[ "func", "newTtlRule", "(", "nextAction", "string", ",", "args", "...", "string", ")", "(", "Rule", ",", "error", ")", "{", "if", "len", "(", "args", ")", "<", "2", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "len", "(",...
// newTtlRule creates a name matching rule based on exact, partial, or regex match
[ "newTtlRule", "creates", "a", "name", "matching", "rule", "based", "on", "exact", "partial", "or", "regex", "match" ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/rewrite/ttl.go#L90-L177
130,739
coredns/coredns
plugin/rewrite/ttl.go
isValidTtl
func isValidTtl(v string) (uint32, bool) { i, err := strconv.Atoi(v) if err != nil { return uint32(0), false } if i > 2147483647 { return uint32(0), false } if i < 0 { return uint32(0), false } return uint32(i), true }
go
func isValidTtl(v string) (uint32, bool) { i, err := strconv.Atoi(v) if err != nil { return uint32(0), false } if i > 2147483647 { return uint32(0), false } if i < 0 { return uint32(0), false } return uint32(i), true }
[ "func", "isValidTtl", "(", "v", "string", ")", "(", "uint32", ",", "bool", ")", "{", "i", ",", "err", ":=", "strconv", ".", "Atoi", "(", "v", ")", "\n", "if", "err", "!=", "nil", "{", "return", "uint32", "(", "0", ")", ",", "false", "\n", "}", ...
// validTtl returns true if v is valid TTL value.
[ "validTtl", "returns", "true", "if", "v", "is", "valid", "TTL", "value", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/rewrite/ttl.go#L212-L224
130,740
coredns/coredns
plugin/pkg/log/plugin.go
Debugf
func (p P) Debugf(format string, v ...interface{}) { if !D { return } p.logf(debug, format, v...) }
go
func (p P) Debugf(format string, v ...interface{}) { if !D { return } p.logf(debug, format, v...) }
[ "func", "(", "p", "P", ")", "Debugf", "(", "format", "string", ",", "v", "...", "interface", "{", "}", ")", "{", "if", "!", "D", "{", "return", "\n", "}", "\n", "p", ".", "logf", "(", "debug", ",", "format", ",", "v", "...", ")", "\n", "}" ]
// Debugf logs as log.Debugf.
[ "Debugf", "logs", "as", "log", ".", "Debugf", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/pkg/log/plugin.go#L34-L39
130,741
coredns/coredns
plugin/forward/setup.go
OnStartup
func (f *Forward) OnStartup() (err error) { for _, p := range f.proxies { p.start(f.hcInterval) } return nil }
go
func (f *Forward) OnStartup() (err error) { for _, p := range f.proxies { p.start(f.hcInterval) } return nil }
[ "func", "(", "f", "*", "Forward", ")", "OnStartup", "(", ")", "(", "err", "error", ")", "{", "for", "_", ",", "p", ":=", "range", "f", ".", "proxies", "{", "p", ".", "start", "(", "f", ".", "hcInterval", ")", "\n", "}", "\n", "return", "nil", ...
// OnStartup starts a goroutines for all proxies.
[ "OnStartup", "starts", "a", "goroutines", "for", "all", "proxies", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/forward/setup.go#L53-L58
130,742
coredns/coredns
plugin/forward/setup.go
OnShutdown
func (f *Forward) OnShutdown() error { for _, p := range f.proxies { p.close() } return nil }
go
func (f *Forward) OnShutdown() error { for _, p := range f.proxies { p.close() } return nil }
[ "func", "(", "f", "*", "Forward", ")", "OnShutdown", "(", ")", "error", "{", "for", "_", ",", "p", ":=", "range", "f", ".", "proxies", "{", "p", ".", "close", "(", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// OnShutdown stops all configured proxies.
[ "OnShutdown", "stops", "all", "configured", "proxies", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/forward/setup.go#L61-L66
130,743
coredns/coredns
plugin/forward/setup.go
ParseForwardStanza
func ParseForwardStanza(c *caddyfile.Dispenser) (*Forward, error) { f := New() if !c.Args(&f.from) { return f, c.ArgErr() } f.from = plugin.Host(f.from).Normalize() to := c.RemainingArgs() if len(to) == 0 { return f, c.ArgErr() } toHosts, err := parse.HostPortOrFile(to...) if err != nil { return f, er...
go
func ParseForwardStanza(c *caddyfile.Dispenser) (*Forward, error) { f := New() if !c.Args(&f.from) { return f, c.ArgErr() } f.from = plugin.Host(f.from).Normalize() to := c.RemainingArgs() if len(to) == 0 { return f, c.ArgErr() } toHosts, err := parse.HostPortOrFile(to...) if err != nil { return f, er...
[ "func", "ParseForwardStanza", "(", "c", "*", "caddyfile", ".", "Dispenser", ")", "(", "*", "Forward", ",", "error", ")", "{", "f", ":=", "New", "(", ")", "\n\n", "if", "!", "c", ".", "Args", "(", "&", "f", ".", "from", ")", "{", "return", "f", ...
// ParseForwardStanza parses one forward stanza
[ "ParseForwardStanza", "parses", "one", "forward", "stanza" ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/forward/setup.go#L91-L134
130,744
coredns/coredns
plugin/pkg/tls/tls.go
NewTLSConfig
func NewTLSConfig(certPath, keyPath, caPath string) (*tls.Config, error) { cert, err := tls.LoadX509KeyPair(certPath, keyPath) if err != nil { return nil, fmt.Errorf("could not load TLS cert: %s", err) } roots, err := loadRoots(caPath) if err != nil { return nil, err } return &tls.Config{Certificates: []tl...
go
func NewTLSConfig(certPath, keyPath, caPath string) (*tls.Config, error) { cert, err := tls.LoadX509KeyPair(certPath, keyPath) if err != nil { return nil, fmt.Errorf("could not load TLS cert: %s", err) } roots, err := loadRoots(caPath) if err != nil { return nil, err } return &tls.Config{Certificates: []tl...
[ "func", "NewTLSConfig", "(", "certPath", ",", "keyPath", ",", "caPath", "string", ")", "(", "*", "tls", ".", "Config", ",", "error", ")", "{", "cert", ",", "err", ":=", "tls", ".", "LoadX509KeyPair", "(", "certPath", ",", "keyPath", ")", "\n", "if", ...
// NewTLSConfig returns a TLS config that includes a certificate // Use for server TLS config or when using a client certificate // If caPath is empty, system CAs will be used
[ "NewTLSConfig", "returns", "a", "TLS", "config", "that", "includes", "a", "certificate", "Use", "for", "server", "TLS", "config", "or", "when", "using", "a", "client", "certificate", "If", "caPath", "is", "empty", "system", "CAs", "will", "be", "used" ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/pkg/tls/tls.go#L67-L79
130,745
coredns/coredns
plugin/pkg/tls/tls.go
NewTLSClientConfig
func NewTLSClientConfig(caPath string) (*tls.Config, error) { roots, err := loadRoots(caPath) if err != nil { return nil, err } return &tls.Config{RootCAs: roots}, nil }
go
func NewTLSClientConfig(caPath string) (*tls.Config, error) { roots, err := loadRoots(caPath) if err != nil { return nil, err } return &tls.Config{RootCAs: roots}, nil }
[ "func", "NewTLSClientConfig", "(", "caPath", "string", ")", "(", "*", "tls", ".", "Config", ",", "error", ")", "{", "roots", ",", "err", ":=", "loadRoots", "(", "caPath", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", ...
// NewTLSClientConfig returns a TLS config for a client connection // If caPath is empty, system CAs will be used
[ "NewTLSClientConfig", "returns", "a", "TLS", "config", "for", "a", "client", "connection", "If", "caPath", "is", "empty", "system", "CAs", "will", "be", "used" ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/pkg/tls/tls.go#L83-L90
130,746
coredns/coredns
plugin/pkg/tls/tls.go
NewHTTPSTransport
func NewHTTPSTransport(cc *tls.Config) *http.Transport { // this seems like a bad idea but was here in the previous version if cc != nil { cc.InsecureSkipVerify = true } tr := &http.Transport{ Proxy: http.ProxyFromEnvironment, Dial: (&net.Dialer{ Timeout: 30 * time.Second, KeepAlive: 30 * time.Second...
go
func NewHTTPSTransport(cc *tls.Config) *http.Transport { // this seems like a bad idea but was here in the previous version if cc != nil { cc.InsecureSkipVerify = true } tr := &http.Transport{ Proxy: http.ProxyFromEnvironment, Dial: (&net.Dialer{ Timeout: 30 * time.Second, KeepAlive: 30 * time.Second...
[ "func", "NewHTTPSTransport", "(", "cc", "*", "tls", ".", "Config", ")", "*", "http", ".", "Transport", "{", "// this seems like a bad idea but was here in the previous version", "if", "cc", "!=", "nil", "{", "cc", ".", "InsecureSkipVerify", "=", "true", "\n", "}",...
// NewHTTPSTransport returns an HTTP transport configured using tls.Config
[ "NewHTTPSTransport", "returns", "an", "HTTP", "transport", "configured", "using", "tls", ".", "Config" ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/pkg/tls/tls.go#L110-L128
130,747
coredns/coredns
plugin/etcd/etcd.go
shouldInclude
func shouldInclude(serv *msg.Service, qType uint16) bool { if qType == dns.TypeTXT { return serv.Text != "" } return serv.Host != "" }
go
func shouldInclude(serv *msg.Service, qType uint16) bool { if qType == dns.TypeTXT { return serv.Text != "" } return serv.Host != "" }
[ "func", "shouldInclude", "(", "serv", "*", "msg", ".", "Service", ",", "qType", "uint16", ")", "bool", "{", "if", "qType", "==", "dns", ".", "TypeTXT", "{", "return", "serv", ".", "Text", "!=", "\"", "\"", "\n", "}", "\n", "return", "serv", ".", "H...
// shouldInclude returns true if the service should be included in a list of records, given the qType. For all the // currently supported lookup types, the only one to allow for an empty Host field in the service are TXT records. // Similarly, the TXT record in turn requires the Text field to be set.
[ "shouldInclude", "returns", "true", "if", "the", "service", "should", "be", "included", "in", "a", "list", "of", "records", "given", "the", "qType", ".", "For", "all", "the", "currently", "supported", "lookup", "types", "the", "only", "one", "to", "allow", ...
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/etcd/etcd.go#L182-L187
130,748
coredns/coredns
plugin/pkg/dnsutil/cname.go
DuplicateCNAME
func DuplicateCNAME(r *dns.CNAME, records []dns.RR) bool { for _, rec := range records { if v, ok := rec.(*dns.CNAME); ok { if v.Target == r.Target { return true } } } return false }
go
func DuplicateCNAME(r *dns.CNAME, records []dns.RR) bool { for _, rec := range records { if v, ok := rec.(*dns.CNAME); ok { if v.Target == r.Target { return true } } } return false }
[ "func", "DuplicateCNAME", "(", "r", "*", "dns", ".", "CNAME", ",", "records", "[", "]", "dns", ".", "RR", ")", "bool", "{", "for", "_", ",", "rec", ":=", "range", "records", "{", "if", "v", ",", "ok", ":=", "rec", ".", "(", "*", "dns", ".", "...
// DuplicateCNAME returns true if r already exists in records.
[ "DuplicateCNAME", "returns", "true", "if", "r", "already", "exists", "in", "records", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/pkg/dnsutil/cname.go#L6-L15
130,749
coredns/coredns
plugin/pkg/replacer/replacer.go
value
func value(state request.Request, rr *dnstest.Recorder, label string) string { switch label { case "{type}": return state.Type() case "{name}": return state.Name() case "{class}": return state.Class() case "{proto}": return state.Proto() case "{size}": return strconv.Itoa(state.Req.Len()) case "{remote...
go
func value(state request.Request, rr *dnstest.Recorder, label string) string { switch label { case "{type}": return state.Type() case "{name}": return state.Name() case "{class}": return state.Class() case "{proto}": return state.Proto() case "{size}": return strconv.Itoa(state.Req.Len()) case "{remote...
[ "func", "value", "(", "state", "request", ".", "Request", ",", "rr", "*", "dnstest", ".", "Recorder", ",", "label", "string", ")", "string", "{", "switch", "label", "{", "case", "\"", "\"", ":", "return", "state", ".", "Type", "(", ")", "\n", "case",...
// value returns the current value of label.
[ "value", "returns", "the", "current", "value", "of", "label", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/pkg/replacer/replacer.go#L45-L99
130,750
coredns/coredns
plugin/pkg/replacer/replacer.go
flagsToString
func flagsToString(h dns.MsgHdr) string { flags := make([]string, 7) i := 0 if h.Response { flags[i] = "qr" i++ } if h.Authoritative { flags[i] = "aa" i++ } if h.Truncated { flags[i] = "tc" i++ } if h.RecursionDesired { flags[i] = "rd" i++ } if h.RecursionAvailable { flags[i] = "ra" i++...
go
func flagsToString(h dns.MsgHdr) string { flags := make([]string, 7) i := 0 if h.Response { flags[i] = "qr" i++ } if h.Authoritative { flags[i] = "aa" i++ } if h.Truncated { flags[i] = "tc" i++ } if h.RecursionDesired { flags[i] = "rd" i++ } if h.RecursionAvailable { flags[i] = "ra" i++...
[ "func", "flagsToString", "(", "h", "dns", ".", "MsgHdr", ")", "string", "{", "flags", ":=", "make", "(", "[", "]", "string", ",", "7", ")", "\n", "i", ":=", "0", "\n\n", "if", "h", ".", "Response", "{", "flags", "[", "i", "]", "=", "\"", "\"", ...
// flagsToString checks all header flags and returns those // that are set as a string separated with commas
[ "flagsToString", "checks", "all", "header", "flags", "and", "returns", "those", "that", "are", "set", "as", "a", "string", "separated", "with", "commas" ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/pkg/replacer/replacer.go#L155-L193
130,751
coredns/coredns
plugin/kubernetes/reverse.go
serviceRecordForIP
func (k *Kubernetes) serviceRecordForIP(ip, name string) []msg.Service { // First check services with cluster ips for _, service := range k.APIConn.SvcIndexReverse(ip) { if len(k.Namespaces) > 0 && !k.namespaceExposed(service.Namespace) { continue } domain := strings.Join([]string{service.Name, service.Names...
go
func (k *Kubernetes) serviceRecordForIP(ip, name string) []msg.Service { // First check services with cluster ips for _, service := range k.APIConn.SvcIndexReverse(ip) { if len(k.Namespaces) > 0 && !k.namespaceExposed(service.Namespace) { continue } domain := strings.Join([]string{service.Name, service.Names...
[ "func", "(", "k", "*", "Kubernetes", ")", "serviceRecordForIP", "(", "ip", ",", "name", "string", ")", "[", "]", "msg", ".", "Service", "{", "// First check services with cluster ips", "for", "_", ",", "service", ":=", "range", "k", ".", "APIConn", ".", "S...
// serviceRecordForIP gets a service record with a cluster ip matching the ip argument // If a service cluster ip does not match, it checks all endpoints
[ "serviceRecordForIP", "gets", "a", "service", "record", "with", "a", "cluster", "ip", "matching", "the", "ip", "argument", "If", "a", "service", "cluster", "ip", "does", "not", "match", "it", "checks", "all", "endpoints" ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/kubernetes/reverse.go#L31-L55
130,752
coredns/coredns
plugin/file/tree/print.go
Print
func (t *Tree) Print() { if t.Root == nil { fmt.Println("<nil>") } t.Root.print() }
go
func (t *Tree) Print() { if t.Root == nil { fmt.Println("<nil>") } t.Root.print() }
[ "func", "(", "t", "*", "Tree", ")", "Print", "(", ")", "{", "if", "t", ".", "Root", "==", "nil", "{", "fmt", ".", "Println", "(", "\"", "\"", ")", "\n", "}", "\n", "t", ".", "Root", ".", "print", "(", ")", "\n", "}" ]
// Print prints a Tree. Main use is to aid in debugging.
[ "Print", "prints", "a", "Tree", ".", "Main", "use", "is", "to", "aid", "in", "debugging", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/file/tree/print.go#L6-L11
130,753
coredns/coredns
plugin/dnstap/gocontext.go
ContextWithTapper
func ContextWithTapper(ctx context.Context, t Tapper) context.Context { return context.WithValue(ctx, dnstapKey, t) }
go
func ContextWithTapper(ctx context.Context, t Tapper) context.Context { return context.WithValue(ctx, dnstapKey, t) }
[ "func", "ContextWithTapper", "(", "ctx", "context", ".", "Context", ",", "t", "Tapper", ")", "context", ".", "Context", "{", "return", "context", ".", "WithValue", "(", "ctx", ",", "dnstapKey", ",", "t", ")", "\n", "}" ]
// ContextWithTapper returns a new `context.Context` that holds a reference to // `t`'s Tapper.
[ "ContextWithTapper", "returns", "a", "new", "context", ".", "Context", "that", "holds", "a", "reference", "to", "t", "s", "Tapper", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/dnstap/gocontext.go#L11-L13
130,754
coredns/coredns
plugin/dnstap/gocontext.go
TapperFromContext
func TapperFromContext(ctx context.Context) Tapper { val := ctx.Value(dnstapKey) if sp, ok := val.(Tapper); ok { return sp } return nil }
go
func TapperFromContext(ctx context.Context) Tapper { val := ctx.Value(dnstapKey) if sp, ok := val.(Tapper); ok { return sp } return nil }
[ "func", "TapperFromContext", "(", "ctx", "context", ".", "Context", ")", "Tapper", "{", "val", ":=", "ctx", ".", "Value", "(", "dnstapKey", ")", "\n", "if", "sp", ",", "ok", ":=", "val", ".", "(", "Tapper", ")", ";", "ok", "{", "return", "sp", "\n"...
// TapperFromContext returns the `Tapper` previously associated with `ctx`, or // `nil` if no such `Tapper` could be found.
[ "TapperFromContext", "returns", "the", "Tapper", "previously", "associated", "with", "ctx", "or", "nil", "if", "no", "such", "Tapper", "could", "be", "found", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/dnstap/gocontext.go#L17-L23
130,755
coredns/coredns
plugin/rewrite/edns0.go
ruleData
func (rule *edns0VariableRule) ruleData(ctx context.Context, state request.Request) ([]byte, error) { switch rule.variable { case queryName: return []byte(state.QName()), nil case queryType: return uint16ToWire(state.QType()), nil case clientIP: return ipToWire(state.Family(), state.IP()) case serverIP: ...
go
func (rule *edns0VariableRule) ruleData(ctx context.Context, state request.Request) ([]byte, error) { switch rule.variable { case queryName: return []byte(state.QName()), nil case queryType: return uint16ToWire(state.QType()), nil case clientIP: return ipToWire(state.Family(), state.IP()) case serverIP: ...
[ "func", "(", "rule", "*", "edns0VariableRule", ")", "ruleData", "(", "ctx", "context", ".", "Context", ",", "state", "request", ".", "Request", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "switch", "rule", ".", "variable", "{", "case", "queryNa...
// ruleData returns the data specified by the variable.
[ "ruleData", "returns", "the", "data", "specified", "by", "the", "variable", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/rewrite/edns0.go#L188-L222
130,756
coredns/coredns
plugin/rewrite/edns0.go
Rewrite
func (rule *edns0VariableRule) Rewrite(ctx context.Context, state request.Request) Result { data, err := rule.ruleData(ctx, state) if err != nil || data == nil { return RewriteIgnored } o := setupEdns0Opt(state.Req) for _, s := range o.Option { if e, ok := s.(*dns.EDNS0_LOCAL); ok { if rule.code == e.Code ...
go
func (rule *edns0VariableRule) Rewrite(ctx context.Context, state request.Request) Result { data, err := rule.ruleData(ctx, state) if err != nil || data == nil { return RewriteIgnored } o := setupEdns0Opt(state.Req) for _, s := range o.Option { if e, ok := s.(*dns.EDNS0_LOCAL); ok { if rule.code == e.Code ...
[ "func", "(", "rule", "*", "edns0VariableRule", ")", "Rewrite", "(", "ctx", "context", ".", "Context", ",", "state", "request", ".", "Request", ")", "Result", "{", "data", ",", "err", ":=", "rule", ".", "ruleData", "(", "ctx", ",", "state", ")", "\n", ...
// Rewrite will alter the request EDNS0 local options with specified variables.
[ "Rewrite", "will", "alter", "the", "request", "EDNS0", "local", "options", "with", "specified", "variables", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/rewrite/edns0.go#L225-L251
130,757
coredns/coredns
plugin/rewrite/edns0.go
Rewrite
func (rule *edns0SubnetRule) Rewrite(ctx context.Context, state request.Request) Result { o := setupEdns0Opt(state.Req) for _, s := range o.Option { if e, ok := s.(*dns.EDNS0_SUBNET); ok { if rule.action == Replace || rule.action == Set { if rule.fillEcsData(state, e) == nil { return RewriteDone } ...
go
func (rule *edns0SubnetRule) Rewrite(ctx context.Context, state request.Request) Result { o := setupEdns0Opt(state.Req) for _, s := range o.Option { if e, ok := s.(*dns.EDNS0_SUBNET); ok { if rule.action == Replace || rule.action == Set { if rule.fillEcsData(state, e) == nil { return RewriteDone } ...
[ "func", "(", "rule", "*", "edns0SubnetRule", ")", "Rewrite", "(", "ctx", "context", ".", "Context", ",", "state", "request", ".", "Request", ")", "Result", "{", "o", ":=", "setupEdns0Opt", "(", "state", ".", "Req", ")", "\n\n", "for", "_", ",", "s", ...
// Rewrite will alter the request EDNS0 subnet option.
[ "Rewrite", "will", "alter", "the", "request", "EDNS0", "subnet", "option", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/rewrite/edns0.go#L336-L360
130,758
coredns/coredns
core/dnsserver/server_https.go
NewServerHTTPS
func NewServerHTTPS(addr string, group []*Config) (*ServerHTTPS, error) { s, err := NewServer(addr, group) if err != nil { return nil, err } // The *tls* plugin must make sure that multiple conflicting // TLS configuration return an error: it can only be specified once. var tlsConfig *tls.Config for _, conf :=...
go
func NewServerHTTPS(addr string, group []*Config) (*ServerHTTPS, error) { s, err := NewServer(addr, group) if err != nil { return nil, err } // The *tls* plugin must make sure that multiple conflicting // TLS configuration return an error: it can only be specified once. var tlsConfig *tls.Config for _, conf :=...
[ "func", "NewServerHTTPS", "(", "addr", "string", ",", "group", "[", "]", "*", "Config", ")", "(", "*", "ServerHTTPS", ",", "error", ")", "{", "s", ",", "err", ":=", "NewServer", "(", "addr", ",", "group", ")", "\n", "if", "err", "!=", "nil", "{", ...
// NewServerHTTPS returns a new CoreDNS GRPC server and compiles all plugins in to it.
[ "NewServerHTTPS", "returns", "a", "new", "CoreDNS", "GRPC", "server", "and", "compiles", "all", "plugins", "in", "to", "it", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/core/dnsserver/server_https.go#L27-L44
130,759
coredns/coredns
core/dnsserver/server_https.go
ServeHTTP
func (s *ServerHTTPS) ServeHTTP(w http.ResponseWriter, r *http.Request) { if r.URL.Path != doh.Path { http.Error(w, "", http.StatusNotFound) return } msg, err := doh.RequestToMsg(r) if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) return } // Create a DoHWriter with the correct address...
go
func (s *ServerHTTPS) ServeHTTP(w http.ResponseWriter, r *http.Request) { if r.URL.Path != doh.Path { http.Error(w, "", http.StatusNotFound) return } msg, err := doh.RequestToMsg(r) if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) return } // Create a DoHWriter with the correct address...
[ "func", "(", "s", "*", "ServerHTTPS", ")", "ServeHTTP", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "if", "r", ".", "URL", ".", "Path", "!=", "doh", ".", "Path", "{", "http", ".", "Error", "(", "w", ...
// ServeHTTP is the handler that gets the HTTP request and converts to the dns format, calls the plugin // chain, converts it back and write it to the client.
[ "ServeHTTP", "is", "the", "handler", "that", "gets", "the", "HTTP", "request", "and", "converts", "to", "the", "dns", "format", "calls", "the", "plugin", "chain", "converts", "it", "back", "and", "write", "it", "to", "the", "client", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/core/dnsserver/server_https.go#L100-L141
130,760
coredns/coredns
request/request.go
NewWithQuestion
func (r *Request) NewWithQuestion(name string, typ uint16) Request { req1 := Request{W: r.W, Req: r.Req.Copy()} req1.Req.Question[0] = dns.Question{Name: dns.Fqdn(name), Qclass: dns.ClassINET, Qtype: typ} return req1 }
go
func (r *Request) NewWithQuestion(name string, typ uint16) Request { req1 := Request{W: r.W, Req: r.Req.Copy()} req1.Req.Question[0] = dns.Question{Name: dns.Fqdn(name), Qclass: dns.ClassINET, Qtype: typ} return req1 }
[ "func", "(", "r", "*", "Request", ")", "NewWithQuestion", "(", "name", "string", ",", "typ", "uint16", ")", "Request", "{", "req1", ":=", "Request", "{", "W", ":", "r", ".", "W", ",", "Req", ":", "r", ".", "Req", ".", "Copy", "(", ")", "}", "\n...
// NewWithQuestion returns a new request based on the old, but with a new question // section in the request.
[ "NewWithQuestion", "returns", "a", "new", "request", "based", "on", "the", "old", "but", "with", "a", "new", "question", "section", "in", "the", "request", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/request/request.go#L36-L40
130,761
coredns/coredns
request/request.go
LocalPort
func (r *Request) LocalPort() string { if r.localPort != "" { return r.localPort } _, port, err := net.SplitHostPort(r.W.LocalAddr().String()) if err != nil { r.localPort = "0" return r.localPort } r.localPort = port return r.localPort }
go
func (r *Request) LocalPort() string { if r.localPort != "" { return r.localPort } _, port, err := net.SplitHostPort(r.W.LocalAddr().String()) if err != nil { r.localPort = "0" return r.localPort } r.localPort = port return r.localPort }
[ "func", "(", "r", "*", "Request", ")", "LocalPort", "(", ")", "string", "{", "if", "r", ".", "localPort", "!=", "\"", "\"", "{", "return", "r", ".", "localPort", "\n", "}", "\n\n", "_", ",", "port", ",", "err", ":=", "net", ".", "SplitHostPort", ...
// LocalPort gets the local port of the server handling the request.
[ "LocalPort", "gets", "the", "local", "port", "of", "the", "server", "handling", "the", "request", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/request/request.go#L91-L104
130,762
coredns/coredns
request/request.go
Proto
func Proto(w dns.ResponseWriter) string { // FIXME(miek): why not a method on Request if _, ok := w.RemoteAddr().(*net.UDPAddr); ok { return "udp" } if _, ok := w.RemoteAddr().(*net.TCPAddr); ok { return "tcp" } return "udp" }
go
func Proto(w dns.ResponseWriter) string { // FIXME(miek): why not a method on Request if _, ok := w.RemoteAddr().(*net.UDPAddr); ok { return "udp" } if _, ok := w.RemoteAddr().(*net.TCPAddr); ok { return "tcp" } return "udp" }
[ "func", "Proto", "(", "w", "dns", ".", "ResponseWriter", ")", "string", "{", "// FIXME(miek): why not a method on Request", "if", "_", ",", "ok", ":=", "w", ".", "RemoteAddr", "(", ")", ".", "(", "*", "net", ".", "UDPAddr", ")", ";", "ok", "{", "return",...
// Proto gets the protocol used as the transport. This will be udp or tcp.
[ "Proto", "gets", "the", "protocol", "used", "as", "the", "transport", ".", "This", "will", "be", "udp", "or", "tcp", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/request/request.go#L116-L125
130,763
coredns/coredns
request/request.go
SizeAndDo
func (r *Request) SizeAndDo(m *dns.Msg) bool { o := r.Req.IsEdns0() if o == nil { return false } if mo := m.IsEdns0(); mo != nil { mo.Hdr.Name = "." mo.Hdr.Rrtype = dns.TypeOPT mo.SetVersion(0) mo.SetUDPSize(o.UDPSize()) mo.Hdr.Ttl &= 0xff00 // clear flags // Assume if the message m has options set,...
go
func (r *Request) SizeAndDo(m *dns.Msg) bool { o := r.Req.IsEdns0() if o == nil { return false } if mo := m.IsEdns0(); mo != nil { mo.Hdr.Name = "." mo.Hdr.Rrtype = dns.TypeOPT mo.SetVersion(0) mo.SetUDPSize(o.UDPSize()) mo.Hdr.Ttl &= 0xff00 // clear flags // Assume if the message m has options set,...
[ "func", "(", "r", "*", "Request", ")", "SizeAndDo", "(", "m", "*", "dns", ".", "Msg", ")", "bool", "{", "o", ":=", "r", ".", "Req", ".", "IsEdns0", "(", ")", "\n", "if", "o", "==", "nil", "{", "return", "false", "\n", "}", "\n\n", "if", "mo",...
// SizeAndDo adds an OPT record that the reflects the intent from request. // The returned bool indicates if an record was found and normalised.
[ "SizeAndDo", "adds", "an", "OPT", "record", "that", "the", "reflects", "the", "intent", "from", "request", ".", "The", "returned", "bool", "indicates", "if", "an", "record", "was", "found", "and", "normalised", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/request/request.go#L192-L225
130,764
coredns/coredns
request/request.go
Type
func (r *Request) Type() string { if r.Req == nil { return "" } if len(r.Req.Question) == 0 { return "" } return dns.Type(r.Req.Question[0].Qtype).String() }
go
func (r *Request) Type() string { if r.Req == nil { return "" } if len(r.Req.Question) == 0 { return "" } return dns.Type(r.Req.Question[0].Qtype).String() }
[ "func", "(", "r", "*", "Request", ")", "Type", "(", ")", "string", "{", "if", "r", ".", "Req", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "if", "len", "(", "r", ".", "Req", ".", "Question", ")", "==", "0", "{", "return", "\"", ...
// Type returns the type of the question as a string. If the request is malformed the empty string is returned.
[ "Type", "returns", "the", "type", "of", "the", "question", "as", "a", "string", ".", "If", "the", "request", "is", "malformed", "the", "empty", "string", "is", "returned", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/request/request.go#L346-L355
130,765
coredns/coredns
request/request.go
QType
func (r *Request) QType() uint16 { if r.Req == nil { return 0 } if len(r.Req.Question) == 0 { return 0 } return r.Req.Question[0].Qtype }
go
func (r *Request) QType() uint16 { if r.Req == nil { return 0 } if len(r.Req.Question) == 0 { return 0 } return r.Req.Question[0].Qtype }
[ "func", "(", "r", "*", "Request", ")", "QType", "(", ")", "uint16", "{", "if", "r", ".", "Req", "==", "nil", "{", "return", "0", "\n", "}", "\n", "if", "len", "(", "r", ".", "Req", ".", "Question", ")", "==", "0", "{", "return", "0", "\n", ...
// QType returns the type of the question as an uint16. If the request is malformed // 0 is returned.
[ "QType", "returns", "the", "type", "of", "the", "question", "as", "an", "uint16", ".", "If", "the", "request", "is", "malformed", "0", "is", "returned", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/request/request.go#L359-L368
130,766
coredns/coredns
request/request.go
Name
func (r *Request) Name() string { if r.name != "" { return r.name } if r.Req == nil { r.name = "." return "." } if len(r.Req.Question) == 0 { r.name = "." return "." } r.name = strings.ToLower(dns.Name(r.Req.Question[0].Name).String()) return r.name }
go
func (r *Request) Name() string { if r.name != "" { return r.name } if r.Req == nil { r.name = "." return "." } if len(r.Req.Question) == 0 { r.name = "." return "." } r.name = strings.ToLower(dns.Name(r.Req.Question[0].Name).String()) return r.name }
[ "func", "(", "r", "*", "Request", ")", "Name", "(", ")", "string", "{", "if", "r", ".", "name", "!=", "\"", "\"", "{", "return", "r", ".", "name", "\n", "}", "\n", "if", "r", ".", "Req", "==", "nil", "{", "r", ".", "name", "=", "\"", "\"", ...
// Name returns the name of the question in the request. Note // this name will always have a closing dot and will be lower cased. After a call Name // the value will be cached. To clear this caching call Clear. // If the request is malformed the root zone is returned.
[ "Name", "returns", "the", "name", "of", "the", "question", "in", "the", "request", ".", "Note", "this", "name", "will", "always", "have", "a", "closing", "dot", "and", "will", "be", "lower", "cased", ".", "After", "a", "call", "Name", "the", "value", "...
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/request/request.go#L374-L389
130,767
coredns/coredns
request/request.go
QName
func (r *Request) QName() string { if r.Req == nil { return "." } if len(r.Req.Question) == 0 { return "." } return dns.Name(r.Req.Question[0].Name).String() }
go
func (r *Request) QName() string { if r.Req == nil { return "." } if len(r.Req.Question) == 0 { return "." } return dns.Name(r.Req.Question[0].Name).String() }
[ "func", "(", "r", "*", "Request", ")", "QName", "(", ")", "string", "{", "if", "r", ".", "Req", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "if", "len", "(", "r", ".", "Req", ".", "Question", ")", "==", "0", "{", "return", "\"", ...
// QName returns the name of the question in the request. // If the request is malformed the root zone is returned.
[ "QName", "returns", "the", "name", "of", "the", "question", "in", "the", "request", ".", "If", "the", "request", "is", "malformed", "the", "root", "zone", "is", "returned", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/request/request.go#L393-L402
130,768
coredns/coredns
request/request.go
Class
func (r *Request) Class() string { if r.Req == nil { return "" } if len(r.Req.Question) == 0 { return "" } return dns.Class(r.Req.Question[0].Qclass).String() }
go
func (r *Request) Class() string { if r.Req == nil { return "" } if len(r.Req.Question) == 0 { return "" } return dns.Class(r.Req.Question[0].Qclass).String() }
[ "func", "(", "r", "*", "Request", ")", "Class", "(", ")", "string", "{", "if", "r", ".", "Req", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "if", "len", "(", "r", ".", "Req", ".", "Question", ")", "==", "0", "{", "return", "\"", ...
// Class returns the class of the question in the request. // If the request is malformed the empty string is returned.
[ "Class", "returns", "the", "class", "of", "the", "question", "in", "the", "request", ".", "If", "the", "request", "is", "malformed", "the", "empty", "string", "is", "returned", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/request/request.go#L406-L416
130,769
coredns/coredns
request/request.go
QClass
func (r *Request) QClass() uint16 { if r.Req == nil { return 0 } if len(r.Req.Question) == 0 { return 0 } return r.Req.Question[0].Qclass }
go
func (r *Request) QClass() uint16 { if r.Req == nil { return 0 } if len(r.Req.Question) == 0 { return 0 } return r.Req.Question[0].Qclass }
[ "func", "(", "r", "*", "Request", ")", "QClass", "(", ")", "uint16", "{", "if", "r", ".", "Req", "==", "nil", "{", "return", "0", "\n", "}", "\n", "if", "len", "(", "r", ".", "Req", ".", "Question", ")", "==", "0", "{", "return", "0", "\n", ...
// QClass returns the class of the question in the request. // If the request is malformed 0 returned.
[ "QClass", "returns", "the", "class", "of", "the", "question", "in", "the", "request", ".", "If", "the", "request", "is", "malformed", "0", "returned", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/request/request.go#L420-L430
130,770
coredns/coredns
request/request.go
Clear
func (r *Request) Clear() { r.name = "" r.ip = "" r.localIP = "" r.port = "" r.localPort = "" r.family = 0 }
go
func (r *Request) Clear() { r.name = "" r.ip = "" r.localIP = "" r.port = "" r.localPort = "" r.family = 0 }
[ "func", "(", "r", "*", "Request", ")", "Clear", "(", ")", "{", "r", ".", "name", "=", "\"", "\"", "\n", "r", ".", "ip", "=", "\"", "\"", "\n", "r", ".", "localIP", "=", "\"", "\"", "\n", "r", ".", "port", "=", "\"", "\"", "\n", "r", ".", ...
// Clear clears all caching from Request s.
[ "Clear", "clears", "all", "caching", "from", "Request", "s", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/request/request.go#L433-L440
130,771
coredns/coredns
request/request.go
Match
func (r *Request) Match(reply *dns.Msg) bool { if len(reply.Question) != 1 { return false } if reply.Response == false { return false } if strings.ToLower(reply.Question[0].Name) != r.Name() { return false } if reply.Question[0].Qtype != r.QType() { return false } return true }
go
func (r *Request) Match(reply *dns.Msg) bool { if len(reply.Question) != 1 { return false } if reply.Response == false { return false } if strings.ToLower(reply.Question[0].Name) != r.Name() { return false } if reply.Question[0].Qtype != r.QType() { return false } return true }
[ "func", "(", "r", "*", "Request", ")", "Match", "(", "reply", "*", "dns", ".", "Msg", ")", "bool", "{", "if", "len", "(", "reply", ".", "Question", ")", "!=", "1", "{", "return", "false", "\n", "}", "\n\n", "if", "reply", ".", "Response", "==", ...
// Match checks if the reply matches the qname and qtype from the request, it returns // false when they don't match.
[ "Match", "checks", "if", "the", "reply", "matches", "the", "qname", "and", "qtype", "from", "the", "request", "it", "returns", "false", "when", "they", "don", "t", "match", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/request/request.go#L444-L462
130,772
coredns/coredns
plugin/file/tree/tree.go
Search
func (t *Tree) Search(qname string) (*Elem, bool) { if t.Root == nil { return nil, false } n, res := t.Root.search(qname) if n == nil { return nil, res } return n.Elem, res }
go
func (t *Tree) Search(qname string) (*Elem, bool) { if t.Root == nil { return nil, false } n, res := t.Root.search(qname) if n == nil { return nil, res } return n.Elem, res }
[ "func", "(", "t", "*", "Tree", ")", "Search", "(", "qname", "string", ")", "(", "*", "Elem", ",", "bool", ")", "{", "if", "t", ".", "Root", "==", "nil", "{", "return", "nil", ",", "false", "\n", "}", "\n", "n", ",", "res", ":=", "t", ".", "...
// Search returns the first match of qname in the Tree.
[ "Search", "returns", "the", "first", "match", "of", "qname", "in", "the", "Tree", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/file/tree/tree.go#L141-L150
130,773
coredns/coredns
plugin/file/tree/tree.go
search
func (n *Node) search(qname string) (*Node, bool) { for n != nil { switch c := Less(n.Elem, qname); { case c == 0: return n, true case c < 0: n = n.Left default: n = n.Right } } return n, false }
go
func (n *Node) search(qname string) (*Node, bool) { for n != nil { switch c := Less(n.Elem, qname); { case c == 0: return n, true case c < 0: n = n.Left default: n = n.Right } } return n, false }
[ "func", "(", "n", "*", "Node", ")", "search", "(", "qname", "string", ")", "(", "*", "Node", ",", "bool", ")", "{", "for", "n", "!=", "nil", "{", "switch", "c", ":=", "Less", "(", "n", ".", "Elem", ",", "qname", ")", ";", "{", "case", "c", ...
// search searches the tree for qname and type.
[ "search", "searches", "the", "tree", "for", "qname", "and", "type", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/file/tree/tree.go#L153-L166
130,774
coredns/coredns
plugin/file/tree/tree.go
Insert
func (t *Tree) Insert(rr dns.RR) { var d int t.Root, d = t.Root.insert(rr) t.Count += d t.Root.Color = black }
go
func (t *Tree) Insert(rr dns.RR) { var d int t.Root, d = t.Root.insert(rr) t.Count += d t.Root.Color = black }
[ "func", "(", "t", "*", "Tree", ")", "Insert", "(", "rr", "dns", ".", "RR", ")", "{", "var", "d", "int", "\n", "t", ".", "Root", ",", "d", "=", "t", ".", "Root", ".", "insert", "(", "rr", ")", "\n", "t", ".", "Count", "+=", "d", "\n", "t",...
// Insert inserts rr into the Tree at the first match found // with e or when a nil node is reached.
[ "Insert", "inserts", "rr", "into", "the", "Tree", "at", "the", "first", "match", "found", "with", "e", "or", "when", "a", "nil", "node", "is", "reached", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/file/tree/tree.go#L170-L175
130,775
coredns/coredns
plugin/file/tree/tree.go
insert
func (n *Node) insert(rr dns.RR) (root *Node, d int) { if n == nil { return &Node{Elem: newElem(rr)}, 1 } else if n.Elem == nil { n.Elem = newElem(rr) return n, 1 } if mode == td234 { if n.Left.color() == red && n.Right.color() == red { n.flipColors() } } switch c := Less(n.Elem, rr.Header().Name);...
go
func (n *Node) insert(rr dns.RR) (root *Node, d int) { if n == nil { return &Node{Elem: newElem(rr)}, 1 } else if n.Elem == nil { n.Elem = newElem(rr) return n, 1 } if mode == td234 { if n.Left.color() == red && n.Right.color() == red { n.flipColors() } } switch c := Less(n.Elem, rr.Header().Name);...
[ "func", "(", "n", "*", "Node", ")", "insert", "(", "rr", "dns", ".", "RR", ")", "(", "root", "*", "Node", ",", "d", "int", ")", "{", "if", "n", "==", "nil", "{", "return", "&", "Node", "{", "Elem", ":", "newElem", "(", "rr", ")", "}", ",", ...
// insert inserts rr in to the tree.
[ "insert", "inserts", "rr", "in", "to", "the", "tree", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/file/tree/tree.go#L178-L217
130,776
coredns/coredns
plugin/file/tree/tree.go
DeleteMin
func (t *Tree) DeleteMin() { if t.Root == nil { return } var d int t.Root, d = t.Root.deleteMin() t.Count += d if t.Root == nil { return } t.Root.Color = black }
go
func (t *Tree) DeleteMin() { if t.Root == nil { return } var d int t.Root, d = t.Root.deleteMin() t.Count += d if t.Root == nil { return } t.Root.Color = black }
[ "func", "(", "t", "*", "Tree", ")", "DeleteMin", "(", ")", "{", "if", "t", ".", "Root", "==", "nil", "{", "return", "\n", "}", "\n", "var", "d", "int", "\n", "t", ".", "Root", ",", "d", "=", "t", ".", "Root", ".", "deleteMin", "(", ")", "\n...
// DeleteMin deletes the node with the minimum value in the tree.
[ "DeleteMin", "deletes", "the", "node", "with", "the", "minimum", "value", "in", "the", "tree", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/file/tree/tree.go#L220-L231
130,777
coredns/coredns
plugin/file/tree/tree.go
Delete
func (t *Tree) Delete(rr dns.RR) { if t.Root == nil { return } el, _ := t.Search(rr.Header().Name) if el == nil { t.deleteNode(rr) return } // Delete from this element. empty := el.Delete(rr) if empty { t.deleteNode(rr) return } }
go
func (t *Tree) Delete(rr dns.RR) { if t.Root == nil { return } el, _ := t.Search(rr.Header().Name) if el == nil { t.deleteNode(rr) return } // Delete from this element. empty := el.Delete(rr) if empty { t.deleteNode(rr) return } }
[ "func", "(", "t", "*", "Tree", ")", "Delete", "(", "rr", "dns", ".", "RR", ")", "{", "if", "t", ".", "Root", "==", "nil", "{", "return", "\n", "}", "\n\n", "el", ",", "_", ":=", "t", ".", "Search", "(", "rr", ".", "Header", "(", ")", ".", ...
// Delete removes rr from the tree, is the node turns empty, that node is deleted with DeleteNode.
[ "Delete", "removes", "rr", "from", "the", "tree", "is", "the", "node", "turns", "empty", "that", "node", "is", "deleted", "with", "DeleteNode", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/file/tree/tree.go#L279-L295
130,778
coredns/coredns
plugin/kubernetes/external.go
External
func (k *Kubernetes) External(state request.Request) ([]msg.Service, int) { base, _ := dnsutil.TrimZone(state.Name(), state.Zone) segs := dns.SplitDomainName(base) last := len(segs) - 1 if last < 0 { return nil, dns.RcodeServerFailure } // We dealing with a fairly normal domain name here, but; we still need to...
go
func (k *Kubernetes) External(state request.Request) ([]msg.Service, int) { base, _ := dnsutil.TrimZone(state.Name(), state.Zone) segs := dns.SplitDomainName(base) last := len(segs) - 1 if last < 0 { return nil, dns.RcodeServerFailure } // We dealing with a fairly normal domain name here, but; we still need to...
[ "func", "(", "k", "*", "Kubernetes", ")", "External", "(", "state", "request", ".", "Request", ")", "(", "[", "]", "msg", ".", "Service", ",", "int", ")", "{", "base", ",", "_", ":=", "dnsutil", ".", "TrimZone", "(", "state", ".", "Name", "(", ")...
// External implements the ExternalFunc call from the external plugin. // It returns any services matching in the services' ExternalIPs.
[ "External", "implements", "the", "ExternalFunc", "call", "from", "the", "external", "plugin", ".", "It", "returns", "any", "services", "matching", "in", "the", "services", "ExternalIPs", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/kubernetes/external.go#L16-L84
130,779
coredns/coredns
plugin/file/zone.go
Copy
func (z *Zone) Copy() *Zone { z1 := NewZone(z.origin, z.file) z1.TransferTo = z.TransferTo z1.TransferFrom = z.TransferFrom z1.Expired = z.Expired z1.Apex = z.Apex return z1 }
go
func (z *Zone) Copy() *Zone { z1 := NewZone(z.origin, z.file) z1.TransferTo = z.TransferTo z1.TransferFrom = z.TransferFrom z1.Expired = z.Expired z1.Apex = z.Apex return z1 }
[ "func", "(", "z", "*", "Zone", ")", "Copy", "(", ")", "*", "Zone", "{", "z1", ":=", "NewZone", "(", "z", ".", "origin", ",", "z", ".", "file", ")", "\n", "z1", ".", "TransferTo", "=", "z", ".", "TransferTo", "\n", "z1", ".", "TransferFrom", "="...
// Copy copies a zone.
[ "Copy", "copies", "a", "zone", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/file/zone.go#L63-L71
130,780
coredns/coredns
plugin/file/zone.go
CopyWithoutApex
func (z *Zone) CopyWithoutApex() *Zone { z1 := NewZone(z.origin, z.file) z1.TransferTo = z.TransferTo z1.TransferFrom = z.TransferFrom z1.Expired = z.Expired return z1 }
go
func (z *Zone) CopyWithoutApex() *Zone { z1 := NewZone(z.origin, z.file) z1.TransferTo = z.TransferTo z1.TransferFrom = z.TransferFrom z1.Expired = z.Expired return z1 }
[ "func", "(", "z", "*", "Zone", ")", "CopyWithoutApex", "(", ")", "*", "Zone", "{", "z1", ":=", "NewZone", "(", "z", ".", "origin", ",", "z", ".", "file", ")", "\n", "z1", ".", "TransferTo", "=", "z", ".", "TransferTo", "\n", "z1", ".", "TransferF...
// CopyWithoutApex copies zone z without the Apex records.
[ "CopyWithoutApex", "copies", "zone", "z", "without", "the", "Apex", "records", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/file/zone.go#L74-L81
130,781
coredns/coredns
plugin/file/zone.go
Insert
func (z *Zone) Insert(r dns.RR) error { r.Header().Name = strings.ToLower(r.Header().Name) switch h := r.Header().Rrtype; h { case dns.TypeNS: r.(*dns.NS).Ns = strings.ToLower(r.(*dns.NS).Ns) if r.Header().Name == z.origin { z.Apex.NS = append(z.Apex.NS, r) return nil } case dns.TypeSOA: r.(*dns.SOA...
go
func (z *Zone) Insert(r dns.RR) error { r.Header().Name = strings.ToLower(r.Header().Name) switch h := r.Header().Rrtype; h { case dns.TypeNS: r.(*dns.NS).Ns = strings.ToLower(r.(*dns.NS).Ns) if r.Header().Name == z.origin { z.Apex.NS = append(z.Apex.NS, r) return nil } case dns.TypeSOA: r.(*dns.SOA...
[ "func", "(", "z", "*", "Zone", ")", "Insert", "(", "r", "dns", ".", "RR", ")", "error", "{", "r", ".", "Header", "(", ")", ".", "Name", "=", "strings", ".", "ToLower", "(", "r", ".", "Header", "(", ")", ".", "Name", ")", "\n\n", "switch", "h"...
// Insert inserts r into z.
[ "Insert", "inserts", "r", "into", "z", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/file/zone.go#L84-L125
130,782
coredns/coredns
plugin/file/zone.go
File
func (z *Zone) File() string { z.reloadMu.Lock() defer z.reloadMu.Unlock() return z.file }
go
func (z *Zone) File() string { z.reloadMu.Lock() defer z.reloadMu.Unlock() return z.file }
[ "func", "(", "z", "*", "Zone", ")", "File", "(", ")", "string", "{", "z", ".", "reloadMu", ".", "Lock", "(", ")", "\n", "defer", "z", ".", "reloadMu", ".", "Unlock", "(", ")", "\n", "return", "z", ".", "file", "\n", "}" ]
// File retrieves the file path in a safe way
[ "File", "retrieves", "the", "file", "path", "in", "a", "safe", "way" ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/file/zone.go#L131-L135
130,783
coredns/coredns
plugin/file/zone.go
SetFile
func (z *Zone) SetFile(path string) { z.reloadMu.Lock() z.file = path z.reloadMu.Unlock() }
go
func (z *Zone) SetFile(path string) { z.reloadMu.Lock() z.file = path z.reloadMu.Unlock() }
[ "func", "(", "z", "*", "Zone", ")", "SetFile", "(", "path", "string", ")", "{", "z", ".", "reloadMu", ".", "Lock", "(", ")", "\n", "z", ".", "file", "=", "path", "\n", "z", ".", "reloadMu", ".", "Unlock", "(", ")", "\n", "}" ]
// SetFile updates the file path in a safe way
[ "SetFile", "updates", "the", "file", "path", "in", "a", "safe", "way" ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/file/zone.go#L138-L142
130,784
coredns/coredns
plugin/file/zone.go
TransferAllowed
func (z *Zone) TransferAllowed(state request.Request) bool { for _, t := range z.TransferTo { if t == "*" { return true } // If remote IP matches we accept. remote := state.IP() to, _, err := net.SplitHostPort(t) if err != nil { continue } if to == remote { return true } } // TODO(miek): f...
go
func (z *Zone) TransferAllowed(state request.Request) bool { for _, t := range z.TransferTo { if t == "*" { return true } // If remote IP matches we accept. remote := state.IP() to, _, err := net.SplitHostPort(t) if err != nil { continue } if to == remote { return true } } // TODO(miek): f...
[ "func", "(", "z", "*", "Zone", ")", "TransferAllowed", "(", "state", "request", ".", "Request", ")", "bool", "{", "for", "_", ",", "t", ":=", "range", "z", ".", "TransferTo", "{", "if", "t", "==", "\"", "\"", "{", "return", "true", "\n", "}", "\n...
// TransferAllowed checks if incoming request for transferring the zone is allowed according to the ACLs.
[ "TransferAllowed", "checks", "if", "incoming", "request", "for", "transferring", "the", "zone", "is", "allowed", "according", "to", "the", "ACLs", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/file/zone.go#L145-L162
130,785
coredns/coredns
plugin/file/zone.go
nameFromRight
func (z *Zone) nameFromRight(qname string, i int) (string, bool) { if i <= 0 { return z.origin, false } for j := 1; j <= z.origLen; j++ { if _, shot := dns.PrevLabel(qname, j); shot { return qname, shot } } k := 0 var shot bool for j := 1; j <= i; j++ { k, shot = dns.PrevLabel(qname, j+z.origLen) ...
go
func (z *Zone) nameFromRight(qname string, i int) (string, bool) { if i <= 0 { return z.origin, false } for j := 1; j <= z.origLen; j++ { if _, shot := dns.PrevLabel(qname, j); shot { return qname, shot } } k := 0 var shot bool for j := 1; j <= i; j++ { k, shot = dns.PrevLabel(qname, j+z.origLen) ...
[ "func", "(", "z", "*", "Zone", ")", "nameFromRight", "(", "qname", "string", ",", "i", "int", ")", "(", "string", ",", "bool", ")", "{", "if", "i", "<=", "0", "{", "return", "z", ".", "origin", ",", "false", "\n", "}", "\n\n", "for", "j", ":=",...
// NameFromRight returns the labels from the right, staring with the // origin and then i labels extra. When we are overshooting the name // the returned boolean is set to true.
[ "NameFromRight", "returns", "the", "labels", "from", "the", "right", "staring", "with", "the", "origin", "and", "then", "i", "labels", "extra", ".", "When", "we", "are", "overshooting", "the", "name", "the", "returned", "boolean", "is", "set", "to", "true", ...
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/file/zone.go#L197-L217
130,786
coredns/coredns
plugin/health/health.go
newHealth
func newHealth(addr string) *health { return &health{Addr: addr, stop: make(chan bool)} }
go
func newHealth(addr string) *health { return &health{Addr: addr, stop: make(chan bool)} }
[ "func", "newHealth", "(", "addr", "string", ")", "*", "health", "{", "return", "&", "health", "{", "Addr", ":", "addr", ",", "stop", ":", "make", "(", "chan", "bool", ")", "}", "\n", "}" ]
// newHealth returns a new initialized health.
[ "newHealth", "returns", "a", "new", "initialized", "health", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/health/health.go#L28-L30
130,787
coredns/coredns
plugin/pkg/upstream/upstream.go
Lookup
func (u *Upstream) Lookup(ctx context.Context, state request.Request, name string, typ uint16) (*dns.Msg, error) { server, ok := ctx.Value(dnsserver.Key{}).(*dnsserver.Server) if !ok { return nil, fmt.Errorf("no full server is running") } req := new(dns.Msg) req.SetQuestion(name, typ) nw := nonwriter.New(stat...
go
func (u *Upstream) Lookup(ctx context.Context, state request.Request, name string, typ uint16) (*dns.Msg, error) { server, ok := ctx.Value(dnsserver.Key{}).(*dnsserver.Server) if !ok { return nil, fmt.Errorf("no full server is running") } req := new(dns.Msg) req.SetQuestion(name, typ) nw := nonwriter.New(stat...
[ "func", "(", "u", "*", "Upstream", ")", "Lookup", "(", "ctx", "context", ".", "Context", ",", "state", "request", ".", "Request", ",", "name", "string", ",", "typ", "uint16", ")", "(", "*", "dns", ".", "Msg", ",", "error", ")", "{", "server", ",", ...
// Lookup routes lookups to our selves or forward to a remote.
[ "Lookup", "routes", "lookups", "to", "our", "selves", "or", "forward", "to", "a", "remote", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/pkg/upstream/upstream.go#L22-L36
130,788
coredns/coredns
plugin/forward/persistent.go
connManager
func (t *Transport) connManager() { ticker := time.NewTicker(t.expire) Wait: for { select { case proto := <-t.dial: // take the last used conn - complexity O(1) if stack := t.conns[proto]; len(stack) > 0 { pc := stack[len(stack)-1] if time.Since(pc.used) < t.expire { // Found one, remove from p...
go
func (t *Transport) connManager() { ticker := time.NewTicker(t.expire) Wait: for { select { case proto := <-t.dial: // take the last used conn - complexity O(1) if stack := t.conns[proto]; len(stack) > 0 { pc := stack[len(stack)-1] if time.Since(pc.used) < t.expire { // Found one, remove from p...
[ "func", "(", "t", "*", "Transport", ")", "connManager", "(", ")", "{", "ticker", ":=", "time", ".", "NewTicker", "(", "t", ".", "expire", ")", "\n", "Wait", ":", "for", "{", "select", "{", "case", "proto", ":=", "<-", "t", ".", "dial", ":", "// t...
// connManagers manages the persistent connection cache for UDP and TCP.
[ "connManagers", "manages", "the", "persistent", "connection", "cache", "for", "UDP", "and", "TCP", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/forward/persistent.go#L57-L108
130,789
coredns/coredns
plugin/forward/persistent.go
cleanup
func (t *Transport) cleanup(all bool) { staleTime := time.Now().Add(-t.expire) for proto, stack := range t.conns { if len(stack) == 0 { continue } if all { t.conns[proto] = nil // now, the connections being passed to closeConns() are not reachable from // transport methods anymore. So, it's safe to ...
go
func (t *Transport) cleanup(all bool) { staleTime := time.Now().Add(-t.expire) for proto, stack := range t.conns { if len(stack) == 0 { continue } if all { t.conns[proto] = nil // now, the connections being passed to closeConns() are not reachable from // transport methods anymore. So, it's safe to ...
[ "func", "(", "t", "*", "Transport", ")", "cleanup", "(", "all", "bool", ")", "{", "staleTime", ":=", "time", ".", "Now", "(", ")", ".", "Add", "(", "-", "t", ".", "expire", ")", "\n", "for", "proto", ",", "stack", ":=", "range", "t", ".", "conn...
// cleanup removes connections from cache.
[ "cleanup", "removes", "connections", "from", "cache", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/forward/persistent.go#L118-L144
130,790
coredns/coredns
plugin/kubernetes/ns.go
nsAddr
func (k *Kubernetes) nsAddr() *dns.A { var ( svcName string svcNamespace string ) rr := new(dns.A) localIP := k.interfaceAddrsFunc() rr.A = localIP FindEndpoint: for _, ep := range k.APIConn.EpIndexReverse(localIP.String()) { for _, eps := range ep.Subsets { for _, addr := range eps.Addresses { ...
go
func (k *Kubernetes) nsAddr() *dns.A { var ( svcName string svcNamespace string ) rr := new(dns.A) localIP := k.interfaceAddrsFunc() rr.A = localIP FindEndpoint: for _, ep := range k.APIConn.EpIndexReverse(localIP.String()) { for _, eps := range ep.Subsets { for _, addr := range eps.Addresses { ...
[ "func", "(", "k", "*", "Kubernetes", ")", "nsAddr", "(", ")", "*", "dns", ".", "A", "{", "var", "(", "svcName", "string", "\n", "svcNamespace", "string", "\n", ")", "\n\n", "rr", ":=", "new", "(", "dns", ".", "A", ")", "\n", "localIP", ":=", "k",...
// nsAddr return the A record for the CoreDNS service in the cluster. If it fails that it fallsback // on the local address of the machine we're running on. // // This function is rather expensive to run.
[ "nsAddr", "return", "the", "A", "record", "for", "the", "CoreDNS", "service", "in", "the", "cluster", ".", "If", "it", "fails", "that", "it", "fallsback", "on", "the", "local", "address", "of", "the", "machine", "we", "re", "running", "on", ".", "This", ...
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/kubernetes/ns.go#L19-L63
130,791
coredns/coredns
plugin/pkg/parse/host.go
tryFile
func tryFile(s string) ([]string, error) { c, err := dns.ClientConfigFromFile(s) if err == os.ErrNotExist { return nil, fmt.Errorf("failed to open file %q: %q", s, err) } else if err != nil { return nil, err } servers := []string{} for _, s := range c.Servers { servers = append(servers, net.JoinHostPort(s,...
go
func tryFile(s string) ([]string, error) { c, err := dns.ClientConfigFromFile(s) if err == os.ErrNotExist { return nil, fmt.Errorf("failed to open file %q: %q", s, err) } else if err != nil { return nil, err } servers := []string{} for _, s := range c.Servers { servers = append(servers, net.JoinHostPort(s,...
[ "func", "tryFile", "(", "s", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "c", ",", "err", ":=", "dns", ".", "ClientConfigFromFile", "(", "s", ")", "\n", "if", "err", "==", "os", ".", "ErrNotExist", "{", "return", "nil", ",", "...
// Try to open this is a file first.
[ "Try", "to", "open", "this", "is", "a", "file", "first", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/pkg/parse/host.go#L65-L78
130,792
coredns/coredns
plugin/pkg/parse/host.go
HostPort
func HostPort(s, defaultPort string) (string, error) { addr, port, err := net.SplitHostPort(s) if port == "" { port = defaultPort } if err != nil { if net.ParseIP(s) == nil { return "", fmt.Errorf("must specify an IP address: `%s'", s) } return net.JoinHostPort(s, port), nil } if net.ParseIP(addr) == ...
go
func HostPort(s, defaultPort string) (string, error) { addr, port, err := net.SplitHostPort(s) if port == "" { port = defaultPort } if err != nil { if net.ParseIP(s) == nil { return "", fmt.Errorf("must specify an IP address: `%s'", s) } return net.JoinHostPort(s, port), nil } if net.ParseIP(addr) == ...
[ "func", "HostPort", "(", "s", ",", "defaultPort", "string", ")", "(", "string", ",", "error", ")", "{", "addr", ",", "port", ",", "err", ":=", "net", ".", "SplitHostPort", "(", "s", ")", "\n", "if", "port", "==", "\"", "\"", "{", "port", "=", "de...
// HostPort will check if the host part is a valid IP address, if the // IP address is valid, but no port is found, defaultPort is added.
[ "HostPort", "will", "check", "if", "the", "host", "part", "is", "a", "valid", "IP", "address", "if", "the", "IP", "address", "is", "valid", "but", "no", "port", "is", "found", "defaultPort", "is", "added", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/pkg/parse/host.go#L82-L98
130,793
coredns/coredns
plugin/rewrite/condition.go
matchFunc
func matchFunc(a, b string) bool { matched, _ := regexp.MatchString(b, a) return matched }
go
func matchFunc(a, b string) bool { matched, _ := regexp.MatchString(b, a) return matched }
[ "func", "matchFunc", "(", "a", ",", "b", "string", ")", "bool", "{", "matched", ",", "_", ":=", "regexp", ".", "MatchString", "(", "b", ",", "a", ")", "\n", "return", "matched", "\n", "}" ]
// matchFunc is condition for Match operator. It does regexp matching of a against pattern in b // and returns if they match.
[ "matchFunc", "is", "condition", "for", "Match", "operator", ".", "It", "does", "regexp", "matching", "of", "a", "against", "pattern", "in", "b", "and", "returns", "if", "they", "match", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/rewrite/condition.go#L66-L69
130,794
coredns/coredns
plugin/rewrite/condition.go
NewIf
func NewIf(a, operator, b string) (If, error) { if _, ok := conditions[operator]; !ok { return If{}, fmt.Errorf("invalid operator %v", operator) } return If{ A: a, Operator: operator, B: b, }, nil }
go
func NewIf(a, operator, b string) (If, error) { if _, ok := conditions[operator]; !ok { return If{}, fmt.Errorf("invalid operator %v", operator) } return If{ A: a, Operator: operator, B: b, }, nil }
[ "func", "NewIf", "(", "a", ",", "operator", ",", "b", "string", ")", "(", "If", ",", "error", ")", "{", "if", "_", ",", "ok", ":=", "conditions", "[", "operator", "]", ";", "!", "ok", "{", "return", "If", "{", "}", ",", "fmt", ".", "Errorf", ...
// NewIf creates a new If condition.
[ "NewIf", "creates", "a", "new", "If", "condition", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/rewrite/condition.go#L102-L111
130,795
coredns/coredns
plugin/hosts/hostsfile.go
ipVersion
func ipVersion(s string) int { for i := len(s) - 1; i >= 0; i-- { switch s[i] { case '.': return 4 case ':': return 6 } } return 0 }
go
func ipVersion(s string) int { for i := len(s) - 1; i >= 0; i-- { switch s[i] { case '.': return 4 case ':': return 6 } } return 0 }
[ "func", "ipVersion", "(", "s", "string", ")", "int", "{", "for", "i", ":=", "len", "(", "s", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", "{", "switch", "s", "[", "i", "]", "{", "case", "'.'", ":", "return", "4", "\n", "case", "':'",...
// ipVersion returns what IP version was used textually // For why the string is parsed end to start, // see IPv4-Compatible IPv6 addresses - RFC 4291 section 2.5.5
[ "ipVersion", "returns", "what", "IP", "version", "was", "used", "textually", "For", "why", "the", "string", "is", "parsed", "end", "to", "start", "see", "IPv4", "-", "Compatible", "IPv6", "addresses", "-", "RFC", "4291", "section", "2", ".", "5", ".", "5...
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/hosts/hostsfile.go#L219-L229
130,796
coredns/coredns
plugin/hosts/hostsfile.go
lookupStaticHost
func (h *Hostsfile) lookupStaticHost(hmapByName map[string][]net.IP, host string) []net.IP { fqhost := absDomainName(host) h.RLock() defer h.RUnlock() if len(hmapByName) == 0 { return nil } ips, ok := hmapByName[fqhost] if !ok { return nil } ipsCp := make([]net.IP, len(ips)) copy(ipsCp, ips) return ip...
go
func (h *Hostsfile) lookupStaticHost(hmapByName map[string][]net.IP, host string) []net.IP { fqhost := absDomainName(host) h.RLock() defer h.RUnlock() if len(hmapByName) == 0 { return nil } ips, ok := hmapByName[fqhost] if !ok { return nil } ipsCp := make([]net.IP, len(ips)) copy(ipsCp, ips) return ip...
[ "func", "(", "h", "*", "Hostsfile", ")", "lookupStaticHost", "(", "hmapByName", "map", "[", "string", "]", "[", "]", "net", ".", "IP", ",", "host", "string", ")", "[", "]", "net", ".", "IP", "{", "fqhost", ":=", "absDomainName", "(", "host", ")", "...
// LookupStaticHost looks up the IP addresses for the given host from the hosts file.
[ "LookupStaticHost", "looks", "up", "the", "IP", "addresses", "for", "the", "given", "host", "from", "the", "hosts", "file", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/hosts/hostsfile.go#L232-L249
130,797
coredns/coredns
plugin/hosts/hostsfile.go
LookupStaticHostV6
func (h *Hostsfile) LookupStaticHostV6(host string) []net.IP { return h.lookupStaticHost(h.hmap.byNameV6, host) }
go
func (h *Hostsfile) LookupStaticHostV6(host string) []net.IP { return h.lookupStaticHost(h.hmap.byNameV6, host) }
[ "func", "(", "h", "*", "Hostsfile", ")", "LookupStaticHostV6", "(", "host", "string", ")", "[", "]", "net", ".", "IP", "{", "return", "h", ".", "lookupStaticHost", "(", "h", ".", "hmap", ".", "byNameV6", ",", "host", ")", "\n", "}" ]
// LookupStaticHostV6 looks up the IPv6 addresses for the given host from the hosts file.
[ "LookupStaticHostV6", "looks", "up", "the", "IPv6", "addresses", "for", "the", "given", "host", "from", "the", "hosts", "file", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/hosts/hostsfile.go#L257-L259
130,798
coredns/coredns
core/dnsserver/config.go
keyForConfig
func keyForConfig(blocIndex int, blocKeyIndex int) string { return fmt.Sprintf("%d:%d", blocIndex, blocKeyIndex) }
go
func keyForConfig(blocIndex int, blocKeyIndex int) string { return fmt.Sprintf("%d:%d", blocIndex, blocKeyIndex) }
[ "func", "keyForConfig", "(", "blocIndex", "int", ",", "blocKeyIndex", "int", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "blocIndex", ",", "blocKeyIndex", ")", "\n", "}" ]
// keyForConfig build a key for identifying the configs during setup time
[ "keyForConfig", "build", "a", "key", "for", "identifying", "the", "configs", "during", "setup", "time" ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/core/dnsserver/config.go#L56-L58
130,799
coredns/coredns
plugin/cache/cache.go
New
func New() *Cache { return &Cache{ Zones: []string{"."}, pcap: defaultCap, pcache: cache.New(defaultCap), pttl: maxTTL, minpttl: minTTL, ncap: defaultCap, ncache: cache.New(defaultCap), nttl: maxNTTL, minnttl: minNTTL, prefetch: 0, duration: 1 * time...
go
func New() *Cache { return &Cache{ Zones: []string{"."}, pcap: defaultCap, pcache: cache.New(defaultCap), pttl: maxTTL, minpttl: minTTL, ncap: defaultCap, ncache: cache.New(defaultCap), nttl: maxNTTL, minnttl: minNTTL, prefetch: 0, duration: 1 * time...
[ "func", "New", "(", ")", "*", "Cache", "{", "return", "&", "Cache", "{", "Zones", ":", "[", "]", "string", "{", "\"", "\"", "}", ",", "pcap", ":", "defaultCap", ",", "pcache", ":", "cache", ".", "New", "(", "defaultCap", ")", ",", "pttl", ":", ...
// New returns an initialized Cache with default settings. It's up to the // caller to set the Next handler.
[ "New", "returns", "an", "initialized", "Cache", "with", "default", "settings", ".", "It", "s", "up", "to", "the", "caller", "to", "set", "the", "Next", "handler", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/cache/cache.go#L45-L61