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
partition
stringclasses
1 value
inverse-inc/packetfence
go/coredns/plugin/proxy/lookup.go
Lookup
func (p Proxy) Lookup(state request.Request, name string, typ uint16) (*dns.Msg, error) { req := new(dns.Msg) req.SetQuestion(name, typ) state.SizeAndDo(req) state2 := request.Request{W: state.W, Req: req} return p.lookup(state2) }
go
func (p Proxy) Lookup(state request.Request, name string, typ uint16) (*dns.Msg, error) { req := new(dns.Msg) req.SetQuestion(name, typ) state.SizeAndDo(req) state2 := request.Request{W: state.W, Req: req} return p.lookup(state2) }
[ "func", "(", "p", "Proxy", ")", "Lookup", "(", "state", "request", ".", "Request", ",", "name", "string", ",", "typ", "uint16", ")", "(", "*", "dns", ".", "Msg", ",", "error", ")", "{", "req", ":=", "new", "(", "dns", ".", "Msg", ")", "\n", "re...
// Lookup will use name and type to forge a new message and will send that upstream. It will // set any EDNS0 options correctly so that downstream will be able to process the reply.
[ "Lookup", "will", "use", "name", "and", "type", "to", "forge", "a", "new", "message", "and", "will", "send", "that", "upstream", ".", "It", "will", "set", "any", "EDNS0", "options", "correctly", "so", "that", "downstream", "will", "be", "able", "to", "pr...
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/coredns/plugin/proxy/lookup.go#L52-L60
train
inverse-inc/packetfence
go/coredns/plugin/proxy/lookup.go
Forward
func (p Proxy) Forward(state request.Request) (*dns.Msg, error) { return p.lookup(state) }
go
func (p Proxy) Forward(state request.Request) (*dns.Msg, error) { return p.lookup(state) }
[ "func", "(", "p", "Proxy", ")", "Forward", "(", "state", "request", ".", "Request", ")", "(", "*", "dns", ".", "Msg", ",", "error", ")", "{", "return", "p", ".", "lookup", "(", "state", ")", "\n", "}" ]
// Forward forward the request in state as-is. Unlike Lookup that adds EDNS0 suffix to the message.
[ "Forward", "forward", "the", "request", "in", "state", "as", "-", "is", ".", "Unlike", "Lookup", "that", "adds", "EDNS0", "suffix", "to", "the", "message", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/coredns/plugin/proxy/lookup.go#L63-L65
train
inverse-inc/packetfence
go/caddy/caddy/caddyhttp/internalsrv/internal.go
Write
func (w internalResponseWriter) Write(b []byte) (int, error) { if isInternalRedirect(w) { return 0, nil } return w.ResponseWriter.Write(b) }
go
func (w internalResponseWriter) Write(b []byte) (int, error) { if isInternalRedirect(w) { return 0, nil } return w.ResponseWriter.Write(b) }
[ "func", "(", "w", "internalResponseWriter", ")", "Write", "(", "b", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "if", "isInternalRedirect", "(", "w", ")", "{", "return", "0", ",", "nil", "\n", "}", "\n", "return", "w", ".", "Response...
// Write ignores the call if the response should be redirected to an internal // location.
[ "Write", "ignores", "the", "call", "if", "the", "response", "should", "be", "redirected", "to", "an", "internal", "location", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/caddyhttp/internalsrv/internal.go#L91-L96
train
inverse-inc/packetfence
go/coredns/plugin/pkg/replacer/replacer.go
Set
func (r replacer) Set(key, value string) { r.replacements["{"+key+"}"] = value }
go
func (r replacer) Set(key, value string) { r.replacements["{"+key+"}"] = value }
[ "func", "(", "r", "replacer", ")", "Set", "(", "key", ",", "value", "string", ")", "{", "r", ".", "replacements", "[", "\"", "\"", "+", "key", "+", "\"", "\"", "]", "=", "value", "\n", "}" ]
// Set sets key to value in the replacements map.
[ "Set", "sets", "key", "to", "value", "in", "the", "replacements", "map", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/coredns/plugin/pkg/replacer/replacer.go#L105-L107
train
inverse-inc/packetfence
go/pfconfigdriver/pool.go
NewPool
func NewPool() Pool { p := Pool{} p.lock = timedlock.NewRWLock() p.lock.Timeout = 1 * time.Second p.lock.RTimeout = 3 * time.Second p.lock.PrintErrors = false p.lock.Panic = false p.structs = make(map[string]interface{}) return p }
go
func NewPool() Pool { p := Pool{} p.lock = timedlock.NewRWLock() p.lock.Timeout = 1 * time.Second p.lock.RTimeout = 3 * time.Second p.lock.PrintErrors = false p.lock.Panic = false p.structs = make(map[string]interface{}) return p }
[ "func", "NewPool", "(", ")", "Pool", "{", "p", ":=", "Pool", "{", "}", "\n", "p", ".", "lock", "=", "timedlock", ".", "NewRWLock", "(", ")", "\n", "p", ".", "lock", ".", "Timeout", "=", "1", "*", "time", ".", "Second", "\n", "p", ".", "lock", ...
// Create a new Pool with a 1 second refresh timeout and initialize the lock
[ "Create", "a", "new", "Pool", "with", "a", "1", "second", "refresh", "timeout", "and", "initialize", "the", "lock" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/pfconfigdriver/pool.go#L36-L45
train
inverse-inc/packetfence
go/pfconfigdriver/pool.go
ReadLock
func (p *Pool) ReadLock(ctx context.Context) (uint64, error) { return p.lock.RLock() }
go
func (p *Pool) ReadLock(ctx context.Context) (uint64, error) { return p.lock.RLock() }
[ "func", "(", "p", "*", "Pool", ")", "ReadLock", "(", "ctx", "context", ".", "Context", ")", "(", "uint64", ",", "error", ")", "{", "return", "p", ".", "lock", ".", "RLock", "(", ")", "\n", "}" ]
// Acquire a read lock on the pool // All the goroutines that use resources from the pool should call this and release it when they are done // Long running processes should aim to retain this lock for the smallest time possible since Refresh will need a RW lock to refresh the resources // This lock can be acquired mul...
[ "Acquire", "a", "read", "lock", "on", "the", "pool", "All", "the", "goroutines", "that", "use", "resources", "from", "the", "pool", "should", "call", "this", "and", "release", "it", "when", "they", "are", "done", "Long", "running", "processes", "should", "...
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/pfconfigdriver/pool.go#L51-L53
train
inverse-inc/packetfence
go/pfconfigdriver/pool.go
ReadUnlock
func (p *Pool) ReadUnlock(ctx context.Context, id uint64) { p.lock.RUnlock(id) }
go
func (p *Pool) ReadUnlock(ctx context.Context, id uint64) { p.lock.RUnlock(id) }
[ "func", "(", "p", "*", "Pool", ")", "ReadUnlock", "(", "ctx", "context", ".", "Context", ",", "id", "uint64", ")", "{", "p", ".", "lock", ".", "RUnlock", "(", "id", ")", "\n", "}" ]
// Unlock the read lock
[ "Unlock", "the", "read", "lock" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/pfconfigdriver/pool.go#L56-L58
train
inverse-inc/packetfence
go/pfconfigdriver/pool.go
AddRefreshable
func (p *Pool) AddRefreshable(ctx context.Context, r Refreshable) { id, err := p.lock.Lock() if err == nil { defer p.lock.Unlock(id) p.refreshables = append(p.refreshables, r) r.Refresh(ctx) } }
go
func (p *Pool) AddRefreshable(ctx context.Context, r Refreshable) { id, err := p.lock.Lock() if err == nil { defer p.lock.Unlock(id) p.refreshables = append(p.refreshables, r) r.Refresh(ctx) } }
[ "func", "(", "p", "*", "Pool", ")", "AddRefreshable", "(", "ctx", "context", ".", "Context", ",", "r", "Refreshable", ")", "{", "id", ",", "err", ":=", "p", ".", "lock", ".", "Lock", "(", ")", "\n", "if", "err", "==", "nil", "{", "defer", "p", ...
// Add a refreshable resource to the pool // Requires the RW lock and will not timeout like Refresh does
[ "Add", "a", "refreshable", "resource", "to", "the", "pool", "Requires", "the", "RW", "lock", "and", "will", "not", "timeout", "like", "Refresh", "does" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/pfconfigdriver/pool.go#L62-L69
train
inverse-inc/packetfence
go/pfconfigdriver/pool.go
AddStruct
func (p *Pool) AddStruct(ctx context.Context, s interface{}) { id, err := p.lock.Lock() if err == nil { defer p.lock.Unlock(id) addr := fmt.Sprintf("%p", s) log.LoggerWContext(ctx).Debug("Adding struct with address " + addr + " to the pool") p.structs[addr] = s p.refreshStruct(ctx, s) } }
go
func (p *Pool) AddStruct(ctx context.Context, s interface{}) { id, err := p.lock.Lock() if err == nil { defer p.lock.Unlock(id) addr := fmt.Sprintf("%p", s) log.LoggerWContext(ctx).Debug("Adding struct with address " + addr + " to the pool") p.structs[addr] = s p.refreshStruct(ctx, s) } }
[ "func", "(", "p", "*", "Pool", ")", "AddStruct", "(", "ctx", "context", ".", "Context", ",", "s", "interface", "{", "}", ")", "{", "id", ",", "err", ":=", "p", ".", "lock", ".", "Lock", "(", ")", "\n", "if", "err", "==", "nil", "{", "defer", ...
// Add a struct to the pool // Requires the RW lock and will not timeout like Refresh does
[ "Add", "a", "struct", "to", "the", "pool", "Requires", "the", "RW", "lock", "and", "will", "not", "timeout", "like", "Refresh", "does" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/pfconfigdriver/pool.go#L73-L84
train
inverse-inc/packetfence
go/pfconfigdriver/pool.go
refreshRefreshables
func (p *Pool) refreshRefreshables(ctx context.Context) { for _, r := range p.refreshables { r.Refresh(ctx) } }
go
func (p *Pool) refreshRefreshables(ctx context.Context) { for _, r := range p.refreshables { r.Refresh(ctx) } }
[ "func", "(", "p", "*", "Pool", ")", "refreshRefreshables", "(", "ctx", "context", ".", "Context", ")", "{", "for", "_", ",", "r", ":=", "range", "p", ".", "refreshables", "{", "r", ".", "Refresh", "(", "ctx", ")", "\n", "}", "\n", "}" ]
// Refresh all the refreshables of the pool
[ "Refresh", "all", "the", "refreshables", "of", "the", "pool" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/pfconfigdriver/pool.go#L87-L91
train
inverse-inc/packetfence
go/pfconfigdriver/pool.go
refreshStruct
func (p *Pool) refreshStruct(ctx context.Context, s interface{}) { v := reflect.ValueOf(s) for v.Kind() == reflect.Ptr || v.Kind() == reflect.Interface { v = v.Elem() } // Check if s itself is a PfconfigObject, otherwise, we cycle though its fields and process them if o, ok := v.Addr().Interface().(PfconfigObje...
go
func (p *Pool) refreshStruct(ctx context.Context, s interface{}) { v := reflect.ValueOf(s) for v.Kind() == reflect.Ptr || v.Kind() == reflect.Interface { v = v.Elem() } // Check if s itself is a PfconfigObject, otherwise, we cycle though its fields and process them if o, ok := v.Addr().Interface().(PfconfigObje...
[ "func", "(", "p", "*", "Pool", ")", "refreshStruct", "(", "ctx", "context", ".", "Context", ",", "s", "interface", "{", "}", ")", "{", "v", ":=", "reflect", ".", "ValueOf", "(", "s", ")", "\n", "for", "v", ".", "Kind", "(", ")", "==", "reflect", ...
// Refresh a struct // If this struct is a PfconfigObject, it will be sent directly to FetchDecodeSocketCache // Otherwise, the struct fields and sub-fields will be analyzed to find all the PfconfigObjects and these will be sent to FetchDecodeSocketCache
[ "Refresh", "a", "struct", "If", "this", "struct", "is", "a", "PfconfigObject", "it", "will", "be", "sent", "directly", "to", "FetchDecodeSocketCache", "Otherwise", "the", "struct", "fields", "and", "sub", "-", "fields", "will", "be", "analyzed", "to", "find", ...
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/pfconfigdriver/pool.go#L96-L115
train
inverse-inc/packetfence
go/pfconfigdriver/pool.go
refreshStructs
func (p *Pool) refreshStructs(ctx context.Context) { for _, o := range p.structs { p.refreshStruct(ctx, o) } }
go
func (p *Pool) refreshStructs(ctx context.Context) { for _, o := range p.structs { p.refreshStruct(ctx, o) } }
[ "func", "(", "p", "*", "Pool", ")", "refreshStructs", "(", "ctx", "context", ".", "Context", ")", "{", "for", "_", ",", "o", ":=", "range", "p", ".", "structs", "{", "p", ".", "refreshStruct", "(", "ctx", ",", "o", ")", "\n", "}", "\n", "}" ]
// Refresh all the structs of the pool
[ "Refresh", "all", "the", "structs", "of", "the", "pool" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/pfconfigdriver/pool.go#L118-L122
train
inverse-inc/packetfence
go/pfconfigdriver/pool.go
acquireWriteLock
func (p *Pool) acquireWriteLock(ctx context.Context) (bool, uint64) { defer func() { if r := recover(); r != nil { log.LoggerWContext(ctx).Warn("Couldn't acquire lock for pfconfig pool") } }() id, err := p.lock.Lock() if err != nil { panic("Couldn't acquire lock for pfconfig pool") } log.LoggerWContext...
go
func (p *Pool) acquireWriteLock(ctx context.Context) (bool, uint64) { defer func() { if r := recover(); r != nil { log.LoggerWContext(ctx).Warn("Couldn't acquire lock for pfconfig pool") } }() id, err := p.lock.Lock() if err != nil { panic("Couldn't acquire lock for pfconfig pool") } log.LoggerWContext...
[ "func", "(", "p", "*", "Pool", ")", "acquireWriteLock", "(", "ctx", "context", ".", "Context", ")", "(", "bool", ",", "uint64", ")", "{", "defer", "func", "(", ")", "{", "if", "r", ":=", "recover", "(", ")", ";", "r", "!=", "nil", "{", "log", "...
// Attempts to obtain a RW lock with the timeout set in RefreshLockTimeout // Even if the timeout gets reached, the lock will still be acquired when available but it will be immediately released // This is done by sending a message twice in the timeoutChan, one will be caught by the main waiting goroutine, the other on...
[ "Attempts", "to", "obtain", "a", "RW", "lock", "with", "the", "timeout", "set", "in", "RefreshLockTimeout", "Even", "if", "the", "timeout", "gets", "reached", "the", "lock", "will", "still", "be", "acquired", "when", "available", "but", "it", "will", "be", ...
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/pfconfigdriver/pool.go#L128-L142
train
inverse-inc/packetfence
go/pfconfigdriver/pool.go
Refresh
func (p *Pool) Refresh(ctx context.Context) bool { log.LoggerWContext(ctx).Debug("Refreshing pfconfig pool") var locked bool var id uint64 if locked, id = p.acquireWriteLock(ctx); !locked { return false } log.LoggerWContext(ctx).Debug("Refresh got lock ID", id) defer func(ctx context.Context) { log.LoggerWC...
go
func (p *Pool) Refresh(ctx context.Context) bool { log.LoggerWContext(ctx).Debug("Refreshing pfconfig pool") var locked bool var id uint64 if locked, id = p.acquireWriteLock(ctx); !locked { return false } log.LoggerWContext(ctx).Debug("Refresh got lock ID", id) defer func(ctx context.Context) { log.LoggerWC...
[ "func", "(", "p", "*", "Pool", ")", "Refresh", "(", "ctx", "context", ".", "Context", ")", "bool", "{", "log", ".", "LoggerWContext", "(", "ctx", ")", ".", "Debug", "(", "\"", "\"", ")", "\n\n", "var", "locked", "bool", "\n", "var", "id", "uint64",...
// Refresh all the structs and resources of the pool using the RW lock // An attempt to get the RW lock will be done for up to RefreshLockTimeout
[ "Refresh", "all", "the", "structs", "and", "resources", "of", "the", "pool", "using", "the", "RW", "lock", "An", "attempt", "to", "get", "the", "RW", "lock", "will", "be", "done", "for", "up", "to", "RefreshLockTimeout" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/pfconfigdriver/pool.go#L146-L164
train
inverse-inc/packetfence
go/caddy/caddy/caddyhttp/rewrite/rewrite.go
Match
func (r *ComplexRule) Match(req *http.Request) bool { // validate RequestMatcher // includes if and path if !r.RequestMatcher.Match(req) { return false } // validate extensions if !r.matchExt(req.URL.Path) { return false } // if regex is nil, ignore if r.Regexp == nil { return true } // otherwise val...
go
func (r *ComplexRule) Match(req *http.Request) bool { // validate RequestMatcher // includes if and path if !r.RequestMatcher.Match(req) { return false } // validate extensions if !r.matchExt(req.URL.Path) { return false } // if regex is nil, ignore if r.Regexp == nil { return true } // otherwise val...
[ "func", "(", "r", "*", "ComplexRule", ")", "Match", "(", "req", "*", "http", ".", "Request", ")", "bool", "{", "// validate RequestMatcher", "// includes if and path", "if", "!", "r", ".", "RequestMatcher", ".", "Match", "(", "req", ")", "{", "return", "fa...
// Match satisfies httpserver.Config. // // Though ComplexRule embeds a RequestMatcher, additional // checks are needed which requires a custom implementation.
[ "Match", "satisfies", "httpserver", ".", "Config", ".", "Though", "ComplexRule", "embeds", "a", "RequestMatcher", "additional", "checks", "are", "needed", "which", "requires", "a", "custom", "implementation", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/caddyhttp/rewrite/rewrite.go#L140-L158
train
inverse-inc/packetfence
go/coredns/plugin/pkg/response/typify.go
Typify
func Typify(m *dns.Msg, t time.Time) (Type, *dns.OPT) { if m == nil { return OtherError, nil } opt := m.IsEdns0() do := false if opt != nil { do = opt.Do() } if m.Opcode == dns.OpcodeUpdate { return Update, opt } // Check transfer and update first if m.Opcode == dns.OpcodeNotify { return Meta, opt ...
go
func Typify(m *dns.Msg, t time.Time) (Type, *dns.OPT) { if m == nil { return OtherError, nil } opt := m.IsEdns0() do := false if opt != nil { do = opt.Do() } if m.Opcode == dns.OpcodeUpdate { return Update, opt } // Check transfer and update first if m.Opcode == dns.OpcodeNotify { return Meta, opt ...
[ "func", "Typify", "(", "m", "*", "dns", ".", "Msg", ",", "t", "time", ".", "Time", ")", "(", "Type", ",", "*", "dns", ".", "OPT", ")", "{", "if", "m", "==", "nil", "{", "return", "OtherError", ",", "nil", "\n", "}", "\n", "opt", ":=", "m", ...
// Typify classifies a message, it returns the Type.
[ "Typify", "classifies", "a", "message", "it", "returns", "the", "Type", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/coredns/plugin/pkg/response/typify.go#L54-L118
train
inverse-inc/packetfence
go/caddy/caddy/caddy.go
HasListenerWithAddress
func HasListenerWithAddress(addr string) bool { instancesMu.Lock() defer instancesMu.Unlock() for _, inst := range instances { for _, sln := range inst.servers { if listenerAddrEqual(sln.listener, addr) { return true } } } return false }
go
func HasListenerWithAddress(addr string) bool { instancesMu.Lock() defer instancesMu.Unlock() for _, inst := range instances { for _, sln := range inst.servers { if listenerAddrEqual(sln.listener, addr) { return true } } } return false }
[ "func", "HasListenerWithAddress", "(", "addr", "string", ")", "bool", "{", "instancesMu", ".", "Lock", "(", ")", "\n", "defer", "instancesMu", ".", "Unlock", "(", ")", "\n", "for", "_", ",", "inst", ":=", "range", "instances", "{", "for", "_", ",", "sl...
// HasListenerWithAddress returns whether this package is // tracking a server using a listener with the address // addr.
[ "HasListenerWithAddress", "returns", "whether", "this", "package", "is", "tracking", "a", "server", "using", "a", "listener", "with", "the", "address", "addr", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/caddy.go#L223-L234
train
inverse-inc/packetfence
go/caddy/caddy/caddy.go
ValidateAndExecuteDirectives
func ValidateAndExecuteDirectives(cdyfile Input, inst *Instance, justValidate bool) error { // If parsing only inst will be nil, create an instance for this function call only. if justValidate { inst = &Instance{serverType: cdyfile.ServerType(), wg: new(sync.WaitGroup)} } stypeName := cdyfile.ServerType() sty...
go
func ValidateAndExecuteDirectives(cdyfile Input, inst *Instance, justValidate bool) error { // If parsing only inst will be nil, create an instance for this function call only. if justValidate { inst = &Instance{serverType: cdyfile.ServerType(), wg: new(sync.WaitGroup)} } stypeName := cdyfile.ServerType() sty...
[ "func", "ValidateAndExecuteDirectives", "(", "cdyfile", "Input", ",", "inst", "*", "Instance", ",", "justValidate", "bool", ")", "error", "{", "// If parsing only inst will be nil, create an instance for this function call only.", "if", "justValidate", "{", "inst", "=", "&"...
// ValidateAndExecuteDirectives will load the server blocks from cdyfile // by parsing it, then execute the directives configured by it and store // the resulting server blocks into inst. If justValidate is true, parse // callbacks will not be executed between directives, since the purpose // is only to check the input...
[ "ValidateAndExecuteDirectives", "will", "load", "the", "server", "blocks", "from", "cdyfile", "by", "parsing", "it", "then", "execute", "the", "directives", "configured", "by", "it", "and", "store", "the", "resulting", "server", "blocks", "into", "inst", ".", "I...
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/caddy.go#L516-L554
train
inverse-inc/packetfence
go/coredns/plugin/file/secondary.go
TransferIn
func (z *Zone) TransferIn() error { if len(z.TransferFrom) == 0 { return nil } m := new(dns.Msg) m.SetAxfr(z.origin) z1 := z.Copy() var ( Err error tr string ) Transfer: for _, tr = range z.TransferFrom { t := new(dns.Transfer) c, err := t.In(m, tr) if err != nil { log.Printf("[ERROR] Failed t...
go
func (z *Zone) TransferIn() error { if len(z.TransferFrom) == 0 { return nil } m := new(dns.Msg) m.SetAxfr(z.origin) z1 := z.Copy() var ( Err error tr string ) Transfer: for _, tr = range z.TransferFrom { t := new(dns.Transfer) c, err := t.In(m, tr) if err != nil { log.Printf("[ERROR] Failed t...
[ "func", "(", "z", "*", "Zone", ")", "TransferIn", "(", ")", "error", "{", "if", "len", "(", "z", ".", "TransferFrom", ")", "==", "0", "{", "return", "nil", "\n", "}", "\n", "m", ":=", "new", "(", "dns", ".", "Msg", ")", "\n", "m", ".", "SetAx...
// TransferIn retrieves the zone from the masters, parses it and sets it live.
[ "TransferIn", "retrieves", "the", "zone", "from", "the", "masters", "parses", "it", "and", "sets", "it", "live", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/coredns/plugin/file/secondary.go#L12-L60
train
inverse-inc/packetfence
go/caddy/caddy/caddyhttp/httpserver/recorder.go
NewResponseRecorder
func NewResponseRecorder(w http.ResponseWriter) *ResponseRecorder { return &ResponseRecorder{ ResponseWriter: w, status: http.StatusOK, start: time.Now(), } }
go
func NewResponseRecorder(w http.ResponseWriter) *ResponseRecorder { return &ResponseRecorder{ ResponseWriter: w, status: http.StatusOK, start: time.Now(), } }
[ "func", "NewResponseRecorder", "(", "w", "http", ".", "ResponseWriter", ")", "*", "ResponseRecorder", "{", "return", "&", "ResponseRecorder", "{", "ResponseWriter", ":", "w", ",", "status", ":", "http", ".", "StatusOK", ",", "start", ":", "time", ".", "Now",...
// NewResponseRecorder makes and returns a new responseRecorder, // which captures the HTTP Status code from the ResponseWriter // and also the length of the response body written through it. // Because a status is not set unless WriteHeader is called // explicitly, this constructor initializes with a status code // of...
[ "NewResponseRecorder", "makes", "and", "returns", "a", "new", "responseRecorder", "which", "captures", "the", "HTTP", "Status", "code", "from", "the", "ResponseWriter", "and", "also", "the", "length", "of", "the", "response", "body", "written", "through", "it", ...
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/caddyhttp/httpserver/recorder.go#L36-L42
train
inverse-inc/packetfence
go/caddy/caddy/caddyhttp/httpserver/recorder.go
Flush
func (r *ResponseRecorder) Flush() { if f, ok := r.ResponseWriter.(http.Flusher); ok { f.Flush() } else { panic(NonFlusherError{Underlying: r.ResponseWriter}) // should be recovered at the beginning of middleware stack } }
go
func (r *ResponseRecorder) Flush() { if f, ok := r.ResponseWriter.(http.Flusher); ok { f.Flush() } else { panic(NonFlusherError{Underlying: r.ResponseWriter}) // should be recovered at the beginning of middleware stack } }
[ "func", "(", "r", "*", "ResponseRecorder", ")", "Flush", "(", ")", "{", "if", "f", ",", "ok", ":=", "r", ".", "ResponseWriter", ".", "(", "http", ".", "Flusher", ")", ";", "ok", "{", "f", ".", "Flush", "(", ")", "\n", "}", "else", "{", "panic",...
// Flush implements http.Flusher. It simply wraps the underlying // ResponseWriter's Flush method if there is one, or does nothing.
[ "Flush", "implements", "http", ".", "Flusher", ".", "It", "simply", "wraps", "the", "underlying", "ResponseWriter", "s", "Flush", "method", "if", "there", "is", "one", "or", "does", "nothing", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/caddyhttp/httpserver/recorder.go#L82-L88
train
inverse-inc/packetfence
go/caddy/caddy/caddyhttp/markdown/setup.go
setup
func setup(c *caddy.Controller) error { mdconfigs, err := markdownParse(c) if err != nil { return err } cfg := httpserver.GetConfig(c) md := Markdown{ Root: cfg.Root, FileSys: http.Dir(cfg.Root), Configs: mdconfigs, IndexFiles: []string{"index.md"}, } cfg.AddMiddleware(func(next httpserv...
go
func setup(c *caddy.Controller) error { mdconfigs, err := markdownParse(c) if err != nil { return err } cfg := httpserver.GetConfig(c) md := Markdown{ Root: cfg.Root, FileSys: http.Dir(cfg.Root), Configs: mdconfigs, IndexFiles: []string{"index.md"}, } cfg.AddMiddleware(func(next httpserv...
[ "func", "setup", "(", "c", "*", "caddy", ".", "Controller", ")", "error", "{", "mdconfigs", ",", "err", ":=", "markdownParse", "(", "c", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "cfg", ":=", "httpserver", ".", "...
// setup configures a new Markdown middleware instance.
[ "setup", "configures", "a", "new", "Markdown", "middleware", "instance", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/caddyhttp/markdown/setup.go#L20-L41
train
inverse-inc/packetfence
go/caddy/caddy/caddytls/tls.go
HostQualifies
func HostQualifies(hostname string) bool { return hostname != "localhost" && // localhost is ineligible // hostname must not be empty strings.TrimSpace(hostname) != "" && // must not contain wildcard (*) characters (until CA supports it) !strings.Contains(hostname, "*") && // must not start or end with a ...
go
func HostQualifies(hostname string) bool { return hostname != "localhost" && // localhost is ineligible // hostname must not be empty strings.TrimSpace(hostname) != "" && // must not contain wildcard (*) characters (until CA supports it) !strings.Contains(hostname, "*") && // must not start or end with a ...
[ "func", "HostQualifies", "(", "hostname", "string", ")", "bool", "{", "return", "hostname", "!=", "\"", "\"", "&&", "// localhost is ineligible", "// hostname must not be empty", "strings", ".", "TrimSpace", "(", "hostname", ")", "!=", "\"", "\"", "&&", "// must n...
// HostQualifies returns true if the hostname alone // appears eligible for automatic HTTPS. For example, // localhost, empty hostname, and IP addresses are // not eligible because we cannot obtain certificates // for those names.
[ "HostQualifies", "returns", "true", "if", "the", "hostname", "alone", "appears", "eligible", "for", "automatic", "HTTPS", ".", "For", "example", "localhost", "empty", "hostname", "and", "IP", "addresses", "are", "not", "eligible", "because", "we", "cannot", "obt...
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/caddytls/tls.go#L31-L47
train
inverse-inc/packetfence
go/caddy/caddy/caddytls/tls.go
saveCertResource
func saveCertResource(storage Storage, cert acme.CertificateResource) error { // Save cert, private key, and metadata siteData := &SiteData{ Cert: cert.Certificate, Key: cert.PrivateKey, } var err error siteData.Meta, err = json.MarshalIndent(&cert, "", "\t") if err == nil { err = storage.StoreSite(cert.Do...
go
func saveCertResource(storage Storage, cert acme.CertificateResource) error { // Save cert, private key, and metadata siteData := &SiteData{ Cert: cert.Certificate, Key: cert.PrivateKey, } var err error siteData.Meta, err = json.MarshalIndent(&cert, "", "\t") if err == nil { err = storage.StoreSite(cert.Do...
[ "func", "saveCertResource", "(", "storage", "Storage", ",", "cert", "acme", ".", "CertificateResource", ")", "error", "{", "// Save cert, private key, and metadata", "siteData", ":=", "&", "SiteData", "{", "Cert", ":", "cert", ".", "Certificate", ",", "Key", ":", ...
// saveCertResource saves the certificate resource to disk. This // includes the certificate file itself, the private key, and the // metadata file.
[ "saveCertResource", "saves", "the", "certificate", "resource", "to", "disk", ".", "This", "includes", "the", "certificate", "file", "itself", "the", "private", "key", "and", "the", "metadata", "file", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/caddytls/tls.go#L52-L64
train
inverse-inc/packetfence
go/caddy/caddy/caddytls/tls.go
Revoke
func Revoke(host string) error { client, err := newACMEClient(new(Config), true) if err != nil { return err } return client.Revoke(host) }
go
func Revoke(host string) error { client, err := newACMEClient(new(Config), true) if err != nil { return err } return client.Revoke(host) }
[ "func", "Revoke", "(", "host", "string", ")", "error", "{", "client", ",", "err", ":=", "newACMEClient", "(", "new", "(", "Config", ")", ",", "true", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "client", "....
// Revoke revokes the certificate for host via ACME protocol. // It assumes the certificate was obtained from the // CA at DefaultCAUrl.
[ "Revoke", "revokes", "the", "certificate", "for", "host", "via", "ACME", "protocol", ".", "It", "assumes", "the", "certificate", "was", "obtained", "from", "the", "CA", "at", "DefaultCAUrl", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/caddytls/tls.go#L69-L75
train
inverse-inc/packetfence
go/caddy/caddy/caddytls/tls.go
Present
func (s tlsSniSolver) Present(domain, token, keyAuth string) error { cert, acmeDomain, err := acme.TLSSNI01ChallengeCert(keyAuth) if err != nil { return err } cacheCertificate(Certificate{ Certificate: cert, Names: []string{acmeDomain}, }) return nil }
go
func (s tlsSniSolver) Present(domain, token, keyAuth string) error { cert, acmeDomain, err := acme.TLSSNI01ChallengeCert(keyAuth) if err != nil { return err } cacheCertificate(Certificate{ Certificate: cert, Names: []string{acmeDomain}, }) return nil }
[ "func", "(", "s", "tlsSniSolver", ")", "Present", "(", "domain", ",", "token", ",", "keyAuth", "string", ")", "error", "{", "cert", ",", "acmeDomain", ",", "err", ":=", "acme", ".", "TLSSNI01ChallengeCert", "(", "keyAuth", ")", "\n", "if", "err", "!=", ...
// Present adds the challenge certificate to the cache.
[ "Present", "adds", "the", "challenge", "certificate", "to", "the", "cache", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/caddytls/tls.go#L82-L92
train
inverse-inc/packetfence
go/caddy/caddy/caddytls/tls.go
CleanUp
func (s tlsSniSolver) CleanUp(domain, token, keyAuth string) error { _, acmeDomain, err := acme.TLSSNI01ChallengeCert(keyAuth) if err != nil { return err } uncacheCertificate(acmeDomain) return nil }
go
func (s tlsSniSolver) CleanUp(domain, token, keyAuth string) error { _, acmeDomain, err := acme.TLSSNI01ChallengeCert(keyAuth) if err != nil { return err } uncacheCertificate(acmeDomain) return nil }
[ "func", "(", "s", "tlsSniSolver", ")", "CleanUp", "(", "domain", ",", "token", ",", "keyAuth", "string", ")", "error", "{", "_", ",", "acmeDomain", ",", "err", ":=", "acme", ".", "TLSSNI01ChallengeCert", "(", "keyAuth", ")", "\n", "if", "err", "!=", "n...
// CleanUp removes the challenge certificate from the cache.
[ "CleanUp", "removes", "the", "challenge", "certificate", "from", "the", "cache", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/caddytls/tls.go#L95-L102
train
inverse-inc/packetfence
go/caddy/caddy/caddytls/tls.go
RegisterStorageProvider
func RegisterStorageProvider(name string, provider StorageConstructor) { storageProviders[name] = provider caddy.RegisterPlugin("tls.storage."+name, caddy.Plugin{}) }
go
func RegisterStorageProvider(name string, provider StorageConstructor) { storageProviders[name] = provider caddy.RegisterPlugin("tls.storage."+name, caddy.Plugin{}) }
[ "func", "RegisterStorageProvider", "(", "name", "string", ",", "provider", "StorageConstructor", ")", "{", "storageProviders", "[", "name", "]", "=", "provider", "\n", "caddy", ".", "RegisterPlugin", "(", "\"", "\"", "+", "name", ",", "caddy", ".", "Plugin", ...
// RegisterStorageProvider registers provider by name for storing tls data
[ "RegisterStorageProvider", "registers", "provider", "by", "name", "for", "storing", "tls", "data" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/caddytls/tls.go#L175-L178
train
inverse-inc/packetfence
go/caddy/caddy/caddytls/httphandler.go
HTTPChallengeHandler
func HTTPChallengeHandler(w http.ResponseWriter, r *http.Request, listenHost, altPort string) bool { if !strings.HasPrefix(r.URL.Path, challengeBasePath) { return false } if !namesObtaining.Has(r.Host) { return false } scheme := "http" if r.TLS != nil { scheme = "https" } if listenHost == "" { listenH...
go
func HTTPChallengeHandler(w http.ResponseWriter, r *http.Request, listenHost, altPort string) bool { if !strings.HasPrefix(r.URL.Path, challengeBasePath) { return false } if !namesObtaining.Has(r.Host) { return false } scheme := "http" if r.TLS != nil { scheme = "https" } if listenHost == "" { listenH...
[ "func", "HTTPChallengeHandler", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "listenHost", ",", "altPort", "string", ")", "bool", "{", "if", "!", "strings", ".", "HasPrefix", "(", "r", ".", "URL", ".", "Path", ",...
// HTTPChallengeHandler proxies challenge requests to ACME client if the // request path starts with challengeBasePath. It returns true if it // handled the request and no more needs to be done; it returns false // if this call was a no-op and the request still needs handling.
[ "HTTPChallengeHandler", "proxies", "challenge", "requests", "to", "ACME", "client", "if", "the", "request", "path", "starts", "with", "challengeBasePath", ".", "It", "returns", "true", "if", "it", "handled", "the", "request", "and", "no", "more", "needs", "to", ...
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/caddytls/httphandler.go#L19-L50
train
inverse-inc/packetfence
go/filter_client/filter_client.go
FilterProfile
func (c *Client) FilterProfile(data interface{}) (interface{}, error) { socket, err := net.Dial("unix", c.SocketPath) if err != nil { return nil, err } defer socket.Close() return c.SendRequest("filter_profile", data, socket) }
go
func (c *Client) FilterProfile(data interface{}) (interface{}, error) { socket, err := net.Dial("unix", c.SocketPath) if err != nil { return nil, err } defer socket.Close() return c.SendRequest("filter_profile", data, socket) }
[ "func", "(", "c", "*", "Client", ")", "FilterProfile", "(", "data", "interface", "{", "}", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "socket", ",", "err", ":=", "net", ".", "Dial", "(", "\"", "\"", ",", "c", ".", "SocketPath", ")",...
// Sends a filter_profile message to the pffilter service
[ "Sends", "a", "filter_profile", "message", "to", "the", "pffilter", "service" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/filter_client/filter_client.go#L47-L54
train
inverse-inc/packetfence
go/filter_client/filter_client.go
AccessFilter
func (c *Client) AccessFilter(filter string, scope string, data interface{}) (interface{}, error) { socket, err := net.Dial("unix", c.SocketPath) if err != nil { return nil, err } defer socket.Close() return c.SendRequest(filter, []interface{}{scope, data}, socket) }
go
func (c *Client) AccessFilter(filter string, scope string, data interface{}) (interface{}, error) { socket, err := net.Dial("unix", c.SocketPath) if err != nil { return nil, err } defer socket.Close() return c.SendRequest(filter, []interface{}{scope, data}, socket) }
[ "func", "(", "c", "*", "Client", ")", "AccessFilter", "(", "filter", "string", ",", "scope", "string", ",", "data", "interface", "{", "}", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "socket", ",", "err", ":=", "net", ".", "Dial", "(",...
// A generalize function for sending access filter messages
[ "A", "generalize", "function", "for", "sending", "access", "filter", "messages" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/filter_client/filter_client.go#L57-L64
train
inverse-inc/packetfence
go/filter_client/filter_client.go
FilterVlan
func (c *Client) FilterVlan(scope string, data interface{}) (interface{}, error) { return c.AccessFilter("filter_vlan", scope, data) }
go
func (c *Client) FilterVlan(scope string, data interface{}) (interface{}, error) { return c.AccessFilter("filter_vlan", scope, data) }
[ "func", "(", "c", "*", "Client", ")", "FilterVlan", "(", "scope", "string", ",", "data", "interface", "{", "}", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "return", "c", ".", "AccessFilter", "(", "\"", "\"", ",", "scope", ",", "data",...
// Sends a filter_vlan message to the pffilter service
[ "Sends", "a", "filter_vlan", "message", "to", "the", "pffilter", "service" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/filter_client/filter_client.go#L67-L69
train
inverse-inc/packetfence
go/filter_client/filter_client.go
FilterDhcp
func (c *Client) FilterDhcp(scope string, data interface{}) (interface{}, error) { return c.AccessFilter("filter_dhcp", scope, data) }
go
func (c *Client) FilterDhcp(scope string, data interface{}) (interface{}, error) { return c.AccessFilter("filter_dhcp", scope, data) }
[ "func", "(", "c", "*", "Client", ")", "FilterDhcp", "(", "scope", "string", ",", "data", "interface", "{", "}", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "return", "c", ".", "AccessFilter", "(", "\"", "\"", ",", "scope", ",", "data",...
// Sends a filter_dhcp message to the pffilter service
[ "Sends", "a", "filter_dhcp", "message", "to", "the", "pffilter", "service" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/filter_client/filter_client.go#L72-L74
train
inverse-inc/packetfence
go/filter_client/filter_client.go
FilterDns
func (c *Client) FilterDns(scope string, data interface{}) (interface{}, error) { return c.AccessFilter("filter_dns", scope, data) }
go
func (c *Client) FilterDns(scope string, data interface{}) (interface{}, error) { return c.AccessFilter("filter_dns", scope, data) }
[ "func", "(", "c", "*", "Client", ")", "FilterDns", "(", "scope", "string", ",", "data", "interface", "{", "}", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "return", "c", ".", "AccessFilter", "(", "\"", "\"", ",", "scope", ",", "data", ...
// Sends a filter_dns message to the pffilter service
[ "Sends", "a", "filter_dns", "message", "to", "the", "pffilter", "service" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/filter_client/filter_client.go#L77-L79
train
inverse-inc/packetfence
go/filter_client/filter_client.go
FilterRadius
func (c *Client) FilterRadius(scope string, data interface{}) (interface{}, error) { return c.AccessFilter("filter_radius", scope, data) }
go
func (c *Client) FilterRadius(scope string, data interface{}) (interface{}, error) { return c.AccessFilter("filter_radius", scope, data) }
[ "func", "(", "c", "*", "Client", ")", "FilterRadius", "(", "scope", "string", ",", "data", "interface", "{", "}", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "return", "c", ".", "AccessFilter", "(", "\"", "\"", ",", "scope", ",", "data...
// Sends a filter_radius message to the pffilter service
[ "Sends", "a", "filter_radius", "message", "to", "the", "pffilter", "service" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/filter_client/filter_client.go#L82-L84
train
inverse-inc/packetfence
go/filter_client/filter_client.go
SendRequest
func (c *Client) SendRequest(method string, params interface{}, conn net.Conn) (interface{}, error) { request := Request{Method: method, Params: params} b, err := json.Marshal(request) if err != nil { return nil, err } b = append(b, '\n') _, err = conn.Write(b) if err != nil { return nil, err } reader := b...
go
func (c *Client) SendRequest(method string, params interface{}, conn net.Conn) (interface{}, error) { request := Request{Method: method, Params: params} b, err := json.Marshal(request) if err != nil { return nil, err } b = append(b, '\n') _, err = conn.Write(b) if err != nil { return nil, err } reader := b...
[ "func", "(", "c", "*", "Client", ")", "SendRequest", "(", "method", "string", ",", "params", "interface", "{", "}", ",", "conn", "net", ".", "Conn", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "request", ":=", "Request", "{", "Method", ...
// Send a request to the pffilter service
[ "Send", "a", "request", "to", "the", "pffilter", "service" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/filter_client/filter_client.go#L87-L117
train
inverse-inc/packetfence
go/firewallsso/checkpoint.go
Start
func (fw *Checkpoint) Start(ctx context.Context, info map[string]string, timeout int) (bool, error) { p := fw.startRadiusPacket(ctx, info, timeout) client := fw.getRadiusClient(ctx) // Use the background context since we don't want the lib to use our context ctx2, cancel := fw.RadiusContextWithTimeout() defer canc...
go
func (fw *Checkpoint) Start(ctx context.Context, info map[string]string, timeout int) (bool, error) { p := fw.startRadiusPacket(ctx, info, timeout) client := fw.getRadiusClient(ctx) // Use the background context since we don't want the lib to use our context ctx2, cancel := fw.RadiusContextWithTimeout() defer canc...
[ "func", "(", "fw", "*", "Checkpoint", ")", "Start", "(", "ctx", "context", ".", "Context", ",", "info", "map", "[", "string", "]", "string", ",", "timeout", "int", ")", "(", "bool", ",", "error", ")", "{", "p", ":=", "fw", ".", "startRadiusPacket", ...
// Send an SSO start to the Checkpoint firewall // Returns an error unless there is a valid reply from the firewall
[ "Send", "an", "SSO", "start", "to", "the", "Checkpoint", "firewall", "Returns", "an", "error", "unless", "there", "is", "a", "valid", "reply", "from", "the", "firewall" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/firewallsso/checkpoint.go#L22-L35
train
inverse-inc/packetfence
go/firewallsso/checkpoint.go
startRadiusPacket
func (fw *Checkpoint) startRadiusPacket(ctx context.Context, info map[string]string, timeout int) *radius.Packet { r := radius.New(radius.CodeAccountingRequest, []byte(fw.Password)) rfc2866.AcctStatusType_Add(r, rfc2866.AcctStatusType_Value_Start) rfc2866.AcctSessionID_AddString(r, "acct_pf-"+info["mac"]) rfc2865.U...
go
func (fw *Checkpoint) startRadiusPacket(ctx context.Context, info map[string]string, timeout int) *radius.Packet { r := radius.New(radius.CodeAccountingRequest, []byte(fw.Password)) rfc2866.AcctStatusType_Add(r, rfc2866.AcctStatusType_Value_Start) rfc2866.AcctSessionID_AddString(r, "acct_pf-"+info["mac"]) rfc2865.U...
[ "func", "(", "fw", "*", "Checkpoint", ")", "startRadiusPacket", "(", "ctx", "context", ".", "Context", ",", "info", "map", "[", "string", "]", "string", ",", "timeout", "int", ")", "*", "radius", ".", "Packet", "{", "r", ":=", "radius", ".", "New", "...
// Build the RADIUS packet for an SSO start
[ "Build", "the", "RADIUS", "packet", "for", "an", "SSO", "start" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/firewallsso/checkpoint.go#L38-L49
train
inverse-inc/packetfence
go/firewallsso/checkpoint.go
Stop
func (fw *Checkpoint) Stop(ctx context.Context, info map[string]string) (bool, error) { log.LoggerWContext(ctx).Warn("SSO Stop is not available for this firewall") return false, nil }
go
func (fw *Checkpoint) Stop(ctx context.Context, info map[string]string) (bool, error) { log.LoggerWContext(ctx).Warn("SSO Stop is not available for this firewall") return false, nil }
[ "func", "(", "fw", "*", "Checkpoint", ")", "Stop", "(", "ctx", "context", ".", "Context", ",", "info", "map", "[", "string", "]", "string", ")", "(", "bool", ",", "error", ")", "{", "log", ".", "LoggerWContext", "(", "ctx", ")", ".", "Warn", "(", ...
// SSO stop handler which does nothing other than printing a warning since the SSO stop is unimplemented for this firewall
[ "SSO", "stop", "handler", "which", "does", "nothing", "other", "than", "printing", "a", "warning", "since", "the", "SSO", "stop", "is", "unimplemented", "for", "this", "firewall" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/firewallsso/checkpoint.go#L52-L55
train
inverse-inc/packetfence
go/coredns/coremain/run.go
setVersion
func setVersion() { // A development build is one that's not at a tag or has uncommitted changes devBuild = gitTag == "" || gitShortStat != "" // Only set the appVersion if -ldflags was used if gitNearestTag != "" || gitTag != "" { if devBuild && gitNearestTag != "" { appVersion = fmt.Sprintf("%s (+%s %s)", ...
go
func setVersion() { // A development build is one that's not at a tag or has uncommitted changes devBuild = gitTag == "" || gitShortStat != "" // Only set the appVersion if -ldflags was used if gitNearestTag != "" || gitTag != "" { if devBuild && gitNearestTag != "" { appVersion = fmt.Sprintf("%s (+%s %s)", ...
[ "func", "setVersion", "(", ")", "{", "// A development build is one that's not at a tag or has uncommitted changes", "devBuild", "=", "gitTag", "==", "\"", "\"", "||", "gitShortStat", "!=", "\"", "\"", "\n\n", "// Only set the appVersion if -ldflags was used", "if", "gitNeare...
// setVersion figures out the version information // based on variables set by -ldflags.
[ "setVersion", "figures", "out", "the", "version", "information", "based", "on", "variables", "set", "by", "-", "ldflags", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/coredns/coremain/run.go#L188-L201
train
inverse-inc/packetfence
go/coredns/plugin/proxy/metrics.go
OnStartupMetrics
func OnStartupMetrics() error { metricsOnce.Do(func() { prometheus.MustRegister(RequestCount) prometheus.MustRegister(RequestDuration) }) return nil }
go
func OnStartupMetrics() error { metricsOnce.Do(func() { prometheus.MustRegister(RequestCount) prometheus.MustRegister(RequestDuration) }) return nil }
[ "func", "OnStartupMetrics", "(", ")", "error", "{", "metricsOnce", ".", "Do", "(", "func", "(", ")", "{", "prometheus", ".", "MustRegister", "(", "RequestCount", ")", "\n", "prometheus", ".", "MustRegister", "(", "RequestDuration", ")", "\n", "}", ")", "\n...
// OnStartupMetrics sets up the metrics on startup. This is done for all proxy protocols.
[ "OnStartupMetrics", "sets", "up", "the", "metrics", "on", "startup", ".", "This", "is", "done", "for", "all", "proxy", "protocols", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/coredns/plugin/proxy/metrics.go#L29-L35
train
inverse-inc/packetfence
go/caddy/caddy/caddytls/crypto.go
stapleOCSP
func stapleOCSP(cert *Certificate, pemBundle []byte) error { if pemBundle == nil { // The function in the acme package that gets OCSP requires a PEM-encoded cert bundle := new(bytes.Buffer) for _, derBytes := range cert.Certificate.Certificate { pem.Encode(bundle, &pem.Block{Type: "CERTIFICATE", Bytes: derByt...
go
func stapleOCSP(cert *Certificate, pemBundle []byte) error { if pemBundle == nil { // The function in the acme package that gets OCSP requires a PEM-encoded cert bundle := new(bytes.Buffer) for _, derBytes := range cert.Certificate.Certificate { pem.Encode(bundle, &pem.Block{Type: "CERTIFICATE", Bytes: derByt...
[ "func", "stapleOCSP", "(", "cert", "*", "Certificate", ",", "pemBundle", "[", "]", "byte", ")", "error", "{", "if", "pemBundle", "==", "nil", "{", "// The function in the acme package that gets OCSP requires a PEM-encoded cert", "bundle", ":=", "new", "(", "bytes", ...
// stapleOCSP staples OCSP information to cert for hostname name. // If you have it handy, you should pass in the PEM-encoded certificate // bundle; otherwise the DER-encoded cert will have to be PEM-encoded. // If you don't have the PEM blocks already, just pass in nil. // // Errors here are not necessarily fatal, it ...
[ "stapleOCSP", "staples", "OCSP", "information", "to", "cert", "for", "hostname", "name", ".", "If", "you", "have", "it", "handy", "you", "should", "pass", "in", "the", "PEM", "-", "encoded", "certificate", "bundle", ";", "otherwise", "the", "DER", "-", "en...
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/caddytls/crypto.go#L74-L154
train
inverse-inc/packetfence
go/caddy/caddy/caddytls/crypto.go
makeSelfSignedCert
func makeSelfSignedCert(config *Config) error { // start by generating private key var privKey interface{} var err error switch config.KeyType { case "", acme.EC256: privKey, err = ecdsa.GenerateKey(elliptic.P256(), rand.Reader) case acme.EC384: privKey, err = ecdsa.GenerateKey(elliptic.P384(), rand.Reader) ...
go
func makeSelfSignedCert(config *Config) error { // start by generating private key var privKey interface{} var err error switch config.KeyType { case "", acme.EC256: privKey, err = ecdsa.GenerateKey(elliptic.P256(), rand.Reader) case acme.EC384: privKey, err = ecdsa.GenerateKey(elliptic.P384(), rand.Reader) ...
[ "func", "makeSelfSignedCert", "(", "config", "*", "Config", ")", "error", "{", "// start by generating private key", "var", "privKey", "interface", "{", "}", "\n", "var", "err", "error", "\n", "switch", "config", ".", "KeyType", "{", "case", "\"", "\"", ",", ...
// makeSelfSignedCert makes a self-signed certificate according // to the parameters in config. It then caches the certificate // in our cache.
[ "makeSelfSignedCert", "makes", "a", "self", "-", "signed", "certificate", "according", "to", "the", "parameters", "in", "config", ".", "It", "then", "caches", "the", "certificate", "in", "our", "cache", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/caddytls/crypto.go#L159-L230
train
inverse-inc/packetfence
go/caddy/caddy/caddytls/crypto.go
fastHash
func fastHash(input []byte) string { h := fnv.New32a() h.Write([]byte(input)) return fmt.Sprintf("%x", h.Sum32()) }
go
func fastHash(input []byte) string { h := fnv.New32a() h.Write([]byte(input)) return fmt.Sprintf("%x", h.Sum32()) }
[ "func", "fastHash", "(", "input", "[", "]", "byte", ")", "string", "{", "h", ":=", "fnv", ".", "New32a", "(", ")", "\n", "h", ".", "Write", "(", "[", "]", "byte", "(", "input", ")", ")", "\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ...
// fastHash hashes input using a hashing algorithm that // is fast, and returns the hash as a hex-encoded string. // Do not use this for cryptographic purposes.
[ "fastHash", "hashes", "input", "using", "a", "hashing", "algorithm", "that", "is", "fast", "and", "returns", "the", "hash", "as", "a", "hex", "-", "encoded", "string", ".", "Do", "not", "use", "this", "for", "cryptographic", "purposes", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/caddytls/crypto.go#L310-L314
train
inverse-inc/packetfence
go/coredns/request/request.go
ErrorMessage
func (r *Request) ErrorMessage(rcode int) *dns.Msg { m := new(dns.Msg) m.SetRcode(r.Req, rcode) return m }
go
func (r *Request) ErrorMessage(rcode int) *dns.Msg { m := new(dns.Msg) m.SetRcode(r.Req, rcode) return m }
[ "func", "(", "r", "*", "Request", ")", "ErrorMessage", "(", "rcode", "int", ")", "*", "dns", ".", "Msg", "{", "m", ":=", "new", "(", "dns", ".", "Msg", ")", "\n", "m", ".", "SetRcode", "(", "r", ".", "Req", ",", "rcode", ")", "\n", "return", ...
// ErrorMessage returns an error message suitable for sending // back to the client.
[ "ErrorMessage", "returns", "an", "error", "message", "suitable", "for", "sending", "back", "to", "the", "client", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/coredns/request/request.go#L298-L302
train
inverse-inc/packetfence
go/firewallsso/factory.go
NewFactory
func NewFactory(ctx context.Context) Factory { f := Factory{} f.typeRegistry = make(map[string]reflect.Type) f.typeRegistry["BarracudaNG"] = reflect.TypeOf(&BarracudaNG{}).Elem() f.typeRegistry["Iboss"] = reflect.TypeOf(&Iboss{}).Elem() f.typeRegistry["PaloAlto"] = reflect.TypeOf(&PaloAlto{}).Elem() f.typeRegistr...
go
func NewFactory(ctx context.Context) Factory { f := Factory{} f.typeRegistry = make(map[string]reflect.Type) f.typeRegistry["BarracudaNG"] = reflect.TypeOf(&BarracudaNG{}).Elem() f.typeRegistry["Iboss"] = reflect.TypeOf(&Iboss{}).Elem() f.typeRegistry["PaloAlto"] = reflect.TypeOf(&PaloAlto{}).Elem() f.typeRegistr...
[ "func", "NewFactory", "(", "ctx", "context", ".", "Context", ")", "Factory", "{", "f", ":=", "Factory", "{", "}", "\n", "f", ".", "typeRegistry", "=", "make", "(", "map", "[", "string", "]", "reflect", ".", "Type", ")", "\n", "f", ".", "typeRegistry"...
// Create a new FirewallSSO factory containing all the valid types
[ "Create", "a", "new", "FirewallSSO", "factory", "containing", "all", "the", "valid", "types" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/firewallsso/factory.go#L16-L28
train
inverse-inc/packetfence
go/firewallsso/factory.go
Instantiate
func (f *Factory) Instantiate(ctx context.Context, id string) (FirewallSSOInt, error) { firewall := FirewallSSO{} firewall.PfconfigHashNS = id _, err := pfconfigdriver.FetchDecodeSocketCache(ctx, &firewall) if err != nil { return nil, err } if oType, ok := f.typeRegistry[firewall.Type]; ok { or := reflect.New...
go
func (f *Factory) Instantiate(ctx context.Context, id string) (FirewallSSOInt, error) { firewall := FirewallSSO{} firewall.PfconfigHashNS = id _, err := pfconfigdriver.FetchDecodeSocketCache(ctx, &firewall) if err != nil { return nil, err } if oType, ok := f.typeRegistry[firewall.Type]; ok { or := reflect.New...
[ "func", "(", "f", "*", "Factory", ")", "Instantiate", "(", "ctx", "context", ".", "Context", ",", "id", "string", ")", "(", "FirewallSSOInt", ",", "error", ")", "{", "firewall", ":=", "FirewallSSO", "{", "}", "\n", "firewall", ".", "PfconfigHashNS", "=",...
// Instantiate a new FirewallSSO given its configuration ID in PacketFence
[ "Instantiate", "a", "new", "FirewallSSO", "given", "its", "configuration", "ID", "in", "PacketFence" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/firewallsso/factory.go#L31-L63
train
inverse-inc/packetfence
go/caddy/caddy/caddytls/client.go
Renew
func (c *ACMEClient) Renew(name string) error { // Get access to ACME storage storage, err := c.config.StorageFor(c.config.CAUrl) if err != nil { return err } waiter, err := storage.TryLock(name) if err != nil { return err } if waiter != nil { log.Printf("[INFO] Certificate for %s is already being renewe...
go
func (c *ACMEClient) Renew(name string) error { // Get access to ACME storage storage, err := c.config.StorageFor(c.config.CAUrl) if err != nil { return err } waiter, err := storage.TryLock(name) if err != nil { return err } if waiter != nil { log.Printf("[INFO] Certificate for %s is already being renewe...
[ "func", "(", "c", "*", "ACMEClient", ")", "Renew", "(", "name", "string", ")", "error", "{", "// Get access to ACME storage", "storage", ",", "err", ":=", "c", ".", "config", ".", "StorageFor", "(", "c", ".", "config", ".", "CAUrl", ")", "\n", "if", "e...
// Renew renews the managed certificate for name. This function is // safe for concurrent use. // // Callers who have access to a Config value should use the RenewCert // method on that instead of this lower-level method.
[ "Renew", "renews", "the", "managed", "certificate", "for", "name", ".", "This", "function", "is", "safe", "for", "concurrent", "use", ".", "Callers", "who", "have", "access", "to", "a", "Config", "value", "should", "use", "the", "RenewCert", "method", "on", ...
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/caddytls/client.go#L250-L317
train
inverse-inc/packetfence
go/caddy/caddy/caddytls/client.go
Revoke
func (c *ACMEClient) Revoke(name string) error { storage, err := c.config.StorageFor(c.config.CAUrl) if err != nil { return err } siteExists, err := storage.SiteExists(name) if err != nil { return err } if !siteExists { return errors.New("no certificate and key for " + name) } siteData, err := storage...
go
func (c *ACMEClient) Revoke(name string) error { storage, err := c.config.StorageFor(c.config.CAUrl) if err != nil { return err } siteExists, err := storage.SiteExists(name) if err != nil { return err } if !siteExists { return errors.New("no certificate and key for " + name) } siteData, err := storage...
[ "func", "(", "c", "*", "ACMEClient", ")", "Revoke", "(", "name", "string", ")", "error", "{", "storage", ",", "err", ":=", "c", ".", "config", ".", "StorageFor", "(", "c", ".", "config", ".", "CAUrl", ")", "\n", "if", "err", "!=", "nil", "{", "re...
// Revoke revokes the certificate for name and deltes // it from storage.
[ "Revoke", "revokes", "the", "certificate", "for", "name", "and", "deltes", "it", "from", "storage", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/caddytls/client.go#L321-L352
train
inverse-inc/packetfence
go/caddy/caddy/caddytls/client.go
Add
func (c *nameCoordinator) Add(names []string) { c.mu.Lock() for _, name := range names { c.names[strings.ToLower(name)] = struct{}{} } c.mu.Unlock() }
go
func (c *nameCoordinator) Add(names []string) { c.mu.Lock() for _, name := range names { c.names[strings.ToLower(name)] = struct{}{} } c.mu.Unlock() }
[ "func", "(", "c", "*", "nameCoordinator", ")", "Add", "(", "names", "[", "]", "string", ")", "{", "c", ".", "mu", ".", "Lock", "(", ")", "\n", "for", "_", ",", "name", ":=", "range", "names", "{", "c", ".", "names", "[", "strings", ".", "ToLowe...
// Add adds names to c. It is safe for concurrent use.
[ "Add", "adds", "names", "to", "c", ".", "It", "is", "safe", "for", "concurrent", "use", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/caddytls/client.go#L369-L375
train
inverse-inc/packetfence
go/caddy/caddy/caddytls/client.go
Remove
func (c *nameCoordinator) Remove(names []string) { c.mu.Lock() for _, name := range names { delete(c.names, strings.ToLower(name)) } c.mu.Unlock() }
go
func (c *nameCoordinator) Remove(names []string) { c.mu.Lock() for _, name := range names { delete(c.names, strings.ToLower(name)) } c.mu.Unlock() }
[ "func", "(", "c", "*", "nameCoordinator", ")", "Remove", "(", "names", "[", "]", "string", ")", "{", "c", ".", "mu", ".", "Lock", "(", ")", "\n", "for", "_", ",", "name", ":=", "range", "names", "{", "delete", "(", "c", ".", "names", ",", "stri...
// Remove removes names from c. It is safe for concurrent use.
[ "Remove", "removes", "names", "from", "c", ".", "It", "is", "safe", "for", "concurrent", "use", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/caddytls/client.go#L378-L384
train
inverse-inc/packetfence
go/caddy/caddy/caddytls/client.go
Has
func (c *nameCoordinator) Has(name string) bool { hostname, _, err := net.SplitHostPort(name) if err != nil { hostname = name } c.mu.RLock() _, ok := c.names[strings.ToLower(hostname)] c.mu.RUnlock() return ok }
go
func (c *nameCoordinator) Has(name string) bool { hostname, _, err := net.SplitHostPort(name) if err != nil { hostname = name } c.mu.RLock() _, ok := c.names[strings.ToLower(hostname)] c.mu.RUnlock() return ok }
[ "func", "(", "c", "*", "nameCoordinator", ")", "Has", "(", "name", "string", ")", "bool", "{", "hostname", ",", "_", ",", "err", ":=", "net", ".", "SplitHostPort", "(", "name", ")", "\n", "if", "err", "!=", "nil", "{", "hostname", "=", "name", "\n"...
// Has returns true if c has name. It is safe for concurrent use.
[ "Has", "returns", "true", "if", "c", "has", "name", ".", "It", "is", "safe", "for", "concurrent", "use", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/caddytls/client.go#L387-L396
train
inverse-inc/packetfence
go/coredns/plugin/metrics/metrics.go
OnShutdown
func (m *Metrics) OnShutdown() error { if m.ln != nil { return m.ln.Close() } return nil }
go
func (m *Metrics) OnShutdown() error { if m.ln != nil { return m.ln.Close() } return nil }
[ "func", "(", "m", "*", "Metrics", ")", "OnShutdown", "(", ")", "error", "{", "if", "m", ".", "ln", "!=", "nil", "{", "return", "m", ".", "ln", ".", "Close", "(", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// OnShutdown tears down the metrics on shutdown and restart.
[ "OnShutdown", "tears", "down", "the", "metrics", "on", "shutdown", "and", "restart", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/coredns/plugin/metrics/metrics.go#L84-L89
train
inverse-inc/packetfence
go/sharedutils/util.go
Inc
func Inc(ip net.IP) { for j := len(ip) - 1; j >= 0; j-- { ip[j]++ if ip[j] > 0 { break } } }
go
func Inc(ip net.IP) { for j := len(ip) - 1; j >= 0; j-- { ip[j]++ if ip[j] > 0 { break } } }
[ "func", "Inc", "(", "ip", "net", ".", "IP", ")", "{", "for", "j", ":=", "len", "(", "ip", ")", "-", "1", ";", "j", ">=", "0", ";", "j", "--", "{", "ip", "[", "j", "]", "++", "\n", "if", "ip", "[", "j", "]", ">", "0", "{", "break", "\n...
// Inc function use to increment an ip
[ "Inc", "function", "use", "to", "increment", "an", "ip" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/sharedutils/util.go#L172-L179
train
inverse-inc/packetfence
go/sharedutils/util.go
Dec
func Dec(ip net.IP) { for j := len(ip) - 1; j >= 0; j-- { ip[j]-- if ip[j] == 255 { continue } if ip[j] > 0 { break } } }
go
func Dec(ip net.IP) { for j := len(ip) - 1; j >= 0; j-- { ip[j]-- if ip[j] == 255 { continue } if ip[j] > 0 { break } } }
[ "func", "Dec", "(", "ip", "net", ".", "IP", ")", "{", "for", "j", ":=", "len", "(", "ip", ")", "-", "1", ";", "j", ">=", "0", ";", "j", "--", "{", "ip", "[", "j", "]", "--", "\n", "if", "ip", "[", "j", "]", "==", "255", "{", "continue",...
// Dec function use to decrement an ip
[ "Dec", "function", "use", "to", "decrement", "an", "ip" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/sharedutils/util.go#L182-L192
train
inverse-inc/packetfence
go/sharedutils/util.go
ConvertToString
func ConvertToString(b []byte) string { s := make([]string, len(b)) for i := range b { s[i] = strconv.Itoa(int(b[i])) } return strings.Join(s, ",") }
go
func ConvertToString(b []byte) string { s := make([]string, len(b)) for i := range b { s[i] = strconv.Itoa(int(b[i])) } return strings.Join(s, ",") }
[ "func", "ConvertToString", "(", "b", "[", "]", "byte", ")", "string", "{", "s", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "b", ")", ")", "\n", "for", "i", ":=", "range", "b", "{", "s", "[", "i", "]", "=", "strconv", ".", "Itoa",...
// ConvertToSting convert byte to string
[ "ConvertToSting", "convert", "byte", "to", "string" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/sharedutils/util.go#L195-L201
train
inverse-inc/packetfence
go/sharedutils/util.go
ConvertToByte
func ConvertToByte(b string) []byte { s := strings.Split(b, ",") var result []byte for i := range s { value, _ := strconv.Atoi(s[i]) result = append(result, byte(value)) } return result }
go
func ConvertToByte(b string) []byte { s := strings.Split(b, ",") var result []byte for i := range s { value, _ := strconv.Atoi(s[i]) result = append(result, byte(value)) } return result }
[ "func", "ConvertToByte", "(", "b", "string", ")", "[", "]", "byte", "{", "s", ":=", "strings", ".", "Split", "(", "b", ",", "\"", "\"", ")", "\n", "var", "result", "[", "]", "byte", "\n", "for", "i", ":=", "range", "s", "{", "value", ",", "_", ...
// ConvertToByte convert string to byte
[ "ConvertToByte", "convert", "string", "to", "byte" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/sharedutils/util.go#L204-L213
train
inverse-inc/packetfence
go/sharedutils/util.go
ByteToString
func ByteToString(a []byte) string { const hexDigit = "0123456789abcdef" if len(a) == 0 { return "" } buf := make([]byte, 0, len(a)*3-1) for i, b := range a { if i > 0 { buf = append(buf, ':') } buf = append(buf, hexDigit[b>>4]) buf = append(buf, hexDigit[b&0xF]) } return string(buf) }
go
func ByteToString(a []byte) string { const hexDigit = "0123456789abcdef" if len(a) == 0 { return "" } buf := make([]byte, 0, len(a)*3-1) for i, b := range a { if i > 0 { buf = append(buf, ':') } buf = append(buf, hexDigit[b>>4]) buf = append(buf, hexDigit[b&0xF]) } return string(buf) }
[ "func", "ByteToString", "(", "a", "[", "]", "byte", ")", "string", "{", "const", "hexDigit", "=", "\"", "\"", "\n", "if", "len", "(", "a", ")", "==", "0", "{", "return", "\"", "\"", "\n", "}", "\n", "buf", ":=", "make", "(", "[", "]", "byte", ...
// ByteToString return a human readeable string of the byte
[ "ByteToString", "return", "a", "human", "readeable", "string", "of", "the", "byte" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/sharedutils/util.go#L216-L230
train
inverse-inc/packetfence
go/caddy/caddy/caddytls/config.go
RenewCert
func (c *Config) RenewCert(name string, allowPrompts bool) error { client, err := newACMEClient(c, allowPrompts) if err != nil { return err } return client.Renew(name) }
go
func (c *Config) RenewCert(name string, allowPrompts bool) error { client, err := newACMEClient(c, allowPrompts) if err != nil { return err } return client.Renew(name) }
[ "func", "(", "c", "*", "Config", ")", "RenewCert", "(", "name", "string", ",", "allowPrompts", "bool", ")", "error", "{", "client", ",", "err", ":=", "newACMEClient", "(", "c", ",", "allowPrompts", ")", "\n", "if", "err", "!=", "nil", "{", "return", ...
// RenewCert renews the certificate for name using c. It stows the // renewed certificate and its assets in storage if successful.
[ "RenewCert", "renews", "the", "certificate", "for", "name", "using", "c", ".", "It", "stows", "the", "renewed", "certificate", "and", "its", "assets", "in", "storage", "if", "successful", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/caddytls/config.go#L164-L170
train
inverse-inc/packetfence
go/caddy/caddy/caddytls/config.go
StorageFor
func (c *Config) StorageFor(caURL string) (Storage, error) { // Validate CA URL if caURL == "" { caURL = DefaultCAUrl } if caURL == "" { return nil, fmt.Errorf("cannot create storage without CA URL") } caURL = strings.ToLower(caURL) // scheme required or host will be parsed as path (as of Go 1.6) if !strin...
go
func (c *Config) StorageFor(caURL string) (Storage, error) { // Validate CA URL if caURL == "" { caURL = DefaultCAUrl } if caURL == "" { return nil, fmt.Errorf("cannot create storage without CA URL") } caURL = strings.ToLower(caURL) // scheme required or host will be parsed as path (as of Go 1.6) if !strin...
[ "func", "(", "c", "*", "Config", ")", "StorageFor", "(", "caURL", "string", ")", "(", "Storage", ",", "error", ")", "{", "// Validate CA URL", "if", "caURL", "==", "\"", "\"", "{", "caURL", "=", "DefaultCAUrl", "\n", "}", "\n", "if", "caURL", "==", "...
// StorageFor obtains a TLS Storage instance for the given CA URL which should // be unique for every different ACME CA. If a StorageCreator is set on this // Config, it will be used. Otherwise the default file storage implementation // is used. When the error is nil, this is guaranteed to return a non-nil // Storage i...
[ "StorageFor", "obtains", "a", "TLS", "Storage", "instance", "for", "the", "given", "CA", "URL", "which", "should", "be", "unique", "for", "every", "different", "ACME", "CA", ".", "If", "a", "StorageCreator", "is", "set", "on", "this", "Config", "it", "will...
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/caddytls/config.go#L177-L218
train
inverse-inc/packetfence
go/coredns/plugin/auto/zone.go
Remove
func (z *Zones) Remove(name string) { z.Lock() if zo, ok := z.Z[name]; ok && !zo.NoReload { zo.ReloadShutdown <- true } delete(z.Z, name) // TODO(miek): just regenerate Names (might be bad if you have a lot of zones...) z.names = []string{} for n := range z.Z { z.names = append(z.names, n) } z.Unlock()...
go
func (z *Zones) Remove(name string) { z.Lock() if zo, ok := z.Z[name]; ok && !zo.NoReload { zo.ReloadShutdown <- true } delete(z.Z, name) // TODO(miek): just regenerate Names (might be bad if you have a lot of zones...) z.names = []string{} for n := range z.Z { z.names = append(z.names, n) } z.Unlock()...
[ "func", "(", "z", "*", "Zones", ")", "Remove", "(", "name", "string", ")", "{", "z", ".", "Lock", "(", ")", "\n\n", "if", "zo", ",", "ok", ":=", "z", ".", "Z", "[", "name", "]", ";", "ok", "&&", "!", "zo", ".", "NoReload", "{", "zo", ".", ...
// Remove removes the zone named name from z. It also stop the the zone's reload goroutine.
[ "Remove", "removes", "the", "zone", "named", "name", "from", "z", ".", "It", "also", "stop", "the", "the", "zone", "s", "reload", "goroutine", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/coredns/plugin/auto/zone.go#L60-L76
train
inverse-inc/packetfence
go/firewallsso/base.go
init
func (fw *FirewallSSO) init(ctx context.Context) error { for _, net := range fw.Networks { err := net.init(ctx) if err != nil { return err } } return nil }
go
func (fw *FirewallSSO) init(ctx context.Context) error { for _, net := range fw.Networks { err := net.init(ctx) if err != nil { return err } } return nil }
[ "func", "(", "fw", "*", "FirewallSSO", ")", "init", "(", "ctx", "context", ".", "Context", ")", "error", "{", "for", "_", ",", "net", ":=", "range", "fw", ".", "Networks", "{", "err", ":=", "net", ".", "init", "(", "ctx", ")", "\n", "if", "err", ...
// Builds all networks, meant to be called after the data is loaded into the struct attributes
[ "Builds", "all", "networks", "meant", "to", "be", "called", "after", "the", "data", "is", "loaded", "into", "the", "struct", "attributes" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/firewallsso/base.go#L61-L69
train
inverse-inc/packetfence
go/firewallsso/base.go
init
func (fwn *FirewallSSONetwork) init(ctx context.Context) error { var err error fwn.Ip, fwn.IpNet, err = net.ParseCIDR(fwn.Cidr) return err }
go
func (fwn *FirewallSSONetwork) init(ctx context.Context) error { var err error fwn.Ip, fwn.IpNet, err = net.ParseCIDR(fwn.Cidr) return err }
[ "func", "(", "fwn", "*", "FirewallSSONetwork", ")", "init", "(", "ctx", "context", ".", "Context", ")", "error", "{", "var", "err", "error", "\n", "fwn", ".", "Ip", ",", "fwn", ".", "IpNet", ",", "err", "=", "net", ".", "ParseCIDR", "(", "fwn", "."...
// Builds Ip and IpNet based on the Cidr in the struct
[ "Builds", "Ip", "and", "IpNet", "based", "on", "the", "Cidr", "in", "the", "struct" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/firewallsso/base.go#L84-L88
train
inverse-inc/packetfence
go/firewallsso/base.go
GetCacheTimeout
func (fw *FirewallSSO) GetCacheTimeout(ctx context.Context) int { timeout, err := strconv.ParseInt(fw.CacheTimeout, 10, 32) if err != nil { log.LoggerWContext(ctx).Debug(fmt.Sprintf("Can't parse timeout '%s' into an int (%s).", fw.CacheTimeout, err)) return 0 } else { return int(timeout) } }
go
func (fw *FirewallSSO) GetCacheTimeout(ctx context.Context) int { timeout, err := strconv.ParseInt(fw.CacheTimeout, 10, 32) if err != nil { log.LoggerWContext(ctx).Debug(fmt.Sprintf("Can't parse timeout '%s' into an int (%s).", fw.CacheTimeout, err)) return 0 } else { return int(timeout) } }
[ "func", "(", "fw", "*", "FirewallSSO", ")", "GetCacheTimeout", "(", "ctx", "context", ".", "Context", ")", "int", "{", "timeout", ",", "err", ":=", "strconv", ".", "ParseInt", "(", "fw", ".", "CacheTimeout", ",", "10", ",", "32", ")", "\n", "if", "er...
// Get the cache_timeout configured in the firewall as an int // Will return 0 if its not there or not a valid int
[ "Get", "the", "cache_timeout", "configured", "in", "the", "firewall", "as", "an", "int", "Will", "return", "0", "if", "its", "not", "there", "or", "not", "a", "valid", "int" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/firewallsso/base.go#L103-L111
train
inverse-inc/packetfence
go/firewallsso/base.go
Start
func (fw *FirewallSSO) Start(ctx context.Context, info map[string]string, timeout int) (bool, error) { log.LoggerWContext(ctx).Debug("Sending SSO start") return true, nil }
go
func (fw *FirewallSSO) Start(ctx context.Context, info map[string]string, timeout int) (bool, error) { log.LoggerWContext(ctx).Debug("Sending SSO start") return true, nil }
[ "func", "(", "fw", "*", "FirewallSSO", ")", "Start", "(", "ctx", "context", ".", "Context", ",", "info", "map", "[", "string", "]", "string", ",", "timeout", "int", ")", "(", "bool", ",", "error", ")", "{", "log", ".", "LoggerWContext", "(", "ctx", ...
// Start method that will be called on every SSO called via ExecuteStart
[ "Start", "method", "that", "will", "be", "called", "on", "every", "SSO", "called", "via", "ExecuteStart" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/firewallsso/base.go#L153-L156
train
inverse-inc/packetfence
go/firewallsso/base.go
Stop
func (fw *FirewallSSO) Stop(ctx context.Context, info map[string]string) (bool, error) { log.LoggerWContext(ctx).Debug("Sending SSO stop") return true, nil }
go
func (fw *FirewallSSO) Stop(ctx context.Context, info map[string]string) (bool, error) { log.LoggerWContext(ctx).Debug("Sending SSO stop") return true, nil }
[ "func", "(", "fw", "*", "FirewallSSO", ")", "Stop", "(", "ctx", "context", ".", "Context", ",", "info", "map", "[", "string", "]", "string", ")", "(", "bool", ",", "error", ")", "{", "log", ".", "LoggerWContext", "(", "ctx", ")", ".", "Debug", "(",...
// Stop method that will be called on every SSO called via ExecuteStop
[ "Stop", "method", "that", "will", "be", "called", "on", "every", "SSO", "called", "via", "ExecuteStop" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/firewallsso/base.go#L159-L162
train
inverse-inc/packetfence
go/firewallsso/base.go
getSourceIp
func (fw *FirewallSSO) getSourceIp(ctx context.Context) net.IP { managementNetwork := pfconfigdriver.Config.Interfaces.ManagementNetwork if managementNetwork.Vip != "" { return net.ParseIP(managementNetwork.Vip) } else { return net.ParseIP(managementNetwork.Ip) } }
go
func (fw *FirewallSSO) getSourceIp(ctx context.Context) net.IP { managementNetwork := pfconfigdriver.Config.Interfaces.ManagementNetwork if managementNetwork.Vip != "" { return net.ParseIP(managementNetwork.Vip) } else { return net.ParseIP(managementNetwork.Ip) } }
[ "func", "(", "fw", "*", "FirewallSSO", ")", "getSourceIp", "(", "ctx", "context", ".", "Context", ")", "net", ".", "IP", "{", "managementNetwork", ":=", "pfconfigdriver", ".", "Config", ".", "Interfaces", ".", "ManagementNetwork", "\n\n", "if", "managementNetw...
// Get the source IP address for the SSO packets // Will return either the management VIP if there is one of the IP of the management network
[ "Get", "the", "source", "IP", "address", "for", "the", "SSO", "packets", "Will", "return", "either", "the", "management", "VIP", "if", "there", "is", "one", "of", "the", "IP", "of", "the", "management", "network" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/firewallsso/base.go#L170-L178
train
inverse-inc/packetfence
go/firewallsso/base.go
getHttpClient
func (fw *FirewallSSO) getHttpClient(ctx context.Context) *http.Client { // We don't check the TLS certificate if applicable transport := &http.Transport{ TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, } return &http.Client{Transport: transport} }
go
func (fw *FirewallSSO) getHttpClient(ctx context.Context) *http.Client { // We don't check the TLS certificate if applicable transport := &http.Transport{ TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, } return &http.Client{Transport: transport} }
[ "func", "(", "fw", "*", "FirewallSSO", ")", "getHttpClient", "(", "ctx", "context", ".", "Context", ")", "*", "http", ".", "Client", "{", "// We don't check the TLS certificate if applicable", "transport", ":=", "&", "http", ".", "Transport", "{", "TLSClientConfig...
// Get the default SSO HTTP client that doesn't check for valid certificates
[ "Get", "the", "default", "SSO", "HTTP", "client", "that", "doesn", "t", "check", "for", "valid", "certificates" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/firewallsso/base.go#L181-L187
train
inverse-inc/packetfence
go/firewallsso/base.go
getRadiusClient
func (fw *FirewallSSO) getRadiusClient(ctx context.Context) *radius.Client { return &radius.Client{} }
go
func (fw *FirewallSSO) getRadiusClient(ctx context.Context) *radius.Client { return &radius.Client{} }
[ "func", "(", "fw", "*", "FirewallSSO", ")", "getRadiusClient", "(", "ctx", "context", ".", "Context", ")", "*", "radius", ".", "Client", "{", "return", "&", "radius", ".", "Client", "{", "}", "\n", "}" ]
// Get the default RADIUS client
[ "Get", "the", "default", "RADIUS", "client" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/firewallsso/base.go#L190-L192
train
inverse-inc/packetfence
go/firewallsso/base.go
logger
func (fw *FirewallSSO) logger(ctx context.Context) log15.Logger { ctx = log.AddToLogContext(ctx, "firewall-id", fw.PfconfigHashNS) return log.LoggerWContext(ctx) }
go
func (fw *FirewallSSO) logger(ctx context.Context) log15.Logger { ctx = log.AddToLogContext(ctx, "firewall-id", fw.PfconfigHashNS) return log.LoggerWContext(ctx) }
[ "func", "(", "fw", "*", "FirewallSSO", ")", "logger", "(", "ctx", "context", ".", "Context", ")", "log15", ".", "Logger", "{", "ctx", "=", "log", ".", "AddToLogContext", "(", "ctx", ",", "\"", "\"", ",", "fw", ".", "PfconfigHashNS", ")", "\n", "retur...
// Get the logger for a firewall
[ "Get", "the", "logger", "for", "a", "firewall" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/firewallsso/base.go#L237-L240
train
inverse-inc/packetfence
go/firewallsso/base.go
ExecuteStart
func ExecuteStart(ctx context.Context, fw FirewallSSOInt, info map[string]string, timeout int) (bool, error) { ctx = log.AddToLogContext(ctx, "firewall-id", fw.GetFirewallSSO(ctx).PfconfigHashNS) if !fw.CheckStatus(ctx, info) { return false, nil } log.LoggerWContext(ctx).Info("Processing SSO Start") if !fw.Matc...
go
func ExecuteStart(ctx context.Context, fw FirewallSSOInt, info map[string]string, timeout int) (bool, error) { ctx = log.AddToLogContext(ctx, "firewall-id", fw.GetFirewallSSO(ctx).PfconfigHashNS) if !fw.CheckStatus(ctx, info) { return false, nil } log.LoggerWContext(ctx).Info("Processing SSO Start") if !fw.Matc...
[ "func", "ExecuteStart", "(", "ctx", "context", ".", "Context", ",", "fw", "FirewallSSOInt", ",", "info", "map", "[", "string", "]", "string", ",", "timeout", "int", ")", "(", "bool", ",", "error", ")", "{", "ctx", "=", "log", ".", "AddToLogContext", "(...
// Execute an SSO Start request on the specified firewall // Makes sure to call FirewallSSO.Start and to validate the network and role if necessary
[ "Execute", "an", "SSO", "Start", "request", "on", "the", "specified", "firewall", "Makes", "sure", "to", "call", "FirewallSSO", ".", "Start", "and", "to", "validate", "the", "network", "and", "role", "if", "necessary" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/firewallsso/base.go#L244-L272
train
inverse-inc/packetfence
go/firewallsso/base.go
ExecuteStop
func ExecuteStop(ctx context.Context, fw FirewallSSOInt, info map[string]string) (bool, error) { ctx = log.AddToLogContext(ctx, "firewall-id", fw.GetFirewallSSO(ctx).PfconfigHashNS) log.LoggerWContext(ctx).Info("Processing SSO Stop") if !fw.MatchesNetwork(ctx, info) { log.LoggerWContext(ctx).Debug(fmt.Sprintf("No...
go
func ExecuteStop(ctx context.Context, fw FirewallSSOInt, info map[string]string) (bool, error) { ctx = log.AddToLogContext(ctx, "firewall-id", fw.GetFirewallSSO(ctx).PfconfigHashNS) log.LoggerWContext(ctx).Info("Processing SSO Stop") if !fw.MatchesNetwork(ctx, info) { log.LoggerWContext(ctx).Debug(fmt.Sprintf("No...
[ "func", "ExecuteStop", "(", "ctx", "context", ".", "Context", ",", "fw", "FirewallSSOInt", ",", "info", "map", "[", "string", "]", "string", ")", "(", "bool", ",", "error", ")", "{", "ctx", "=", "log", ".", "AddToLogContext", "(", "ctx", ",", "\"", "...
// Execute an SSO Stop request on the specified firewall // Makes sure to call FirewallSSO.Start and to validate the network if necessary
[ "Execute", "an", "SSO", "Stop", "request", "on", "the", "specified", "firewall", "Makes", "sure", "to", "call", "FirewallSSO", ".", "Start", "and", "to", "validate", "the", "network", "if", "necessary" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/firewallsso/base.go#L276-L297
train
inverse-inc/packetfence
go/coredns/plugin/pkg/cache/cache.go
New
func New(size int) *Cache { ssize := size / shardSize if ssize < 512 { ssize = 512 } c := &Cache{} // Initialize all the shards for i := 0; i < shardSize; i++ { c.shards[i] = newShard(ssize) } return c }
go
func New(size int) *Cache { ssize := size / shardSize if ssize < 512 { ssize = 512 } c := &Cache{} // Initialize all the shards for i := 0; i < shardSize; i++ { c.shards[i] = newShard(ssize) } return c }
[ "func", "New", "(", "size", "int", ")", "*", "Cache", "{", "ssize", ":=", "size", "/", "shardSize", "\n", "if", "ssize", "<", "512", "{", "ssize", "=", "512", "\n", "}", "\n\n", "c", ":=", "&", "Cache", "{", "}", "\n\n", "// Initialize all the shards...
// New returns a new cache.
[ "New", "returns", "a", "new", "cache", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/coredns/plugin/pkg/cache/cache.go#L32-L45
train
inverse-inc/packetfence
go/coredns/plugin/pkg/cache/cache.go
Get
func (c *Cache) Get(key uint32) (interface{}, bool) { shard := key & (shardSize - 1) return c.shards[shard].Get(key) }
go
func (c *Cache) Get(key uint32) (interface{}, bool) { shard := key & (shardSize - 1) return c.shards[shard].Get(key) }
[ "func", "(", "c", "*", "Cache", ")", "Get", "(", "key", "uint32", ")", "(", "interface", "{", "}", ",", "bool", ")", "{", "shard", ":=", "key", "&", "(", "shardSize", "-", "1", ")", "\n", "return", "c", ".", "shards", "[", "shard", "]", ".", ...
// Get looks up element index under key.
[ "Get", "looks", "up", "element", "index", "under", "key", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/coredns/plugin/pkg/cache/cache.go#L54-L57
train
inverse-inc/packetfence
go/coredns/plugin/pkg/cache/cache.go
Add
func (s *shard) Add(key uint32, el interface{}) { l := s.Len() if l+1 > s.size { s.Evict() } s.Lock() s.items[key] = el s.Unlock() }
go
func (s *shard) Add(key uint32, el interface{}) { l := s.Len() if l+1 > s.size { s.Evict() } s.Lock() s.items[key] = el s.Unlock() }
[ "func", "(", "s", "*", "shard", ")", "Add", "(", "key", "uint32", ",", "el", "interface", "{", "}", ")", "{", "l", ":=", "s", ".", "Len", "(", ")", "\n", "if", "l", "+", "1", ">", "s", ".", "size", "{", "s", ".", "Evict", "(", ")", "\n", ...
// Add adds element indexed by key into the cache. Any existing element is overwritten
[ "Add", "adds", "element", "indexed", "by", "key", "into", "the", "cache", ".", "Any", "existing", "element", "is", "overwritten" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/coredns/plugin/pkg/cache/cache.go#L78-L87
train
inverse-inc/packetfence
go/coredns/plugin/pkg/cache/cache.go
Remove
func (s *shard) Remove(key uint32) { s.Lock() delete(s.items, key) s.Unlock() }
go
func (s *shard) Remove(key uint32) { s.Lock() delete(s.items, key) s.Unlock() }
[ "func", "(", "s", "*", "shard", ")", "Remove", "(", "key", "uint32", ")", "{", "s", ".", "Lock", "(", ")", "\n", "delete", "(", "s", ".", "items", ",", "key", ")", "\n", "s", ".", "Unlock", "(", ")", "\n", "}" ]
// Remove removes the element indexed by key from the cache.
[ "Remove", "removes", "the", "element", "indexed", "by", "key", "from", "the", "cache", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/coredns/plugin/pkg/cache/cache.go#L90-L94
train
inverse-inc/packetfence
go/coredns/plugin/pkg/cache/cache.go
Get
func (s *shard) Get(key uint32) (interface{}, bool) { s.RLock() el, found := s.items[key] s.RUnlock() return el, found }
go
func (s *shard) Get(key uint32) (interface{}, bool) { s.RLock() el, found := s.items[key] s.RUnlock() return el, found }
[ "func", "(", "s", "*", "shard", ")", "Get", "(", "key", "uint32", ")", "(", "interface", "{", "}", ",", "bool", ")", "{", "s", ".", "RLock", "(", ")", "\n", "el", ",", "found", ":=", "s", ".", "items", "[", "key", "]", "\n", "s", ".", "RUnl...
// Get looks up the element indexed under key.
[ "Get", "looks", "up", "the", "element", "indexed", "under", "key", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/coredns/plugin/pkg/cache/cache.go#L117-L122
train
inverse-inc/packetfence
go/caddy/caddy/caddyhttp/httpserver/server.go
ServePacket
func (s *Server) ServePacket(pc net.PacketConn) error { if QUIC { err := s.quicServer.Serve(pc.(*net.UDPConn)) return fmt.Errorf("serving QUIC connections: %v", err) } return nil }
go
func (s *Server) ServePacket(pc net.PacketConn) error { if QUIC { err := s.quicServer.Serve(pc.(*net.UDPConn)) return fmt.Errorf("serving QUIC connections: %v", err) } return nil }
[ "func", "(", "s", "*", "Server", ")", "ServePacket", "(", "pc", "net", ".", "PacketConn", ")", "error", "{", "if", "QUIC", "{", "err", ":=", "s", ".", "quicServer", ".", "Serve", "(", "pc", ".", "(", "*", "net", ".", "UDPConn", ")", ")", "\n", ...
// ServePacket serves QUIC requests on pc until it is closed.
[ "ServePacket", "serves", "QUIC", "requests", "on", "pc", "until", "it", "is", "closed", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/caddyhttp/httpserver/server.go#L193-L199
train
inverse-inc/packetfence
go/firewallsso/junipersrx.go
Start
func (fw *JuniperSRX) Start(ctx context.Context, info map[string]string, timeout int) (bool, error) { log.LoggerWContext(ctx).Info("Sending SSO to JuniperSRX using HTTP") return fw.startHttp(ctx, info, timeout) }
go
func (fw *JuniperSRX) Start(ctx context.Context, info map[string]string, timeout int) (bool, error) { log.LoggerWContext(ctx).Info("Sending SSO to JuniperSRX using HTTP") return fw.startHttp(ctx, info, timeout) }
[ "func", "(", "fw", "*", "JuniperSRX", ")", "Start", "(", "ctx", "context", ".", "Context", ",", "info", "map", "[", "string", "]", "string", ",", "timeout", "int", ")", "(", "bool", ",", "error", ")", "{", "log", ".", "LoggerWContext", "(", "ctx", ...
// Send an SSO start to the JuniperSRX using HTTP // This will return any value from startSyslog or startHttp depending on the type of the transport
[ "Send", "an", "SSO", "start", "to", "the", "JuniperSRX", "using", "HTTP", "This", "will", "return", "any", "value", "from", "startSyslog", "or", "startHttp", "depending", "on", "the", "type", "of", "the", "transport" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/firewallsso/junipersrx.go#L23-L27
train
inverse-inc/packetfence
go/firewallsso/junipersrx.go
startHttp
func (fw *JuniperSRX) startHttp(ctx context.Context, info map[string]string, timeout int) (bool, error) { req, err := http.NewRequest("POST", "https://"+fw.PfconfigHashNS+":"+fw.Port+"/api/userfw/v1/post-entry", bytes.NewBuffer([]byte(fw.startHttpPayload(ctx, info)))) req.SetBasicAuth(fw.Username, fw.Password) clie...
go
func (fw *JuniperSRX) startHttp(ctx context.Context, info map[string]string, timeout int) (bool, error) { req, err := http.NewRequest("POST", "https://"+fw.PfconfigHashNS+":"+fw.Port+"/api/userfw/v1/post-entry", bytes.NewBuffer([]byte(fw.startHttpPayload(ctx, info)))) req.SetBasicAuth(fw.Username, fw.Password) clie...
[ "func", "(", "fw", "*", "JuniperSRX", ")", "startHttp", "(", "ctx", "context", ".", "Context", ",", "info", "map", "[", "string", "]", "string", ",", "timeout", "int", ")", "(", "bool", ",", "error", ")", "{", "req", ",", "err", ":=", "http", ".", ...
// Send a start to the JuniperSRX using the HTTP transport // Will return an error if it fails to get a valid reply from it
[ "Send", "a", "start", "to", "the", "JuniperSRX", "using", "the", "HTTP", "transport", "Will", "return", "an", "error", "if", "it", "fails", "to", "get", "a", "valid", "reply", "from", "it" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/firewallsso/junipersrx.go#L31-L48
train
inverse-inc/packetfence
go/firewallsso/junipersrx.go
Stop
func (fw *JuniperSRX) Stop(ctx context.Context, info map[string]string) (bool, error) { log.LoggerWContext(ctx).Info("Sending SSO to JuniperSRX using HTTP") return fw.stopHttp(ctx, info) }
go
func (fw *JuniperSRX) Stop(ctx context.Context, info map[string]string) (bool, error) { log.LoggerWContext(ctx).Info("Sending SSO to JuniperSRX using HTTP") return fw.stopHttp(ctx, info) }
[ "func", "(", "fw", "*", "JuniperSRX", ")", "Stop", "(", "ctx", "context", ".", "Context", ",", "info", "map", "[", "string", "]", "string", ")", "(", "bool", ",", "error", ")", "{", "log", ".", "LoggerWContext", "(", "ctx", ")", ".", "Info", "(", ...
// Send an SSO stop to the firewall by using HTTP transport.
[ "Send", "an", "SSO", "stop", "to", "the", "firewall", "by", "using", "HTTP", "transport", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/firewallsso/junipersrx.go#L103-L107
train
inverse-inc/packetfence
go/firewallsso/barracudang.go
getSshSession
func (fw *BarracudaNG) getSshSession(ctx context.Context) (*ssh.Session, error) { sshConfig := &ssh.ClientConfig{ User: fw.Username, Auth: []ssh.AuthMethod{ ssh.Password(fw.Password), }, } connection, err := ssh.Dial("tcp", fw.PfconfigHashNS+":"+fw.Port, sshConfig) if err != nil { return nil, err } s...
go
func (fw *BarracudaNG) getSshSession(ctx context.Context) (*ssh.Session, error) { sshConfig := &ssh.ClientConfig{ User: fw.Username, Auth: []ssh.AuthMethod{ ssh.Password(fw.Password), }, } connection, err := ssh.Dial("tcp", fw.PfconfigHashNS+":"+fw.Port, sshConfig) if err != nil { return nil, err } s...
[ "func", "(", "fw", "*", "BarracudaNG", ")", "getSshSession", "(", "ctx", "context", ".", "Context", ")", "(", "*", "ssh", ".", "Session", ",", "error", ")", "{", "sshConfig", ":=", "&", "ssh", ".", "ClientConfig", "{", "User", ":", "fw", ".", "Userna...
// Get an SSH session to the firewall
[ "Get", "an", "SSH", "session", "to", "the", "firewall" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/firewallsso/barracudang.go#L18-L34
train
inverse-inc/packetfence
go/firewallsso/barracudang.go
Start
func (fw *BarracudaNG) Start(ctx context.Context, info map[string]string, timeout int) (bool, error) { session, err := fw.getSshSession(ctx) if err != nil { log.LoggerWContext(ctx).Error(fmt.Sprintf("Cannot connect to BarracudaNG: %s", err)) return false, err } cmd := "phibstest 127.0.0.1 l peer=" + info["ip"...
go
func (fw *BarracudaNG) Start(ctx context.Context, info map[string]string, timeout int) (bool, error) { session, err := fw.getSshSession(ctx) if err != nil { log.LoggerWContext(ctx).Error(fmt.Sprintf("Cannot connect to BarracudaNG: %s", err)) return false, err } cmd := "phibstest 127.0.0.1 l peer=" + info["ip"...
[ "func", "(", "fw", "*", "BarracudaNG", ")", "Start", "(", "ctx", "context", ".", "Context", ",", "info", "map", "[", "string", "]", "string", ",", "timeout", "int", ")", "(", "bool", ",", "error", ")", "{", "session", ",", "err", ":=", "fw", ".", ...
// Send an SSO start to the BarracudaNG Firewall // Will return an error if it can't connect
[ "Send", "an", "SSO", "start", "to", "the", "BarracudaNG", "Firewall", "Will", "return", "an", "error", "if", "it", "can", "t", "connect" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/firewallsso/barracudang.go#L38-L50
train
inverse-inc/packetfence
go/stats/main.go
detectVIP
func detectVIP(management pfconfigdriver.ManagementNetwork) { if pfconfigdriver.GetClusterSummary(ctx).ClusterEnabled == 1 { var keyConfCluster pfconfigdriver.NetInterface keyConfCluster.PfconfigNS = "config::Pf(CLUSTER," + pfconfigdriver.FindClusterName(ctx) + ")" keyConfCluster.PfconfigHashNS = "interface " +...
go
func detectVIP(management pfconfigdriver.ManagementNetwork) { if pfconfigdriver.GetClusterSummary(ctx).ClusterEnabled == 1 { var keyConfCluster pfconfigdriver.NetInterface keyConfCluster.PfconfigNS = "config::Pf(CLUSTER," + pfconfigdriver.FindClusterName(ctx) + ")" keyConfCluster.PfconfigHashNS = "interface " +...
[ "func", "detectVIP", "(", "management", "pfconfigdriver", ".", "ManagementNetwork", ")", "{", "if", "pfconfigdriver", ".", "GetClusterSummary", "(", "ctx", ")", ".", "ClusterEnabled", "==", "1", "{", "var", "keyConfCluster", "pfconfigdriver", ".", "NetInterface", ...
// Detect the vip on management
[ "Detect", "the", "vip", "on", "management" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/stats/main.go#L1791-L1820
train
inverse-inc/packetfence
go/coredns/plugin/proxy/upstream.go
NewStaticUpstreams
func NewStaticUpstreams(c *caddyfile.Dispenser) ([]Upstream, error) { var upstreams []Upstream for c.Next() { upstream := &staticUpstream{ from: ".", HealthCheck: healthcheck.HealthCheck{ FailTimeout: 5 * time.Second, MaxFails: 3, }, ex: newDNSEx(), } if !c.Args(&upstream.netsource) { ...
go
func NewStaticUpstreams(c *caddyfile.Dispenser) ([]Upstream, error) { var upstreams []Upstream for c.Next() { upstream := &staticUpstream{ from: ".", HealthCheck: healthcheck.HealthCheck{ FailTimeout: 5 * time.Second, MaxFails: 3, }, ex: newDNSEx(), } if !c.Args(&upstream.netsource) { ...
[ "func", "NewStaticUpstreams", "(", "c", "*", "caddyfile", ".", "Dispenser", ")", "(", "[", "]", "Upstream", ",", "error", ")", "{", "var", "upstreams", "[", "]", "Upstream", "\n", "for", "c", ".", "Next", "(", ")", "{", "upstream", ":=", "&", "static...
// NewStaticUpstreams parses the configuration input and sets up // static upstreams for the proxy plugin.
[ "NewStaticUpstreams", "parses", "the", "configuration", "input", "and", "sets", "up", "static", "upstreams", "for", "the", "proxy", "plugin", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/coredns/plugin/proxy/upstream.go#L29-L86
train
inverse-inc/packetfence
go/coredns/plugin/proxy/fuzz.go
Fuzz
func Fuzz(data []byte) int { c := caddy.NewTestController("dns", "proxy . 8.8.8.8:53") up, err := NewStaticUpstreams(&c.Dispenser) if err != nil { return 0 } p := &Proxy{Upstreams: &up} return fuzz.Do(p, data) }
go
func Fuzz(data []byte) int { c := caddy.NewTestController("dns", "proxy . 8.8.8.8:53") up, err := NewStaticUpstreams(&c.Dispenser) if err != nil { return 0 } p := &Proxy{Upstreams: &up} return fuzz.Do(p, data) }
[ "func", "Fuzz", "(", "data", "[", "]", "byte", ")", "int", "{", "c", ":=", "caddy", ".", "NewTestController", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "up", ",", "err", ":=", "NewStaticUpstreams", "(", "&", "c", ".", "Dispenser", ")", "\n", "...
// Fuzz fuzzes proxy.
[ "Fuzz", "fuzzes", "proxy", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/coredns/plugin/proxy/fuzz.go#L10-L19
train
inverse-inc/packetfence
go/unifiedapiclient/client.go
ensureRequestComplete
func (c *Client) ensureRequestComplete(ctx context.Context, resp *http.Response) { if resp == nil { return } defer resp.Body.Close() io.Copy(ioutil.Discard, resp.Body) }
go
func (c *Client) ensureRequestComplete(ctx context.Context, resp *http.Response) { if resp == nil { return } defer resp.Body.Close() io.Copy(ioutil.Discard, resp.Body) }
[ "func", "(", "c", "*", "Client", ")", "ensureRequestComplete", "(", "ctx", "context", ".", "Context", ",", "resp", "*", "http", ".", "Response", ")", "{", "if", "resp", "==", "nil", "{", "return", "\n", "}", "\n\n", "defer", "resp", ".", "Body", ".",...
// Ensures that the full body is read and closes the reader so that the connection can be reused
[ "Ensures", "that", "the", "full", "body", "is", "read", "and", "closes", "the", "reader", "so", "that", "the", "connection", "can", "be", "reused" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/unifiedapiclient/client.go#L128-L135
train
inverse-inc/packetfence
go/coredns/plugin/proxy/google_rr.go
toMsg
func toMsg(g *googleMsg) (*dns.Msg, error) { m := new(dns.Msg) m.Response = true m.Rcode = g.Status m.Truncated = g.TC m.RecursionDesired = g.RD m.RecursionAvailable = g.RA m.AuthenticatedData = g.AD m.CheckingDisabled = g.CD m.Question = make([]dns.Question, 1) m.Answer = make([]dns.RR, len(g.Answer)) m.Ns...
go
func toMsg(g *googleMsg) (*dns.Msg, error) { m := new(dns.Msg) m.Response = true m.Rcode = g.Status m.Truncated = g.TC m.RecursionDesired = g.RD m.RecursionAvailable = g.RA m.AuthenticatedData = g.AD m.CheckingDisabled = g.CD m.Question = make([]dns.Question, 1) m.Answer = make([]dns.RR, len(g.Answer)) m.Ns...
[ "func", "toMsg", "(", "g", "*", "googleMsg", ")", "(", "*", "dns", ".", "Msg", ",", "error", ")", "{", "m", ":=", "new", "(", "dns", ".", "Msg", ")", "\n", "m", ".", "Response", "=", "true", "\n", "m", ".", "Rcode", "=", "g", ".", "Status", ...
// toMsg converts a googleMsg into the dns message.
[ "toMsg", "converts", "a", "googleMsg", "into", "the", "dns", "message", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/coredns/plugin/proxy/google_rr.go#L10-L48
train
inverse-inc/packetfence
go/coredns/plugin/proxy/google_rr.go
toRR
func toRR(g googleRR) (dns.RR, error) { typ, ok := dns.TypeToString[g.Type] if !ok { return nil, fmt.Errorf("failed to convert type %q", g.Type) } str := fmt.Sprintf("%s %d %s %s", g.Name, g.TTL, typ, g.Data) rr, err := dns.NewRR(str) if err != nil { return nil, fmt.Errorf("failed to parse %q: %s", str, err)...
go
func toRR(g googleRR) (dns.RR, error) { typ, ok := dns.TypeToString[g.Type] if !ok { return nil, fmt.Errorf("failed to convert type %q", g.Type) } str := fmt.Sprintf("%s %d %s %s", g.Name, g.TTL, typ, g.Data) rr, err := dns.NewRR(str) if err != nil { return nil, fmt.Errorf("failed to parse %q: %s", str, err)...
[ "func", "toRR", "(", "g", "googleRR", ")", "(", "dns", ".", "RR", ",", "error", ")", "{", "typ", ",", "ok", ":=", "dns", ".", "TypeToString", "[", "g", ".", "Type", "]", "\n", "if", "!", "ok", "{", "return", "nil", ",", "fmt", ".", "Errorf", ...
// toRR transforms a "google" RR to a dns.RR.
[ "toRR", "transforms", "a", "google", "RR", "to", "a", "dns", ".", "RR", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/coredns/plugin/proxy/google_rr.go#L51-L63
train
inverse-inc/packetfence
go/coredns/plugin/dnstap/taprw/writer.go
WriteMsg
func (w *ResponseWriter) WriteMsg(resp *dns.Msg) (writeErr error) { writeErr = w.ResponseWriter.WriteMsg(resp) writeEpoch := uint64(time.Now().Unix()) b := w.TapBuilder() b.TimeSec = w.queryEpoch if w.Send == nil || w.Send.Cq { if err := func() (err error) { err = b.AddrMsg(w.ResponseWriter.RemoteAddr(), w....
go
func (w *ResponseWriter) WriteMsg(resp *dns.Msg) (writeErr error) { writeErr = w.ResponseWriter.WriteMsg(resp) writeEpoch := uint64(time.Now().Unix()) b := w.TapBuilder() b.TimeSec = w.queryEpoch if w.Send == nil || w.Send.Cq { if err := func() (err error) { err = b.AddrMsg(w.ResponseWriter.RemoteAddr(), w....
[ "func", "(", "w", "*", "ResponseWriter", ")", "WriteMsg", "(", "resp", "*", "dns", ".", "Msg", ")", "(", "writeErr", "error", ")", "{", "writeErr", "=", "w", ".", "ResponseWriter", ".", "WriteMsg", "(", "resp", ")", "\n", "writeEpoch", ":=", "uint64", ...
// WriteMsg writes back the response to the client and THEN works on logging the request // and response to dnstap. // Dnstap errors are to be checked by DnstapError.
[ "WriteMsg", "writes", "back", "the", "response", "to", "the", "client", "and", "THEN", "works", "on", "logging", "the", "request", "and", "response", "to", "dnstap", ".", "Dnstap", "errors", "are", "to", "be", "checked", "by", "DnstapError", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/coredns/plugin/dnstap/taprw/writer.go#L53-L87
train
inverse-inc/packetfence
go/firewallsso/iboss.go
Start
func (fw *Iboss) Start(ctx context.Context, info map[string]string, timeout int) (bool, error) { req, err := fw.getRequest(ctx, "login", info) if err != nil { return false, err } resp, err := fw.getHttpClient(ctx).Do(req) if err != nil { log.LoggerWContext(ctx).Error(fmt.Sprintf("Error contacting Iboss: %s"...
go
func (fw *Iboss) Start(ctx context.Context, info map[string]string, timeout int) (bool, error) { req, err := fw.getRequest(ctx, "login", info) if err != nil { return false, err } resp, err := fw.getHttpClient(ctx).Do(req) if err != nil { log.LoggerWContext(ctx).Error(fmt.Sprintf("Error contacting Iboss: %s"...
[ "func", "(", "fw", "*", "Iboss", ")", "Start", "(", "ctx", "context", ".", "Context", ",", "info", "map", "[", "string", "]", "string", ",", "timeout", "int", ")", "(", "bool", ",", "error", ")", "{", "req", ",", "err", ":=", "fw", ".", "getReque...
// Send an SSO start to the Iboss firewall // Returns an error unless there is a valid reply from the firewall or if the HTTP request fails to be built
[ "Send", "an", "SSO", "start", "to", "the", "Iboss", "firewall", "Returns", "an", "error", "unless", "there", "is", "a", "valid", "reply", "from", "the", "firewall", "or", "if", "the", "HTTP", "request", "fails", "to", "be", "built" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/firewallsso/iboss.go#L20-L39
train
inverse-inc/packetfence
go/firewallsso/iboss.go
getRequest
func (fw *Iboss) getRequest(ctx context.Context, action string, info map[string]string) (*http.Request, error) { req, err := http.NewRequest( "GET", fmt.Sprintf( "http://%s:%s/nacAgent?action=%s&user=%s&dc=%s&key=%s&ip=%s&cn=%s&g=%s", fw.PfconfigHashNS, fw.Port, action, info["username"], fw.NacNa...
go
func (fw *Iboss) getRequest(ctx context.Context, action string, info map[string]string) (*http.Request, error) { req, err := http.NewRequest( "GET", fmt.Sprintf( "http://%s:%s/nacAgent?action=%s&user=%s&dc=%s&key=%s&ip=%s&cn=%s&g=%s", fw.PfconfigHashNS, fw.Port, action, info["username"], fw.NacNa...
[ "func", "(", "fw", "*", "Iboss", ")", "getRequest", "(", "ctx", "context", ".", "Context", ",", "action", "string", ",", "info", "map", "[", "string", "]", "string", ")", "(", "*", "http", ".", "Request", ",", "error", ")", "{", "req", ",", "err", ...
// Build an HTTP request to send to the Iboss firewall // This builds the request for start+stop and is controlled by the action parameter // This will return an error if the request cannot be built
[ "Build", "an", "HTTP", "request", "to", "send", "to", "the", "Iboss", "firewall", "This", "builds", "the", "request", "for", "start", "+", "stop", "and", "is", "controlled", "by", "the", "action", "parameter", "This", "will", "return", "an", "error", "if",...
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/firewallsso/iboss.go#L67-L90
train
inverse-inc/packetfence
go/caddy/caddy/caddytls/maintain.go
RenewManagedCertificates
func RenewManagedCertificates(allowPrompts bool) (err error) { var renewQueue, deleteQueue []Certificate visitedNames := make(map[string]struct{}) certCacheMu.RLock() for name, cert := range certCache { if !cert.Config.Managed || cert.Config.SelfSigned { continue } // the list of names on this cert shoul...
go
func RenewManagedCertificates(allowPrompts bool) (err error) { var renewQueue, deleteQueue []Certificate visitedNames := make(map[string]struct{}) certCacheMu.RLock() for name, cert := range certCache { if !cert.Config.Managed || cert.Config.SelfSigned { continue } // the list of names on this cert shoul...
[ "func", "RenewManagedCertificates", "(", "allowPrompts", "bool", ")", "(", "err", "error", ")", "{", "var", "renewQueue", ",", "deleteQueue", "[", "]", "Certificate", "\n", "visitedNames", ":=", "make", "(", "map", "[", "string", "]", "struct", "{", "}", "...
// RenewManagedCertificates renews managed certificates.
[ "RenewManagedCertificates", "renews", "managed", "certificates", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/caddytls/maintain.go#L67-L175
train
inverse-inc/packetfence
go/caddy/caddy/caddytls/maintain.go
freshOCSP
func freshOCSP(resp *ocsp.Response) bool { // start checking OCSP staple about halfway through validity period for good measure refreshTime := resp.ThisUpdate.Add(resp.NextUpdate.Sub(resp.ThisUpdate) / 2) return time.Now().Before(refreshTime) }
go
func freshOCSP(resp *ocsp.Response) bool { // start checking OCSP staple about halfway through validity period for good measure refreshTime := resp.ThisUpdate.Add(resp.NextUpdate.Sub(resp.ThisUpdate) / 2) return time.Now().Before(refreshTime) }
[ "func", "freshOCSP", "(", "resp", "*", "ocsp", ".", "Response", ")", "bool", "{", "// start checking OCSP staple about halfway through validity period for good measure", "refreshTime", ":=", "resp", ".", "ThisUpdate", ".", "Add", "(", "resp", ".", "NextUpdate", ".", "...
// freshOCSP returns true if resp is still fresh, // meaning that it is not expedient to get an // updated response from the OCSP server.
[ "freshOCSP", "returns", "true", "if", "resp", "is", "still", "fresh", "meaning", "that", "it", "is", "not", "expedient", "to", "get", "an", "updated", "response", "from", "the", "OCSP", "server", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/caddytls/maintain.go#L295-L299
train
inverse-inc/packetfence
go/caddy/pfipset/utils.go
initIPSet
func (IPSET *pfIPSET) initIPSet(ctx context.Context, db *sql.DB) { logger := log.LoggerWContext(ctx) IPSET.ListALL, _ = ipset.ListAll() rows, err := db.Query("select distinct n.mac, i.ip, n.category_id as node_id from node as n left join locationlog as l on n.mac=l.mac left join ip4log as i on n.mac=i.mac where l.c...
go
func (IPSET *pfIPSET) initIPSet(ctx context.Context, db *sql.DB) { logger := log.LoggerWContext(ctx) IPSET.ListALL, _ = ipset.ListAll() rows, err := db.Query("select distinct n.mac, i.ip, n.category_id as node_id from node as n left join locationlog as l on n.mac=l.mac left join ip4log as i on n.mac=i.mac where l.c...
[ "func", "(", "IPSET", "*", "pfIPSET", ")", "initIPSet", "(", "ctx", "context", ".", "Context", ",", "db", "*", "sql", ".", "DB", ")", "{", "logger", ":=", "log", ".", "LoggerWContext", "(", "ctx", ")", "\n\n", "IPSET", ".", "ListALL", ",", "_", "="...
// initIPSet fetch the database to remove already assigned ip addresses
[ "initIPSet", "fetch", "the", "database", "to", "remove", "already", "assigned", "ip", "addresses" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/pfipset/utils.go#L124-L161
train
inverse-inc/packetfence
go/caddy/pfipset/utils.go
detectType
func (IPSET *pfIPSET) detectType(ctx context.Context) error { IPSET.ListALL, _ = ipset.ListAll() var NetIndex net.IPNet IPSET.Network = make(map[*net.IPNet]string) var interfaces pfconfigdriver.ListenInts pfconfigdriver.FetchDecodeSocket(ctx, &interfaces) var keyConfNet pfconfigdriver.PfconfigKeys keyConfNet.P...
go
func (IPSET *pfIPSET) detectType(ctx context.Context) error { IPSET.ListALL, _ = ipset.ListAll() var NetIndex net.IPNet IPSET.Network = make(map[*net.IPNet]string) var interfaces pfconfigdriver.ListenInts pfconfigdriver.FetchDecodeSocket(ctx, &interfaces) var keyConfNet pfconfigdriver.PfconfigKeys keyConfNet.P...
[ "func", "(", "IPSET", "*", "pfIPSET", ")", "detectType", "(", "ctx", "context", ".", "Context", ")", "error", "{", "IPSET", ".", "ListALL", ",", "_", "=", "ipset", ".", "ListAll", "(", ")", "\n", "var", "NetIndex", "net", ".", "IPNet", "\n", "IPSET",...
// detectType of each network
[ "detectType", "of", "each", "network" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/pfipset/utils.go#L164-L215
train
inverse-inc/packetfence
go/caddy/caddy/caddytls/certificates.go
cacheUnmanagedCertificatePEMFile
func cacheUnmanagedCertificatePEMFile(certFile, keyFile string) error { cert, err := makeCertificateFromDisk(certFile, keyFile) if err != nil { return err } cacheCertificate(cert) return nil }
go
func cacheUnmanagedCertificatePEMFile(certFile, keyFile string) error { cert, err := makeCertificateFromDisk(certFile, keyFile) if err != nil { return err } cacheCertificate(cert) return nil }
[ "func", "cacheUnmanagedCertificatePEMFile", "(", "certFile", ",", "keyFile", "string", ")", "error", "{", "cert", ",", "err", ":=", "makeCertificateFromDisk", "(", "certFile", ",", "keyFile", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "...
// cacheUnmanagedCertificatePEMFile loads a certificate for host using certFile // and keyFile, which must be in PEM format. It stores the certificate in // memory. The Managed and OnDemand flags of the certificate will be set to // false. // // This function is safe for concurrent use.
[ "cacheUnmanagedCertificatePEMFile", "loads", "a", "certificate", "for", "host", "using", "certFile", "and", "keyFile", "which", "must", "be", "in", "PEM", "format", ".", "It", "stores", "the", "certificate", "in", "memory", ".", "The", "Managed", "and", "OnDeman...
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/caddytls/certificates.go#L117-L124
train
inverse-inc/packetfence
go/caddy/caddy/caddytls/certificates.go
cacheUnmanagedCertificatePEMBytes
func cacheUnmanagedCertificatePEMBytes(certBytes, keyBytes []byte) error { cert, err := makeCertificate(certBytes, keyBytes) if err != nil { return err } cacheCertificate(cert) return nil }
go
func cacheUnmanagedCertificatePEMBytes(certBytes, keyBytes []byte) error { cert, err := makeCertificate(certBytes, keyBytes) if err != nil { return err } cacheCertificate(cert) return nil }
[ "func", "cacheUnmanagedCertificatePEMBytes", "(", "certBytes", ",", "keyBytes", "[", "]", "byte", ")", "error", "{", "cert", ",", "err", ":=", "makeCertificate", "(", "certBytes", ",", "keyBytes", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", ...
// cacheUnmanagedCertificatePEMBytes makes a certificate out of the PEM bytes // of the certificate and key, then caches it in memory. // // This function is safe for concurrent use.
[ "cacheUnmanagedCertificatePEMBytes", "makes", "a", "certificate", "out", "of", "the", "PEM", "bytes", "of", "the", "certificate", "and", "key", "then", "caches", "it", "in", "memory", ".", "This", "function", "is", "safe", "for", "concurrent", "use", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/caddytls/certificates.go#L130-L137
train
inverse-inc/packetfence
go/caddy/caddy/caddytls/certificates.go
makeCertificate
func makeCertificate(certPEMBlock, keyPEMBlock []byte) (Certificate, error) { var cert Certificate // Convert to a tls.Certificate tlsCert, err := tls.X509KeyPair(certPEMBlock, keyPEMBlock) if err != nil { return cert, err } if len(tlsCert.Certificate) == 0 { return cert, errors.New("certificate is empty") ...
go
func makeCertificate(certPEMBlock, keyPEMBlock []byte) (Certificate, error) { var cert Certificate // Convert to a tls.Certificate tlsCert, err := tls.X509KeyPair(certPEMBlock, keyPEMBlock) if err != nil { return cert, err } if len(tlsCert.Certificate) == 0 { return cert, errors.New("certificate is empty") ...
[ "func", "makeCertificate", "(", "certPEMBlock", ",", "keyPEMBlock", "[", "]", "byte", ")", "(", "Certificate", ",", "error", ")", "{", "var", "cert", "Certificate", "\n\n", "// Convert to a tls.Certificate", "tlsCert", ",", "err", ":=", "tls", ".", "X509KeyPair"...
// makeCertificate turns a certificate PEM bundle and a key PEM block into // a Certificate, with OCSP and other relevant metadata tagged with it, // except for the OnDemand and Managed flags. It is up to the caller to // set those properties.
[ "makeCertificate", "turns", "a", "certificate", "PEM", "bundle", "and", "a", "key", "PEM", "block", "into", "a", "Certificate", "with", "OCSP", "and", "other", "relevant", "metadata", "tagged", "with", "it", "except", "for", "the", "OnDemand", "and", "Managed"...
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/caddytls/certificates.go#L159-L187
train
inverse-inc/packetfence
go/caddy/caddy/caddytls/certificates.go
fillCertFromLeaf
func fillCertFromLeaf(cert *Certificate, leaf *x509.Certificate) error { if leaf.Subject.CommonName != "" { cert.Names = []string{strings.ToLower(leaf.Subject.CommonName)} } for _, name := range leaf.DNSNames { if name != leaf.Subject.CommonName { cert.Names = append(cert.Names, strings.ToLower(name)) } } ...
go
func fillCertFromLeaf(cert *Certificate, leaf *x509.Certificate) error { if leaf.Subject.CommonName != "" { cert.Names = []string{strings.ToLower(leaf.Subject.CommonName)} } for _, name := range leaf.DNSNames { if name != leaf.Subject.CommonName { cert.Names = append(cert.Names, strings.ToLower(name)) } } ...
[ "func", "fillCertFromLeaf", "(", "cert", "*", "Certificate", ",", "leaf", "*", "x509", ".", "Certificate", ")", "error", "{", "if", "leaf", ".", "Subject", ".", "CommonName", "!=", "\"", "\"", "{", "cert", ".", "Names", "=", "[", "]", "string", "{", ...
// fillCertFromLeaf populates cert.Names and cert.NotAfter // using data in leaf.
[ "fillCertFromLeaf", "populates", "cert", ".", "Names", "and", "cert", ".", "NotAfter", "using", "data", "in", "leaf", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/caddytls/certificates.go#L191-L215
train