id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
30,200
koding/kite
kite.go
OnRegister
func (k *Kite) OnRegister(handler func(*protocol.RegisterResult)) { k.handlersMu.Lock() k.onRegisterHandlers = append(k.onRegisterHandlers, handler) k.handlersMu.Unlock() }
go
func (k *Kite) OnRegister(handler func(*protocol.RegisterResult)) { k.handlersMu.Lock() k.onRegisterHandlers = append(k.onRegisterHandlers, handler) k.handlersMu.Unlock() }
[ "func", "(", "k", "*", "Kite", ")", "OnRegister", "(", "handler", "func", "(", "*", "protocol", ".", "RegisterResult", ")", ")", "{", "k", ".", "handlersMu", ".", "Lock", "(", ")", "\n", "k", ".", "onRegisterHandlers", "=", "append", "(", "k", ".", ...
// OnRegister registers a callback which is called when a Kite registers // to a Kontrol.
[ "OnRegister", "registers", "a", "callback", "which", "is", "called", "when", "a", "Kite", "registers", "to", "a", "Kontrol", "." ]
baa1a54919e3035417f7571dd46005e91afe8abe
https://github.com/koding/kite/blob/baa1a54919e3035417f7571dd46005e91afe8abe/kite.go#L327-L331
30,201
koding/kite
kite.go
RSAKey
func (k *Kite) RSAKey(token *jwt.Token) (interface{}, error) { k.verifyOnce.Do(k.verifyInit) kontrolKey := k.KontrolKey() if kontrolKey == nil { panic("kontrol key is not set in config") } if _, ok := token.Method.(*jwt.SigningMethodRSA); !ok { return nil, errors.New("invalid signing method") } claims, o...
go
func (k *Kite) RSAKey(token *jwt.Token) (interface{}, error) { k.verifyOnce.Do(k.verifyInit) kontrolKey := k.KontrolKey() if kontrolKey == nil { panic("kontrol key is not set in config") } if _, ok := token.Method.(*jwt.SigningMethodRSA); !ok { return nil, errors.New("invalid signing method") } claims, o...
[ "func", "(", "k", "*", "Kite", ")", "RSAKey", "(", "token", "*", "jwt", ".", "Token", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "k", ".", "verifyOnce", ".", "Do", "(", "k", ".", "verifyInit", ")", "\n\n", "kontrolKey", ":=", "k", ...
// RSAKey returns the corresponding public key for the issuer of the token. // It is called by jwt-go package when validating the signature in the token.
[ "RSAKey", "returns", "the", "corresponding", "public", "key", "for", "the", "issuer", "of", "the", "token", ".", "It", "is", "called", "by", "jwt", "-", "go", "package", "when", "validating", "the", "signature", "in", "the", "token", "." ]
baa1a54919e3035417f7571dd46005e91afe8abe
https://github.com/koding/kite/blob/baa1a54919e3035417f7571dd46005e91afe8abe/kite.go#L422-L445
30,202
koding/kite
kite.go
Error
func (err *ErrClose) Error() string { if len(err.Errs) == 1 { return err.Errs[0].Error() } var buf bytes.Buffer fmt.Fprintf(&buf, "The following kites failed to close:\n\n") for i, e := range err.Errs { if e == nil { continue } fmt.Fprintf(&buf, "\t[%d] %s\n", i, e) } return buf.String() }
go
func (err *ErrClose) Error() string { if len(err.Errs) == 1 { return err.Errs[0].Error() } var buf bytes.Buffer fmt.Fprintf(&buf, "The following kites failed to close:\n\n") for i, e := range err.Errs { if e == nil { continue } fmt.Fprintf(&buf, "\t[%d] %s\n", i, e) } return buf.String() }
[ "func", "(", "err", "*", "ErrClose", ")", "Error", "(", ")", "string", "{", "if", "len", "(", "err", ".", "Errs", ")", "==", "1", "{", "return", "err", ".", "Errs", "[", "0", "]", ".", "Error", "(", ")", "\n", "}", "\n\n", "var", "buf", "byte...
// Error implements the built-in error interface.
[ "Error", "implements", "the", "built", "-", "in", "error", "interface", "." ]
baa1a54919e3035417f7571dd46005e91afe8abe
https://github.com/koding/kite/blob/baa1a54919e3035417f7571dd46005e91afe8abe/kite.go#L456-L474
30,203
koding/kite
kontrol/postgres.go
RunCleaner
func (p *Postgres) RunCleaner(interval, expire time.Duration) { cleanFunc := func() { affectedRows, err := p.CleanExpiredRows(expire) if err != nil { p.Log.Warning("postgres: cleaning old rows failed: %s", err) } else if affectedRows != 0 { p.Log.Debug("postgres: cleaned up %d rows", affectedRows) } } ...
go
func (p *Postgres) RunCleaner(interval, expire time.Duration) { cleanFunc := func() { affectedRows, err := p.CleanExpiredRows(expire) if err != nil { p.Log.Warning("postgres: cleaning old rows failed: %s", err) } else if affectedRows != 0 { p.Log.Debug("postgres: cleaned up %d rows", affectedRows) } } ...
[ "func", "(", "p", "*", "Postgres", ")", "RunCleaner", "(", "interval", ",", "expire", "time", ".", "Duration", ")", "{", "cleanFunc", ":=", "func", "(", ")", "{", "affectedRows", ",", "err", ":=", "p", ".", "CleanExpiredRows", "(", "expire", ")", "\n",...
// RunCleaner deletes every "interval" duration rows which are older than // "expire" duration based on the "updated_at" field. For more info check // CleanExpireRows which is used to delete old rows.
[ "RunCleaner", "deletes", "every", "interval", "duration", "rows", "which", "are", "older", "than", "expire", "duration", "based", "on", "the", "updated_at", "field", ".", "For", "more", "info", "check", "CleanExpireRows", "which", "is", "used", "to", "delete", ...
baa1a54919e3035417f7571dd46005e91afe8abe
https://github.com/koding/kite/blob/baa1a54919e3035417f7571dd46005e91afe8abe/kontrol/postgres.go#L93-L106
30,204
koding/kite
kontrol/postgres.go
CleanExpiredRows
func (p *Postgres) CleanExpiredRows(expire time.Duration) (int64, error) { // See: http://stackoverflow.com/questions/14465727/how-to-insert-things-like-now-interval-2-minutes-into-php-pdo-query // basically by passing an integer to INTERVAL is not possible, we need to // cast it. However there is a more simpler way...
go
func (p *Postgres) CleanExpiredRows(expire time.Duration) (int64, error) { // See: http://stackoverflow.com/questions/14465727/how-to-insert-things-like-now-interval-2-minutes-into-php-pdo-query // basically by passing an integer to INTERVAL is not possible, we need to // cast it. However there is a more simpler way...
[ "func", "(", "p", "*", "Postgres", ")", "CleanExpiredRows", "(", "expire", "time", ".", "Duration", ")", "(", "int64", ",", "error", ")", "{", "// See: http://stackoverflow.com/questions/14465727/how-to-insert-things-like-now-interval-2-minutes-into-php-pdo-query", "// basica...
// CleanExpiredRows deletes rows that are at least "expire" duration old. So if // say an expire duration of 10 second is given, it will delete all rows that // were updated 10 seconds ago
[ "CleanExpiredRows", "deletes", "rows", "that", "are", "at", "least", "expire", "duration", "old", ".", "So", "if", "say", "an", "expire", "duration", "of", "10", "second", "is", "given", "it", "will", "delete", "all", "rows", "that", "were", "updated", "10...
baa1a54919e3035417f7571dd46005e91afe8abe
https://github.com/koding/kite/blob/baa1a54919e3035417f7571dd46005e91afe8abe/kontrol/postgres.go#L111-L125
30,205
koding/kite
kontrol/postgres.go
selectQuery
func selectQuery(query *protocol.KontrolQuery) (string, []interface{}, error) { psql := sq.StatementBuilder.PlaceholderFormat(sq.Dollar) kites := psql.Select("*").From("kite.kite") fields := query.Fields() andQuery := sq.And{} // we stop for the first empty value for _, key := range keyOrder { v := fields[key...
go
func selectQuery(query *protocol.KontrolQuery) (string, []interface{}, error) { psql := sq.StatementBuilder.PlaceholderFormat(sq.Dollar) kites := psql.Select("*").From("kite.kite") fields := query.Fields() andQuery := sq.And{} // we stop for the first empty value for _, key := range keyOrder { v := fields[key...
[ "func", "selectQuery", "(", "query", "*", "protocol", ".", "KontrolQuery", ")", "(", "string", ",", "[", "]", "interface", "{", "}", ",", "error", ")", "{", "psql", ":=", "sq", ".", "StatementBuilder", ".", "PlaceholderFormat", "(", "sq", ".", "Dollar", ...
// selectQuery returns a SQL query for the given query
[ "selectQuery", "returns", "a", "SQL", "query", "for", "the", "given", "query" ]
baa1a54919e3035417f7571dd46005e91afe8abe
https://github.com/koding/kite/blob/baa1a54919e3035417f7571dd46005e91afe8abe/kontrol/postgres.go#L334-L361
30,206
koding/kite
kontrol/postgres.go
insertKiteQuery
func insertKiteQuery(kiteProt *protocol.Kite, url, keyId string) (string, []interface{}, error) { psql := sq.StatementBuilder.PlaceholderFormat(sq.Dollar) kiteValues := kiteProt.Values() values := make([]interface{}, len(kiteValues)) for i, kiteVal := range kiteValues { values[i] = kiteVal } values = append(...
go
func insertKiteQuery(kiteProt *protocol.Kite, url, keyId string) (string, []interface{}, error) { psql := sq.StatementBuilder.PlaceholderFormat(sq.Dollar) kiteValues := kiteProt.Values() values := make([]interface{}, len(kiteValues)) for i, kiteVal := range kiteValues { values[i] = kiteVal } values = append(...
[ "func", "insertKiteQuery", "(", "kiteProt", "*", "protocol", ".", "Kite", ",", "url", ",", "keyId", "string", ")", "(", "string", ",", "[", "]", "interface", "{", "}", ",", "error", ")", "{", "psql", ":=", "sq", ".", "StatementBuilder", ".", "Placehold...
// inseryKiteQuery inserts the given kite, url and key to the kite.kite table
[ "inseryKiteQuery", "inserts", "the", "given", "kite", "url", "and", "key", "to", "the", "kite", ".", "kite", "table" ]
baa1a54919e3035417f7571dd46005e91afe8abe
https://github.com/koding/kite/blob/baa1a54919e3035417f7571dd46005e91afe8abe/kontrol/postgres.go#L364-L388
30,207
koding/kite
logger_unix.go
SetupSignalHandler
func (k *Kite) SetupSignalHandler() { c := make(chan os.Signal, 1) signal.Notify(c, syscall.SIGUSR2) go func() { for s := range c { k.Log.Info("Got signal: %s", s) if debugMode { // toogle back to old settings. k.Log.Info("Disabling debug mode") if k.SetLogLevel == nil { k.Log.Error("SetLo...
go
func (k *Kite) SetupSignalHandler() { c := make(chan os.Signal, 1) signal.Notify(c, syscall.SIGUSR2) go func() { for s := range c { k.Log.Info("Got signal: %s", s) if debugMode { // toogle back to old settings. k.Log.Info("Disabling debug mode") if k.SetLogLevel == nil { k.Log.Error("SetLo...
[ "func", "(", "k", "*", "Kite", ")", "SetupSignalHandler", "(", ")", "{", "c", ":=", "make", "(", "chan", "os", ".", "Signal", ",", "1", ")", "\n\n", "signal", ".", "Notify", "(", "c", ",", "syscall", ".", "SIGUSR2", ")", "\n", "go", "func", "(", ...
// SetupSignalHandler listens to signals and toggles the log level to DEBUG // mode when it received a SIGUSR2 signal. Another SIGUSR2 toggles the log // level back to the old level.
[ "SetupSignalHandler", "listens", "to", "signals", "and", "toggles", "the", "log", "level", "to", "DEBUG", "mode", "when", "it", "received", "a", "SIGUSR2", "signal", ".", "Another", "SIGUSR2", "toggles", "the", "log", "level", "back", "to", "the", "old", "le...
baa1a54919e3035417f7571dd46005e91afe8abe
https://github.com/koding/kite/blob/baa1a54919e3035417f7571dd46005e91afe8abe/logger_unix.go#L14-L44
30,208
koding/kite
sockjsclient/xhr.go
DialXHR
func DialXHR(uri string, cfg *config.Config) (*XHRSession, error) { // following /server_id/session_id should always be the same for every session serverID := threeDigits() sessionID := utils.RandomString(20) sessionURL := uri + "/" + serverID + "/" + sessionID // start the initial session handshake sessionResp,...
go
func DialXHR(uri string, cfg *config.Config) (*XHRSession, error) { // following /server_id/session_id should always be the same for every session serverID := threeDigits() sessionID := utils.RandomString(20) sessionURL := uri + "/" + serverID + "/" + sessionID // start the initial session handshake sessionResp,...
[ "func", "DialXHR", "(", "uri", "string", ",", "cfg", "*", "config", ".", "Config", ")", "(", "*", "XHRSession", ",", "error", ")", "{", "// following /server_id/session_id should always be the same for every session", "serverID", ":=", "threeDigits", "(", ")", "\n",...
// DialXHR establishes a SockJS session over a XHR connection. // // Requires cfg.XHR to be a valid client.
[ "DialXHR", "establishes", "a", "SockJS", "session", "over", "a", "XHR", "connection", ".", "Requires", "cfg", ".", "XHR", "to", "be", "a", "valid", "client", "." ]
baa1a54919e3035417f7571dd46005e91afe8abe
https://github.com/koding/kite/blob/baa1a54919e3035417f7571dd46005e91afe8abe/sockjsclient/xhr.go#L49-L84
30,209
koding/kite
handlers.go
ServeKite
func (w *webRTCHandler) ServeKite(r *Request) (interface{}, error) { var args protocol.WebRTCSignalMessage if err := r.Args.One().Unmarshal(&args); err != nil { return nil, fmt.Errorf("invalid query: %s", err) } args.Src = r.Client.ID w.registerSrc(r.Client) dst, err := w.getDst(args.Dst) if err != nil { ...
go
func (w *webRTCHandler) ServeKite(r *Request) (interface{}, error) { var args protocol.WebRTCSignalMessage if err := r.Args.One().Unmarshal(&args); err != nil { return nil, fmt.Errorf("invalid query: %s", err) } args.Src = r.Client.ID w.registerSrc(r.Client) dst, err := w.getDst(args.Dst) if err != nil { ...
[ "func", "(", "w", "*", "webRTCHandler", ")", "ServeKite", "(", "r", "*", "Request", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "var", "args", "protocol", ".", "WebRTCSignalMessage", "\n\n", "if", "err", ":=", "r", ".", "Args", ".", "One...
// ServeKite implements Hander interface.
[ "ServeKite", "implements", "Hander", "interface", "." ]
baa1a54919e3035417f7571dd46005e91afe8abe
https://github.com/koding/kite/blob/baa1a54919e3035417f7571dd46005e91afe8abe/handlers.go#L64-L81
30,210
koding/kite
handlers.go
handleLog
func (k *Kite) handleLog(r *Request) (interface{}, error) { msg, err := r.Args.One().String() if err != nil { return nil, err } k.Log.Info("%s: %s", r.Client.Name, msg) return nil, nil }
go
func (k *Kite) handleLog(r *Request) (interface{}, error) { msg, err := r.Args.One().String() if err != nil { return nil, err } k.Log.Info("%s: %s", r.Client.Name, msg) return nil, nil }
[ "func", "(", "k", "*", "Kite", ")", "handleLog", "(", "r", "*", "Request", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "msg", ",", "err", ":=", "r", ".", "Args", ".", "One", "(", ")", ".", "String", "(", ")", "\n", "if", "err", ...
// handleLog prints a log message to stderr.
[ "handleLog", "prints", "a", "log", "message", "to", "stderr", "." ]
baa1a54919e3035417f7571dd46005e91afe8abe
https://github.com/koding/kite/blob/baa1a54919e3035417f7571dd46005e91afe8abe/handlers.go#L107-L116
30,211
koding/kite
handlers.go
handlePrint
func handlePrint(r *Request) (interface{}, error) { return fmt.Print(r.Args.One().MustString()) }
go
func handlePrint(r *Request) (interface{}, error) { return fmt.Print(r.Args.One().MustString()) }
[ "func", "handlePrint", "(", "r", "*", "Request", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "return", "fmt", ".", "Print", "(", "r", ".", "Args", ".", "One", "(", ")", ".", "MustString", "(", ")", ")", "\n", "}" ]
// handlePrint prints a message to stdout.
[ "handlePrint", "prints", "a", "message", "to", "stdout", "." ]
baa1a54919e3035417f7571dd46005e91afe8abe
https://github.com/koding/kite/blob/baa1a54919e3035417f7571dd46005e91afe8abe/handlers.go#L124-L126
30,212
koding/kite
handlers.go
handlePrompt
func handlePrompt(r *Request) (interface{}, error) { fmt.Print(r.Args.One().MustString()) var s string _, err := fmt.Scanln(&s) return s, err }
go
func handlePrompt(r *Request) (interface{}, error) { fmt.Print(r.Args.One().MustString()) var s string _, err := fmt.Scanln(&s) return s, err }
[ "func", "handlePrompt", "(", "r", "*", "Request", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "fmt", ".", "Print", "(", "r", ".", "Args", ".", "One", "(", ")", ".", "MustString", "(", ")", ")", "\n", "var", "s", "string", "\n", "_"...
// handlePrompt asks user a single line input.
[ "handlePrompt", "asks", "user", "a", "single", "line", "input", "." ]
baa1a54919e3035417f7571dd46005e91afe8abe
https://github.com/koding/kite/blob/baa1a54919e3035417f7571dd46005e91afe8abe/handlers.go#L129-L134
30,213
koding/kite
handlers.go
handleGetPass
func handleGetPass(r *Request) (interface{}, error) { fmt.Print(r.Args.One().MustString()) data, err := terminal.ReadPassword(int(os.Stdin.Fd())) // stdin fmt.Println() if err != nil { return nil, err } return string(data), nil }
go
func handleGetPass(r *Request) (interface{}, error) { fmt.Print(r.Args.One().MustString()) data, err := terminal.ReadPassword(int(os.Stdin.Fd())) // stdin fmt.Println() if err != nil { return nil, err } return string(data), nil }
[ "func", "handleGetPass", "(", "r", "*", "Request", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "fmt", ".", "Print", "(", "r", ".", "Args", ".", "One", "(", ")", ".", "MustString", "(", ")", ")", "\n", "data", ",", "err", ":=", "ter...
// handleGetPass reads a line of input from a terminal without local echo.
[ "handleGetPass", "reads", "a", "line", "of", "input", "from", "a", "terminal", "without", "local", "echo", "." ]
baa1a54919e3035417f7571dd46005e91afe8abe
https://github.com/koding/kite/blob/baa1a54919e3035417f7571dd46005e91afe8abe/handlers.go#L137-L145
30,214
koding/kite
handlers.go
handleNotifyDarwin
func handleNotifyDarwin(r *Request) (interface{}, error) { args := r.Args.MustSliceOfLength(3) cmd := exec.Command("osascript", "-e", fmt.Sprintf("display notification \"%s\" with title \"%s\" subtitle \"%s\"", args[1].MustString(), args[2].MustString(), args[0].MustString())) return nil, cmd.Start() }
go
func handleNotifyDarwin(r *Request) (interface{}, error) { args := r.Args.MustSliceOfLength(3) cmd := exec.Command("osascript", "-e", fmt.Sprintf("display notification \"%s\" with title \"%s\" subtitle \"%s\"", args[1].MustString(), args[2].MustString(), args[0].MustString())) return nil, cmd.Start() }
[ "func", "handleNotifyDarwin", "(", "r", "*", "Request", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "args", ":=", "r", ".", "Args", ".", "MustSliceOfLength", "(", "3", ")", "\n", "cmd", ":=", "exec", ".", "Command", "(", "\"", "\"", ",...
// handleNotifyDarwin displays a desktop notification on OS X.
[ "handleNotifyDarwin", "displays", "a", "desktop", "notification", "on", "OS", "X", "." ]
baa1a54919e3035417f7571dd46005e91afe8abe
https://github.com/koding/kite/blob/baa1a54919e3035417f7571dd46005e91afe8abe/handlers.go#L148-L153
30,215
koding/kite
handlers.go
handleTunnel
func handleTunnel(r *Request) (interface{}, error) { var args struct { URL string } r.Args.One().MustUnmarshal(&args) parsed, err := url.Parse(args.URL) if err != nil { return nil, err } requestHeader := http.Header{} requestHeader.Add("Origin", "http://"+parsed.Host) remoteConn, _, err := websocket.Def...
go
func handleTunnel(r *Request) (interface{}, error) { var args struct { URL string } r.Args.One().MustUnmarshal(&args) parsed, err := url.Parse(args.URL) if err != nil { return nil, err } requestHeader := http.Header{} requestHeader.Add("Origin", "http://"+parsed.Host) remoteConn, _, err := websocket.Def...
[ "func", "handleTunnel", "(", "r", "*", "Request", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "var", "args", "struct", "{", "URL", "string", "\n", "}", "\n", "r", ".", "Args", ".", "One", "(", ")", ".", "MustUnmarshal", "(", "&", "ar...
// handleTunnel opens two websockets, one to proxy kite and one to itself, // then it copies the message between them.
[ "handleTunnel", "opens", "two", "websockets", "one", "to", "proxy", "kite", "and", "one", "to", "itself", "then", "it", "copies", "the", "message", "between", "them", "." ]
baa1a54919e3035417f7571dd46005e91afe8abe
https://github.com/koding/kite/blob/baa1a54919e3035417f7571dd46005e91afe8abe/handlers.go#L157-L180
30,216
koding/kite
tokenrenewer.go
parse
func (t *TokenRenewer) parse(tokenString string) error { claims := &kitekey.KiteClaims{} _, err := jwt.ParseWithClaims(tokenString, claims, t.localKite.RSAKey) if err != nil { valErr, ok := err.(*jwt.ValidationError) if !ok { return err } // do noy return for ValidationErrorSignatureValid. This is becau...
go
func (t *TokenRenewer) parse(tokenString string) error { claims := &kitekey.KiteClaims{} _, err := jwt.ParseWithClaims(tokenString, claims, t.localKite.RSAKey) if err != nil { valErr, ok := err.(*jwt.ValidationError) if !ok { return err } // do noy return for ValidationErrorSignatureValid. This is becau...
[ "func", "(", "t", "*", "TokenRenewer", ")", "parse", "(", "tokenString", "string", ")", "error", "{", "claims", ":=", "&", "kitekey", ".", "KiteClaims", "{", "}", "\n\n", "_", ",", "err", ":=", "jwt", ".", "ParseWithClaims", "(", "tokenString", ",", "c...
// parse the token string and set
[ "parse", "the", "token", "string", "and", "set" ]
baa1a54919e3035417f7571dd46005e91afe8abe
https://github.com/koding/kite/blob/baa1a54919e3035417f7571dd46005e91afe8abe/tokenrenewer.go#L41-L61
30,217
koding/kite
tokenrenewer.go
renewDuration
func (t *TokenRenewer) renewDuration() time.Duration { return t.validUntil.Add(-renewBefore).Sub(time.Now().UTC()) }
go
func (t *TokenRenewer) renewDuration() time.Duration { return t.validUntil.Add(-renewBefore).Sub(time.Now().UTC()) }
[ "func", "(", "t", "*", "TokenRenewer", ")", "renewDuration", "(", ")", "time", ".", "Duration", "{", "return", "t", ".", "validUntil", ".", "Add", "(", "-", "renewBefore", ")", ".", "Sub", "(", "time", ".", "Now", "(", ")", ".", "UTC", "(", ")", ...
// The duration from now to the time token needs to be renewed. // Needs to be calculated after renewing the token.
[ "The", "duration", "from", "now", "to", "the", "time", "token", "needs", "to", "be", "renewed", ".", "Needs", "to", "be", "calculated", "after", "renewing", "the", "token", "." ]
baa1a54919e3035417f7571dd46005e91afe8abe
https://github.com/koding/kite/blob/baa1a54919e3035417f7571dd46005e91afe8abe/tokenrenewer.go#L111-L113
30,218
koding/kite
tokenrenewer.go
renewToken
func (t *TokenRenewer) renewToken() error { renew := &protocol.Kite{ ID: t.client.Kite.ID, } token, err := t.localKite.GetToken(renew) if err != nil { return err } if err = t.parse(token); err != nil { return err } t.client.authMu.Lock() t.client.Auth.Key = token t.client.authMu.Unlock() t.client.c...
go
func (t *TokenRenewer) renewToken() error { renew := &protocol.Kite{ ID: t.client.Kite.ID, } token, err := t.localKite.GetToken(renew) if err != nil { return err } if err = t.parse(token); err != nil { return err } t.client.authMu.Lock() t.client.Auth.Key = token t.client.authMu.Unlock() t.client.c...
[ "func", "(", "t", "*", "TokenRenewer", ")", "renewToken", "(", ")", "error", "{", "renew", ":=", "&", "protocol", ".", "Kite", "{", "ID", ":", "t", ".", "client", ".", "Kite", ".", "ID", ",", "}", "\n\n", "token", ",", "err", ":=", "t", ".", "l...
// renewToken gets a new token from a kontrolClient, parses it and sets it as the token.
[ "renewToken", "gets", "a", "new", "token", "from", "a", "kontrolClient", "parses", "it", "and", "sets", "it", "as", "the", "token", "." ]
baa1a54919e3035417f7571dd46005e91afe8abe
https://github.com/koding/kite/blob/baa1a54919e3035417f7571dd46005e91afe8abe/tokenrenewer.go#L144-L165
30,219
koding/kite
config/config.go
NewFromKiteKey
func NewFromKiteKey(file string) (*Config, error) { key, err := kitekey.ParseFile(file) if err != nil { return nil, err } var c Config if err := c.ReadToken(key); err != nil { return nil, err } return &c, nil }
go
func NewFromKiteKey(file string) (*Config, error) { key, err := kitekey.ParseFile(file) if err != nil { return nil, err } var c Config if err := c.ReadToken(key); err != nil { return nil, err } return &c, nil }
[ "func", "NewFromKiteKey", "(", "file", "string", ")", "(", "*", "Config", ",", "error", ")", "{", "key", ",", "err", ":=", "kitekey", ".", "ParseFile", "(", "file", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", ...
// NewFromKiteKey parses the given kite key file and gives a new Config value.
[ "NewFromKiteKey", "parses", "the", "given", "kite", "key", "file", "and", "gives", "a", "new", "Config", "value", "." ]
baa1a54919e3035417f7571dd46005e91afe8abe
https://github.com/koding/kite/blob/baa1a54919e3035417f7571dd46005e91afe8abe/config/config.go#L154-L166
30,220
koding/kite
config/config.go
ReadKiteKey
func (c *Config) ReadKiteKey() error { key, err := kitekey.Parse() if err != nil { return err } return c.ReadToken(key) }
go
func (c *Config) ReadKiteKey() error { key, err := kitekey.Parse() if err != nil { return err } return c.ReadToken(key) }
[ "func", "(", "c", "*", "Config", ")", "ReadKiteKey", "(", ")", "error", "{", "key", ",", "err", ":=", "kitekey", ".", "Parse", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "c", ".", "ReadToken", "("...
// ReadKiteKey parsed the user's kite key and returns a new Config.
[ "ReadKiteKey", "parsed", "the", "user", "s", "kite", "key", "and", "returns", "a", "new", "Config", "." ]
baa1a54919e3035417f7571dd46005e91afe8abe
https://github.com/koding/kite/blob/baa1a54919e3035417f7571dd46005e91afe8abe/config/config.go#L244-L251
30,221
koding/kite
config/config.go
ReadToken
func (c *Config) ReadToken(key *jwt.Token) error { c.KiteKey = key.Raw claims, ok := key.Claims.(*kitekey.KiteClaims) if !ok { return errors.New("no claims found") } c.Username = claims.Subject c.KontrolUser = claims.Issuer c.Id = claims.Id // jti is used for jwt's but let's also use it for kite ID c.Kontro...
go
func (c *Config) ReadToken(key *jwt.Token) error { c.KiteKey = key.Raw claims, ok := key.Claims.(*kitekey.KiteClaims) if !ok { return errors.New("no claims found") } c.Username = claims.Subject c.KontrolUser = claims.Issuer c.Id = claims.Id // jti is used for jwt's but let's also use it for kite ID c.Kontro...
[ "func", "(", "c", "*", "Config", ")", "ReadToken", "(", "key", "*", "jwt", ".", "Token", ")", "error", "{", "c", ".", "KiteKey", "=", "key", ".", "Raw", "\n\n", "claims", ",", "ok", ":=", "key", ".", "Claims", ".", "(", "*", "kitekey", ".", "Ki...
// ReadToken reads Kite Claims from JWT token and uses them to initialize Config.
[ "ReadToken", "reads", "Kite", "Claims", "from", "JWT", "token", "and", "uses", "them", "to", "initialize", "Config", "." ]
baa1a54919e3035417f7571dd46005e91afe8abe
https://github.com/koding/kite/blob/baa1a54919e3035417f7571dd46005e91afe8abe/config/config.go#L254-L269
30,222
koding/kite
config/config.go
Copy
func (c *Config) Copy() *Config { copy := *c if c.XHR != nil { xhr := *copy.XHR copy.XHR = &xhr } if c.Client != nil { client := *copy.Client copy.Client = &client } if c.Websocket != nil { ws := *copy.Websocket copy.Websocket = &ws } return &copy }
go
func (c *Config) Copy() *Config { copy := *c if c.XHR != nil { xhr := *copy.XHR copy.XHR = &xhr } if c.Client != nil { client := *copy.Client copy.Client = &client } if c.Websocket != nil { ws := *copy.Websocket copy.Websocket = &ws } return &copy }
[ "func", "(", "c", "*", "Config", ")", "Copy", "(", ")", "*", "Config", "{", "copy", ":=", "*", "c", "\n\n", "if", "c", ".", "XHR", "!=", "nil", "{", "xhr", ":=", "*", "copy", ".", "XHR", "\n", "copy", ".", "XHR", "=", "&", "xhr", "\n", "}",...
// Copy returns a new copy of the config object.
[ "Copy", "returns", "a", "new", "copy", "of", "the", "config", "object", "." ]
baa1a54919e3035417f7571dd46005e91afe8abe
https://github.com/koding/kite/blob/baa1a54919e3035417f7571dd46005e91afe8abe/config/config.go#L272-L291
30,223
koding/kite
request.go
runMethod
func (c *Client) runMethod(method *Method, args *dnode.Partial) { var ( callFunc func(interface{}, *Error) request *Request ) // Recover dnode argument errors and send them back. The caller can use // functions like MustString(), MustSlice()... without the fear of panic. defer func() { if r := recover(); r...
go
func (c *Client) runMethod(method *Method, args *dnode.Partial) { var ( callFunc func(interface{}, *Error) request *Request ) // Recover dnode argument errors and send them back. The caller can use // functions like MustString(), MustSlice()... without the fear of panic. defer func() { if r := recover(); r...
[ "func", "(", "c", "*", "Client", ")", "runMethod", "(", "method", "*", "Method", ",", "args", "*", "dnode", ".", "Partial", ")", "{", "var", "(", "callFunc", "func", "(", "interface", "{", "}", ",", "*", "Error", ")", "\n", "request", "*", "Request...
// runMethod is called when a method is received from remote Kite.
[ "runMethod", "is", "called", "when", "a", "method", "is", "received", "from", "remote", "Kite", "." ]
baa1a54919e3035417f7571dd46005e91afe8abe
https://github.com/koding/kite/blob/baa1a54919e3035417f7571dd46005e91afe8abe/request.go#L62-L119
30,224
koding/kite
request.go
runCallback
func (c *Client) runCallback(callback func(*dnode.Partial), args *dnode.Partial) { // Do not panic no matter what. defer func() { if err := recover(); err != nil { c.LocalKite.Log.Warning("Error in calling the callback function : %v", err) } }() // Call the callback function. callback(args) }
go
func (c *Client) runCallback(callback func(*dnode.Partial), args *dnode.Partial) { // Do not panic no matter what. defer func() { if err := recover(); err != nil { c.LocalKite.Log.Warning("Error in calling the callback function : %v", err) } }() // Call the callback function. callback(args) }
[ "func", "(", "c", "*", "Client", ")", "runCallback", "(", "callback", "func", "(", "*", "dnode", ".", "Partial", ")", ",", "args", "*", "dnode", ".", "Partial", ")", "{", "// Do not panic no matter what.", "defer", "func", "(", ")", "{", "if", "err", "...
// runCallback is called when a callback method call is received from remote Kite.
[ "runCallback", "is", "called", "when", "a", "callback", "method", "call", "is", "received", "from", "remote", "Kite", "." ]
baa1a54919e3035417f7571dd46005e91afe8abe
https://github.com/koding/kite/blob/baa1a54919e3035417f7571dd46005e91afe8abe/request.go#L122-L132
30,225
koding/kite
request.go
authenticate
func (r *Request) authenticate() *Error { // Trust the Kite if we have initiated the connection. Following casts // means, session is opened by the client. if _, ok := r.Client.session.(*sockjsclient.WebsocketSession); ok { return nil } if _, ok := r.Client.session.(*sockjsclient.XHRSession); ok { return nil...
go
func (r *Request) authenticate() *Error { // Trust the Kite if we have initiated the connection. Following casts // means, session is opened by the client. if _, ok := r.Client.session.(*sockjsclient.WebsocketSession); ok { return nil } if _, ok := r.Client.session.(*sockjsclient.XHRSession); ok { return nil...
[ "func", "(", "r", "*", "Request", ")", "authenticate", "(", ")", "*", "Error", "{", "// Trust the Kite if we have initiated the connection. Following casts", "// means, session is opened by the client.", "if", "_", ",", "ok", ":=", "r", ".", "Client", ".", "session", ...
// authenticate tries to authenticate the user by selecting appropriate // authenticator function.
[ "authenticate", "tries", "to", "authenticate", "the", "user", "by", "selecting", "appropriate", "authenticator", "function", "." ]
baa1a54919e3035417f7571dd46005e91afe8abe
https://github.com/koding/kite/blob/baa1a54919e3035417f7571dd46005e91afe8abe/request.go#L182-L222
30,226
koding/kite
request.go
AuthenticateFromToken
func (k *Kite) AuthenticateFromToken(r *Request) error { k.verifyOnce.Do(k.verifyInit) token, err := jwt.ParseWithClaims(r.Auth.Key, &kitekey.KiteClaims{}, r.LocalKite.RSAKey) if e, ok := err.(*jwt.ValidationError); ok { // Translate public key mismatch errors to token-is-expired one. // This is to signal remo...
go
func (k *Kite) AuthenticateFromToken(r *Request) error { k.verifyOnce.Do(k.verifyInit) token, err := jwt.ParseWithClaims(r.Auth.Key, &kitekey.KiteClaims{}, r.LocalKite.RSAKey) if e, ok := err.(*jwt.ValidationError); ok { // Translate public key mismatch errors to token-is-expired one. // This is to signal remo...
[ "func", "(", "k", "*", "Kite", ")", "AuthenticateFromToken", "(", "r", "*", "Request", ")", "error", "{", "k", ".", "verifyOnce", ".", "Do", "(", "k", ".", "verifyInit", ")", "\n\n", "token", ",", "err", ":=", "jwt", ".", "ParseWithClaims", "(", "r",...
// AuthenticateFromToken is the default Authenticator for Kite.
[ "AuthenticateFromToken", "is", "the", "default", "Authenticator", "for", "Kite", "." ]
baa1a54919e3035417f7571dd46005e91afe8abe
https://github.com/koding/kite/blob/baa1a54919e3035417f7571dd46005e91afe8abe/request.go#L225-L272
30,227
koding/kite
request.go
AuthenticateFromKiteKey
func (k *Kite) AuthenticateFromKiteKey(r *Request) error { claims := &kitekey.KiteClaims{} token, err := jwt.ParseWithClaims(r.Auth.Key, claims, k.verify) if err != nil { return err } if !token.Valid { return errors.New("Invalid signature in kite key") } if claims.Subject == "" { return errors.New("toke...
go
func (k *Kite) AuthenticateFromKiteKey(r *Request) error { claims := &kitekey.KiteClaims{} token, err := jwt.ParseWithClaims(r.Auth.Key, claims, k.verify) if err != nil { return err } if !token.Valid { return errors.New("Invalid signature in kite key") } if claims.Subject == "" { return errors.New("toke...
[ "func", "(", "k", "*", "Kite", ")", "AuthenticateFromKiteKey", "(", "r", "*", "Request", ")", "error", "{", "claims", ":=", "&", "kitekey", ".", "KiteClaims", "{", "}", "\n\n", "token", ",", "err", ":=", "jwt", ".", "ParseWithClaims", "(", "r", ".", ...
// AuthenticateFromKiteKey authenticates user from kite key.
[ "AuthenticateFromKiteKey", "authenticates", "user", "from", "kite", "key", "." ]
baa1a54919e3035417f7571dd46005e91afe8abe
https://github.com/koding/kite/blob/baa1a54919e3035417f7571dd46005e91afe8abe/request.go#L275-L294
30,228
koding/kite
registerurl.go
publicIP
func publicIP() (net.IP, error) { resp, err := http.Get(publicEcho) if err != nil { return nil, err } defer resp.Body.Close() // The ip address is 16 chars long, we read more // to account for excessive whitespace. p, err := ioutil.ReadAll(io.LimitReader(resp.Body, 24)) if err != nil { return nil, err } ...
go
func publicIP() (net.IP, error) { resp, err := http.Get(publicEcho) if err != nil { return nil, err } defer resp.Body.Close() // The ip address is 16 chars long, we read more // to account for excessive whitespace. p, err := ioutil.ReadAll(io.LimitReader(resp.Body, 24)) if err != nil { return nil, err } ...
[ "func", "publicIP", "(", ")", "(", "net", ".", "IP", ",", "error", ")", "{", "resp", ",", "err", ":=", "http", ".", "Get", "(", "publicEcho", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "defer", "resp...
// publicIP returns an IP that is supposed to be Public.
[ "publicIP", "returns", "an", "IP", "that", "is", "supposed", "to", "be", "Public", "." ]
baa1a54919e3035417f7571dd46005e91afe8abe
https://github.com/koding/kite/blob/baa1a54919e3035417f7571dd46005e91afe8abe/registerurl.go#L80-L100
30,229
koding/kite
kitectl/command/install.go
extractTar
func extractTar(r io.Reader, dir string) error { first := true // true if we are on the first entry of tarball tr := tar.NewReader(r) for { hdr, err := tr.Next() if err == io.EOF { // end of tar archive break } if err != nil { return err } // Check if the same kite version is installed before ...
go
func extractTar(r io.Reader, dir string) error { first := true // true if we are on the first entry of tarball tr := tar.NewReader(r) for { hdr, err := tr.Next() if err == io.EOF { // end of tar archive break } if err != nil { return err } // Check if the same kite version is installed before ...
[ "func", "extractTar", "(", "r", "io", ".", "Reader", ",", "dir", "string", ")", "error", "{", "first", ":=", "true", "// true if we are on the first entry of tarball", "\n", "tr", ":=", "tar", ".", "NewReader", "(", "r", ")", "\n", "for", "{", "hdr", ",", ...
// extractTar reads from the io.Reader and writes the files into the directory.
[ "extractTar", "reads", "from", "the", "io", ".", "Reader", "and", "writes", "the", "files", "into", "the", "directory", "." ]
baa1a54919e3035417f7571dd46005e91afe8abe
https://github.com/koding/kite/blob/baa1a54919e3035417f7571dd46005e91afe8abe/kitectl/command/install.go#L189-L238
30,230
koding/kite
kitectl/command/install.go
validatePackage
func validatePackage(tempKitePath, repoName string) (bundlePath string, err error) { dirs, err := ioutil.ReadDir(tempKitePath) if err != nil { return "", err } if len(dirs) != 1 { return "", errors.New("Invalid package: Package must contain only one directory.") } bundlePath = filepath.Join(tempKitePath, di...
go
func validatePackage(tempKitePath, repoName string) (bundlePath string, err error) { dirs, err := ioutil.ReadDir(tempKitePath) if err != nil { return "", err } if len(dirs) != 1 { return "", errors.New("Invalid package: Package must contain only one directory.") } bundlePath = filepath.Join(tempKitePath, di...
[ "func", "validatePackage", "(", "tempKitePath", ",", "repoName", "string", ")", "(", "bundlePath", "string", ",", "err", "error", ")", "{", "dirs", ",", "err", ":=", "ioutil", ".", "ReadDir", "(", "tempKitePath", ")", "\n", "if", "err", "!=", "nil", "{",...
// validatePackage does some checks on kite bundle and returns the bundle path.
[ "validatePackage", "does", "some", "checks", "on", "kite", "bundle", "and", "returns", "the", "bundle", "path", "." ]
baa1a54919e3035417f7571dd46005e91afe8abe
https://github.com/koding/kite/blob/baa1a54919e3035417f7571dd46005e91afe8abe/kitectl/command/install.go#L241-L262
30,231
koding/kite
dnode/scrubber.go
RemoveCallback
func (s *Scrubber) RemoveCallback(id uint64) { s.Lock() delete(s.callbacks, id) s.Unlock() }
go
func (s *Scrubber) RemoveCallback(id uint64) { s.Lock() delete(s.callbacks, id) s.Unlock() }
[ "func", "(", "s", "*", "Scrubber", ")", "RemoveCallback", "(", "id", "uint64", ")", "{", "s", ".", "Lock", "(", ")", "\n", "delete", "(", "s", ".", "callbacks", ",", "id", ")", "\n", "s", ".", "Unlock", "(", ")", "\n", "}" ]
// RemoveCallback removes the callback with id from callbacks. // Can be used to remove unused callbacks to free memory.
[ "RemoveCallback", "removes", "the", "callback", "with", "id", "from", "callbacks", ".", "Can", "be", "used", "to", "remove", "unused", "callbacks", "to", "free", "memory", "." ]
baa1a54919e3035417f7571dd46005e91afe8abe
https://github.com/koding/kite/blob/baa1a54919e3035417f7571dd46005e91afe8abe/dnode/scrubber.go#L24-L28
30,232
koding/kite
method.go
addHandle
func (k *Kite) addHandle(method string, handler Handler) *Method { authenticate := true if k.Config.DisableAuthentication { authenticate = false } m := &Method{ name: method, handler: handler, authenticate: authenticate, handling: k.MethodHandling, } k.handlers[method] = m return m }
go
func (k *Kite) addHandle(method string, handler Handler) *Method { authenticate := true if k.Config.DisableAuthentication { authenticate = false } m := &Method{ name: method, handler: handler, authenticate: authenticate, handling: k.MethodHandling, } k.handlers[method] = m return m }
[ "func", "(", "k", "*", "Kite", ")", "addHandle", "(", "method", "string", ",", "handler", "Handler", ")", "*", "Method", "{", "authenticate", ":=", "true", "\n", "if", "k", ".", "Config", ".", "DisableAuthentication", "{", "authenticate", "=", "false", "...
// addHandle is an internal method to add a handler
[ "addHandle", "is", "an", "internal", "method", "to", "add", "a", "handler" ]
baa1a54919e3035417f7571dd46005e91afe8abe
https://github.com/koding/kite/blob/baa1a54919e3035417f7571dd46005e91afe8abe/method.go#L78-L93
30,233
koding/kite
method.go
PreHandle
func (m *Method) PreHandle(handler Handler) *Method { m.preHandlers = append(m.preHandlers, handler) return m }
go
func (m *Method) PreHandle(handler Handler) *Method { m.preHandlers = append(m.preHandlers, handler) return m }
[ "func", "(", "m", "*", "Method", ")", "PreHandle", "(", "handler", "Handler", ")", "*", "Method", "{", "m", ".", "preHandlers", "=", "append", "(", "m", ".", "preHandlers", ",", "handler", ")", "\n", "return", "m", "\n", "}" ]
// PreHandler adds a new kite handler which is executed before the method.
[ "PreHandler", "adds", "a", "new", "kite", "handler", "which", "is", "executed", "before", "the", "method", "." ]
baa1a54919e3035417f7571dd46005e91afe8abe
https://github.com/koding/kite/blob/baa1a54919e3035417f7571dd46005e91afe8abe/method.go#L126-L129
30,234
koding/kite
method.go
PostHandle
func (m *Method) PostHandle(handler Handler) *Method { m.postHandlers = append(m.postHandlers, handler) return m }
go
func (m *Method) PostHandle(handler Handler) *Method { m.postHandlers = append(m.postHandlers, handler) return m }
[ "func", "(", "m", "*", "Method", ")", "PostHandle", "(", "handler", "Handler", ")", "*", "Method", "{", "m", ".", "postHandlers", "=", "append", "(", "m", ".", "postHandlers", ",", "handler", ")", "\n", "return", "m", "\n", "}" ]
// PostHandle adds a new kite handler which is executed after the method.
[ "PostHandle", "adds", "a", "new", "kite", "handler", "which", "is", "executed", "after", "the", "method", "." ]
baa1a54919e3035417f7571dd46005e91afe8abe
https://github.com/koding/kite/blob/baa1a54919e3035417f7571dd46005e91afe8abe/method.go#L138-L141
30,235
koding/kite
method.go
FinalFunc
func (m *Method) FinalFunc(f FinalFunc) *Method { m.finalFuncs = append(m.finalFuncs, f) return m }
go
func (m *Method) FinalFunc(f FinalFunc) *Method { m.finalFuncs = append(m.finalFuncs, f) return m }
[ "func", "(", "m", "*", "Method", ")", "FinalFunc", "(", "f", "FinalFunc", ")", "*", "Method", "{", "m", ".", "finalFuncs", "=", "append", "(", "m", ".", "finalFuncs", ",", "f", ")", "\n", "return", "m", "\n", "}" ]
// FinalFunc registers a function that is always called as a last one // after pre-, handler and post- functions for the given method. // // It receives a result and an error from last handler that // got executed prior to calling final func.
[ "FinalFunc", "registers", "a", "function", "that", "is", "always", "called", "as", "a", "last", "one", "after", "pre", "-", "handler", "and", "post", "-", "functions", "for", "the", "given", "method", ".", "It", "receives", "a", "result", "and", "an", "e...
baa1a54919e3035417f7571dd46005e91afe8abe
https://github.com/koding/kite/blob/baa1a54919e3035417f7571dd46005e91afe8abe/method.go#L154-L157
30,236
koding/kite
method.go
Handle
func (k *Kite) Handle(method string, handler Handler) *Method { return k.addHandle(method, handler) }
go
func (k *Kite) Handle(method string, handler Handler) *Method { return k.addHandle(method, handler) }
[ "func", "(", "k", "*", "Kite", ")", "Handle", "(", "method", "string", ",", "handler", "Handler", ")", "*", "Method", "{", "return", "k", ".", "addHandle", "(", "method", ",", "handler", ")", "\n", "}" ]
// Handle registers the handler for the given method. The handler is called // when a method call is received from a Kite.
[ "Handle", "registers", "the", "handler", "for", "the", "given", "method", ".", "The", "handler", "is", "called", "when", "a", "method", "call", "is", "received", "from", "a", "Kite", "." ]
baa1a54919e3035417f7571dd46005e91afe8abe
https://github.com/koding/kite/blob/baa1a54919e3035417f7571dd46005e91afe8abe/method.go#L161-L163
30,237
koding/kite
method.go
PreHandle
func (k *Kite) PreHandle(handler Handler) { k.preHandlers = append(k.preHandlers, handler) }
go
func (k *Kite) PreHandle(handler Handler) { k.preHandlers = append(k.preHandlers, handler) }
[ "func", "(", "k", "*", "Kite", ")", "PreHandle", "(", "handler", "Handler", ")", "{", "k", ".", "preHandlers", "=", "append", "(", "k", ".", "preHandlers", ",", "handler", ")", "\n", "}" ]
// PreHandle registers an handler which is executed before a kite.Handler // method is executed. Calling PreHandle multiple times registers multiple // handlers. A non-error return triggers the execution of the next handler. The // execution order is FIFO.
[ "PreHandle", "registers", "an", "handler", "which", "is", "executed", "before", "a", "kite", ".", "Handler", "method", "is", "executed", ".", "Calling", "PreHandle", "multiple", "times", "registers", "multiple", "handlers", ".", "A", "non", "-", "error", "retu...
baa1a54919e3035417f7571dd46005e91afe8abe
https://github.com/koding/kite/blob/baa1a54919e3035417f7571dd46005e91afe8abe/method.go#L176-L178
30,238
koding/kite
method.go
PostHandle
func (k *Kite) PostHandle(handler Handler) { k.postHandlers = append(k.postHandlers, handler) }
go
func (k *Kite) PostHandle(handler Handler) { k.postHandlers = append(k.postHandlers, handler) }
[ "func", "(", "k", "*", "Kite", ")", "PostHandle", "(", "handler", "Handler", ")", "{", "k", ".", "postHandlers", "=", "append", "(", "k", ".", "postHandlers", ",", "handler", ")", "\n", "}" ]
// PostHandle registers an handler which is executed after a kite.Handler // method is executed. Calling PostHandler multiple times registers multiple // handlers. A non-error return triggers the execution of the next handler. The // execution order is FIFO.
[ "PostHandle", "registers", "an", "handler", "which", "is", "executed", "after", "a", "kite", ".", "Handler", "method", "is", "executed", ".", "Calling", "PostHandler", "multiple", "times", "registers", "multiple", "handlers", ".", "A", "non", "-", "error", "re...
baa1a54919e3035417f7571dd46005e91afe8abe
https://github.com/koding/kite/blob/baa1a54919e3035417f7571dd46005e91afe8abe/method.go#L189-L191
30,239
koding/kite
method.go
FinalFunc
func (k *Kite) FinalFunc(f FinalFunc) { k.finalFuncs = append(k.finalFuncs, f) }
go
func (k *Kite) FinalFunc(f FinalFunc) { k.finalFuncs = append(k.finalFuncs, f) }
[ "func", "(", "k", "*", "Kite", ")", "FinalFunc", "(", "f", "FinalFunc", ")", "{", "k", ".", "finalFuncs", "=", "append", "(", "k", ".", "finalFuncs", ",", "f", ")", "\n", "}" ]
// FinalFunc registers a function that is always called as a last one // after pre-, handler and post- functions. // // It receives a result and an error from last handler that // got executed prior to calling final func.
[ "FinalFunc", "registers", "a", "function", "that", "is", "always", "called", "as", "a", "last", "one", "after", "pre", "-", "handler", "and", "post", "-", "functions", ".", "It", "receives", "a", "result", "and", "an", "error", "from", "last", "handler", ...
baa1a54919e3035417f7571dd46005e91afe8abe
https://github.com/koding/kite/blob/baa1a54919e3035417f7571dd46005e91afe8abe/method.go#L203-L205
30,240
inverse-inc/packetfence
go/caddy/caddy/caddyhttp/httpserver/path.go
Matches
func (p Path) Matches(other string) bool { if CaseSensitivePath { return strings.HasPrefix(string(p), other) } return strings.HasPrefix(strings.ToLower(string(p)), strings.ToLower(other)) }
go
func (p Path) Matches(other string) bool { if CaseSensitivePath { return strings.HasPrefix(string(p), other) } return strings.HasPrefix(strings.ToLower(string(p)), strings.ToLower(other)) }
[ "func", "(", "p", "Path", ")", "Matches", "(", "other", "string", ")", "bool", "{", "if", "CaseSensitivePath", "{", "return", "strings", ".", "HasPrefix", "(", "string", "(", "p", ")", ",", "other", ")", "\n", "}", "\n", "return", "strings", ".", "Ha...
// Matches checks to see if other matches p. // // Path matching will probably not always be a direct // comparison; this method assures that paths can be // easily and consistently matched.
[ "Matches", "checks", "to", "see", "if", "other", "matches", "p", ".", "Path", "matching", "will", "probably", "not", "always", "be", "a", "direct", "comparison", ";", "this", "method", "assures", "that", "paths", "can", "be", "easily", "and", "consistently",...
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/caddyhttp/httpserver/path.go#L16-L21
30,241
inverse-inc/packetfence
go/caddy/caddy/caddyhttp/gzip/gzip.go
Write
func (w *gzipResponseWriter) Write(b []byte) (int, error) { if w.Header().Get("Content-Type") == "" { w.Header().Set("Content-Type", http.DetectContentType(b)) } if !w.statusCodeWritten { w.WriteHeader(http.StatusOK) } n, err := w.Writer.Write(b) return n, err }
go
func (w *gzipResponseWriter) Write(b []byte) (int, error) { if w.Header().Get("Content-Type") == "" { w.Header().Set("Content-Type", http.DetectContentType(b)) } if !w.statusCodeWritten { w.WriteHeader(http.StatusOK) } n, err := w.Writer.Write(b) return n, err }
[ "func", "(", "w", "*", "gzipResponseWriter", ")", "Write", "(", "b", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "if", "w", ".", "Header", "(", ")", ".", "Get", "(", "\"", "\"", ")", "==", "\"", "\"", "{", "w", ".", "Header", ...
// Write wraps the underlying Write method to do compression.
[ "Write", "wraps", "the", "underlying", "Write", "method", "to", "do", "compression", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/caddyhttp/gzip/gzip.go#L126-L135
30,242
inverse-inc/packetfence
go/caddy/caddy/caddyhttp/staticfiles/fileserver.go
IsHidden
func (fs FileServer) IsHidden(d os.FileInfo) bool { // If the file is supposed to be hidden, return a 404 for _, hiddenPath := range fs.Hide { // Check if the served file is exactly the hidden file. if hFile, err := fs.Root.Open(hiddenPath); err == nil { fs, _ := hFile.Stat() hFile.Close() if os.SameFile...
go
func (fs FileServer) IsHidden(d os.FileInfo) bool { // If the file is supposed to be hidden, return a 404 for _, hiddenPath := range fs.Hide { // Check if the served file is exactly the hidden file. if hFile, err := fs.Root.Open(hiddenPath); err == nil { fs, _ := hFile.Stat() hFile.Close() if os.SameFile...
[ "func", "(", "fs", "FileServer", ")", "IsHidden", "(", "d", "os", ".", "FileInfo", ")", "bool", "{", "// If the file is supposed to be hidden, return a 404", "for", "_", ",", "hiddenPath", ":=", "range", "fs", ".", "Hide", "{", "// Check if the served file is exactl...
// IsHidden checks if file with FileInfo d is on hide list.
[ "IsHidden", "checks", "if", "file", "with", "FileInfo", "d", "is", "on", "hide", "list", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/caddyhttp/staticfiles/fileserver.go#L184-L197
30,243
inverse-inc/packetfence
go/caddy/caddy/caddyhttp/staticfiles/fileserver.go
Redirect
func Redirect(w http.ResponseWriter, r *http.Request, newPath string, statusCode int) { if q := r.URL.RawQuery; q != "" { newPath += "?" + q } http.Redirect(w, r, newPath, statusCode) }
go
func Redirect(w http.ResponseWriter, r *http.Request, newPath string, statusCode int) { if q := r.URL.RawQuery; q != "" { newPath += "?" + q } http.Redirect(w, r, newPath, statusCode) }
[ "func", "Redirect", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "newPath", "string", ",", "statusCode", "int", ")", "{", "if", "q", ":=", "r", ".", "URL", ".", "RawQuery", ";", "q", "!=", "\"", "\"", "{", ...
// Redirect sends an HTTP redirect to the client but will preserve // the query string for the new path. Based on http.localRedirect // from the Go standard library.
[ "Redirect", "sends", "an", "HTTP", "redirect", "to", "the", "client", "but", "will", "preserve", "the", "query", "string", "for", "the", "new", "path", ".", "Based", "on", "http", ".", "localRedirect", "from", "the", "Go", "standard", "library", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/caddyhttp/staticfiles/fileserver.go#L202-L207
30,244
inverse-inc/packetfence
go/coredns/plugin/dnstap/handler.go
TapperFromContext
func TapperFromContext(ctx context.Context) (t Tapper) { t, _ = ctx.(Tapper) return }
go
func TapperFromContext(ctx context.Context) (t Tapper) { t, _ = ctx.(Tapper) return }
[ "func", "TapperFromContext", "(", "ctx", "context", ".", "Context", ")", "(", "t", "Tapper", ")", "{", "t", ",", "_", "=", "ctx", ".", "(", "Tapper", ")", "\n", "return", "\n", "}" ]
// TapperFromContext will return a Tapper if the dnstap plugin is enabled.
[ "TapperFromContext", "will", "return", "a", "Tapper", "if", "the", "dnstap", "plugin", "is", "enabled", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/coredns/plugin/dnstap/handler.go#L48-L51
30,245
inverse-inc/packetfence
go/coredns/plugin/dnstap/handler.go
TapBuilder
func (h Dnstap) TapBuilder() msg.Builder { return msg.Builder{Full: h.Pack} }
go
func (h Dnstap) TapBuilder() msg.Builder { return msg.Builder{Full: h.Pack} }
[ "func", "(", "h", "Dnstap", ")", "TapBuilder", "(", ")", "msg", ".", "Builder", "{", "return", "msg", ".", "Builder", "{", "Full", ":", "h", ".", "Pack", "}", "\n", "}" ]
// TapBuilder implements Tapper.
[ "TapBuilder", "implements", "Tapper", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/coredns/plugin/dnstap/handler.go#L69-L71
30,246
inverse-inc/packetfence
go/dhcp/pool/pool.go
GetIssues
func (dp *DHCPPool) GetIssues(macs []string) ([]string, map[uint64]string) { dp.lock.Lock() defer dp.lock.Unlock() var found bool found = false var inPoolNotInCache []string var duplicateInPool map[uint64]string duplicateInPool = make(map[uint64]string) var count int var saveindex uint64 for i := uint64(0); ...
go
func (dp *DHCPPool) GetIssues(macs []string) ([]string, map[uint64]string) { dp.lock.Lock() defer dp.lock.Unlock() var found bool found = false var inPoolNotInCache []string var duplicateInPool map[uint64]string duplicateInPool = make(map[uint64]string) var count int var saveindex uint64 for i := uint64(0); ...
[ "func", "(", "dp", "*", "DHCPPool", ")", "GetIssues", "(", "macs", "[", "]", "string", ")", "(", "[", "]", "string", ",", "map", "[", "uint64", "]", "string", ")", "{", "dp", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "dp", ".", "lock",...
// Compare what we have in the cache with what we have in the pool
[ "Compare", "what", "we", "have", "in", "the", "cache", "with", "what", "we", "have", "in", "the", "pool" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/dhcp/pool/pool.go#L34-L81
30,247
inverse-inc/packetfence
go/dhcp/pool/pool.go
ReserveIPIndex
func (dp *DHCPPool) ReserveIPIndex(index uint64, mac string) (error, string) { dp.lock.Lock() defer dp.lock.Unlock() if index >= dp.capacity { return errors.New("Trying to reserve an IP that is outside the capacity of this pool"), FreeMac } if _, free := dp.free[index]; free { delete(dp.free, index) dp.mac...
go
func (dp *DHCPPool) ReserveIPIndex(index uint64, mac string) (error, string) { dp.lock.Lock() defer dp.lock.Unlock() if index >= dp.capacity { return errors.New("Trying to reserve an IP that is outside the capacity of this pool"), FreeMac } if _, free := dp.free[index]; free { delete(dp.free, index) dp.mac...
[ "func", "(", "dp", "*", "DHCPPool", ")", "ReserveIPIndex", "(", "index", "uint64", ",", "mac", "string", ")", "(", "error", ",", "string", ")", "{", "dp", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "dp", ".", "lock", ".", "Unlock", "(", "...
// Reserves an IP in the pool, returns an error if the IP has already been reserved
[ "Reserves", "an", "IP", "in", "the", "pool", "returns", "an", "error", "if", "the", "IP", "has", "already", "been", "reserved" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/dhcp/pool/pool.go#L84-L99
30,248
inverse-inc/packetfence
go/dhcp/pool/pool.go
FreeIPIndex
func (dp *DHCPPool) FreeIPIndex(index uint64) error { dp.lock.Lock() defer dp.lock.Unlock() if !dp.IndexInPool(index) { return errors.New("Trying to free an IP that is outside the capacity of this pool") } if _, free := dp.free[index]; free { return errors.New("IP is already free") } else { dp.free[index]...
go
func (dp *DHCPPool) FreeIPIndex(index uint64) error { dp.lock.Lock() defer dp.lock.Unlock() if !dp.IndexInPool(index) { return errors.New("Trying to free an IP that is outside the capacity of this pool") } if _, free := dp.free[index]; free { return errors.New("IP is already free") } else { dp.free[index]...
[ "func", "(", "dp", "*", "DHCPPool", ")", "FreeIPIndex", "(", "index", "uint64", ")", "error", "{", "dp", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "dp", ".", "lock", ".", "Unlock", "(", ")", "\n\n", "if", "!", "dp", ".", "IndexInPool", "...
// Frees an IP in the pool, returns an error if the IP is already free
[ "Frees", "an", "IP", "in", "the", "pool", "returns", "an", "error", "if", "the", "IP", "is", "already", "free" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/dhcp/pool/pool.go#L102-L117
30,249
inverse-inc/packetfence
go/dhcp/pool/pool.go
GetFreeIPIndex
func (dp *DHCPPool) GetFreeIPIndex(mac string) (uint64, string, error) { dp.lock.Lock() defer dp.lock.Unlock() if len(dp.free) == 0 { return 0, FreeMac, errors.New("DHCP pool is full") } index := rand.Intn(len(dp.free)) var available uint64 for available = range dp.free { if index == 0 { break } ind...
go
func (dp *DHCPPool) GetFreeIPIndex(mac string) (uint64, string, error) { dp.lock.Lock() defer dp.lock.Unlock() if len(dp.free) == 0 { return 0, FreeMac, errors.New("DHCP pool is full") } index := rand.Intn(len(dp.free)) var available uint64 for available = range dp.free { if index == 0 { break } ind...
[ "func", "(", "dp", "*", "DHCPPool", ")", "GetFreeIPIndex", "(", "mac", "string", ")", "(", "uint64", ",", "string", ",", "error", ")", "{", "dp", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "dp", ".", "lock", ".", "Unlock", "(", ")", "\n\n...
// Returns a random free IP address, an error if the pool is full
[ "Returns", "a", "random", "free", "IP", "address", "an", "error", "if", "the", "pool", "is", "full" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/dhcp/pool/pool.go#L152-L173
30,250
inverse-inc/packetfence
go/dhcp/pool/pool.go
FreeIPsRemaining
func (dp *DHCPPool) FreeIPsRemaining() uint64 { dp.lock.Lock() defer dp.lock.Unlock() return uint64(len(dp.free)) }
go
func (dp *DHCPPool) FreeIPsRemaining() uint64 { dp.lock.Lock() defer dp.lock.Unlock() return uint64(len(dp.free)) }
[ "func", "(", "dp", "*", "DHCPPool", ")", "FreeIPsRemaining", "(", ")", "uint64", "{", "dp", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "dp", ".", "lock", ".", "Unlock", "(", ")", "\n", "return", "uint64", "(", "len", "(", "dp", ".", "free...
// Returns the amount of free IPs in the pool
[ "Returns", "the", "amount", "of", "free", "IPs", "in", "the", "pool" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/dhcp/pool/pool.go#L181-L185
30,251
inverse-inc/packetfence
go/firewallsso/watchguard.go
Stop
func (fw *WatchGuard) Stop(ctx context.Context, info map[string]string) (bool, error) { p := fw.stopRadiusPacket(ctx, info) client := fw.getRadiusClient(ctx) var err error client.Dialer.LocalAddr, err = net.ResolveUDPAddr("udp", fw.getSourceIp(ctx).String()+":0") sharedutils.CheckError(err) // Use the backgroun...
go
func (fw *WatchGuard) Stop(ctx context.Context, info map[string]string) (bool, error) { p := fw.stopRadiusPacket(ctx, info) client := fw.getRadiusClient(ctx) var err error client.Dialer.LocalAddr, err = net.ResolveUDPAddr("udp", fw.getSourceIp(ctx).String()+":0") sharedutils.CheckError(err) // Use the backgroun...
[ "func", "(", "fw", "*", "WatchGuard", ")", "Stop", "(", "ctx", "context", ".", "Context", ",", "info", "map", "[", "string", "]", "string", ")", "(", "bool", ",", "error", ")", "{", "p", ":=", "fw", ".", "stopRadiusPacket", "(", "ctx", ",", "info",...
// Send an SSO stop to the WatchGuard firewall // Returns an error unless there is a valid reply from the firewall
[ "Send", "an", "SSO", "stop", "to", "the", "WatchGuard", "firewall", "Returns", "an", "error", "unless", "there", "is", "a", "valid", "reply", "from", "the", "firewall" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/firewallsso/watchguard.go#L58-L76
30,252
inverse-inc/packetfence
go/firewallsso/watchguard.go
stopRadiusPacket
func (fw *WatchGuard) stopRadiusPacket(ctx context.Context, info map[string]string) *radius.Packet { r := radius.New(radius.CodeAccountingRequest, []byte(fw.Password)) rfc2866.AcctSessionID_AddString(r, "acct_pf-"+info["mac"]) rfc2866.AcctStatusType_Add(r, rfc2866.AcctStatusType_Value_Stop) rfc2865.UserName_AddStri...
go
func (fw *WatchGuard) stopRadiusPacket(ctx context.Context, info map[string]string) *radius.Packet { r := radius.New(radius.CodeAccountingRequest, []byte(fw.Password)) rfc2866.AcctSessionID_AddString(r, "acct_pf-"+info["mac"]) rfc2866.AcctStatusType_Add(r, rfc2866.AcctStatusType_Value_Stop) rfc2865.UserName_AddStri...
[ "func", "(", "fw", "*", "WatchGuard", ")", "stopRadiusPacket", "(", "ctx", "context", ".", "Context", ",", "info", "map", "[", "string", "]", "string", ")", "*", "radius", ".", "Packet", "{", "r", ":=", "radius", ".", "New", "(", "radius", ".", "Code...
// Build the RADIUS packet for an SSO stop
[ "Build", "the", "RADIUS", "packet", "for", "an", "SSO", "stop" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/firewallsso/watchguard.go#L79-L90
30,253
inverse-inc/packetfence
go/caddy/requestlimit/requestlimit.go
setup
func setup(c *caddy.Controller) error { var max int for c.Next() { val := c.Val() switch val { case "requestlimit": if !c.NextArg() { fmt.Println("Missing limit argument for requestlimit") return c.ArgErr() } else { val := c.Val() if val != "" { max64, err := strconv.ParseInt(c.Val()...
go
func setup(c *caddy.Controller) error { var max int for c.Next() { val := c.Val() switch val { case "requestlimit": if !c.NextArg() { fmt.Println("Missing limit argument for requestlimit") return c.ArgErr() } else { val := c.Val() if val != "" { max64, err := strconv.ParseInt(c.Val()...
[ "func", "setup", "(", "c", "*", "caddy", ".", "Controller", ")", "error", "{", "var", "max", "int", "\n\n", "for", "c", ".", "Next", "(", ")", "{", "val", ":=", "c", ".", "Val", "(", ")", "\n", "switch", "val", "{", "case", "\"", "\"", ":", "...
// Setup the rate limiter with the configuration in the Caddyfile
[ "Setup", "the", "rate", "limiter", "with", "the", "configuration", "in", "the", "Caddyfile" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/requestlimit/requestlimit.go#L21-L55
30,254
inverse-inc/packetfence
go/caddy/requestlimit/requestlimit.go
ServeHTTP
func (h RequestLimitHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) { // Limit the concurrent requests that can run through the sem channel h.sem <- 1 defer func() { <-h.sem }() return h.Next.ServeHTTP(w, r) }
go
func (h RequestLimitHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) { // Limit the concurrent requests that can run through the sem channel h.sem <- 1 defer func() { <-h.sem }() return h.Next.ServeHTTP(w, r) }
[ "func", "(", "h", "RequestLimitHandler", ")", "ServeHTTP", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "(", "int", ",", "error", ")", "{", "// Limit the concurrent requests that can run through the sem channel", "h", ".", ...
// Middleware that will rate limit the amount of concurrent requests the webserver can do at once // Controlled via the sem channel which has a capacity defined by the limit that is in the Caddyfile
[ "Middleware", "that", "will", "rate", "limit", "the", "amount", "of", "concurrent", "requests", "the", "webserver", "can", "do", "at", "once", "Controlled", "via", "the", "sem", "channel", "which", "has", "a", "capacity", "defined", "by", "the", "limit", "th...
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/requestlimit/requestlimit.go#L64-L72
30,255
inverse-inc/packetfence
go/logging/logging.go
NewContext
func NewContext(ctx context.Context) context.Context { u, _ := uuid.NewV4() uStr := u.String() ctx = context.WithValue(ctx, requestUuidKey, uStr) ctx = context.WithValue(ctx, processPidKey, strconv.Itoa(os.Getpid())) ctx = context.WithValue(ctx, additionnalLogElementsKey, make(map[interface{}]interface{})) return...
go
func NewContext(ctx context.Context) context.Context { u, _ := uuid.NewV4() uStr := u.String() ctx = context.WithValue(ctx, requestUuidKey, uStr) ctx = context.WithValue(ctx, processPidKey, strconv.Itoa(os.Getpid())) ctx = context.WithValue(ctx, additionnalLogElementsKey, make(map[interface{}]interface{})) return...
[ "func", "NewContext", "(", "ctx", "context", ".", "Context", ")", "context", ".", "Context", "{", "u", ",", "_", ":=", "uuid", ".", "NewV4", "(", ")", "\n", "uStr", ":=", "u", ".", "String", "(", ")", "\n", "ctx", "=", "context", ".", "WithValue", ...
// Grab a context that includes a UUID of the request for logging purposes
[ "Grab", "a", "context", "that", "includes", "a", "UUID", "of", "the", "request", "for", "logging", "purposes" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/logging/logging.go#L38-L45
30,256
inverse-inc/packetfence
go/caddy/forwardproxy/forwardproxy.go
dualStream
func dualStream(w1 io.Writer, r1 io.Reader, w2 io.Writer, r2 io.Reader) error { errChan := make(chan error) stream := func(w io.Writer, r io.Reader) { buf := bufferPool.Get().([]byte) buf = buf[0:cap(buf)] _, _err := flushingIoCopy(w, r, buf) errChan <- _err } go stream(w1, r1) go stream(w2, r2) err1 :=...
go
func dualStream(w1 io.Writer, r1 io.Reader, w2 io.Writer, r2 io.Reader) error { errChan := make(chan error) stream := func(w io.Writer, r io.Reader) { buf := bufferPool.Get().([]byte) buf = buf[0:cap(buf)] _, _err := flushingIoCopy(w, r, buf) errChan <- _err } go stream(w1, r1) go stream(w2, r2) err1 :=...
[ "func", "dualStream", "(", "w1", "io", ".", "Writer", ",", "r1", "io", ".", "Reader", ",", "w2", "io", ".", "Writer", ",", "r2", "io", ".", "Reader", ")", "error", "{", "errChan", ":=", "make", "(", "chan", "error", ")", "\n\n", "stream", ":=", "...
// Copies data r1->w1 and r2->w2, flushes as needed, and returns when both streams are done.
[ "Copies", "data", "r1", "-", ">", "w1", "and", "r2", "-", ">", "w2", "flushes", "as", "needed", "and", "returns", "when", "both", "streams", "are", "done", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/forwardproxy/forwardproxy.go#L75-L93
30,257
inverse-inc/packetfence
go/caddy/forwardproxy/forwardproxy.go
serveHijack
func serveHijack(w http.ResponseWriter, targetConn net.Conn) (int, error) { hijacker, ok := w.(http.Hijacker) if !ok { return http.StatusInternalServerError, errors.New("ResponseWriter does not implement Hijacker") } clientConn, bufReader, err := hijacker.Hijack() if err != nil { return http.StatusInternalServ...
go
func serveHijack(w http.ResponseWriter, targetConn net.Conn) (int, error) { hijacker, ok := w.(http.Hijacker) if !ok { return http.StatusInternalServerError, errors.New("ResponseWriter does not implement Hijacker") } clientConn, bufReader, err := hijacker.Hijack() if err != nil { return http.StatusInternalServ...
[ "func", "serveHijack", "(", "w", "http", ".", "ResponseWriter", ",", "targetConn", "net", ".", "Conn", ")", "(", "int", ",", "error", ")", "{", "hijacker", ",", "ok", ":=", "w", ".", "(", "http", ".", "Hijacker", ")", "\n", "if", "!", "ok", "{", ...
// Hijacks the connection from ResponseWriter, writes the response and proxies data between targetConn // and hijacked connection.
[ "Hijacks", "the", "connection", "from", "ResponseWriter", "writes", "the", "response", "and", "proxies", "data", "between", "targetConn", "and", "hijacked", "connection", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/forwardproxy/forwardproxy.go#L97-L134
30,258
inverse-inc/packetfence
go/caddy/forwardproxy/forwardproxy.go
checkCredentials
func (fp *ForwardProxy) checkCredentials(r *http.Request) error { pa := strings.Split(r.Header.Get("Proxy-Authorization"), " ") if len(pa) != 2 { return errors.New("Proxy-Authorization is required! Expected format: <type> <credentials>") } if strings.ToLower(pa[0]) != "basic" { return errors.New("Auth type is n...
go
func (fp *ForwardProxy) checkCredentials(r *http.Request) error { pa := strings.Split(r.Header.Get("Proxy-Authorization"), " ") if len(pa) != 2 { return errors.New("Proxy-Authorization is required! Expected format: <type> <credentials>") } if strings.ToLower(pa[0]) != "basic" { return errors.New("Auth type is n...
[ "func", "(", "fp", "*", "ForwardProxy", ")", "checkCredentials", "(", "r", "*", "http", ".", "Request", ")", "error", "{", "pa", ":=", "strings", ".", "Split", "(", "r", ".", "Header", ".", "Get", "(", "\"", "\"", ")", ",", "\"", "\"", ")", "\n",...
// Returns nil error on successful credentials check.
[ "Returns", "nil", "error", "on", "successful", "credentials", "check", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/forwardproxy/forwardproxy.go#L137-L154
30,259
inverse-inc/packetfence
go/caddy/forwardproxy/forwardproxy.go
isSubdomain
func isSubdomain(s, domain string) bool { if s == domain { return true } if strings.HasSuffix(s, "."+domain) { return true } return false }
go
func isSubdomain(s, domain string) bool { if s == domain { return true } if strings.HasSuffix(s, "."+domain) { return true } return false }
[ "func", "isSubdomain", "(", "s", ",", "domain", "string", ")", "bool", "{", "if", "s", "==", "domain", "{", "return", "true", "\n", "}", "\n", "if", "strings", ".", "HasSuffix", "(", "s", ",", "\"", "\"", "+", "domain", ")", "{", "return", "true", ...
// returns true if `s` is `domain` or subdomain of `domain`. Inputs are expected to be sanitized.
[ "returns", "true", "if", "s", "is", "domain", "or", "subdomain", "of", "domain", ".", "Inputs", "are", "expected", "to", "be", "sanitized", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/forwardproxy/forwardproxy.go#L157-L165
30,260
inverse-inc/packetfence
go/caddy/forwardproxy/forwardproxy.go
forwardResponse
func forwardResponse(w http.ResponseWriter, response *http.Response) error { w.Header().Del("Server") // remove Server: Caddy, append via instead w.Header().Add("Via", strconv.Itoa(response.ProtoMajor)+"."+strconv.Itoa(response.ProtoMinor)+" caddy") for header, values := range response.Header { for _, val := rang...
go
func forwardResponse(w http.ResponseWriter, response *http.Response) error { w.Header().Del("Server") // remove Server: Caddy, append via instead w.Header().Add("Via", strconv.Itoa(response.ProtoMajor)+"."+strconv.Itoa(response.ProtoMinor)+" caddy") for header, values := range response.Header { for _, val := rang...
[ "func", "forwardResponse", "(", "w", "http", ".", "ResponseWriter", ",", "response", "*", "http", ".", "Response", ")", "error", "{", "w", ".", "Header", "(", ")", ".", "Del", "(", "\"", "\"", ")", "// remove Server: Caddy, append via instead", "\n", "w", ...
// Removes hop-by-hop headers, and writes response into ResponseWriter.
[ "Removes", "hop", "-", "by", "-", "hop", "headers", "and", "writes", "response", "into", "ResponseWriter", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/forwardproxy/forwardproxy.go#L304-L320
30,261
inverse-inc/packetfence
go/caddy/forwardproxy/forwardproxy.go
generateForwardRequest
func (fp *ForwardProxy) generateForwardRequest(inReq *http.Request) (*http.Request, error) { // Scheme has to be appended to avoid `unsupported protocol scheme ""` error. // `http://` is used, since this initial request itself is always HTTP, regardless of what client and server // may speak afterwards. if len(inRe...
go
func (fp *ForwardProxy) generateForwardRequest(inReq *http.Request) (*http.Request, error) { // Scheme has to be appended to avoid `unsupported protocol scheme ""` error. // `http://` is used, since this initial request itself is always HTTP, regardless of what client and server // may speak afterwards. if len(inRe...
[ "func", "(", "fp", "*", "ForwardProxy", ")", "generateForwardRequest", "(", "inReq", "*", "http", ".", "Request", ")", "(", "*", "http", ".", "Request", ",", "error", ")", "{", "// Scheme has to be appended to avoid `unsupported protocol scheme \"\"` error.", "// `htt...
// Based on http Request from client, generates new request to be forwarded to target server. // Some fields are shallow-copied, thus genOutReq will mutate original request. // If error is not nil - http.StatusBadRequest is to be sent to client.
[ "Based", "on", "http", "Request", "from", "client", "generates", "new", "request", "to", "be", "forwarded", "to", "target", "server", ".", "Some", "fields", "are", "shallow", "-", "copied", "thus", "genOutReq", "will", "mutate", "original", "request", ".", "...
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/forwardproxy/forwardproxy.go#L325-L357
30,262
inverse-inc/packetfence
go/caddy/caddy/caddyhttp/proxy/proxy.go
createUpstreamRequest
func createUpstreamRequest(r *http.Request) *http.Request { outreq := new(http.Request) *outreq = *r // includes shallow copies of maps, but okay // We should set body to nil explicitly if request body is empty. // For server requests the Request Body is always non-nil. if r.ContentLength == 0 { outreq.Body = ni...
go
func createUpstreamRequest(r *http.Request) *http.Request { outreq := new(http.Request) *outreq = *r // includes shallow copies of maps, but okay // We should set body to nil explicitly if request body is empty. // For server requests the Request Body is always non-nil. if r.ContentLength == 0 { outreq.Body = ni...
[ "func", "createUpstreamRequest", "(", "r", "*", "http", ".", "Request", ")", "*", "http", ".", "Request", "{", "outreq", ":=", "new", "(", "http", ".", "Request", ")", "\n", "*", "outreq", "=", "*", "r", "// includes shallow copies of maps, but okay", "\n", ...
// createUpstremRequest shallow-copies r into a new request // that can be sent upstream. // // Derived from reverseproxy.go in the standard Go httputil package.
[ "createUpstremRequest", "shallow", "-", "copies", "r", "into", "a", "new", "request", "that", "can", "be", "sent", "upstream", ".", "Derived", "from", "reverseproxy", ".", "go", "in", "the", "standard", "Go", "httputil", "package", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/caddyhttp/proxy/proxy.go#L270-L328
30,263
inverse-inc/packetfence
go/caddy/caddy/plugins.go
StartupHooks
func StartupHooks(serverType string) error { for stype, stypePlugins := range plugins { if stype != "" && stype != serverType { continue } for name := range stypePlugins { if stypePlugins[name].StartupHook == nil { continue } err := stypePlugins[name].StartupHook() if err != nil { return...
go
func StartupHooks(serverType string) error { for stype, stypePlugins := range plugins { if stype != "" && stype != serverType { continue } for name := range stypePlugins { if stypePlugins[name].StartupHook == nil { continue } err := stypePlugins[name].StartupHook() if err != nil { return...
[ "func", "StartupHooks", "(", "serverType", "string", ")", "error", "{", "for", "stype", ",", "stypePlugins", ":=", "range", "plugins", "{", "if", "stype", "!=", "\"", "\"", "&&", "stype", "!=", "serverType", "{", "continue", "\n", "}", "\n\n", "for", "na...
// StartupHooks executes the startup hooks defined when the // plugins were registered and returns the first error // it encounters.
[ "StartupHooks", "executes", "the", "startup", "hooks", "defined", "when", "the", "plugins", "were", "registered", "and", "returns", "the", "first", "error", "it", "encounters", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/plugins.go#L75-L94
30,264
inverse-inc/packetfence
go/caddy/caddy/caddyhttp/browse/browse.go
BreadcrumbMap
func (l Listing) BreadcrumbMap() map[string]string { result := map[string]string{} if len(l.Path) == 0 { return result } // skip trailing slash lpath := l.Path if lpath[len(lpath)-1] == '/' { lpath = lpath[:len(lpath)-1] } parts := strings.Split(lpath, "/") for i, part := range parts { if i == 0 && pa...
go
func (l Listing) BreadcrumbMap() map[string]string { result := map[string]string{} if len(l.Path) == 0 { return result } // skip trailing slash lpath := l.Path if lpath[len(lpath)-1] == '/' { lpath = lpath[:len(lpath)-1] } parts := strings.Split(lpath, "/") for i, part := range parts { if i == 0 && pa...
[ "func", "(", "l", "Listing", ")", "BreadcrumbMap", "(", ")", "map", "[", "string", "]", "string", "{", "result", ":=", "map", "[", "string", "]", "string", "{", "}", "\n\n", "if", "len", "(", "l", ".", "Path", ")", "==", "0", "{", "return", "resu...
// BreadcrumbMap returns l.Path where every element is a map // of URLs and path segment names.
[ "BreadcrumbMap", "returns", "l", ".", "Path", "where", "every", "element", "is", "a", "map", "of", "URLs", "and", "path", "segment", "names", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/caddyhttp/browse/browse.go#L82-L106
30,265
inverse-inc/packetfence
go/caddy/caddy/caddyhttp/browse/browse.go
applySort
func (l Listing) applySort() { // Check '.Order' to know how to sort if l.Order == "desc" { switch l.Sort { case sortByName: sort.Sort(sort.Reverse(byName(l))) case sortBySize: sort.Sort(sort.Reverse(bySize(l))) case sortByTime: sort.Sort(sort.Reverse(byTime(l))) default: // If not one of the ab...
go
func (l Listing) applySort() { // Check '.Order' to know how to sort if l.Order == "desc" { switch l.Sort { case sortByName: sort.Sort(sort.Reverse(byName(l))) case sortBySize: sort.Sort(sort.Reverse(bySize(l))) case sortByTime: sort.Sort(sort.Reverse(byTime(l))) default: // If not one of the ab...
[ "func", "(", "l", "Listing", ")", "applySort", "(", ")", "{", "// Check '.Order' to know how to sort", "if", "l", ".", "Order", "==", "\"", "\"", "{", "switch", "l", ".", "Sort", "{", "case", "sortByName", ":", "sort", ".", "Sort", "(", "sort", ".", "R...
// Add sorting method to "Listing" // it will apply what's in ".Sort" and ".Order"
[ "Add", "sorting", "method", "to", "Listing", "it", "will", "apply", "what", "s", "in", ".", "Sort", "and", ".", "Order" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/caddyhttp/browse/browse.go#L166-L193
30,266
inverse-inc/packetfence
go/caddy/caddy/caddyhttp/browse/browse.go
ServeHTTP
func (b Browse) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) { // See if there's a browse configuration to match the path var bc *Config for i := range b.Configs { if httpserver.Path(r.URL.Path).Matches(b.Configs[i].PathScope) { bc = &b.Configs[i] break } } if bc == nil { return b.Nex...
go
func (b Browse) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) { // See if there's a browse configuration to match the path var bc *Config for i := range b.Configs { if httpserver.Path(r.URL.Path).Matches(b.Configs[i].PathScope) { bc = &b.Configs[i] break } } if bc == nil { return b.Nex...
[ "func", "(", "b", "Browse", ")", "ServeHTTP", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "(", "int", ",", "error", ")", "{", "// See if there's a browse configuration to match the path", "var", "bc", "*", "Config", "...
// ServeHTTP determines if the request is for this plugin, and if all prerequisites are met. // If so, control is handed over to ServeListing.
[ "ServeHTTP", "determines", "if", "the", "request", "is", "for", "this", "plugin", "and", "if", "all", "prerequisites", "are", "met", ".", "If", "so", "control", "is", "handed", "over", "to", "ServeListing", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/caddyhttp/browse/browse.go#L247-L307
30,267
inverse-inc/packetfence
go/caddy/caddy/sigtrap.go
executeShutdownCallbacks
func executeShutdownCallbacks(signame string) (exitCode int) { shutdownCallbacksOnce.Do(func() { errs := allShutdownCallbacks() if len(errs) > 0 { for _, err := range errs { log.Printf("[ERROR] %s shutdown: %v", signame, err) } exitCode = 1 } }) return }
go
func executeShutdownCallbacks(signame string) (exitCode int) { shutdownCallbacksOnce.Do(func() { errs := allShutdownCallbacks() if len(errs) > 0 { for _, err := range errs { log.Printf("[ERROR] %s shutdown: %v", signame, err) } exitCode = 1 } }) return }
[ "func", "executeShutdownCallbacks", "(", "signame", "string", ")", "(", "exitCode", "int", ")", "{", "shutdownCallbacksOnce", ".", "Do", "(", "func", "(", ")", "{", "errs", ":=", "allShutdownCallbacks", "(", ")", "\n", "if", "len", "(", "errs", ")", ">", ...
// executeShutdownCallbacks executes the shutdown callbacks as initiated // by signame. It logs any errors and returns the recommended exit status. // This function is idempotent; subsequent invocations always return 0.
[ "executeShutdownCallbacks", "executes", "the", "shutdown", "callbacks", "as", "initiated", "by", "signame", ".", "It", "logs", "any", "errors", "and", "returns", "the", "recommended", "exit", "status", ".", "This", "function", "is", "idempotent", ";", "subsequent"...
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/sigtrap.go#L53-L64
30,268
inverse-inc/packetfence
go/caddy/caddy/caddyhttp/httpserver/plugin.go
standardizeAddress
func standardizeAddress(str string) (Address, error) { input := str // Split input into components (prepend with // to assert host by default) if !strings.Contains(str, "//") && !strings.HasPrefix(str, "/") { str = "//" + str } u, err := url.Parse(str) if err != nil { return Address{}, err } // separate h...
go
func standardizeAddress(str string) (Address, error) { input := str // Split input into components (prepend with // to assert host by default) if !strings.Contains(str, "//") && !strings.HasPrefix(str, "/") { str = "//" + str } u, err := url.Parse(str) if err != nil { return Address{}, err } // separate h...
[ "func", "standardizeAddress", "(", "str", "string", ")", "(", "Address", ",", "error", ")", "{", "input", ":=", "str", "\n\n", "// Split input into components (prepend with // to assert host by default)", "if", "!", "strings", ".", "Contains", "(", "str", ",", "\"",...
// standardizeAddress parses an address string into a structured format with separate // scheme, host, port, and path portions, as well as the original input string.
[ "standardizeAddress", "parses", "an", "address", "string", "into", "a", "structured", "format", "with", "separate", "scheme", "host", "port", "and", "path", "portions", "as", "well", "as", "the", "original", "input", "string", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/caddyhttp/httpserver/plugin.go#L306-L356
30,269
inverse-inc/packetfence
go/caddy/caddy/caddyhttp/httpserver/logger.go
Close
func (l *Logger) Close() error { // Will close local/remote syslog connections too :) if closer, ok := l.writer.(io.WriteCloser); ok { l.fileMu.Lock() err := closer.Close() l.fileMu.Unlock() return err } return nil }
go
func (l *Logger) Close() error { // Will close local/remote syslog connections too :) if closer, ok := l.writer.(io.WriteCloser); ok { l.fileMu.Lock() err := closer.Close() l.fileMu.Unlock() return err } return nil }
[ "func", "(", "l", "*", "Logger", ")", "Close", "(", ")", "error", "{", "// Will close local/remote syslog connections too :)", "if", "closer", ",", "ok", ":=", "l", ".", "writer", ".", "(", "io", ".", "WriteCloser", ")", ";", "ok", "{", "l", ".", "fileMu...
// Close closes open log files or connections to syslog.
[ "Close", "closes", "open", "log", "files", "or", "connections", "to", "syslog", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/caddyhttp/httpserver/logger.go#L138-L148
30,270
inverse-inc/packetfence
go/coredns/core/dnsserver/address.go
Transport
func Transport(s string) string { switch { case strings.HasPrefix(s, TransportTLS+"://"): return TransportTLS case strings.HasPrefix(s, TransportDNS+"://"): return TransportDNS case strings.HasPrefix(s, TransportGRPC+"://"): return TransportGRPC } return TransportDNS }
go
func Transport(s string) string { switch { case strings.HasPrefix(s, TransportTLS+"://"): return TransportTLS case strings.HasPrefix(s, TransportDNS+"://"): return TransportDNS case strings.HasPrefix(s, TransportGRPC+"://"): return TransportGRPC } return TransportDNS }
[ "func", "Transport", "(", "s", "string", ")", "string", "{", "switch", "{", "case", "strings", ".", "HasPrefix", "(", "s", ",", "TransportTLS", "+", "\"", "\"", ")", ":", "return", "TransportTLS", "\n", "case", "strings", ".", "HasPrefix", "(", "s", ",...
// Transport returns the protocol of the string s
[ "Transport", "returns", "the", "protocol", "of", "the", "string", "s" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/coredns/core/dnsserver/address.go#L23-L33
30,271
inverse-inc/packetfence
go/coredns/core/dnsserver/address.go
normalizeZone
func normalizeZone(str string) (zoneAddr, error) { var err error // Default to DNS if there isn't a transport protocol prefix. trans := TransportDNS switch { case strings.HasPrefix(str, TransportTLS+"://"): trans = TransportTLS str = str[len(TransportTLS+"://"):] case strings.HasPrefix(str, TransportDNS+":/...
go
func normalizeZone(str string) (zoneAddr, error) { var err error // Default to DNS if there isn't a transport protocol prefix. trans := TransportDNS switch { case strings.HasPrefix(str, TransportTLS+"://"): trans = TransportTLS str = str[len(TransportTLS+"://"):] case strings.HasPrefix(str, TransportDNS+":/...
[ "func", "normalizeZone", "(", "str", "string", ")", "(", "zoneAddr", ",", "error", ")", "{", "var", "err", "error", "\n\n", "// Default to DNS if there isn't a transport protocol prefix.", "trans", ":=", "TransportDNS", "\n\n", "switch", "{", "case", "strings", ".",...
// normalizeZone parses an zone string into a structured format with separate // host, and port portions, as well as the original input string.
[ "normalizeZone", "parses", "an", "zone", "string", "into", "a", "structured", "format", "with", "separate", "host", "and", "port", "portions", "as", "well", "as", "the", "original", "input", "string", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/coredns/core/dnsserver/address.go#L37-L73
30,272
inverse-inc/packetfence
go/caddy/caddy/caddyhttp/proxy/reverseproxy.go
cloneTLSClientConfig
func cloneTLSClientConfig(cfg *tls.Config) *tls.Config { if cfg == nil { return &tls.Config{} } return &tls.Config{ Rand: cfg.Rand, Time: cfg.Time, Certificates: cfg.Certificates, NameToCertificate: cfg.NameToCertificate, GetCertifica...
go
func cloneTLSClientConfig(cfg *tls.Config) *tls.Config { if cfg == nil { return &tls.Config{} } return &tls.Config{ Rand: cfg.Rand, Time: cfg.Time, Certificates: cfg.Certificates, NameToCertificate: cfg.NameToCertificate, GetCertifica...
[ "func", "cloneTLSClientConfig", "(", "cfg", "*", "tls", ".", "Config", ")", "*", "tls", ".", "Config", "{", "if", "cfg", "==", "nil", "{", "return", "&", "tls", ".", "Config", "{", "}", "\n", "}", "\n", "return", "&", "tls", ".", "Config", "{", "...
// cloneTLSClientConfig is like cloneTLSConfig but omits // the fields SessionTicketsDisabled and SessionTicketKey. // This makes it safe to call cloneTLSClientConfig on a config // in active use by a server.
[ "cloneTLSClientConfig", "is", "like", "cloneTLSConfig", "but", "omits", "the", "fields", "SessionTicketsDisabled", "and", "SessionTicketKey", ".", "This", "makes", "it", "safe", "to", "call", "cloneTLSClientConfig", "on", "a", "config", "in", "active", "use", "by", ...
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/caddyhttp/proxy/reverseproxy.go#L555-L580
30,273
inverse-inc/packetfence
go/coredns/plugin/auto/walk.go
matches
func matches(re *regexp.Regexp, filename, template string) (match bool, origin string) { base := path.Base(filename) matches := re.FindStringSubmatchIndex(base) if matches == nil { return false, "" } by := re.ExpandString(nil, template, base, matches) if by == nil { return false, "" } origin = dns.Fqdn(s...
go
func matches(re *regexp.Regexp, filename, template string) (match bool, origin string) { base := path.Base(filename) matches := re.FindStringSubmatchIndex(base) if matches == nil { return false, "" } by := re.ExpandString(nil, template, base, matches) if by == nil { return false, "" } origin = dns.Fqdn(s...
[ "func", "matches", "(", "re", "*", "regexp", ".", "Regexp", ",", "filename", ",", "template", "string", ")", "(", "match", "bool", ",", "origin", "string", ")", "{", "base", ":=", "path", ".", "Base", "(", "filename", ")", "\n\n", "matches", ":=", "r...
// matches matches re to filename, if is is a match, the subexpression will be used to expand // template to an origin. When match is true that origin is returned. Origin is fully qualified.
[ "matches", "matches", "re", "to", "filename", "if", "is", "is", "a", "match", "the", "subexpression", "will", "be", "used", "to", "expand", "template", "to", "an", "origin", ".", "When", "match", "is", "true", "that", "origin", "is", "returned", ".", "Or...
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/coredns/plugin/auto/walk.go#L93-L109
30,274
inverse-inc/packetfence
go/caddy/caddy/caddyhttp/httpserver/graceful.go
Accept
func (gl *gracefulListener) Accept() (c net.Conn, err error) { c, err = gl.Listener.Accept() if err != nil { return } c = gracefulConn{Conn: c, connWg: gl.connWg} gl.connWg.Add(1) return }
go
func (gl *gracefulListener) Accept() (c net.Conn, err error) { c, err = gl.Listener.Accept() if err != nil { return } c = gracefulConn{Conn: c, connWg: gl.connWg} gl.connWg.Add(1) return }
[ "func", "(", "gl", "*", "gracefulListener", ")", "Accept", "(", ")", "(", "c", "net", ".", "Conn", ",", "err", "error", ")", "{", "c", ",", "err", "=", "gl", ".", "Listener", ".", "Accept", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return...
// Accept accepts a connection.
[ "Accept", "accepts", "a", "connection", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/caddyhttp/httpserver/graceful.go#L39-L47
30,275
inverse-inc/packetfence
go/caddy/caddy/caddyhttp/httpserver/graceful.go
Close
func (gl *gracefulListener) Close() error { gl.Lock() if gl.stopped { gl.Unlock() return syscall.EINVAL } gl.Unlock() gl.stop <- nil return <-gl.stop }
go
func (gl *gracefulListener) Close() error { gl.Lock() if gl.stopped { gl.Unlock() return syscall.EINVAL } gl.Unlock() gl.stop <- nil return <-gl.stop }
[ "func", "(", "gl", "*", "gracefulListener", ")", "Close", "(", ")", "error", "{", "gl", ".", "Lock", "(", ")", "\n", "if", "gl", ".", "stopped", "{", "gl", ".", "Unlock", "(", ")", "\n", "return", "syscall", ".", "EINVAL", "\n", "}", "\n", "gl", ...
// Close immediately closes the listener.
[ "Close", "immediately", "closes", "the", "listener", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/caddyhttp/httpserver/graceful.go#L50-L59
30,276
inverse-inc/packetfence
go/caddy/caddy/caddyhttp/httpserver/graceful.go
Close
func (c gracefulConn) Close() error { err := c.Conn.Close() if err != nil { return err } // close can fail on http2 connections (as of Oct. 2015, before http2 in std lib) // so don't decrement count unless close succeeds c.connWg.Done() return nil }
go
func (c gracefulConn) Close() error { err := c.Conn.Close() if err != nil { return err } // close can fail on http2 connections (as of Oct. 2015, before http2 in std lib) // so don't decrement count unless close succeeds c.connWg.Done() return nil }
[ "func", "(", "c", "gracefulConn", ")", "Close", "(", ")", "error", "{", "err", ":=", "c", ".", "Conn", ".", "Close", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "// close can fail on http2 connections (as of Oct. 2015, ...
// Close closes c's underlying connection while updating the wg count.
[ "Close", "closes", "c", "s", "underlying", "connection", "while", "updating", "the", "wg", "count", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/caddyhttp/httpserver/graceful.go#L71-L80
30,277
inverse-inc/packetfence
go/caddy/caddy/controller.go
OnRestart
func (c *Controller) OnRestart(fn func() error) { c.instance.onRestart = append(c.instance.onRestart, fn) }
go
func (c *Controller) OnRestart(fn func() error) { c.instance.onRestart = append(c.instance.onRestart, fn) }
[ "func", "(", "c", "*", "Controller", ")", "OnRestart", "(", "fn", "func", "(", ")", "error", ")", "{", "c", ".", "instance", ".", "onRestart", "=", "append", "(", "c", ".", "instance", ".", "onRestart", ",", "fn", ")", "\n", "}" ]
// OnRestart adds fn to the list of callback functions to execute // when the server is about to be restarted.
[ "OnRestart", "adds", "fn", "to", "the", "list", "of", "callback", "functions", "to", "execute", "when", "the", "server", "is", "about", "to", "be", "restarted", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/controller.go#L71-L73
30,278
inverse-inc/packetfence
go/caddy/caddy/controller.go
OnFinalShutdown
func (c *Controller) OnFinalShutdown(fn func() error) { c.instance.onFinalShutdown = append(c.instance.onFinalShutdown, fn) }
go
func (c *Controller) OnFinalShutdown(fn func() error) { c.instance.onFinalShutdown = append(c.instance.onFinalShutdown, fn) }
[ "func", "(", "c", "*", "Controller", ")", "OnFinalShutdown", "(", "fn", "func", "(", ")", "error", ")", "{", "c", ".", "instance", ".", "onFinalShutdown", "=", "append", "(", "c", ".", "instance", ".", "onFinalShutdown", ",", "fn", ")", "\n", "}" ]
// OnFinalShutdown adds fn to the list of callback functions to execute // when the server is about to be shut down NOT as part of a restart.
[ "OnFinalShutdown", "adds", "fn", "to", "the", "list", "of", "callback", "functions", "to", "execute", "when", "the", "server", "is", "about", "to", "be", "shut", "down", "NOT", "as", "part", "of", "a", "restart", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/controller.go#L83-L85
30,279
inverse-inc/packetfence
go/coredns/plugin/hosts/hostsfile.go
parse
func (h *Hostsfile) parse(r io.Reader, override *hostsMap) *hostsMap { hmap := newHostsMap() scanner := bufio.NewScanner(r) for scanner.Scan() { line := scanner.Bytes() if i := bytes.Index(line, []byte{'#'}); i >= 0 { // Discard comments. line = line[0:i] } f := bytes.Fields(line) if len(f) < 2 { ...
go
func (h *Hostsfile) parse(r io.Reader, override *hostsMap) *hostsMap { hmap := newHostsMap() scanner := bufio.NewScanner(r) for scanner.Scan() { line := scanner.Bytes() if i := bytes.Index(line, []byte{'#'}); i >= 0 { // Discard comments. line = line[0:i] } f := bytes.Fields(line) if len(f) < 2 { ...
[ "func", "(", "h", "*", "Hostsfile", ")", "parse", "(", "r", "io", ".", "Reader", ",", "override", "*", "hostsMap", ")", "*", "hostsMap", "{", "hmap", ":=", "newHostsMap", "(", ")", "\n\n", "scanner", ":=", "bufio", ".", "NewScanner", "(", "r", ")", ...
// Parse reads the hostsfile and populates the byName and byAddr maps.
[ "Parse", "reads", "the", "hostsfile", "and", "populates", "the", "byName", "and", "byAddr", "maps", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/coredns/plugin/hosts/hostsfile.go#L117-L169
30,280
inverse-inc/packetfence
go/coredns/plugin/hosts/hostsfile.go
LookupStaticAddr
func (h *Hostsfile) LookupStaticAddr(addr string) []string { h.RLock() defer h.RUnlock() addr = parseLiteralIP(addr).String() if addr == "" { return nil } if len(h.hmap.byAddr) != 0 { if hosts, ok := h.hmap.byAddr[addr]; ok { hostsCp := make([]string, len(hosts)) copy(hostsCp, hosts) return hostsCp ...
go
func (h *Hostsfile) LookupStaticAddr(addr string) []string { h.RLock() defer h.RUnlock() addr = parseLiteralIP(addr).String() if addr == "" { return nil } if len(h.hmap.byAddr) != 0 { if hosts, ok := h.hmap.byAddr[addr]; ok { hostsCp := make([]string, len(hosts)) copy(hostsCp, hosts) return hostsCp ...
[ "func", "(", "h", "*", "Hostsfile", ")", "LookupStaticAddr", "(", "addr", "string", ")", "[", "]", "string", "{", "h", ".", "RLock", "(", ")", "\n", "defer", "h", ".", "RUnlock", "(", ")", "\n", "addr", "=", "parseLiteralIP", "(", "addr", ")", ".",...
// LookupStaticAddr looks up the hosts for the given address from the hosts file.
[ "LookupStaticAddr", "looks", "up", "the", "hosts", "for", "the", "given", "address", "from", "the", "hosts", "file", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/coredns/plugin/hosts/hostsfile.go#L213-L228
30,281
inverse-inc/packetfence
go/coredns/plugin/cache/cache.go
key
func key(m *dns.Msg, t response.Type, do bool) int { // We don't store truncated responses. if m.Truncated { return -1 } // Nor errors or Meta or Update if t == response.OtherError || t == response.Meta || t == response.Update { return -1 } return int(hash(m.Question[0].Name, m.Question[0].Qtype, do)) }
go
func key(m *dns.Msg, t response.Type, do bool) int { // We don't store truncated responses. if m.Truncated { return -1 } // Nor errors or Meta or Update if t == response.OtherError || t == response.Meta || t == response.Update { return -1 } return int(hash(m.Question[0].Name, m.Question[0].Qtype, do)) }
[ "func", "key", "(", "m", "*", "dns", ".", "Msg", ",", "t", "response", ".", "Type", ",", "do", "bool", ")", "int", "{", "// We don't store truncated responses.", "if", "m", ".", "Truncated", "{", "return", "-", "1", "\n", "}", "\n", "// Nor errors or Met...
// Return key under which we store the item, -1 will be returned if we don't store the // message. // Currently we do not cache Truncated, errors zone transfers or dynamic update messages.
[ "Return", "key", "under", "which", "we", "store", "the", "item", "-", "1", "will", "be", "returned", "if", "we", "don", "t", "store", "the", "message", ".", "Currently", "we", "do", "not", "cache", "Truncated", "errors", "zone", "transfers", "or", "dynam...
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/coredns/plugin/cache/cache.go#L40-L51
30,282
inverse-inc/packetfence
go/caddy/caddy/startupshutdown/startupshutdown.go
registerCallback
func registerCallback(c *caddy.Controller, registerFunc func(func() error)) error { var funcs []func() error for c.Next() { args := c.RemainingArgs() if len(args) == 0 { return c.ArgErr() } nonblock := false if len(args) > 1 && args[len(args)-1] == "&" { // Run command in background; non-blocking ...
go
func registerCallback(c *caddy.Controller, registerFunc func(func() error)) error { var funcs []func() error for c.Next() { args := c.RemainingArgs() if len(args) == 0 { return c.ArgErr() } nonblock := false if len(args) > 1 && args[len(args)-1] == "&" { // Run command in background; non-blocking ...
[ "func", "registerCallback", "(", "c", "*", "caddy", ".", "Controller", ",", "registerFunc", "func", "(", "func", "(", ")", "error", ")", ")", "error", "{", "var", "funcs", "[", "]", "func", "(", ")", "error", "\n\n", "for", "c", ".", "Next", "(", "...
// registerCallback registers a callback function to execute by // using c to parse the directive. It registers the callback // to be executed using registerFunc.
[ "registerCallback", "registers", "a", "callback", "function", "to", "execute", "by", "using", "c", "to", "parse", "the", "directive", ".", "It", "registers", "the", "callback", "to", "be", "executed", "using", "registerFunc", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/startupshutdown/startupshutdown.go#L30-L73
30,283
inverse-inc/packetfence
go/coredns/plugin/dnstap/msg/msg.go
AddrMsg
func (b *Builder) AddrMsg(a net.Addr, m *dns.Msg) (err error) { err = b.RemoteAddr(a) if err != nil { return } return b.Msg(m) }
go
func (b *Builder) AddrMsg(a net.Addr, m *dns.Msg) (err error) { err = b.RemoteAddr(a) if err != nil { return } return b.Msg(m) }
[ "func", "(", "b", "*", "Builder", ")", "AddrMsg", "(", "a", "net", ".", "Addr", ",", "m", "*", "dns", ".", "Msg", ")", "(", "err", "error", ")", "{", "err", "=", "b", ".", "RemoteAddr", "(", "a", ")", "\n", "if", "err", "!=", "nil", "{", "r...
// AddrMsg parses the info of net.Addr and dns.Msg.
[ "AddrMsg", "parses", "the", "info", "of", "net", ".", "Addr", "and", "dns", ".", "Msg", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/coredns/plugin/dnstap/msg/msg.go#L20-L26
30,284
inverse-inc/packetfence
go/coredns/plugin/dnstap/msg/msg.go
Msg
func (b *Builder) Msg(m *dns.Msg) (err error) { if b.Full { err = b.Pack(m) } return }
go
func (b *Builder) Msg(m *dns.Msg) (err error) { if b.Full { err = b.Pack(m) } return }
[ "func", "(", "b", "*", "Builder", ")", "Msg", "(", "m", "*", "dns", ".", "Msg", ")", "(", "err", "error", ")", "{", "if", "b", ".", "Full", "{", "err", "=", "b", ".", "Pack", "(", "m", ")", "\n", "}", "\n", "return", "\n", "}" ]
// Msg parses the info of dns.Msg.
[ "Msg", "parses", "the", "info", "of", "dns", ".", "Msg", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/coredns/plugin/dnstap/msg/msg.go#L29-L34
30,285
inverse-inc/packetfence
go/coredns/plugin/dnstap/msg/msg.go
HostPort
func (d *Data) HostPort(addr string) error { ip, port, err := net.SplitHostPort(addr) if err != nil { return err } p, err := strconv.ParseUint(port, 10, 32) if err != nil { return err } d.Port = uint32(p) if ip := net.ParseIP(ip); ip != nil { d.Address = []byte(ip) if ip := ip.To4(); ip != nil { d.S...
go
func (d *Data) HostPort(addr string) error { ip, port, err := net.SplitHostPort(addr) if err != nil { return err } p, err := strconv.ParseUint(port, 10, 32) if err != nil { return err } d.Port = uint32(p) if ip := net.ParseIP(ip); ip != nil { d.Address = []byte(ip) if ip := ip.To4(); ip != nil { d.S...
[ "func", "(", "d", "*", "Data", ")", "HostPort", "(", "addr", "string", ")", "error", "{", "ip", ",", "port", ",", "err", ":=", "net", ".", "SplitHostPort", "(", "addr", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", ...
// HostPort decodes into Data any string returned by dnsutil.ParseHostPortOrFile.
[ "HostPort", "decodes", "into", "Data", "any", "string", "returned", "by", "dnsutil", ".", "ParseHostPortOrFile", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/coredns/plugin/dnstap/msg/msg.go#L48-L69
30,286
inverse-inc/packetfence
go/coredns/plugin/dnstap/msg/msg.go
RemoteAddr
func (d *Data) RemoteAddr(remote net.Addr) error { switch addr := remote.(type) { case *net.TCPAddr: d.Address = addr.IP d.Port = uint32(addr.Port) d.SocketProto = tap.SocketProtocol_TCP case *net.UDPAddr: d.Address = addr.IP d.Port = uint32(addr.Port) d.SocketProto = tap.SocketProtocol_UDP default: r...
go
func (d *Data) RemoteAddr(remote net.Addr) error { switch addr := remote.(type) { case *net.TCPAddr: d.Address = addr.IP d.Port = uint32(addr.Port) d.SocketProto = tap.SocketProtocol_TCP case *net.UDPAddr: d.Address = addr.IP d.Port = uint32(addr.Port) d.SocketProto = tap.SocketProtocol_UDP default: r...
[ "func", "(", "d", "*", "Data", ")", "RemoteAddr", "(", "remote", "net", ".", "Addr", ")", "error", "{", "switch", "addr", ":=", "remote", ".", "(", "type", ")", "{", "case", "*", "net", ".", "TCPAddr", ":", "d", ".", "Address", "=", "addr", ".", ...
// RemoteAddr parses the information about the remote address into Data.
[ "RemoteAddr", "parses", "the", "information", "about", "the", "remote", "address", "into", "Data", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/coredns/plugin/dnstap/msg/msg.go#L72-L93
30,287
inverse-inc/packetfence
go/coredns/plugin/dnstap/msg/msg.go
Pack
func (d *Data) Pack(m *dns.Msg) error { packed, err := m.Pack() if err != nil { return err } d.Packed = packed return nil }
go
func (d *Data) Pack(m *dns.Msg) error { packed, err := m.Pack() if err != nil { return err } d.Packed = packed return nil }
[ "func", "(", "d", "*", "Data", ")", "Pack", "(", "m", "*", "dns", ".", "Msg", ")", "error", "{", "packed", ",", "err", ":=", "m", ".", "Pack", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "d", ".", "Packe...
// Pack encodes the DNS message into Data.
[ "Pack", "encodes", "the", "DNS", "message", "into", "Data", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/coredns/plugin/dnstap/msg/msg.go#L96-L103
30,288
inverse-inc/packetfence
go/coredns/plugin/proxy/google.go
newUpstream
func newUpstream(hosts []string, old *staticUpstream) Upstream { upstream := &staticUpstream{ from: old.from, HealthCheck: healthcheck.HealthCheck{ FailTimeout: 5 * time.Second, MaxFails: 3, }, ex: old.ex, IgnoredSubDomains: old.IgnoredSubDomains, } upstream.Hosts = make([]*healthc...
go
func newUpstream(hosts []string, old *staticUpstream) Upstream { upstream := &staticUpstream{ from: old.from, HealthCheck: healthcheck.HealthCheck{ FailTimeout: 5 * time.Second, MaxFails: 3, }, ex: old.ex, IgnoredSubDomains: old.IgnoredSubDomains, } upstream.Hosts = make([]*healthc...
[ "func", "newUpstream", "(", "hosts", "[", "]", "string", ",", "old", "*", "staticUpstream", ")", "Upstream", "{", "upstream", ":=", "&", "staticUpstream", "{", "from", ":", "old", ".", "from", ",", "HealthCheck", ":", "healthcheck", ".", "HealthCheck", "{"...
// newUpstream returns an upstream initialized with hosts.
[ "newUpstream", "returns", "an", "upstream", "initialized", "with", "hosts", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/coredns/plugin/proxy/google.go#L191-L214
30,289
inverse-inc/packetfence
go/caddy/caddy/caddyfile/parse.go
replaceEnvReferences
func replaceEnvReferences(s, refStart, refEnd string) string { index := strings.Index(s, refStart) for index != -1 { endIndex := strings.Index(s, refEnd) if endIndex != -1 { ref := s[index : endIndex+len(refEnd)] s = strings.Replace(s, ref, os.Getenv(ref[len(refStart):len(ref)-len(refEnd)]), -1) } else { ...
go
func replaceEnvReferences(s, refStart, refEnd string) string { index := strings.Index(s, refStart) for index != -1 { endIndex := strings.Index(s, refEnd) if endIndex != -1 { ref := s[index : endIndex+len(refEnd)] s = strings.Replace(s, ref, os.Getenv(ref[len(refStart):len(ref)-len(refEnd)]), -1) } else { ...
[ "func", "replaceEnvReferences", "(", "s", ",", "refStart", ",", "refEnd", "string", ")", "string", "{", "index", ":=", "strings", ".", "Index", "(", "s", ",", "refStart", ")", "\n", "for", "index", "!=", "-", "1", "{", "endIndex", ":=", "strings", ".",...
// replaceEnvReferences performs the actual replacement of env variables // in s, given the placeholder start and placeholder end strings.
[ "replaceEnvReferences", "performs", "the", "actual", "replacement", "of", "env", "variables", "in", "s", "given", "the", "placeholder", "start", "and", "placeholder", "end", "strings", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/caddyfile/parse.go#L396-L409
30,290
inverse-inc/packetfence
go/caddy/caddy/caddyhttp/httpserver/https.go
redirPlaintextHost
func redirPlaintextHost(cfg *SiteConfig) *SiteConfig { redirPort := cfg.Addr.Port if redirPort == "443" { // default port is redundant redirPort = "" } redirMiddleware := func(next Handler) Handler { return HandlerFunc(func(w http.ResponseWriter, r *http.Request) (int, error) { toURL := "https://" + r.Host...
go
func redirPlaintextHost(cfg *SiteConfig) *SiteConfig { redirPort := cfg.Addr.Port if redirPort == "443" { // default port is redundant redirPort = "" } redirMiddleware := func(next Handler) Handler { return HandlerFunc(func(w http.ResponseWriter, r *http.Request) (int, error) { toURL := "https://" + r.Host...
[ "func", "redirPlaintextHost", "(", "cfg", "*", "SiteConfig", ")", "*", "SiteConfig", "{", "redirPort", ":=", "cfg", ".", "Addr", ".", "Port", "\n", "if", "redirPort", "==", "\"", "\"", "{", "// default port is redundant", "redirPort", "=", "\"", "\"", "\n", ...
// redirPlaintextHost returns a new plaintext HTTP configuration for // a virtualHost that simply redirects to cfg, which is assumed to // be the HTTPS configuration. The returned configuration is set // to listen on port 80. The TLS field of cfg must not be nil.
[ "redirPlaintextHost", "returns", "a", "new", "plaintext", "HTTP", "configuration", "for", "a", "virtualHost", "that", "simply", "redirects", "to", "cfg", "which", "is", "assumed", "to", "be", "the", "HTTPS", "configuration", ".", "The", "returned", "configuration"...
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/caddy/caddyhttp/httpserver/https.go#L139-L166
30,291
inverse-inc/packetfence
go/coredns/plugin/metrics/vars/report.go
Report
func Report(req request.Request, zone, rcode string, size int, start time.Time) { // Proto and Family. net := req.Proto() fam := "1" if req.Family() == 2 { fam = "2" } typ := req.QType() RequestCount.WithLabelValues(zone, net, fam).Inc() RequestDuration.WithLabelValues(zone).Observe(float64(time.Since(start...
go
func Report(req request.Request, zone, rcode string, size int, start time.Time) { // Proto and Family. net := req.Proto() fam := "1" if req.Family() == 2 { fam = "2" } typ := req.QType() RequestCount.WithLabelValues(zone, net, fam).Inc() RequestDuration.WithLabelValues(zone).Observe(float64(time.Since(start...
[ "func", "Report", "(", "req", "request", ".", "Request", ",", "zone", ",", "rcode", "string", ",", "size", "int", ",", "start", "time", ".", "Time", ")", "{", "// Proto and Family.", "net", ":=", "req", ".", "Proto", "(", ")", "\n", "fam", ":=", "\""...
// Report reports the metrics data associcated with request.
[ "Report", "reports", "the", "metrics", "data", "associcated", "with", "request", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/coredns/plugin/metrics/vars/report.go#L12-L39
30,292
inverse-inc/packetfence
go/caddy/api-aaa/api-aaa.go
setup
func setup(c *caddy.Controller) error { ctx := log.LoggerNewContext(context.Background()) apiAAA, err := buildApiAAAHandler(ctx) if err != nil { return err } httpserver.GetConfig(c).AddMiddleware(func(next httpserver.Handler) httpserver.Handler { apiAAA.Next = next return apiAAA }) return nil }
go
func setup(c *caddy.Controller) error { ctx := log.LoggerNewContext(context.Background()) apiAAA, err := buildApiAAAHandler(ctx) if err != nil { return err } httpserver.GetConfig(c).AddMiddleware(func(next httpserver.Handler) httpserver.Handler { apiAAA.Next = next return apiAAA }) return nil }
[ "func", "setup", "(", "c", "*", "caddy", ".", "Controller", ")", "error", "{", "ctx", ":=", "log", ".", "LoggerNewContext", "(", "context", ".", "Background", "(", ")", ")", "\n\n", "apiAAA", ",", "err", ":=", "buildApiAAAHandler", "(", "ctx", ")", "\n...
// Setup the api-aaa middleware // Also loads the pfconfig resources and registers them in the pool
[ "Setup", "the", "api", "-", "aaa", "middleware", "Also", "loads", "the", "pfconfig", "resources", "and", "registers", "them", "in", "the", "pool" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/api-aaa/api-aaa.go#L50-L65
30,293
inverse-inc/packetfence
go/caddy/api-aaa/api-aaa.go
buildApiAAAHandler
func buildApiAAAHandler(ctx context.Context) (ApiAAAHandler, error) { apiAAA := ApiAAAHandler{} pfconfigdriver.PfconfigPool.AddStruct(ctx, &pfconfigdriver.Config.PfConf.Webservices) pfconfigdriver.PfconfigPool.AddStruct(ctx, &pfconfigdriver.Config.UnifiedApiSystemUser) pfconfigdriver.PfconfigPool.AddStruct(ctx, &...
go
func buildApiAAAHandler(ctx context.Context) (ApiAAAHandler, error) { apiAAA := ApiAAAHandler{} pfconfigdriver.PfconfigPool.AddStruct(ctx, &pfconfigdriver.Config.PfConf.Webservices) pfconfigdriver.PfconfigPool.AddStruct(ctx, &pfconfigdriver.Config.UnifiedApiSystemUser) pfconfigdriver.PfconfigPool.AddStruct(ctx, &...
[ "func", "buildApiAAAHandler", "(", "ctx", "context", ".", "Context", ")", "(", "ApiAAAHandler", ",", "error", ")", "{", "apiAAA", ":=", "ApiAAAHandler", "{", "}", "\n\n", "pfconfigdriver", ".", "PfconfigPool", ".", "AddStruct", "(", "ctx", ",", "&", "pfconfi...
// Build the ApiAAAHandler which will initialize the cache and instantiate the router along with its routes
[ "Build", "the", "ApiAAAHandler", "which", "will", "initialize", "the", "cache", "and", "instantiate", "the", "router", "along", "with", "its", "routes" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/api-aaa/api-aaa.go#L68-L113
30,294
inverse-inc/packetfence
go/caddy/api-aaa/api-aaa.go
handleLogin
func (h ApiAAAHandler) handleLogin(w http.ResponseWriter, r *http.Request, p httprouter.Params) { ctx := r.Context() defer statsd.NewStatsDTiming(ctx).Send("api-aaa.login") var loginParams struct { Username string Password string } err := json.NewDecoder(r.Body).Decode(&loginParams) if err != nil { msg :...
go
func (h ApiAAAHandler) handleLogin(w http.ResponseWriter, r *http.Request, p httprouter.Params) { ctx := r.Context() defer statsd.NewStatsDTiming(ctx).Send("api-aaa.login") var loginParams struct { Username string Password string } err := json.NewDecoder(r.Body).Decode(&loginParams) if err != nil { msg :...
[ "func", "(", "h", "ApiAAAHandler", ")", "handleLogin", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "p", "httprouter", ".", "Params", ")", "{", "ctx", ":=", "r", ".", "Context", "(", ")", "\n", "defer", "statsd...
// Handle an API login
[ "Handle", "an", "API", "login" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/api-aaa/api-aaa.go#L116-L149
30,295
inverse-inc/packetfence
go/caddy/api-aaa/api-aaa.go
handleTokenInfo
func (h ApiAAAHandler) handleTokenInfo(w http.ResponseWriter, r *http.Request, p httprouter.Params) { ctx := r.Context() defer statsd.NewStatsDTiming(ctx).Send("api-aaa.token_info") info, expiration := h.authorization.GetTokenInfoFromBearerRequest(ctx, r) if info != nil { // We'll want to render the roles as an...
go
func (h ApiAAAHandler) handleTokenInfo(w http.ResponseWriter, r *http.Request, p httprouter.Params) { ctx := r.Context() defer statsd.NewStatsDTiming(ctx).Send("api-aaa.token_info") info, expiration := h.authorization.GetTokenInfoFromBearerRequest(ctx, r) if info != nil { // We'll want to render the roles as an...
[ "func", "(", "h", "ApiAAAHandler", ")", "handleTokenInfo", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "p", "httprouter", ".", "Params", ")", "{", "ctx", ":=", "r", ".", "Context", "(", ")", "\n", "defer", "st...
// Handle getting the token info
[ "Handle", "getting", "the", "token", "info" ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/caddy/api-aaa/api-aaa.go#L152-L192
30,296
inverse-inc/packetfence
go/coredns/core/dnsserver/server-grpc.go
NewServergRPC
func NewServergRPC(addr string, group []*Config) (*ServergRPC, error) { s, err := NewServer(addr, group) if err != nil { return nil, err } gs := &ServergRPC{Server: s} return gs, nil }
go
func NewServergRPC(addr string, group []*Config) (*ServergRPC, error) { s, err := NewServer(addr, group) if err != nil { return nil, err } gs := &ServergRPC{Server: s} return gs, nil }
[ "func", "NewServergRPC", "(", "addr", "string", ",", "group", "[", "]", "*", "Config", ")", "(", "*", "ServergRPC", ",", "error", ")", "{", "s", ",", "err", ":=", "NewServer", "(", "addr", ",", "group", ")", "\n", "if", "err", "!=", "nil", "{", "...
// NewServergRPC returns a new CoreDNS GRPC server and compiles all plugin in to it.
[ "NewServergRPC", "returns", "a", "new", "CoreDNS", "GRPC", "server", "and", "compiles", "all", "plugin", "in", "to", "it", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/coredns/core/dnsserver/server-grpc.go#L28-L36
30,297
inverse-inc/packetfence
go/coredns/core/dnsserver/server-grpc.go
Query
func (s *ServergRPC) Query(ctx context.Context, in *pb.DnsPacket) (*pb.DnsPacket, error) { msg := new(dns.Msg) err := msg.Unpack(in.Msg) if err != nil { return nil, err } p, ok := peer.FromContext(ctx) if !ok { return nil, errors.New("no peer in gRPC context") } a, ok := p.Addr.(*net.TCPAddr) if !ok { ...
go
func (s *ServergRPC) Query(ctx context.Context, in *pb.DnsPacket) (*pb.DnsPacket, error) { msg := new(dns.Msg) err := msg.Unpack(in.Msg) if err != nil { return nil, err } p, ok := peer.FromContext(ctx) if !ok { return nil, errors.New("no peer in gRPC context") } a, ok := p.Addr.(*net.TCPAddr) if !ok { ...
[ "func", "(", "s", "*", "ServergRPC", ")", "Query", "(", "ctx", "context", ".", "Context", ",", "in", "*", "pb", ".", "DnsPacket", ")", "(", "*", "pb", ".", "DnsPacket", ",", "error", ")", "{", "msg", ":=", "new", "(", "dns", ".", "Msg", ")", "\...
// Query is the main entry-point into the gRPC server. From here we call ServeDNS like // any normal server. We use a custom responseWriter to pick up the bytes we need to write // back to the client as a protobuf.
[ "Query", "is", "the", "main", "entry", "-", "point", "into", "the", "gRPC", "server", ".", "From", "here", "we", "call", "ServeDNS", "like", "any", "normal", "server", ".", "We", "use", "a", "custom", "responseWriter", "to", "pick", "up", "the", "bytes",...
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/coredns/core/dnsserver/server-grpc.go#L119-L147
30,298
inverse-inc/packetfence
go/coredns/core/dnsserver/server.go
DefaultErrorFunc
func DefaultErrorFunc(w dns.ResponseWriter, r *dns.Msg, rc int) { state := request.Request{W: w, Req: r} answer := new(dns.Msg) answer.SetRcode(r, rc) state.SizeAndDo(answer) vars.Report(state, vars.Dropped, rcode.ToString(rc), answer.Len(), time.Now()) w.WriteMsg(answer) }
go
func DefaultErrorFunc(w dns.ResponseWriter, r *dns.Msg, rc int) { state := request.Request{W: w, Req: r} answer := new(dns.Msg) answer.SetRcode(r, rc) state.SizeAndDo(answer) vars.Report(state, vars.Dropped, rcode.ToString(rc), answer.Len(), time.Now()) w.WriteMsg(answer) }
[ "func", "DefaultErrorFunc", "(", "w", "dns", ".", "ResponseWriter", ",", "r", "*", "dns", ".", "Msg", ",", "rc", "int", ")", "{", "state", ":=", "request", ".", "Request", "{", "W", ":", "w", ",", "Req", ":", "r", "}", "\n\n", "answer", ":=", "ne...
// DefaultErrorFunc responds to an DNS request with an error.
[ "DefaultErrorFunc", "responds", "to", "an", "DNS", "request", "with", "an", "error", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/coredns/core/dnsserver/server.go#L304-L315
30,299
inverse-inc/packetfence
go/coredns/plugin/file/reload.go
Reload
func (z *Zone) Reload() error { if z.NoReload { return nil } tick := time.NewTicker(TickTime) go func() { for { select { case <-tick.C: reader, err := os.Open(z.file) if err != nil { log.Printf("[ERROR] Failed to open zone %q in %q: %v", z.origin, z.file, err) continue } ser...
go
func (z *Zone) Reload() error { if z.NoReload { return nil } tick := time.NewTicker(TickTime) go func() { for { select { case <-tick.C: reader, err := os.Open(z.file) if err != nil { log.Printf("[ERROR] Failed to open zone %q in %q: %v", z.origin, z.file, err) continue } ser...
[ "func", "(", "z", "*", "Zone", ")", "Reload", "(", ")", "error", "{", "if", "z", ".", "NoReload", "{", "return", "nil", "\n", "}", "\n\n", "tick", ":=", "time", ".", "NewTicker", "(", "TickTime", ")", "\n\n", "go", "func", "(", ")", "{", "for", ...
// Reload reloads a zone when it is changed on disk. If z.NoRoload is true, no reloading will be done.
[ "Reload", "reloads", "a", "zone", "when", "it", "is", "changed", "on", "disk", ".", "If", "z", ".", "NoRoload", "is", "true", "no", "reloading", "will", "be", "done", "." ]
f29912bde7974931d699aba60aa8fde1c5d9a826
https://github.com/inverse-inc/packetfence/blob/f29912bde7974931d699aba60aa8fde1c5d9a826/go/coredns/plugin/file/reload.go#L13-L57