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
136,100
itsyouonline/identityserver
db/organization/db.go
UpdateRequiredScope
func (m *Manager) UpdateRequiredScope(globalId string, oldRequiredScope string, newRequiredScope RequiredScope) error { qry := bson.M{ "globalid": globalId, "requiredscopes.scope": oldRequiredScope, } update := bson.M{ "$set": bson.M{ "requiredscopes.$": newRequiredScope, }, } return m.colle...
go
func (m *Manager) UpdateRequiredScope(globalId string, oldRequiredScope string, newRequiredScope RequiredScope) error { qry := bson.M{ "globalid": globalId, "requiredscopes.scope": oldRequiredScope, } update := bson.M{ "$set": bson.M{ "requiredscopes.$": newRequiredScope, }, } return m.colle...
[ "func", "(", "m", "*", "Manager", ")", "UpdateRequiredScope", "(", "globalId", "string", ",", "oldRequiredScope", "string", ",", "newRequiredScope", "RequiredScope", ")", "error", "{", "qry", ":=", "bson", ".", "M", "{", "\"", "\"", ":", "globalId", ",", "...
// UpdateRequiredScope updates a required scope
[ "UpdateRequiredScope", "updates", "a", "required", "scope" ]
333d78810c675fe259e970c190f35a5dc5586569
https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/organization/db.go#L1161-L1172
136,101
itsyouonline/identityserver
db/organization/db.go
DeleteRequiredScope
func (m *Manager) DeleteRequiredScope(globalId string, requiredScope string) error { return m.collection.Update(bson.M{"globalid": globalId}, bson.M{"$pull": bson.M{"requiredscopes": bson.M{"scope": requiredScope}}}) }
go
func (m *Manager) DeleteRequiredScope(globalId string, requiredScope string) error { return m.collection.Update(bson.M{"globalid": globalId}, bson.M{"$pull": bson.M{"requiredscopes": bson.M{"scope": requiredScope}}}) }
[ "func", "(", "m", "*", "Manager", ")", "DeleteRequiredScope", "(", "globalId", "string", ",", "requiredScope", "string", ")", "error", "{", "return", "m", ".", "collection", ".", "Update", "(", "bson", ".", "M", "{", "\"", "\"", ":", "globalId", "}", "...
// DeleteRequiredScope deletes a required scope
[ "DeleteRequiredScope", "deletes", "a", "required", "scope" ]
333d78810c675fe259e970c190f35a5dc5586569
https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/organization/db.go#L1175-L1178
136,102
itsyouonline/identityserver
db/organization/db.go
SaveDescription
func (m *DescriptionManager) SaveDescription(globalId string, text LocalizedInfoText) error { _, err := m.collection.Upsert(bson.M{"globalid": globalId}, bson.M{"$addToSet": bson.M{"infotexts": text}}) return err }
go
func (m *DescriptionManager) SaveDescription(globalId string, text LocalizedInfoText) error { _, err := m.collection.Upsert(bson.M{"globalid": globalId}, bson.M{"$addToSet": bson.M{"infotexts": text}}) return err }
[ "func", "(", "m", "*", "DescriptionManager", ")", "SaveDescription", "(", "globalId", "string", ",", "text", "LocalizedInfoText", ")", "error", "{", "_", ",", "err", ":=", "m", ".", "collection", ".", "Upsert", "(", "bson", ".", "M", "{", "\"", "\"", "...
// SaveDescription saves a description for an organization
[ "SaveDescription", "saves", "a", "description", "for", "an", "organization" ]
333d78810c675fe259e970c190f35a5dc5586569
https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/organization/db.go#L1196-L1199
136,103
itsyouonline/identityserver
db/organization/db.go
UpdateDescription
func (m *DescriptionManager) UpdateDescription(globalId string, text LocalizedInfoText) error { err := m.collection.Update(bson.M{"globalid": globalId}, bson.M{"$pull": bson.M{"infotexts": bson.M{"langkey": text.LangKey}}}) if err != nil { return err } _, err = m.collection.Upsert(bson.M{"globalid": globalId}, bs...
go
func (m *DescriptionManager) UpdateDescription(globalId string, text LocalizedInfoText) error { err := m.collection.Update(bson.M{"globalid": globalId}, bson.M{"$pull": bson.M{"infotexts": bson.M{"langkey": text.LangKey}}}) if err != nil { return err } _, err = m.collection.Upsert(bson.M{"globalid": globalId}, bs...
[ "func", "(", "m", "*", "DescriptionManager", ")", "UpdateDescription", "(", "globalId", "string", ",", "text", "LocalizedInfoText", ")", "error", "{", "err", ":=", "m", ".", "collection", ".", "Update", "(", "bson", ".", "M", "{", "\"", "\"", ":", "globa...
// UpdateDescription updates a description for an organization
[ "UpdateDescription", "updates", "a", "description", "for", "an", "organization" ]
333d78810c675fe259e970c190f35a5dc5586569
https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/organization/db.go#L1202-L1209
136,104
itsyouonline/identityserver
db/organization/db.go
GetDescription
func (m *DescriptionManager) GetDescription(globalId string) (OrganizationInfoText, error) { var info OrganizationInfoText err := m.collection.Find(bson.M{"globalid": globalId}).One(&info) return info, err }
go
func (m *DescriptionManager) GetDescription(globalId string) (OrganizationInfoText, error) { var info OrganizationInfoText err := m.collection.Find(bson.M{"globalid": globalId}).One(&info) return info, err }
[ "func", "(", "m", "*", "DescriptionManager", ")", "GetDescription", "(", "globalId", "string", ")", "(", "OrganizationInfoText", ",", "error", ")", "{", "var", "info", "OrganizationInfoText", "\n", "err", ":=", "m", ".", "collection", ".", "Find", "(", "bson...
// GetDescription get all descriptions for an organization
[ "GetDescription", "get", "all", "descriptions", "for", "an", "organization" ]
333d78810c675fe259e970c190f35a5dc5586569
https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/organization/db.go#L1217-L1221
136,105
itsyouonline/identityserver
siteservice/login.go
initLoginModels
func (service *Service) initLoginModels() { index := mgo.Index{ Key: []string{"sessionkey"}, Unique: true, DropDups: false, } db.EnsureIndex(mongoLoginCollectionName, index) automaticExpiration := mgo.Index{ Key: []string{"createdat"}, ExpireAfter: time.Second * 60 * 10, Background: tr...
go
func (service *Service) initLoginModels() { index := mgo.Index{ Key: []string{"sessionkey"}, Unique: true, DropDups: false, } db.EnsureIndex(mongoLoginCollectionName, index) automaticExpiration := mgo.Index{ Key: []string{"createdat"}, ExpireAfter: time.Second * 60 * 10, Background: tr...
[ "func", "(", "service", "*", "Service", ")", "initLoginModels", "(", ")", "{", "index", ":=", "mgo", ".", "Index", "{", "Key", ":", "[", "]", "string", "{", "\"", "\"", "}", ",", "Unique", ":", "true", ",", "DropDups", ":", "false", ",", "}", "\n...
//initLoginModels initialize models in mongo
[ "initLoginModels", "initialize", "models", "in", "mongo" ]
333d78810c675fe259e970c190f35a5dc5586569
https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/siteservice/login.go#L40-L56
136,106
itsyouonline/identityserver
siteservice/login.go
ShowLoginForm
func (service *Service) ShowLoginForm(w http.ResponseWriter, request *http.Request) { htmlData, err := html.Asset(loginFileName) if err != nil { log.Error(err) http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError) return } loginSession, err := service.GetSession(reques...
go
func (service *Service) ShowLoginForm(w http.ResponseWriter, request *http.Request) { htmlData, err := html.Asset(loginFileName) if err != nil { log.Error(err) http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError) return } loginSession, err := service.GetSession(reques...
[ "func", "(", "service", "*", "Service", ")", "ShowLoginForm", "(", "w", "http", ".", "ResponseWriter", ",", "request", "*", "http", ".", "Request", ")", "{", "htmlData", ",", "err", ":=", "html", ".", "Asset", "(", "loginFileName", ")", "\n", "if", "er...
//ShowLoginForm shows the user login page on the initial request
[ "ShowLoginForm", "shows", "the", "user", "login", "page", "on", "the", "initial", "request" ]
333d78810c675fe259e970c190f35a5dc5586569
https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/siteservice/login.go#L82-L99
136,107
itsyouonline/identityserver
siteservice/login.go
GetTwoFactorAuthenticationMethods
func (service *Service) GetTwoFactorAuthenticationMethods(w http.ResponseWriter, request *http.Request) { loginSession, err := service.GetSession(request, SessionLogin, "loginsession") if err != nil { log.Error(err) http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError) r...
go
func (service *Service) GetTwoFactorAuthenticationMethods(w http.ResponseWriter, request *http.Request) { loginSession, err := service.GetSession(request, SessionLogin, "loginsession") if err != nil { log.Error(err) http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError) r...
[ "func", "(", "service", "*", "Service", ")", "GetTwoFactorAuthenticationMethods", "(", "w", "http", ".", "ResponseWriter", ",", "request", "*", "http", ".", "Request", ")", "{", "loginSession", ",", "err", ":=", "service", ".", "GetSession", "(", "request", ...
// GetTwoFactorAuthenticationMethods returns the possible two factor authentication methods the user can use to login with.
[ "GetTwoFactorAuthenticationMethods", "returns", "the", "possible", "two", "factor", "authentication", "methods", "the", "user", "can", "use", "to", "login", "with", "." ]
333d78810c675fe259e970c190f35a5dc5586569
https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/siteservice/login.go#L256-L303
136,108
itsyouonline/identityserver
siteservice/login.go
getUserLoggingIn
func (service *Service) getUserLoggingIn(request *http.Request) (username string, err error) { loginSession, err := service.GetSession(request, SessionLogin, "loginsession") if err != nil { log.Error(err) return } savedusername := loginSession.Values["username"] if savedusername != nil { username, _ = savedu...
go
func (service *Service) getUserLoggingIn(request *http.Request) (username string, err error) { loginSession, err := service.GetSession(request, SessionLogin, "loginsession") if err != nil { log.Error(err) return } savedusername := loginSession.Values["username"] if savedusername != nil { username, _ = savedu...
[ "func", "(", "service", "*", "Service", ")", "getUserLoggingIn", "(", "request", "*", "http", ".", "Request", ")", "(", "username", "string", ",", "err", "error", ")", "{", "loginSession", ",", "err", ":=", "service", ".", "GetSession", "(", "request", "...
//getUserLoggingIn returns an user trying to log in, or an empty string if there is none
[ "getUserLoggingIn", "returns", "an", "user", "trying", "to", "log", "in", "or", "an", "empty", "string", "if", "there", "is", "none" ]
333d78810c675fe259e970c190f35a5dc5586569
https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/siteservice/login.go#L306-L317
136,109
itsyouonline/identityserver
siteservice/login.go
getSessionKey
func (service *Service) getSessionKey(request *http.Request) (sessionKey string, err error) { loginSession, err := service.GetSession(request, SessionLogin, "loginsession") if err != nil { log.Error(err) return } savedSessionKey := loginSession.Values["sessionkey"] if savedSessionKey != nil { sessionKey, _ =...
go
func (service *Service) getSessionKey(request *http.Request) (sessionKey string, err error) { loginSession, err := service.GetSession(request, SessionLogin, "loginsession") if err != nil { log.Error(err) return } savedSessionKey := loginSession.Values["sessionkey"] if savedSessionKey != nil { sessionKey, _ =...
[ "func", "(", "service", "*", "Service", ")", "getSessionKey", "(", "request", "*", "http", ".", "Request", ")", "(", "sessionKey", "string", ",", "err", "error", ")", "{", "loginSession", ",", "err", ":=", "service", ".", "GetSession", "(", "request", ",...
//getSessionKey returns an the login session key, or an empty string if there is none
[ "getSessionKey", "returns", "an", "the", "login", "session", "key", "or", "an", "empty", "string", "if", "there", "is", "none" ]
333d78810c675fe259e970c190f35a5dc5586569
https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/siteservice/login.go#L320-L331
136,110
itsyouonline/identityserver
siteservice/login.go
ProcessTOTPConfirmation
func (service *Service) ProcessTOTPConfirmation(w http.ResponseWriter, request *http.Request) { username, err := service.getUserLoggingIn(request) if err != nil { http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError) return } if username == "" { sessions.Save(request, ...
go
func (service *Service) ProcessTOTPConfirmation(w http.ResponseWriter, request *http.Request) { username, err := service.getUserLoggingIn(request) if err != nil { http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError) return } if username == "" { sessions.Save(request, ...
[ "func", "(", "service", "*", "Service", ")", "ProcessTOTPConfirmation", "(", "w", "http", ".", "ResponseWriter", ",", "request", "*", "http", ".", "Request", ")", "{", "username", ",", "err", ":=", "service", ".", "getUserLoggingIn", "(", "request", ")", "...
//ProcessTOTPConfirmation checks the totp 2 factor authentication code
[ "ProcessTOTPConfirmation", "checks", "the", "totp", "2", "factor", "authentication", "code" ]
333d78810c675fe259e970c190f35a5dc5586569
https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/siteservice/login.go#L427-L462
136,111
itsyouonline/identityserver
siteservice/login.go
PhonenumberValidationAndLogin
func (service *Service) PhonenumberValidationAndLogin(w http.ResponseWriter, request *http.Request) { err := request.ParseForm() if err != nil { log.Debug(err) http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest) return } values := request.Form key := values.Get("k") smscode := val...
go
func (service *Service) PhonenumberValidationAndLogin(w http.ResponseWriter, request *http.Request) { err := request.ParseForm() if err != nil { log.Debug(err) http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest) return } values := request.Form key := values.Get("k") smscode := val...
[ "func", "(", "service", "*", "Service", ")", "PhonenumberValidationAndLogin", "(", "w", "http", ".", "ResponseWriter", ",", "request", "*", "http", ".", "Request", ")", "{", "err", ":=", "request", ".", "ParseForm", "(", ")", "\n", "if", "err", "!=", "ni...
// PhonenumberValidationAndLogin is the page that is linked to in the SMS for phonenumbervalidation // and login. Therefore it is accessed on the mobile phone
[ "PhonenumberValidationAndLogin", "is", "the", "page", "that", "is", "linked", "to", "in", "the", "SMS", "for", "phonenumbervalidation", "and", "login", ".", "Therefore", "it", "is", "accessed", "on", "the", "mobile", "phone" ]
333d78810c675fe259e970c190f35a5dc5586569
https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/siteservice/login.go#L485-L550
136,112
itsyouonline/identityserver
siteservice/login.go
Check2FASMSConfirmation
func (service *Service) Check2FASMSConfirmation(w http.ResponseWriter, request *http.Request) { sessionInfo, err := service.getLoginSessionInformation(request, "") if err != nil { http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError) return } response := map[string]bool...
go
func (service *Service) Check2FASMSConfirmation(w http.ResponseWriter, request *http.Request) { sessionInfo, err := service.getLoginSessionInformation(request, "") if err != nil { http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError) return } response := map[string]bool...
[ "func", "(", "service", "*", "Service", ")", "Check2FASMSConfirmation", "(", "w", "http", ".", "ResponseWriter", ",", "request", "*", "http", ".", "Request", ")", "{", "sessionInfo", ",", "err", ":=", "service", ".", "getLoginSessionInformation", "(", "request...
//Check2FASMSConfirmation is called by the sms code form to check if the sms is already confirmed on the mobile phone
[ "Check2FASMSConfirmation", "is", "called", "by", "the", "sms", "code", "form", "to", "check", "if", "the", "sms", "is", "already", "confirmed", "on", "the", "mobile", "phone" ]
333d78810c675fe259e970c190f35a5dc5586569
https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/siteservice/login.go#L609-L625
136,113
itsyouonline/identityserver
siteservice/login.go
Process2FASMSConfirmation
func (service *Service) Process2FASMSConfirmation(w http.ResponseWriter, request *http.Request) { username, err := service.getUserLoggingIn(request) if err != nil { http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError) return } if username == "" { sessions.Save(request...
go
func (service *Service) Process2FASMSConfirmation(w http.ResponseWriter, request *http.Request) { username, err := service.getUserLoggingIn(request) if err != nil { http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError) return } if username == "" { sessions.Save(request...
[ "func", "(", "service", "*", "Service", ")", "Process2FASMSConfirmation", "(", "w", "http", ".", "ResponseWriter", ",", "request", "*", "http", ".", "Request", ")", "{", "username", ",", "err", ":=", "service", ".", "getUserLoggingIn", "(", "request", ")", ...
//Process2FASMSConfirmation checks the totp 2 factor authentication code
[ "Process2FASMSConfirmation", "checks", "the", "totp", "2", "factor", "authentication", "code" ]
333d78810c675fe259e970c190f35a5dc5586569
https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/siteservice/login.go#L628-L687
136,114
itsyouonline/identityserver
communication/email.go
NewSMTPEmailService
func NewSMTPEmailService(host string, port int, user string, password string) (service *SMTPEmailService) { dialer := gomail.NewDialer(host, port, user, password) service = &SMTPEmailService{dialer: dialer} return }
go
func NewSMTPEmailService(host string, port int, user string, password string) (service *SMTPEmailService) { dialer := gomail.NewDialer(host, port, user, password) service = &SMTPEmailService{dialer: dialer} return }
[ "func", "NewSMTPEmailService", "(", "host", "string", ",", "port", "int", ",", "user", "string", ",", "password", "string", ")", "(", "service", "*", "SMTPEmailService", ")", "{", "dialer", ":=", "gomail", ".", "NewDialer", "(", "host", ",", "port", ",", ...
//NewSMTPEmailService creates a nes SMTPEmailService
[ "NewSMTPEmailService", "creates", "a", "nes", "SMTPEmailService" ]
333d78810c675fe259e970c190f35a5dc5586569
https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/communication/email.go#L28-L32
136,115
itsyouonline/identityserver
db/user/User.go
GetPublicKeyByLabel
func (u *User) GetPublicKeyByLabel(label string) (publicKey PublicKey, err error) { for _, publicKey = range u.PublicKeys { if publicKey.Label == label { return } } err = errors.New("Could not find PublicKey with label " + label) return }
go
func (u *User) GetPublicKeyByLabel(label string) (publicKey PublicKey, err error) { for _, publicKey = range u.PublicKeys { if publicKey.Label == label { return } } err = errors.New("Could not find PublicKey with label " + label) return }
[ "func", "(", "u", "*", "User", ")", "GetPublicKeyByLabel", "(", "label", "string", ")", "(", "publicKey", "PublicKey", ",", "err", "error", ")", "{", "for", "_", ",", "publicKey", "=", "range", "u", ".", "PublicKeys", "{", "if", "publicKey", ".", "Labe...
// GetPublicKeyByLabel Gets the public key associated with this label
[ "GetPublicKeyByLabel", "Gets", "the", "public", "key", "associated", "with", "this", "label" ]
333d78810c675fe259e970c190f35a5dc5586569
https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/user/User.go#L98-L106
136,116
itsyouonline/identityserver
db/user/User.go
GetAvatarByLabel
func (u *User) GetAvatarByLabel(label string) (avatar Avatar, err error) { for _, avatar = range u.Avatars { if avatar.Label == label { return } } err = errors.New("Could not find Avatar with Label " + label) return }
go
func (u *User) GetAvatarByLabel(label string) (avatar Avatar, err error) { for _, avatar = range u.Avatars { if avatar.Label == label { return } } err = errors.New("Could not find Avatar with Label " + label) return }
[ "func", "(", "u", "*", "User", ")", "GetAvatarByLabel", "(", "label", "string", ")", "(", "avatar", "Avatar", ",", "err", "error", ")", "{", "for", "_", ",", "avatar", "=", "range", "u", ".", "Avatars", "{", "if", "avatar", ".", "Label", "==", "lab...
// GetAvatarByLabel gets the avatar associated with this label
[ "GetAvatarByLabel", "gets", "the", "avatar", "associated", "with", "this", "label" ]
333d78810c675fe259e970c190f35a5dc5586569
https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/user/User.go#L109-L117
136,117
itsyouonline/identityserver
db/company/Company.go
IsValid
func (c *Company) IsValid() (valid bool) { valid = true globalIDLength := len(c.Globalid) valid = valid && (globalIDLength >= 3) && (globalIDLength <= 150) && c.Globalid == strings.ToLower(c.Globalid) return }
go
func (c *Company) IsValid() (valid bool) { valid = true globalIDLength := len(c.Globalid) valid = valid && (globalIDLength >= 3) && (globalIDLength <= 150) && c.Globalid == strings.ToLower(c.Globalid) return }
[ "func", "(", "c", "*", "Company", ")", "IsValid", "(", ")", "(", "valid", "bool", ")", "{", "valid", "=", "true", "\n", "globalIDLength", ":=", "len", "(", "c", ".", "Globalid", ")", "\n", "valid", "=", "valid", "&&", "(", "globalIDLength", ">=", "...
// IsValid performs basic validation on the content of a company's fields
[ "IsValid", "performs", "basic", "validation", "on", "the", "content", "of", "a", "company", "s", "fields" ]
333d78810c675fe259e970c190f35a5dc5586569
https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/company/Company.go#L21-L26
136,118
itsyouonline/identityserver
oauthservice/service.go
GetWebuser
func (service *Service) GetWebuser(r *http.Request, w http.ResponseWriter) (username string, err error) { username, err = service.sessionService.GetLoggedInUser(r, w) return }
go
func (service *Service) GetWebuser(r *http.Request, w http.ResponseWriter) (username string, err error) { username, err = service.sessionService.GetLoggedInUser(r, w) return }
[ "func", "(", "service", "*", "Service", ")", "GetWebuser", "(", "r", "*", "http", ".", "Request", ",", "w", "http", ".", "ResponseWriter", ")", "(", "username", "string", ",", "err", "error", ")", "{", "username", ",", "err", "=", "service", ".", "se...
//GetWebuser returns the authenticated user if any or an empty string if not
[ "GetWebuser", "returns", "the", "authenticated", "user", "if", "any", "or", "an", "empty", "string", "if", "not" ]
333d78810c675fe259e970c190f35a5dc5586569
https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/oauthservice/service.go#L53-L56
136,119
itsyouonline/identityserver
oauthservice/service.go
AddRoutes
func (service *Service) AddRoutes(router *mux.Router) { service.router = router router.HandleFunc("/v1/oauth/authorize", service.AuthorizeHandler).Methods("GET") router.HandleFunc("/v1/oauth/authorize", func(w http.ResponseWriter, r *http.Request) { w.Header().Add("Allow", "GET") }).Methods("OPTIONS") route...
go
func (service *Service) AddRoutes(router *mux.Router) { service.router = router router.HandleFunc("/v1/oauth/authorize", service.AuthorizeHandler).Methods("GET") router.HandleFunc("/v1/oauth/authorize", func(w http.ResponseWriter, r *http.Request) { w.Header().Add("Allow", "GET") }).Methods("OPTIONS") route...
[ "func", "(", "service", "*", "Service", ")", "AddRoutes", "(", "router", "*", "mux", ".", "Router", ")", "{", "service", ".", "router", "=", "router", "\n", "router", ".", "HandleFunc", "(", "\"", "\"", ",", "service", ".", "AuthorizeHandler", ")", "."...
//AddRoutes adds the routes and handlerfunctions to the router
[ "AddRoutes", "adds", "the", "routes", "and", "handlerfunctions", "to", "the", "router" ]
333d78810c675fe259e970c190f35a5dc5586569
https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/oauthservice/service.go#L72-L103
136,120
itsyouonline/identityserver
globalconfig/globalconfig.go
Insert
func (m *Manager) Insert(c *GlobalConfig) error { err := m.collection.Insert(c) return err }
go
func (m *Manager) Insert(c *GlobalConfig) error { err := m.collection.Insert(c) return err }
[ "func", "(", "m", "*", "Manager", ")", "Insert", "(", "c", "*", "GlobalConfig", ")", "error", "{", "err", ":=", "m", ".", "collection", ".", "Insert", "(", "c", ")", "\n\n", "return", "err", "\n", "}" ]
// Insert a config key
[ "Insert", "a", "config", "key" ]
333d78810c675fe259e970c190f35a5dc5586569
https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/globalconfig/globalconfig.go#L66-L70
136,121
itsyouonline/identityserver
globalconfig/globalconfig.go
Delete
func (m *Manager) Delete(key string) error { config, err := m.GetByKey(key) if err != nil { return err } return m.collection.Remove(config) }
go
func (m *Manager) Delete(key string) error { config, err := m.GetByKey(key) if err != nil { return err } return m.collection.Remove(config) }
[ "func", "(", "m", "*", "Manager", ")", "Delete", "(", "key", "string", ")", "error", "{", "config", ",", "err", ":=", "m", ".", "GetByKey", "(", "key", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "m",...
// Delete a config key
[ "Delete", "a", "config", "key" ]
333d78810c675fe259e970c190f35a5dc5586569
https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/globalconfig/globalconfig.go#L73-L81
136,122
itsyouonline/identityserver
db/organization/Organization.go
IsValid
func (org *Organization) IsValid() bool { regex, _ := regexp.Compile(`^[a-z\d\-_\s]{3,150}$`) return validator.Validate(org) == nil && regex.MatchString(org.Globalid) }
go
func (org *Organization) IsValid() bool { regex, _ := regexp.Compile(`^[a-z\d\-_\s]{3,150}$`) return validator.Validate(org) == nil && regex.MatchString(org.Globalid) }
[ "func", "(", "org", "*", "Organization", ")", "IsValid", "(", ")", "bool", "{", "regex", ",", "_", ":=", "regexp", ".", "Compile", "(", "`^[a-z\\d\\-_\\s]{3,150}$`", ")", "\n", "return", "validator", ".", "Validate", "(", "org", ")", "==", "nil", "&&", ...
// IsValid performs basic validation on the content of an organizations fields
[ "IsValid", "performs", "basic", "validation", "on", "the", "content", "of", "an", "organizations", "fields" ]
333d78810c675fe259e970c190f35a5dc5586569
https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/organization/Organization.go#L28-L31
136,123
itsyouonline/identityserver
db/organization/Organization.go
ConvertToView
func (org *Organization) ConvertToView(usrMgr *user.Manager, valMgr *validation.Manager) (*OrganizationView, error) { view := &OrganizationView{} view.DNS = org.DNS view.Globalid = org.Globalid view.PublicKeys = org.PublicKeys view.SecondsValidity = org.SecondsValidity view.OrgOwners = org.OrgOwners view.OrgMemb...
go
func (org *Organization) ConvertToView(usrMgr *user.Manager, valMgr *validation.Manager) (*OrganizationView, error) { view := &OrganizationView{} view.DNS = org.DNS view.Globalid = org.Globalid view.PublicKeys = org.PublicKeys view.SecondsValidity = org.SecondsValidity view.OrgOwners = org.OrgOwners view.OrgMemb...
[ "func", "(", "org", "*", "Organization", ")", "ConvertToView", "(", "usrMgr", "*", "user", ".", "Manager", ",", "valMgr", "*", "validation", ".", "Manager", ")", "(", "*", "OrganizationView", ",", "error", ")", "{", "view", ":=", "&", "OrganizationView", ...
// ConvertToView converts an organization from the DB to a view served by the API
[ "ConvertToView", "converts", "an", "organization", "from", "the", "DB", "to", "a", "view", "served", "by", "the", "API" ]
333d78810c675fe259e970c190f35a5dc5586569
https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/organization/Organization.go#L40-L59
136,124
itsyouonline/identityserver
db/organization/Organization.go
ConvertUsernamesToIdentifiers
func ConvertUsernamesToIdentifiers(usernames []string, valMgr *validation.Manager) ([]string, error) { identifiers := []string{} checkedUsers := map[string]bool{} for _, u := range usernames { checkedUsers[u] = false } emails, err := valMgr.GetValidatedEmailAddressesByUsernames(usernames) if err != nil { retu...
go
func ConvertUsernamesToIdentifiers(usernames []string, valMgr *validation.Manager) ([]string, error) { identifiers := []string{} checkedUsers := map[string]bool{} for _, u := range usernames { checkedUsers[u] = false } emails, err := valMgr.GetValidatedEmailAddressesByUsernames(usernames) if err != nil { retu...
[ "func", "ConvertUsernamesToIdentifiers", "(", "usernames", "[", "]", "string", ",", "valMgr", "*", "validation", ".", "Manager", ")", "(", "[", "]", "string", ",", "error", ")", "{", "identifiers", ":=", "[", "]", "string", "{", "}", "\n", "checkedUsers", ...
// ConvertUsernamesToIdentifiers converts a list of usernames to a list of user identifiers
[ "ConvertUsernamesToIdentifiers", "converts", "a", "list", "of", "usernames", "to", "a", "list", "of", "user", "identifiers" ]
333d78810c675fe259e970c190f35a5dc5586569
https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/organization/Organization.go#L62-L95
136,125
itsyouonline/identityserver
db/organization/Organization.go
ConvertUsernameToIdentifier
func ConvertUsernameToIdentifier(username string, usrMgr *user.Manager, valMgr *validation.Manager) (string, error) { userIdentifier := username usr, err := usrMgr.GetByName(username) if err != nil { return userIdentifier, err } // check for a validated email address for _, email := range usr.EmailAddresses { ...
go
func ConvertUsernameToIdentifier(username string, usrMgr *user.Manager, valMgr *validation.Manager) (string, error) { userIdentifier := username usr, err := usrMgr.GetByName(username) if err != nil { return userIdentifier, err } // check for a validated email address for _, email := range usr.EmailAddresses { ...
[ "func", "ConvertUsernameToIdentifier", "(", "username", "string", ",", "usrMgr", "*", "user", ".", "Manager", ",", "valMgr", "*", "validation", ".", "Manager", ")", "(", "string", ",", "error", ")", "{", "userIdentifier", ":=", "username", "\n", "usr", ",", ...
// ConvertUsernameToIdentifier converts a username into an identifier. It tries validated email addresses first. If // there are none, attempt to use validated phone numbers. If the user also doesn't have any of those, keep the username
[ "ConvertUsernameToIdentifier", "converts", "a", "username", "into", "an", "identifier", ".", "It", "tries", "validated", "email", "addresses", "first", ".", "If", "there", "are", "none", "attempt", "to", "use", "validated", "phone", "numbers", ".", "If", "the", ...
333d78810c675fe259e970c190f35a5dc5586569
https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/organization/Organization.go#L119-L147
136,126
itsyouonline/identityserver
db/organization/Organization.go
ConvertIdentifierToUsername
func ConvertIdentifierToUsername(identifier string, valMgr *validation.Manager) (string, error) { email, err := valMgr.GetByEmailAddress(identifier) if err == nil { return email.Username, err } else if valMgr.IsErrNotFound(err) { phone, err := valMgr.GetByPhoneNumber(identifier) if err == nil || db.IsNotFound(...
go
func ConvertIdentifierToUsername(identifier string, valMgr *validation.Manager) (string, error) { email, err := valMgr.GetByEmailAddress(identifier) if err == nil { return email.Username, err } else if valMgr.IsErrNotFound(err) { phone, err := valMgr.GetByPhoneNumber(identifier) if err == nil || db.IsNotFound(...
[ "func", "ConvertIdentifierToUsername", "(", "identifier", "string", ",", "valMgr", "*", "validation", ".", "Manager", ")", "(", "string", ",", "error", ")", "{", "email", ",", "err", ":=", "valMgr", ".", "GetByEmailAddress", "(", "identifier", ")", "\n", "if...
// ConvertIdentifierToUsername converts an identifier to a username.
[ "ConvertIdentifierToUsername", "converts", "an", "identifier", "to", "a", "username", "." ]
333d78810c675fe259e970c190f35a5dc5586569
https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/organization/Organization.go#L150-L163
136,127
itsyouonline/identityserver
db/smshistory/model.go
New
func New(phonenumber string) *SmsHistory { return &SmsHistory{ Phonenumber: phonenumber, CreatedAt: time.Now(), } }
go
func New(phonenumber string) *SmsHistory { return &SmsHistory{ Phonenumber: phonenumber, CreatedAt: time.Now(), } }
[ "func", "New", "(", "phonenumber", "string", ")", "*", "SmsHistory", "{", "return", "&", "SmsHistory", "{", "Phonenumber", ":", "phonenumber", ",", "CreatedAt", ":", "time", ".", "Now", "(", ")", ",", "}", "\n", "}" ]
// New creates a new SmsHistory
[ "New", "creates", "a", "new", "SmsHistory" ]
333d78810c675fe259e970c190f35a5dc5586569
https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/smshistory/model.go#L12-L17
136,128
itsyouonline/identityserver
credentials/oauth2/scopes.go
SplitScopeString
func SplitScopeString(scopestring string) (scopeList []string) { scopeList = []string{} for _, value := range strings.Split(scopestring, ",") { scope := strings.TrimSpace(value) if scope != "" { scopeList = append(scopeList, scope) } } return }
go
func SplitScopeString(scopestring string) (scopeList []string) { scopeList = []string{} for _, value := range strings.Split(scopestring, ",") { scope := strings.TrimSpace(value) if scope != "" { scopeList = append(scopeList, scope) } } return }
[ "func", "SplitScopeString", "(", "scopestring", "string", ")", "(", "scopeList", "[", "]", "string", ")", "{", "scopeList", "=", "[", "]", "string", "{", "}", "\n", "for", "_", ",", "value", ":=", "range", "strings", ".", "Split", "(", "scopestring", "...
//SplitScopeString takes a comma seperated string representation of scopes and returns it as a slice
[ "SplitScopeString", "takes", "a", "comma", "seperated", "string", "representation", "of", "scopes", "and", "returns", "it", "as", "a", "slice" ]
333d78810c675fe259e970c190f35a5dc5586569
https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/credentials/oauth2/scopes.go#L6-L15
136,129
itsyouonline/identityserver
credentials/oauth2/scopes.go
CheckScopes
func CheckScopes(possibleScopes []string, authorizedScopes []string) bool { if len(possibleScopes) == 0 { return true } for _, allowed := range possibleScopes { for _, scope := range authorizedScopes { if scope == allowed { return true } } } return false }
go
func CheckScopes(possibleScopes []string, authorizedScopes []string) bool { if len(possibleScopes) == 0 { return true } for _, allowed := range possibleScopes { for _, scope := range authorizedScopes { if scope == allowed { return true } } } return false }
[ "func", "CheckScopes", "(", "possibleScopes", "[", "]", "string", ",", "authorizedScopes", "[", "]", "string", ")", "bool", "{", "if", "len", "(", "possibleScopes", ")", "==", "0", "{", "return", "true", "\n", "}", "\n\n", "for", "_", ",", "allowed", "...
// CheckScopes checks whether one of the possibleScopes is in the authorized scopes list
[ "CheckScopes", "checks", "whether", "one", "of", "the", "possibleScopes", "is", "in", "the", "authorized", "scopes", "list" ]
333d78810c675fe259e970c190f35a5dc5586569
https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/credentials/oauth2/scopes.go#L18-L31
136,130
itsyouonline/identityserver
siteservice/middleware/ratelimit.go
RateLimit
func RateLimit(period time.Duration, limit int) RateLimiter { store := memory.NewStore() rate := limiter.Rate{ Period: period, Limit: int64(limit), } lmt := limiter.New(store, rate) middleware := stdlib.NewMiddleware(lmt, stdlib.WithForwardHeader(true)) middleware.OnLimitReached = func(w http.ResponseWriter...
go
func RateLimit(period time.Duration, limit int) RateLimiter { store := memory.NewStore() rate := limiter.Rate{ Period: period, Limit: int64(limit), } lmt := limiter.New(store, rate) middleware := stdlib.NewMiddleware(lmt, stdlib.WithForwardHeader(true)) middleware.OnLimitReached = func(w http.ResponseWriter...
[ "func", "RateLimit", "(", "period", "time", ".", "Duration", ",", "limit", "int", ")", "RateLimiter", "{", "store", ":=", "memory", ".", "NewStore", "(", ")", "\n", "rate", ":=", "limiter", ".", "Rate", "{", "Period", ":", "period", ",", "Limit", ":", ...
// RateLimit creates a new rate limiting middleware with in memory store // the amount of maximum requests can be set as wel as the duration in which this limit // applies
[ "RateLimit", "creates", "a", "new", "rate", "limiting", "middleware", "with", "in", "memory", "store", "the", "amount", "of", "maximum", "requests", "can", "be", "set", "as", "wel", "as", "the", "duration", "in", "which", "this", "limit", "applies" ]
333d78810c675fe259e970c190f35a5dc5586569
https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/siteservice/middleware/ratelimit.go#L28-L62
136,131
itsyouonline/identityserver
db/smshistory/db.go
AddSMSHistory
func (m *Manager) AddSMSHistory(sh *SmsHistory) error { return m.collection.Insert(sh) }
go
func (m *Manager) AddSMSHistory(sh *SmsHistory) error { return m.collection.Insert(sh) }
[ "func", "(", "m", "*", "Manager", ")", "AddSMSHistory", "(", "sh", "*", "SmsHistory", ")", "error", "{", "return", "m", ".", "collection", ".", "Insert", "(", "sh", ")", "\n", "}" ]
// AddSMSHistory adds SmsHistory to the database
[ "AddSMSHistory", "adds", "SmsHistory", "to", "the", "database" ]
333d78810c675fe259e970c190f35a5dc5586569
https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/smshistory/db.go#L44-L46
136,132
itsyouonline/identityserver
db/smshistory/db.go
CountSMSHistorySince
func (m *Manager) CountSMSHistorySince(phonenumber string, since time.Time) (int, error) { return m.collection.Find(bson.M{"createdat": bson.M{"$gte": since}}).Count() }
go
func (m *Manager) CountSMSHistorySince(phonenumber string, since time.Time) (int, error) { return m.collection.Find(bson.M{"createdat": bson.M{"$gte": since}}).Count() }
[ "func", "(", "m", "*", "Manager", ")", "CountSMSHistorySince", "(", "phonenumber", "string", ",", "since", "time", ".", "Time", ")", "(", "int", ",", "error", ")", "{", "return", "m", ".", "collection", ".", "Find", "(", "bson", ".", "M", "{", "\"", ...
// CountSMSHistorySince counts the amount of sms sent to a phone number since a specific time
[ "CountSMSHistorySince", "counts", "the", "amount", "of", "sms", "sent", "to", "a", "phone", "number", "since", "a", "specific", "time" ]
333d78810c675fe259e970c190f35a5dc5586569
https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/smshistory/db.go#L49-L51
136,133
itsyouonline/identityserver
identityservice/organization/APIKey.go
FromOAuthClient
func FromOAuthClient(client *oauthservice.Oauth2Client) APIKey { apiKey := APIKey{ CallbackURL: client.CallbackURL, ClientCredentialsGrantType: client.ClientCredentialsGrantType, Label: client.Label, Secret: client.Secret, } return apiKey }
go
func FromOAuthClient(client *oauthservice.Oauth2Client) APIKey { apiKey := APIKey{ CallbackURL: client.CallbackURL, ClientCredentialsGrantType: client.ClientCredentialsGrantType, Label: client.Label, Secret: client.Secret, } return apiKey }
[ "func", "FromOAuthClient", "(", "client", "*", "oauthservice", ".", "Oauth2Client", ")", "APIKey", "{", "apiKey", ":=", "APIKey", "{", "CallbackURL", ":", "client", ".", "CallbackURL", ",", "ClientCredentialsGrantType", ":", "client", ".", "ClientCredentialsGrantTyp...
//FromOAuthClient creates an APIKey instance from an oauthservice.Oauth2Client
[ "FromOAuthClient", "creates", "an", "APIKey", "instance", "from", "an", "oauthservice", ".", "Oauth2Client" ]
333d78810c675fe259e970c190f35a5dc5586569
https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/identityservice/organization/APIKey.go#L18-L26
136,134
itsyouonline/identityserver
identityservice/invitations/JoinOrganizationInvitation.go
ConvertToView
func (inv *JoinOrganizationInvitation) ConvertToView(usrMgr *user.Manager, valMgr *validation.Manager) (*JoinOrganizationInvitationView, error) { vw := &JoinOrganizationInvitationView{} vw.Organization = inv.Organization vw.Role = inv.Role vw.Status = inv.Status vw.Created = inv.Created vw.Method = inv.Method vw...
go
func (inv *JoinOrganizationInvitation) ConvertToView(usrMgr *user.Manager, valMgr *validation.Manager) (*JoinOrganizationInvitationView, error) { vw := &JoinOrganizationInvitationView{} vw.Organization = inv.Organization vw.Role = inv.Role vw.Status = inv.Status vw.Created = inv.Created vw.Method = inv.Method vw...
[ "func", "(", "inv", "*", "JoinOrganizationInvitation", ")", "ConvertToView", "(", "usrMgr", "*", "user", ".", "Manager", ",", "valMgr", "*", "validation", ".", "Manager", ")", "(", "*", "JoinOrganizationInvitationView", ",", "error", ")", "{", "vw", ":=", "&...
// ConvertToView converts a JoinOrganizationInvitation to a JoinOrganizationInvitationView
[ "ConvertToView", "converts", "a", "JoinOrganizationInvitation", "to", "a", "JoinOrganizationInvitationView" ]
333d78810c675fe259e970c190f35a5dc5586569
https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/identityservice/invitations/JoinOrganizationInvitation.go#L89-L107
136,135
itsyouonline/identityserver
credentials/oauth2/jwt.go
GetValidJWT
func GetValidJWT(r *http.Request, publicKey *ecdsa.PublicKey) (token *jwt.Token, err error) { authorizationHeader := r.Header.Get("Authorization") if !strings.HasPrefix(authorizationHeader, "bearer ") && !strings.HasPrefix(authorizationHeader, "Bearer ") { return } jwtstring := strings.TrimSpace(strings.TrimPrefi...
go
func GetValidJWT(r *http.Request, publicKey *ecdsa.PublicKey) (token *jwt.Token, err error) { authorizationHeader := r.Header.Get("Authorization") if !strings.HasPrefix(authorizationHeader, "bearer ") && !strings.HasPrefix(authorizationHeader, "Bearer ") { return } jwtstring := strings.TrimSpace(strings.TrimPrefi...
[ "func", "GetValidJWT", "(", "r", "*", "http", ".", "Request", ",", "publicKey", "*", "ecdsa", ".", "PublicKey", ")", "(", "token", "*", "jwt", ".", "Token", ",", "err", "error", ")", "{", "authorizationHeader", ":=", "r", ".", "Header", ".", "Get", "...
//GetValidJWT returns a validated ES384 signed jwt from the authorization header that needs to start with "bearer " // If no jwt is found in the authorization header, nil is returned // Validation against the supplied publickey is performed
[ "GetValidJWT", "returns", "a", "validated", "ES384", "signed", "jwt", "from", "the", "authorization", "header", "that", "needs", "to", "start", "with", "bearer", "If", "no", "jwt", "is", "found", "in", "the", "authorization", "header", "nil", "is", "returned",...
333d78810c675fe259e970c190f35a5dc5586569
https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/credentials/oauth2/jwt.go#L16-L36
136,136
itsyouonline/identityserver
credentials/oauth2/jwt.go
GetScopestringFromJWT
func GetScopestringFromJWT(token *jwt.Token) (scopestring string) { if token == nil { return } scopes := GetScopesFromJWT(token) scopestring = strings.Join(scopes, ",") return }
go
func GetScopestringFromJWT(token *jwt.Token) (scopestring string) { if token == nil { return } scopes := GetScopesFromJWT(token) scopestring = strings.Join(scopes, ",") return }
[ "func", "GetScopestringFromJWT", "(", "token", "*", "jwt", ".", "Token", ")", "(", "scopestring", "string", ")", "{", "if", "token", "==", "nil", "{", "return", "\n", "}", "\n", "scopes", ":=", "GetScopesFromJWT", "(", "token", ")", "\n", "scopestring", ...
// GetScopestringFromJWT turns the scopes from a jwt in to a commaseperated scopestring
[ "GetScopestringFromJWT", "turns", "the", "scopes", "from", "a", "jwt", "in", "to", "a", "commaseperated", "scopestring" ]
333d78810c675fe259e970c190f35a5dc5586569
https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/credentials/oauth2/jwt.go#L53-L60
136,137
itsyouonline/identityserver
credentials/oauth2/jwt.go
IgnoreExpired
func IgnoreExpired(err error) error { vErr, ok := err.(*jwt.ValidationError) if ok && vErr.Errors == jwt.ValidationErrorExpired { return nil } return err }
go
func IgnoreExpired(err error) error { vErr, ok := err.(*jwt.ValidationError) if ok && vErr.Errors == jwt.ValidationErrorExpired { return nil } return err }
[ "func", "IgnoreExpired", "(", "err", "error", ")", "error", "{", "vErr", ",", "ok", ":=", "err", ".", "(", "*", "jwt", ".", "ValidationError", ")", "\n", "if", "ok", "&&", "vErr", ".", "Errors", "==", "jwt", ".", "ValidationErrorExpired", "{", "return"...
// IgnoreExpired checks if the input error is only an expired error. Nil is returned in // this case, else the original error
[ "IgnoreExpired", "checks", "if", "the", "input", "error", "is", "only", "an", "expired", "error", ".", "Nil", "is", "returned", "in", "this", "case", "else", "the", "original", "error" ]
333d78810c675fe259e970c190f35a5dc5586569
https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/credentials/oauth2/jwt.go#L64-L70
136,138
itsyouonline/identityserver
communication/sms.go
Send
func (s *SMSServiceProxySeparateRussia) Send(phonenumber string, message string) (err error) { if IsRussianMobileNumber(phonenumber) { return s.RussianSMSService.Send(phonenumber, message) } return s.DefaultSMSService.Send(phonenumber, message) }
go
func (s *SMSServiceProxySeparateRussia) Send(phonenumber string, message string) (err error) { if IsRussianMobileNumber(phonenumber) { return s.RussianSMSService.Send(phonenumber, message) } return s.DefaultSMSService.Send(phonenumber, message) }
[ "func", "(", "s", "*", "SMSServiceProxySeparateRussia", ")", "Send", "(", "phonenumber", "string", ",", "message", "string", ")", "(", "err", "error", ")", "{", "if", "IsRussianMobileNumber", "(", "phonenumber", ")", "{", "return", "s", ".", "RussianSMSService...
// Send proxies the send call to the right provider based on the phonenumber
[ "Send", "proxies", "the", "send", "call", "to", "the", "right", "provider", "based", "on", "the", "phonenumber" ]
333d78810c675fe259e970c190f35a5dc5586569
https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/communication/sms.go#L110-L115
136,139
itsyouonline/identityserver
communication/ratelimitedsms.go
NewRateLimitedSMSService
func NewRateLimitedSMSService(window int, maxSMS int, actualService SMSService) SMSService { return &RateLimitedSMSService{ actualService: actualService, window: time.Duration(int(time.Second) * window), maxSMS: maxSMS, } }
go
func NewRateLimitedSMSService(window int, maxSMS int, actualService SMSService) SMSService { return &RateLimitedSMSService{ actualService: actualService, window: time.Duration(int(time.Second) * window), maxSMS: maxSMS, } }
[ "func", "NewRateLimitedSMSService", "(", "window", "int", ",", "maxSMS", "int", ",", "actualService", "SMSService", ")", "SMSService", "{", "return", "&", "RateLimitedSMSService", "{", "actualService", ":", "actualService", ",", "window", ":", "time", ".", "Durati...
// NewRateLimitedSMSService rates limit an existing sms service to the defined rate
[ "NewRateLimitedSMSService", "rates", "limit", "an", "existing", "sms", "service", "to", "the", "defined", "rate" ]
333d78810c675fe259e970c190f35a5dc5586569
https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/communication/ratelimitedsms.go#L25-L31
136,140
itsyouonline/identityserver
communication/ratelimitedsms.go
Send
func (s *RateLimitedSMSService) Send(phonenumber string, message string) (err error) { conn := db.NewSession() if conn == nil { return errors.New("Failed to get DB connection") } mgr := smshistory.NewManager(conn) sendCount, err := mgr.CountSMSHistorySince(phonenumber, time.Now().Add(-s.window)) if err != nil...
go
func (s *RateLimitedSMSService) Send(phonenumber string, message string) (err error) { conn := db.NewSession() if conn == nil { return errors.New("Failed to get DB connection") } mgr := smshistory.NewManager(conn) sendCount, err := mgr.CountSMSHistorySince(phonenumber, time.Now().Add(-s.window)) if err != nil...
[ "func", "(", "s", "*", "RateLimitedSMSService", ")", "Send", "(", "phonenumber", "string", ",", "message", "string", ")", "(", "err", "error", ")", "{", "conn", ":=", "db", ".", "NewSession", "(", ")", "\n", "if", "conn", "==", "nil", "{", "return", ...
// Send checksif the message can be send according to the rate limiting rules, and then // deligates the acutal sender to the wrapped service. This uses a sliding window approach
[ "Send", "checksif", "the", "message", "can", "be", "send", "according", "to", "the", "rate", "limiting", "rules", "and", "then", "deligates", "the", "acutal", "sender", "to", "the", "wrapped", "service", ".", "This", "uses", "a", "sliding", "window", "approa...
333d78810c675fe259e970c190f35a5dc5586569
https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/communication/ratelimitedsms.go#L35-L63
136,141
sourcegraph/ctxvfs
namespace.go
Fprint
func (ns NameSpace) Fprint(w io.Writer) { fmt.Fprint(w, "name space {\n") var all []string for mtpt := range ns { all = append(all, mtpt) } sort.Strings(all) for _, mtpt := range all { fmt.Fprintf(w, "\t%s:\n", mtpt) for _, m := range ns[mtpt] { fmt.Fprintf(w, "\t\t%s %s\n", m.fs, m.new) } } fmt.Fpri...
go
func (ns NameSpace) Fprint(w io.Writer) { fmt.Fprint(w, "name space {\n") var all []string for mtpt := range ns { all = append(all, mtpt) } sort.Strings(all) for _, mtpt := range all { fmt.Fprintf(w, "\t%s:\n", mtpt) for _, m := range ns[mtpt] { fmt.Fprintf(w, "\t\t%s %s\n", m.fs, m.new) } } fmt.Fpri...
[ "func", "(", "ns", "NameSpace", ")", "Fprint", "(", "w", "io", ".", "Writer", ")", "{", "fmt", ".", "Fprint", "(", "w", ",", "\"", "\\n", "\"", ")", "\n", "var", "all", "[", "]", "string", "\n", "for", "mtpt", ":=", "range", "ns", "{", "all", ...
// Fprint writes a text representation of the name space to w.
[ "Fprint", "writes", "a", "text", "representation", "of", "the", "name", "space", "to", "w", "." ]
2b65f1b1ea81f660ad7bc9931991f39617eb783e
https://github.com/sourcegraph/ctxvfs/blob/2b65f1b1ea81f660ad7bc9931991f39617eb783e/namespace.go#L58-L72
136,142
sourcegraph/ctxvfs
namespace.go
resolve
func (ns NameSpace) resolve(path string) []mountedFS { path = ns.clean(path) for { if m := ns[path]; m != nil { if debugNS { fmt.Printf("resolve %s: %v\n", path, m) } return m } if path == "/" { break } path = pathpkg.Dir(path) } return nil }
go
func (ns NameSpace) resolve(path string) []mountedFS { path = ns.clean(path) for { if m := ns[path]; m != nil { if debugNS { fmt.Printf("resolve %s: %v\n", path, m) } return m } if path == "/" { break } path = pathpkg.Dir(path) } return nil }
[ "func", "(", "ns", "NameSpace", ")", "resolve", "(", "path", "string", ")", "[", "]", "mountedFS", "{", "path", "=", "ns", ".", "clean", "(", "path", ")", "\n", "for", "{", "if", "m", ":=", "ns", "[", "path", "]", ";", "m", "!=", "nil", "{", ...
// resolve resolves a path to the list of mountedFS to use for path.
[ "resolve", "resolves", "a", "path", "to", "the", "list", "of", "mountedFS", "to", "use", "for", "path", "." ]
2b65f1b1ea81f660ad7bc9931991f39617eb783e
https://github.com/sourcegraph/ctxvfs/blob/2b65f1b1ea81f660ad7bc9931991f39617eb783e/namespace.go#L124-L139
136,143
sourcegraph/ctxvfs
namespace.go
stat
func (ns NameSpace) stat(ctx context.Context, path string, f func(FileSystem, context.Context, string) (os.FileInfo, error)) (os.FileInfo, error) { var err error for _, m := range ns.resolve(path) { fi, err1 := f(m.fs, ctx, m.translate(path)) if err1 == nil { return fi, nil } if err == nil { err = err1 ...
go
func (ns NameSpace) stat(ctx context.Context, path string, f func(FileSystem, context.Context, string) (os.FileInfo, error)) (os.FileInfo, error) { var err error for _, m := range ns.resolve(path) { fi, err1 := f(m.fs, ctx, m.translate(path)) if err1 == nil { return fi, nil } if err == nil { err = err1 ...
[ "func", "(", "ns", "NameSpace", ")", "stat", "(", "ctx", "context", ".", "Context", ",", "path", "string", ",", "f", "func", "(", "FileSystem", ",", "context", ".", "Context", ",", "string", ")", "(", "os", ".", "FileInfo", ",", "error", ")", ")", ...
// stat implements the FileSystem Stat and Lstat methods.
[ "stat", "implements", "the", "FileSystem", "Stat", "and", "Lstat", "methods", "." ]
2b65f1b1ea81f660ad7bc9931991f39617eb783e
https://github.com/sourcegraph/ctxvfs/blob/2b65f1b1ea81f660ad7bc9931991f39617eb783e/namespace.go#L165-L190
136,144
sourcegraph/ctxvfs
walk.go
Walk
func Walk(ctx context.Context, root string, fs FileSystem) *Walker { info, err := fs.Lstat(ctx, root) return &Walker{ fs: fs, ctx: ctx, stack: []item{{root, info, err}}, } }
go
func Walk(ctx context.Context, root string, fs FileSystem) *Walker { info, err := fs.Lstat(ctx, root) return &Walker{ fs: fs, ctx: ctx, stack: []item{{root, info, err}}, } }
[ "func", "Walk", "(", "ctx", "context", ".", "Context", ",", "root", "string", ",", "fs", "FileSystem", ")", "*", "Walker", "{", "info", ",", "err", ":=", "fs", ".", "Lstat", "(", "ctx", ",", "root", ")", "\n", "return", "&", "Walker", "{", "fs", ...
// Walk returns a new Walker rooted at root on the FileSystem fs.
[ "Walk", "returns", "a", "new", "Walker", "rooted", "at", "root", "on", "the", "FileSystem", "fs", "." ]
2b65f1b1ea81f660ad7bc9931991f39617eb783e
https://github.com/sourcegraph/ctxvfs/blob/2b65f1b1ea81f660ad7bc9931991f39617eb783e/walk.go#L60-L67
136,145
sourcegraph/ctxvfs
sync.go
Sync
func Sync(mu *sync.Mutex, fs FileSystem) FileSystem { return &syncFS{mu, fs} }
go
func Sync(mu *sync.Mutex, fs FileSystem) FileSystem { return &syncFS{mu, fs} }
[ "func", "Sync", "(", "mu", "*", "sync", ".", "Mutex", ",", "fs", "FileSystem", ")", "FileSystem", "{", "return", "&", "syncFS", "{", "mu", ",", "fs", "}", "\n", "}" ]
// Sync creates a new file system wrapper around fs that locks a mutex // during its operations. // // The contents of files must be immutable, since it has no way of // synchronizing access to the ReadSeekCloser from Open after Open // returns.
[ "Sync", "creates", "a", "new", "file", "system", "wrapper", "around", "fs", "that", "locks", "a", "mutex", "during", "its", "operations", ".", "The", "contents", "of", "files", "must", "be", "immutable", "since", "it", "has", "no", "way", "of", "synchroniz...
2b65f1b1ea81f660ad7bc9931991f39617eb783e
https://github.com/sourcegraph/ctxvfs/blob/2b65f1b1ea81f660ad7bc9931991f39617eb783e/sync.go#L16-L18
136,146
infobloxopen/infoblox-go-client
object_manager.go
validateMatchClient
func validateMatchClient(value string) bool { match_client := [5]string{"MAC_ADDRESS", "CLIENT_ID", "RESERVED", "CIRCUIT_ID", "REMOTE_ID"} for _, val := range match_client { if val == value { return true } } return false }
go
func validateMatchClient(value string) bool { match_client := [5]string{"MAC_ADDRESS", "CLIENT_ID", "RESERVED", "CIRCUIT_ID", "REMOTE_ID"} for _, val := range match_client { if val == value { return true } } return false }
[ "func", "validateMatchClient", "(", "value", "string", ")", "bool", "{", "match_client", ":=", "[", "5", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", "}", "\n\n", "for", "_", ",", "val", ":="...
// validation for match_client
[ "validation", "for", "match_client" ]
7247dee3156a9d790d26ee2e0ea609bd24e844a0
https://github.com/infobloxopen/infoblox-go-client/blob/7247dee3156a9d790d26ee2e0ea609bd24e844a0/object_manager.go#L350-L359
136,147
infobloxopen/infoblox-go-client
object_manager.go
CreateMultiObject
func (objMgr *ObjectManager) CreateMultiObject(req *MultiRequest) ([]map[string]interface{}, error) { conn := objMgr.connector.(*Connector) queryParams := QueryParams{forceProxy: false} res, err := conn.makeRequest(CREATE, req, "", queryParams) if err != nil { return nil, err } var result []map[string]interf...
go
func (objMgr *ObjectManager) CreateMultiObject(req *MultiRequest) ([]map[string]interface{}, error) { conn := objMgr.connector.(*Connector) queryParams := QueryParams{forceProxy: false} res, err := conn.makeRequest(CREATE, req, "", queryParams) if err != nil { return nil, err } var result []map[string]interf...
[ "func", "(", "objMgr", "*", "ObjectManager", ")", "CreateMultiObject", "(", "req", "*", "MultiRequest", ")", "(", "[", "]", "map", "[", "string", "]", "interface", "{", "}", ",", "error", ")", "{", "conn", ":=", "objMgr", ".", "connector", ".", "(", ...
// CreateMultiObject unmarshals the result into slice of maps
[ "CreateMultiObject", "unmarshals", "the", "result", "into", "slice", "of", "maps" ]
7247dee3156a9d790d26ee2e0ea609bd24e844a0
https://github.com/infobloxopen/infoblox-go-client/blob/7247dee3156a9d790d26ee2e0ea609bd24e844a0/object_manager.go#L610-L628
136,148
infobloxopen/infoblox-go-client
object_manager.go
GetUpgradeStatus
func (objMgr *ObjectManager) GetUpgradeStatus(statusType string) ([]UpgradeStatus, error) { var res []UpgradeStatus if statusType == "" { // TODO option may vary according to the WAPI version, need to // throw relevant error. msg := fmt.Sprintf("Status type can not be nil") return res, errors.New(msg) } u...
go
func (objMgr *ObjectManager) GetUpgradeStatus(statusType string) ([]UpgradeStatus, error) { var res []UpgradeStatus if statusType == "" { // TODO option may vary according to the WAPI version, need to // throw relevant error. msg := fmt.Sprintf("Status type can not be nil") return res, errors.New(msg) } u...
[ "func", "(", "objMgr", "*", "ObjectManager", ")", "GetUpgradeStatus", "(", "statusType", "string", ")", "(", "[", "]", "UpgradeStatus", ",", "error", ")", "{", "var", "res", "[", "]", "UpgradeStatus", "\n\n", "if", "statusType", "==", "\"", "\"", "{", "/...
// GetUpgradeStatus returns the grid upgrade information
[ "GetUpgradeStatus", "returns", "the", "grid", "upgrade", "information" ]
7247dee3156a9d790d26ee2e0ea609bd24e844a0
https://github.com/infobloxopen/infoblox-go-client/blob/7247dee3156a9d790d26ee2e0ea609bd24e844a0/object_manager.go#L631-L644
136,149
infobloxopen/infoblox-go-client
object_manager.go
GetAllMembers
func (objMgr *ObjectManager) GetAllMembers() ([]Member, error) { var res []Member memberObj := NewMember(Member{}) err := objMgr.connector.GetObject(memberObj, "", &res) return res, err }
go
func (objMgr *ObjectManager) GetAllMembers() ([]Member, error) { var res []Member memberObj := NewMember(Member{}) err := objMgr.connector.GetObject(memberObj, "", &res) return res, err }
[ "func", "(", "objMgr", "*", "ObjectManager", ")", "GetAllMembers", "(", ")", "(", "[", "]", "Member", ",", "error", ")", "{", "var", "res", "[", "]", "Member", "\n\n", "memberObj", ":=", "NewMember", "(", "Member", "{", "}", ")", "\n", "err", ":=", ...
// GetAllMembers returns all members information
[ "GetAllMembers", "returns", "all", "members", "information" ]
7247dee3156a9d790d26ee2e0ea609bd24e844a0
https://github.com/infobloxopen/infoblox-go-client/blob/7247dee3156a9d790d26ee2e0ea609bd24e844a0/object_manager.go#L647-L653
136,150
infobloxopen/infoblox-go-client
object_manager.go
GetCapacityReport
func (objMgr *ObjectManager) GetCapacityReport(name string) ([]CapacityReport, error) { var res []CapacityReport capacityObj := CapacityReport{Name: name} capacityReport := NewCapcityReport(capacityObj) err := objMgr.connector.GetObject(capacityReport, "", &res) return res, err }
go
func (objMgr *ObjectManager) GetCapacityReport(name string) ([]CapacityReport, error) { var res []CapacityReport capacityObj := CapacityReport{Name: name} capacityReport := NewCapcityReport(capacityObj) err := objMgr.connector.GetObject(capacityReport, "", &res) return res, err }
[ "func", "(", "objMgr", "*", "ObjectManager", ")", "GetCapacityReport", "(", "name", "string", ")", "(", "[", "]", "CapacityReport", ",", "error", ")", "{", "var", "res", "[", "]", "CapacityReport", "\n\n", "capacityObj", ":=", "CapacityReport", "{", "Name", ...
// GetCapacityReport returns all capacity for members
[ "GetCapacityReport", "returns", "all", "capacity", "for", "members" ]
7247dee3156a9d790d26ee2e0ea609bd24e844a0
https://github.com/infobloxopen/infoblox-go-client/blob/7247dee3156a9d790d26ee2e0ea609bd24e844a0/object_manager.go#L656-L663
136,151
infobloxopen/infoblox-go-client
object_manager.go
GetLicense
func (objMgr *ObjectManager) GetLicense() ([]License, error) { var res []License licenseObj := NewLicense(License{}) err := objMgr.connector.GetObject(licenseObj, "", &res) return res, err }
go
func (objMgr *ObjectManager) GetLicense() ([]License, error) { var res []License licenseObj := NewLicense(License{}) err := objMgr.connector.GetObject(licenseObj, "", &res) return res, err }
[ "func", "(", "objMgr", "*", "ObjectManager", ")", "GetLicense", "(", ")", "(", "[", "]", "License", ",", "error", ")", "{", "var", "res", "[", "]", "License", "\n\n", "licenseObj", ":=", "NewLicense", "(", "License", "{", "}", ")", "\n", "err", ":=",...
// GetLicense returns the license details for member
[ "GetLicense", "returns", "the", "license", "details", "for", "member" ]
7247dee3156a9d790d26ee2e0ea609bd24e844a0
https://github.com/infobloxopen/infoblox-go-client/blob/7247dee3156a9d790d26ee2e0ea609bd24e844a0/object_manager.go#L666-L672
136,152
infobloxopen/infoblox-go-client
object_manager.go
GetGridLicense
func (objMgr *ObjectManager) GetGridLicense() ([]License, error) { var res []License licenseObj := NewGridLicense(License{}) err := objMgr.connector.GetObject(licenseObj, "", &res) return res, err }
go
func (objMgr *ObjectManager) GetGridLicense() ([]License, error) { var res []License licenseObj := NewGridLicense(License{}) err := objMgr.connector.GetObject(licenseObj, "", &res) return res, err }
[ "func", "(", "objMgr", "*", "ObjectManager", ")", "GetGridLicense", "(", ")", "(", "[", "]", "License", ",", "error", ")", "{", "var", "res", "[", "]", "License", "\n\n", "licenseObj", ":=", "NewGridLicense", "(", "License", "{", "}", ")", "\n", "err",...
// GetLicense returns the license details for grid
[ "GetLicense", "returns", "the", "license", "details", "for", "grid" ]
7247dee3156a9d790d26ee2e0ea609bd24e844a0
https://github.com/infobloxopen/infoblox-go-client/blob/7247dee3156a9d790d26ee2e0ea609bd24e844a0/object_manager.go#L675-L681
136,153
infobloxopen/infoblox-go-client
object_manager.go
GetGridInfo
func (objMgr *ObjectManager) GetGridInfo() ([]Grid, error) { var res []Grid gridObj := NewGrid(Grid{}) err := objMgr.connector.GetObject(gridObj, "", &res) return res, err }
go
func (objMgr *ObjectManager) GetGridInfo() ([]Grid, error) { var res []Grid gridObj := NewGrid(Grid{}) err := objMgr.connector.GetObject(gridObj, "", &res) return res, err }
[ "func", "(", "objMgr", "*", "ObjectManager", ")", "GetGridInfo", "(", ")", "(", "[", "]", "Grid", ",", "error", ")", "{", "var", "res", "[", "]", "Grid", "\n\n", "gridObj", ":=", "NewGrid", "(", "Grid", "{", "}", ")", "\n", "err", ":=", "objMgr", ...
// GetGridInfo returns the details for grid
[ "GetGridInfo", "returns", "the", "details", "for", "grid" ]
7247dee3156a9d790d26ee2e0ea609bd24e844a0
https://github.com/infobloxopen/infoblox-go-client/blob/7247dee3156a9d790d26ee2e0ea609bd24e844a0/object_manager.go#L684-L690
136,154
infobloxopen/infoblox-go-client
connector.go
Logout
func (c *Connector) Logout() (err error) { queryParams := QueryParams{forceProxy: false} _, err = c.makeRequest(CREATE, nil, "logout", queryParams) if err != nil { log.Printf("Logout request error: '%s'\n", err) } return }
go
func (c *Connector) Logout() (err error) { queryParams := QueryParams{forceProxy: false} _, err = c.makeRequest(CREATE, nil, "logout", queryParams) if err != nil { log.Printf("Logout request error: '%s'\n", err) } return }
[ "func", "(", "c", "*", "Connector", ")", "Logout", "(", ")", "(", "err", "error", ")", "{", "queryParams", ":=", "QueryParams", "{", "forceProxy", ":", "false", "}", "\n", "_", ",", "err", "=", "c", ".", "makeRequest", "(", "CREATE", ",", "nil", ",...
// Logout sends a request to invalidate the ibapauth cookie and should // be used in a defer statement after the Connector has been successfully // initialized.
[ "Logout", "sends", "a", "request", "to", "invalidate", "the", "ibapauth", "cookie", "and", "should", "be", "used", "in", "a", "defer", "statement", "after", "the", "Connector", "has", "been", "successfully", "initialized", "." ]
7247dee3156a9d790d26ee2e0ea609bd24e844a0
https://github.com/infobloxopen/infoblox-go-client/blob/7247dee3156a9d790d26ee2e0ea609bd24e844a0/connector.go#L349-L357
136,155
d2g/dhcp4client
client.go
SendDiscoverPacket
func (c *Client) SendDiscoverPacket() (dhcp4.Packet, error) { discoveryPacket := c.DiscoverPacket() discoveryPacket.PadToMinSize() return discoveryPacket, c.SendPacket(discoveryPacket) }
go
func (c *Client) SendDiscoverPacket() (dhcp4.Packet, error) { discoveryPacket := c.DiscoverPacket() discoveryPacket.PadToMinSize() return discoveryPacket, c.SendPacket(discoveryPacket) }
[ "func", "(", "c", "*", "Client", ")", "SendDiscoverPacket", "(", ")", "(", "dhcp4", ".", "Packet", ",", "error", ")", "{", "discoveryPacket", ":=", "c", ".", "DiscoverPacket", "(", ")", "\n", "discoveryPacket", ".", "PadToMinSize", "(", ")", "\n\n", "ret...
//Send the Discovery Packet to the Broadcast Channel
[ "Send", "the", "Discovery", "Packet", "to", "the", "Broadcast", "Channel" ]
ef524ad9cb076fe235ecc3c55913ef8445fa35fa
https://github.com/d2g/dhcp4client/blob/ef524ad9cb076fe235ecc3c55913ef8445fa35fa/client.go#L140-L145
136,156
d2g/dhcp4client
client.go
GetOffer
func (c *Client) GetOffer(discoverPacket *dhcp4.Packet) (dhcp4.Packet, error) { start := time.Now() for { timeout := c.timeout - time.Since(start) if timeout < 0 { return dhcp4.Packet{}, &TimeoutError{Timeout: c.timeout} } c.connection.SetReadTimeout(timeout) readBuffer, source, err := c.connection.Rea...
go
func (c *Client) GetOffer(discoverPacket *dhcp4.Packet) (dhcp4.Packet, error) { start := time.Now() for { timeout := c.timeout - time.Since(start) if timeout < 0 { return dhcp4.Packet{}, &TimeoutError{Timeout: c.timeout} } c.connection.SetReadTimeout(timeout) readBuffer, source, err := c.connection.Rea...
[ "func", "(", "c", "*", "Client", ")", "GetOffer", "(", "discoverPacket", "*", "dhcp4", ".", "Packet", ")", "(", "dhcp4", ".", "Packet", ",", "error", ")", "{", "start", ":=", "time", ".", "Now", "(", ")", "\n\n", "for", "{", "timeout", ":=", "c", ...
//Retreive Offer... //Wait for the offer for a specific Discovery Packet.
[ "Retreive", "Offer", "...", "Wait", "for", "the", "offer", "for", "a", "specific", "Discovery", "Packet", "." ]
ef524ad9cb076fe235ecc3c55913ef8445fa35fa
https://github.com/d2g/dhcp4client/blob/ef524ad9cb076fe235ecc3c55913ef8445fa35fa/client.go#L158-L197
136,157
d2g/dhcp4client
client.go
SendRequest
func (c *Client) SendRequest(offerPacket *dhcp4.Packet) (dhcp4.Packet, error) { requestPacket := c.RequestPacket(offerPacket) requestPacket.PadToMinSize() return requestPacket, c.SendPacket(requestPacket) }
go
func (c *Client) SendRequest(offerPacket *dhcp4.Packet) (dhcp4.Packet, error) { requestPacket := c.RequestPacket(offerPacket) requestPacket.PadToMinSize() return requestPacket, c.SendPacket(requestPacket) }
[ "func", "(", "c", "*", "Client", ")", "SendRequest", "(", "offerPacket", "*", "dhcp4", ".", "Packet", ")", "(", "dhcp4", ".", "Packet", ",", "error", ")", "{", "requestPacket", ":=", "c", ".", "RequestPacket", "(", "offerPacket", ")", "\n", "requestPacke...
//Send Request Based On the offer Received.
[ "Send", "Request", "Based", "On", "the", "offer", "Received", "." ]
ef524ad9cb076fe235ecc3c55913ef8445fa35fa
https://github.com/d2g/dhcp4client/blob/ef524ad9cb076fe235ecc3c55913ef8445fa35fa/client.go#L200-L205
136,158
d2g/dhcp4client
client.go
GetAcknowledgement
func (c *Client) GetAcknowledgement(requestPacket *dhcp4.Packet) (dhcp4.Packet, error) { start := time.Now() for { timeout := c.timeout - time.Since(start) if timeout < 0 { return dhcp4.Packet{}, &TimeoutError{Timeout: c.timeout} } c.connection.SetReadTimeout(timeout) readBuffer, source, err := c.conne...
go
func (c *Client) GetAcknowledgement(requestPacket *dhcp4.Packet) (dhcp4.Packet, error) { start := time.Now() for { timeout := c.timeout - time.Since(start) if timeout < 0 { return dhcp4.Packet{}, &TimeoutError{Timeout: c.timeout} } c.connection.SetReadTimeout(timeout) readBuffer, source, err := c.conne...
[ "func", "(", "c", "*", "Client", ")", "GetAcknowledgement", "(", "requestPacket", "*", "dhcp4", ".", "Packet", ")", "(", "dhcp4", ".", "Packet", ",", "error", ")", "{", "start", ":=", "time", ".", "Now", "(", ")", "\n\n", "for", "{", "timeout", ":=",...
//Retreive Acknowledgement //Wait for the offer for a specific Request Packet.
[ "Retreive", "Acknowledgement", "Wait", "for", "the", "offer", "for", "a", "specific", "Request", "Packet", "." ]
ef524ad9cb076fe235ecc3c55913ef8445fa35fa
https://github.com/d2g/dhcp4client/blob/ef524ad9cb076fe235ecc3c55913ef8445fa35fa/client.go#L209-L247
136,159
d2g/dhcp4client
client.go
SendDecline
func (c *Client) SendDecline(acknowledgementPacket *dhcp4.Packet) (dhcp4.Packet, error) { declinePacket := c.DeclinePacket(acknowledgementPacket) declinePacket.PadToMinSize() return declinePacket, c.SendPacket(declinePacket) }
go
func (c *Client) SendDecline(acknowledgementPacket *dhcp4.Packet) (dhcp4.Packet, error) { declinePacket := c.DeclinePacket(acknowledgementPacket) declinePacket.PadToMinSize() return declinePacket, c.SendPacket(declinePacket) }
[ "func", "(", "c", "*", "Client", ")", "SendDecline", "(", "acknowledgementPacket", "*", "dhcp4", ".", "Packet", ")", "(", "dhcp4", ".", "Packet", ",", "error", ")", "{", "declinePacket", ":=", "c", ".", "DeclinePacket", "(", "acknowledgementPacket", ")", "...
//Send Decline to the received acknowledgement.
[ "Send", "Decline", "to", "the", "received", "acknowledgement", "." ]
ef524ad9cb076fe235ecc3c55913ef8445fa35fa
https://github.com/d2g/dhcp4client/blob/ef524ad9cb076fe235ecc3c55913ef8445fa35fa/client.go#L250-L255
136,160
d2g/dhcp4client
client.go
SendPacket
func (c *Client) SendPacket(packet dhcp4.Packet) error { return c.connection.Write(packet) }
go
func (c *Client) SendPacket(packet dhcp4.Packet) error { return c.connection.Write(packet) }
[ "func", "(", "c", "*", "Client", ")", "SendPacket", "(", "packet", "dhcp4", ".", "Packet", ")", "error", "{", "return", "c", ".", "connection", ".", "Write", "(", "packet", ")", "\n", "}" ]
//Send a DHCP Packet.
[ "Send", "a", "DHCP", "Packet", "." ]
ef524ad9cb076fe235ecc3c55913ef8445fa35fa
https://github.com/d2g/dhcp4client/blob/ef524ad9cb076fe235ecc3c55913ef8445fa35fa/client.go#L258-L260
136,161
d2g/dhcp4client
client.go
DiscoverPacket
func (c *Client) DiscoverPacket() dhcp4.Packet { messageid := make([]byte, 4) c.generateXID(messageid) packet := dhcp4.NewPacket(dhcp4.BootRequest) packet.SetCHAddr(c.hardwareAddr) packet.SetXId(messageid) packet.SetBroadcast(c.broadcast) packet.AddOption(dhcp4.OptionDHCPMessageType, []byte{byte(dhcp4.Discover...
go
func (c *Client) DiscoverPacket() dhcp4.Packet { messageid := make([]byte, 4) c.generateXID(messageid) packet := dhcp4.NewPacket(dhcp4.BootRequest) packet.SetCHAddr(c.hardwareAddr) packet.SetXId(messageid) packet.SetBroadcast(c.broadcast) packet.AddOption(dhcp4.OptionDHCPMessageType, []byte{byte(dhcp4.Discover...
[ "func", "(", "c", "*", "Client", ")", "DiscoverPacket", "(", ")", "dhcp4", ".", "Packet", "{", "messageid", ":=", "make", "(", "[", "]", "byte", ",", "4", ")", "\n", "c", ".", "generateXID", "(", "messageid", ")", "\n\n", "packet", ":=", "dhcp4", "...
//Create Discover Packet
[ "Create", "Discover", "Packet" ]
ef524ad9cb076fe235ecc3c55913ef8445fa35fa
https://github.com/d2g/dhcp4client/blob/ef524ad9cb076fe235ecc3c55913ef8445fa35fa/client.go#L263-L275
136,162
d2g/dhcp4client
client.go
RequestPacket
func (c *Client) RequestPacket(offerPacket *dhcp4.Packet) dhcp4.Packet { offerOptions := offerPacket.ParseOptions() packet := dhcp4.NewPacket(dhcp4.BootRequest) packet.SetCHAddr(c.hardwareAddr) packet.SetXId(offerPacket.XId()) packet.SetCIAddr(offerPacket.CIAddr()) packet.SetSIAddr(offerPacket.SIAddr()) packe...
go
func (c *Client) RequestPacket(offerPacket *dhcp4.Packet) dhcp4.Packet { offerOptions := offerPacket.ParseOptions() packet := dhcp4.NewPacket(dhcp4.BootRequest) packet.SetCHAddr(c.hardwareAddr) packet.SetXId(offerPacket.XId()) packet.SetCIAddr(offerPacket.CIAddr()) packet.SetSIAddr(offerPacket.SIAddr()) packe...
[ "func", "(", "c", "*", "Client", ")", "RequestPacket", "(", "offerPacket", "*", "dhcp4", ".", "Packet", ")", "dhcp4", ".", "Packet", "{", "offerOptions", ":=", "offerPacket", ".", "ParseOptions", "(", ")", "\n\n", "packet", ":=", "dhcp4", ".", "NewPacket",...
//Create Request Packet
[ "Create", "Request", "Packet" ]
ef524ad9cb076fe235ecc3c55913ef8445fa35fa
https://github.com/d2g/dhcp4client/blob/ef524ad9cb076fe235ecc3c55913ef8445fa35fa/client.go#L278-L294
136,163
d2g/dhcp4client
client.go
RenewalRequestPacket
func (c *Client) RenewalRequestPacket(acknowledgement *dhcp4.Packet) dhcp4.Packet { messageid := make([]byte, 4) c.generateXID(messageid) acknowledgementOptions := acknowledgement.ParseOptions() packet := dhcp4.NewPacket(dhcp4.BootRequest) packet.SetCHAddr(acknowledgement.CHAddr()) packet.SetXId(messageid) pa...
go
func (c *Client) RenewalRequestPacket(acknowledgement *dhcp4.Packet) dhcp4.Packet { messageid := make([]byte, 4) c.generateXID(messageid) acknowledgementOptions := acknowledgement.ParseOptions() packet := dhcp4.NewPacket(dhcp4.BootRequest) packet.SetCHAddr(acknowledgement.CHAddr()) packet.SetXId(messageid) pa...
[ "func", "(", "c", "*", "Client", ")", "RenewalRequestPacket", "(", "acknowledgement", "*", "dhcp4", ".", "Packet", ")", "dhcp4", ".", "Packet", "{", "messageid", ":=", "make", "(", "[", "]", "byte", ",", "4", ")", "\n", "c", ".", "generateXID", "(", ...
//Create Request Packet For a Renew
[ "Create", "Request", "Packet", "For", "a", "Renew" ]
ef524ad9cb076fe235ecc3c55913ef8445fa35fa
https://github.com/d2g/dhcp4client/blob/ef524ad9cb076fe235ecc3c55913ef8445fa35fa/client.go#L297-L316
136,164
d2g/dhcp4client
client.go
ReleasePacket
func (c *Client) ReleasePacket(acknowledgement *dhcp4.Packet) dhcp4.Packet { messageid := make([]byte, 4) c.generateXID(messageid) acknowledgementOptions := acknowledgement.ParseOptions() packet := dhcp4.NewPacket(dhcp4.BootRequest) packet.SetCHAddr(acknowledgement.CHAddr()) packet.SetXId(messageid) packet.Se...
go
func (c *Client) ReleasePacket(acknowledgement *dhcp4.Packet) dhcp4.Packet { messageid := make([]byte, 4) c.generateXID(messageid) acknowledgementOptions := acknowledgement.ParseOptions() packet := dhcp4.NewPacket(dhcp4.BootRequest) packet.SetCHAddr(acknowledgement.CHAddr()) packet.SetXId(messageid) packet.Se...
[ "func", "(", "c", "*", "Client", ")", "ReleasePacket", "(", "acknowledgement", "*", "dhcp4", ".", "Packet", ")", "dhcp4", ".", "Packet", "{", "messageid", ":=", "make", "(", "[", "]", "byte", ",", "4", ")", "\n", "c", ".", "generateXID", "(", "messag...
//Create Release Packet For a Release
[ "Create", "Release", "Packet", "For", "a", "Release" ]
ef524ad9cb076fe235ecc3c55913ef8445fa35fa
https://github.com/d2g/dhcp4client/blob/ef524ad9cb076fe235ecc3c55913ef8445fa35fa/client.go#L319-L335
136,165
d2g/dhcp4client
client.go
DeclinePacket
func (c *Client) DeclinePacket(acknowledgement *dhcp4.Packet) dhcp4.Packet { messageid := make([]byte, 4) c.generateXID(messageid) acknowledgementOptions := acknowledgement.ParseOptions() packet := dhcp4.NewPacket(dhcp4.BootRequest) packet.SetCHAddr(acknowledgement.CHAddr()) packet.SetXId(messageid) packet.Ad...
go
func (c *Client) DeclinePacket(acknowledgement *dhcp4.Packet) dhcp4.Packet { messageid := make([]byte, 4) c.generateXID(messageid) acknowledgementOptions := acknowledgement.ParseOptions() packet := dhcp4.NewPacket(dhcp4.BootRequest) packet.SetCHAddr(acknowledgement.CHAddr()) packet.SetXId(messageid) packet.Ad...
[ "func", "(", "c", "*", "Client", ")", "DeclinePacket", "(", "acknowledgement", "*", "dhcp4", ".", "Packet", ")", "dhcp4", ".", "Packet", "{", "messageid", ":=", "make", "(", "[", "]", "byte", ",", "4", ")", "\n", "c", ".", "generateXID", "(", "messag...
//Create Decline Packet
[ "Create", "Decline", "Packet" ]
ef524ad9cb076fe235ecc3c55913ef8445fa35fa
https://github.com/d2g/dhcp4client/blob/ef524ad9cb076fe235ecc3c55913ef8445fa35fa/client.go#L338-L353
136,166
d2g/dhcp4client
client.go
Request
func (c *Client) Request() (bool, dhcp4.Packet, error) { discoveryPacket, err := c.SendDiscoverPacket() if err != nil { return false, discoveryPacket, err } offerPacket, err := c.GetOffer(&discoveryPacket) if err != nil { return false, offerPacket, err } requestPacket, err := c.SendRequest(&offerPacket) i...
go
func (c *Client) Request() (bool, dhcp4.Packet, error) { discoveryPacket, err := c.SendDiscoverPacket() if err != nil { return false, discoveryPacket, err } offerPacket, err := c.GetOffer(&discoveryPacket) if err != nil { return false, offerPacket, err } requestPacket, err := c.SendRequest(&offerPacket) i...
[ "func", "(", "c", "*", "Client", ")", "Request", "(", ")", "(", "bool", ",", "dhcp4", ".", "Packet", ",", "error", ")", "{", "discoveryPacket", ",", "err", ":=", "c", ".", "SendDiscoverPacket", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return...
//Lets do a Full DHCP Request.
[ "Lets", "do", "a", "Full", "DHCP", "Request", "." ]
ef524ad9cb076fe235ecc3c55913ef8445fa35fa
https://github.com/d2g/dhcp4client/blob/ef524ad9cb076fe235ecc3c55913ef8445fa35fa/client.go#L356-L383
136,167
d2g/dhcp4client
client.go
Renew
func (c *Client) Renew(acknowledgement dhcp4.Packet) (bool, dhcp4.Packet, error) { renewRequest := c.RenewalRequestPacket(&acknowledgement) renewRequest.PadToMinSize() err := c.SendPacket(renewRequest) if err != nil { return false, renewRequest, err } newAcknowledgement, err := c.GetAcknowledgement(&renewRequ...
go
func (c *Client) Renew(acknowledgement dhcp4.Packet) (bool, dhcp4.Packet, error) { renewRequest := c.RenewalRequestPacket(&acknowledgement) renewRequest.PadToMinSize() err := c.SendPacket(renewRequest) if err != nil { return false, renewRequest, err } newAcknowledgement, err := c.GetAcknowledgement(&renewRequ...
[ "func", "(", "c", "*", "Client", ")", "Renew", "(", "acknowledgement", "dhcp4", ".", "Packet", ")", "(", "bool", ",", "dhcp4", ".", "Packet", ",", "error", ")", "{", "renewRequest", ":=", "c", ".", "RenewalRequestPacket", "(", "&", "acknowledgement", ")"...
//Renew a lease backed on the Acknowledgement Packet. //Returns Sucessfull, The AcknoledgementPacket, Any Errors
[ "Renew", "a", "lease", "backed", "on", "the", "Acknowledgement", "Packet", ".", "Returns", "Sucessfull", "The", "AcknoledgementPacket", "Any", "Errors" ]
ef524ad9cb076fe235ecc3c55913ef8445fa35fa
https://github.com/d2g/dhcp4client/blob/ef524ad9cb076fe235ecc3c55913ef8445fa35fa/client.go#L387-L407
136,168
d2g/dhcp4client
client.go
Release
func (c *Client) Release(acknowledgement dhcp4.Packet) error { release := c.ReleasePacket(&acknowledgement) release.PadToMinSize() return c.SendPacket(release) }
go
func (c *Client) Release(acknowledgement dhcp4.Packet) error { release := c.ReleasePacket(&acknowledgement) release.PadToMinSize() return c.SendPacket(release) }
[ "func", "(", "c", "*", "Client", ")", "Release", "(", "acknowledgement", "dhcp4", ".", "Packet", ")", "error", "{", "release", ":=", "c", ".", "ReleasePacket", "(", "&", "acknowledgement", ")", "\n", "release", ".", "PadToMinSize", "(", ")", "\n\n", "ret...
//Release a lease backed on the Acknowledgement Packet. //Returns Any Errors
[ "Release", "a", "lease", "backed", "on", "the", "Acknowledgement", "Packet", ".", "Returns", "Any", "Errors" ]
ef524ad9cb076fe235ecc3c55913ef8445fa35fa
https://github.com/d2g/dhcp4client/blob/ef524ad9cb076fe235ecc3c55913ef8445fa35fa/client.go#L411-L416
136,169
d2g/dhcp4client
pktsock_linux.go
chksum
func chksum(p []byte, csum []byte) { cklen := len(p) s := uint32(0) for i := 0; i < (cklen - 1); i += 2 { s += uint32(p[i+1])<<8 | uint32(p[i]) } if cklen&1 == 1 { s += uint32(p[cklen-1]) } s = (s >> 16) + (s & 0xffff) s = s + (s >> 16) s = ^s csum[0] = uint8(s & 0xff) csum[1] = uint8(s >> 8) }
go
func chksum(p []byte, csum []byte) { cklen := len(p) s := uint32(0) for i := 0; i < (cklen - 1); i += 2 { s += uint32(p[i+1])<<8 | uint32(p[i]) } if cklen&1 == 1 { s += uint32(p[cklen-1]) } s = (s >> 16) + (s & 0xffff) s = s + (s >> 16) s = ^s csum[0] = uint8(s & 0xff) csum[1] = uint8(s >> 8) }
[ "func", "chksum", "(", "p", "[", "]", "byte", ",", "csum", "[", "]", "byte", ")", "{", "cklen", ":=", "len", "(", "p", ")", "\n", "s", ":=", "uint32", "(", "0", ")", "\n", "for", "i", ":=", "0", ";", "i", "<", "(", "cklen", "-", "1", ")",...
// compute's 1's complement checksum
[ "compute", "s", "1", "s", "complement", "checksum" ]
ef524ad9cb076fe235ecc3c55913ef8445fa35fa
https://github.com/d2g/dhcp4client/blob/ef524ad9cb076fe235ecc3c55913ef8445fa35fa/pktsock_linux.go#L98-L113
136,170
googlearchive/go-gcm
cmd/gcm-logger/gcm-logger.go
onMessage
func onMessage(cm gcm.CcsMessage) error { toylog.Infoln("Message, from:", cm.From, "with:", cm.Data) // Echo the message with a tag. cm.Data["echoed"] = true m := gcm.HttpMessage{To: cm.From, Data: cm.Data} r, err := gcm.SendHttp(*serverKey, m) if err != nil { toylog.Errorln("Error sending message.", err) ret...
go
func onMessage(cm gcm.CcsMessage) error { toylog.Infoln("Message, from:", cm.From, "with:", cm.Data) // Echo the message with a tag. cm.Data["echoed"] = true m := gcm.HttpMessage{To: cm.From, Data: cm.Data} r, err := gcm.SendHttp(*serverKey, m) if err != nil { toylog.Errorln("Error sending message.", err) ret...
[ "func", "onMessage", "(", "cm", "gcm", ".", "CcsMessage", ")", "error", "{", "toylog", ".", "Infoln", "(", "\"", "\"", ",", "cm", ".", "From", ",", "\"", "\"", ",", "cm", ".", "Data", ")", "\n", "// Echo the message with a tag.", "cm", ".", "Data", "...
// onMessage receives messages, logs them, and echoes a response.
[ "onMessage", "receives", "messages", "logs", "them", "and", "echoes", "a", "response", "." ]
f387343038b10aec84c22f3809773a30630c12e8
https://github.com/googlearchive/go-gcm/blob/f387343038b10aec84c22f3809773a30630c12e8/cmd/gcm-logger/gcm-logger.go#L16-L28
136,171
googlearchive/go-gcm
gcm.go
send
func (c *httpGcmClient) send(apiKey string, m HttpMessage) (*HttpResponse, error) { bs, err := json.Marshal(m) if err != nil { return nil, fmt.Errorf("error marshalling message>%v", err) } debug("sending", string(bs)) req, err := http.NewRequest("POST", c.GcmURL, bytes.NewReader(bs)) if err != nil { return ni...
go
func (c *httpGcmClient) send(apiKey string, m HttpMessage) (*HttpResponse, error) { bs, err := json.Marshal(m) if err != nil { return nil, fmt.Errorf("error marshalling message>%v", err) } debug("sending", string(bs)) req, err := http.NewRequest("POST", c.GcmURL, bytes.NewReader(bs)) if err != nil { return ni...
[ "func", "(", "c", "*", "httpGcmClient", ")", "send", "(", "apiKey", "string", ",", "m", "HttpMessage", ")", "(", "*", "HttpResponse", ",", "error", ")", "{", "bs", ",", "err", ":=", "json", ".", "Marshal", "(", "m", ")", "\n", "if", "err", "!=", ...
// httpGcmClient implementation to send a message through GCM Http server.
[ "httpGcmClient", "implementation", "to", "send", "a", "message", "through", "GCM", "Http", "server", "." ]
f387343038b10aec84c22f3809773a30630c12e8
https://github.com/googlearchive/go-gcm/blob/f387343038b10aec84c22f3809773a30630c12e8/gcm.go#L180-L210
136,172
googlearchive/go-gcm
gcm.go
retryMessage
func (c *xmppGcmClient) retryMessage(cm CcsMessage, h MessageHandler) { c.messages.RLock() defer c.messages.RUnlock() if me, ok := c.messages.m[cm.MessageId]; ok { if me.backoff.sendAnother() { go func(m *messageLogEntry) { m.backoff.wait() c.send(*m.body) }(me) } else { debug("Exponential backo...
go
func (c *xmppGcmClient) retryMessage(cm CcsMessage, h MessageHandler) { c.messages.RLock() defer c.messages.RUnlock() if me, ok := c.messages.m[cm.MessageId]; ok { if me.backoff.sendAnother() { go func(m *messageLogEntry) { m.backoff.wait() c.send(*m.body) }(me) } else { debug("Exponential backo...
[ "func", "(", "c", "*", "xmppGcmClient", ")", "retryMessage", "(", "cm", "CcsMessage", ",", "h", "MessageHandler", ")", "{", "c", ".", "messages", ".", "RLock", "(", ")", "\n", "defer", "c", ".", "messages", ".", "RUnlock", "(", ")", "\n", "if", "me",...
// Retry sending a message with exponential backoff; if over limit, bubble up the failed message.
[ "Retry", "sending", "a", "message", "with", "exponential", "backoff", ";", "if", "over", "limit", "bubble", "up", "the", "failed", "message", "." ]
f387343038b10aec84c22f3809773a30630c12e8
https://github.com/googlearchive/go-gcm/blob/f387343038b10aec84c22f3809773a30630c12e8/gcm.go#L405-L419
136,173
googlearchive/go-gcm
gcm.go
newExponentialBackoff
func newExponentialBackoff() *exponentialBackoff { b := &backoff.Backoff{ Min: DefaultMinBackoff, Max: DefaultMaxBackoff, Jitter: true, } return &exponentialBackoff{b: *b, currentDelay: b.Duration()} }
go
func newExponentialBackoff() *exponentialBackoff { b := &backoff.Backoff{ Min: DefaultMinBackoff, Max: DefaultMaxBackoff, Jitter: true, } return &exponentialBackoff{b: *b, currentDelay: b.Duration()} }
[ "func", "newExponentialBackoff", "(", ")", "*", "exponentialBackoff", "{", "b", ":=", "&", "backoff", ".", "Backoff", "{", "Min", ":", "DefaultMinBackoff", ",", "Max", ":", "DefaultMaxBackoff", ",", "Jitter", ":", "true", ",", "}", "\n", "return", "&", "ex...
// Factory method for exponential backoff, uses default values for Min and Max and // adds Jitter.
[ "Factory", "method", "for", "exponential", "backoff", "uses", "default", "values", "for", "Min", "and", "Max", "and", "adds", "Jitter", "." ]
f387343038b10aec84c22f3809773a30630c12e8
https://github.com/googlearchive/go-gcm/blob/f387343038b10aec84c22f3809773a30630c12e8/gcm.go#L436-L443
136,174
googlearchive/go-gcm
gcm.go
setMin
func (eb *exponentialBackoff) setMin(min time.Duration) { eb.b.Min = min if (eb.currentDelay) < min { eb.currentDelay = min } }
go
func (eb *exponentialBackoff) setMin(min time.Duration) { eb.b.Min = min if (eb.currentDelay) < min { eb.currentDelay = min } }
[ "func", "(", "eb", "*", "exponentialBackoff", ")", "setMin", "(", "min", "time", ".", "Duration", ")", "{", "eb", ".", "b", ".", "Min", "=", "min", "\n", "if", "(", "eb", ".", "currentDelay", ")", "<", "min", "{", "eb", ".", "currentDelay", "=", ...
// Set the minumim delay for backoff
[ "Set", "the", "minumim", "delay", "for", "backoff" ]
f387343038b10aec84c22f3809773a30630c12e8
https://github.com/googlearchive/go-gcm/blob/f387343038b10aec84c22f3809773a30630c12e8/gcm.go#L451-L456
136,175
googlearchive/go-gcm
gcm.go
wait
func (eb exponentialBackoff) wait() { time.Sleep(eb.currentDelay) eb.currentDelay = eb.b.Duration() }
go
func (eb exponentialBackoff) wait() { time.Sleep(eb.currentDelay) eb.currentDelay = eb.b.Duration() }
[ "func", "(", "eb", "exponentialBackoff", ")", "wait", "(", ")", "{", "time", ".", "Sleep", "(", "eb", ".", "currentDelay", ")", "\n", "eb", ".", "currentDelay", "=", "eb", ".", "b", ".", "Duration", "(", ")", "\n", "}" ]
// Wait for the current value of backoff
[ "Wait", "for", "the", "current", "value", "of", "backoff" ]
f387343038b10aec84c22f3809773a30630c12e8
https://github.com/googlearchive/go-gcm/blob/f387343038b10aec84c22f3809773a30630c12e8/gcm.go#L459-L462
136,176
googlearchive/go-gcm
gcm.go
SendHttp
func SendHttp(apiKey string, m HttpMessage) (*HttpResponse, error) { c := &httpGcmClient{httpAddress, &http.Client{}, "0"} b := newExponentialBackoff() return sendHttp(apiKey, m, c, b) }
go
func SendHttp(apiKey string, m HttpMessage) (*HttpResponse, error) { c := &httpGcmClient{httpAddress, &http.Client{}, "0"} b := newExponentialBackoff() return sendHttp(apiKey, m, c, b) }
[ "func", "SendHttp", "(", "apiKey", "string", ",", "m", "HttpMessage", ")", "(", "*", "HttpResponse", ",", "error", ")", "{", "c", ":=", "&", "httpGcmClient", "{", "httpAddress", ",", "&", "http", ".", "Client", "{", "}", ",", "\"", "\"", "}", "\n", ...
// Send a message using the HTTP GCM connection server.
[ "Send", "a", "message", "using", "the", "HTTP", "GCM", "connection", "server", "." ]
f387343038b10aec84c22f3809773a30630c12e8
https://github.com/googlearchive/go-gcm/blob/f387343038b10aec84c22f3809773a30630c12e8/gcm.go#L465-L469
136,177
googlearchive/go-gcm
gcm.go
sendHttp
func sendHttp(apiKey string, m HttpMessage, c httpClient, b backoffProvider) (*HttpResponse, error) { // TODO(silvano): check this with responses for topic/notification group gcmResp := &HttpResponse{} var multicastId int targets, err := messageTargetAsStringsArray(m) if err != nil { return gcmResp, fmt.Errorf("...
go
func sendHttp(apiKey string, m HttpMessage, c httpClient, b backoffProvider) (*HttpResponse, error) { // TODO(silvano): check this with responses for topic/notification group gcmResp := &HttpResponse{} var multicastId int targets, err := messageTargetAsStringsArray(m) if err != nil { return gcmResp, fmt.Errorf("...
[ "func", "sendHttp", "(", "apiKey", "string", ",", "m", "HttpMessage", ",", "c", "httpClient", ",", "b", "backoffProvider", ")", "(", "*", "HttpResponse", ",", "error", ")", "{", "// TODO(silvano): check this with responses for topic/notification group", "gcmResp", ":=...
// sendHttp sends an http message using exponential backoff, handling multicast replies.
[ "sendHttp", "sends", "an", "http", "message", "using", "exponential", "backoff", "handling", "multicast", "replies", "." ]
f387343038b10aec84c22f3809773a30630c12e8
https://github.com/googlearchive/go-gcm/blob/f387343038b10aec84c22f3809773a30630c12e8/gcm.go#L472-L519
136,178
googlearchive/go-gcm
gcm.go
buildRespForMulticast
func buildRespForMulticast(to []string, mrs multicastResultsState, mid int) *HttpResponse { resp := &HttpResponse{} resp.MulticastId = mid resp.Results = make([]Result, len(to)) for i, regId := range to { result, ok := mrs[regId] if !ok { continue } resp.Results[i] = *result if result.MessageId != "" {...
go
func buildRespForMulticast(to []string, mrs multicastResultsState, mid int) *HttpResponse { resp := &HttpResponse{} resp.MulticastId = mid resp.Results = make([]Result, len(to)) for i, regId := range to { result, ok := mrs[regId] if !ok { continue } resp.Results[i] = *result if result.MessageId != "" {...
[ "func", "buildRespForMulticast", "(", "to", "[", "]", "string", ",", "mrs", "multicastResultsState", ",", "mid", "int", ")", "*", "HttpResponse", "{", "resp", ":=", "&", "HttpResponse", "{", "}", "\n", "resp", ".", "MulticastId", "=", "mid", "\n", "resp", ...
// Builds the final response for a multicast message, in case there have been retries for // subsets of the original recipients.
[ "Builds", "the", "final", "response", "for", "a", "multicast", "message", "in", "case", "there", "have", "been", "retries", "for", "subsets", "of", "the", "original", "recipients", "." ]
f387343038b10aec84c22f3809773a30630c12e8
https://github.com/googlearchive/go-gcm/blob/f387343038b10aec84c22f3809773a30630c12e8/gcm.go#L523-L543
136,179
googlearchive/go-gcm
gcm.go
messageTargetAsStringsArray
func messageTargetAsStringsArray(m HttpMessage) ([]string, error) { if m.RegistrationIds != nil { return m.RegistrationIds, nil } else if m.To != "" { target := []string{m.To} return target, nil } target := []string{} return target, fmt.Errorf("can't find any valid target field in message.") }
go
func messageTargetAsStringsArray(m HttpMessage) ([]string, error) { if m.RegistrationIds != nil { return m.RegistrationIds, nil } else if m.To != "" { target := []string{m.To} return target, nil } target := []string{} return target, fmt.Errorf("can't find any valid target field in message.") }
[ "func", "messageTargetAsStringsArray", "(", "m", "HttpMessage", ")", "(", "[", "]", "string", ",", "error", ")", "{", "if", "m", ".", "RegistrationIds", "!=", "nil", "{", "return", "m", ".", "RegistrationIds", ",", "nil", "\n", "}", "else", "if", "m", ...
// Transform the recipient in an array of strings if needed.
[ "Transform", "the", "recipient", "in", "an", "array", "of", "strings", "if", "needed", "." ]
f387343038b10aec84c22f3809773a30630c12e8
https://github.com/googlearchive/go-gcm/blob/f387343038b10aec84c22f3809773a30630c12e8/gcm.go#L546-L555
136,180
googlearchive/go-gcm
gcm.go
checkResults
func checkResults(gcmResults []Result, recipients []string, resultsState multicastResultsState) (doRetry bool, toRetry []string, err error) { doRetry = false toRetry = []string{} for i := 0; i < len(gcmResults); i++ { result := gcmResults[i] regId := recipients[i] resultsState[regId] = &result if result.Erro...
go
func checkResults(gcmResults []Result, recipients []string, resultsState multicastResultsState) (doRetry bool, toRetry []string, err error) { doRetry = false toRetry = []string{} for i := 0; i < len(gcmResults); i++ { result := gcmResults[i] regId := recipients[i] resultsState[regId] = &result if result.Erro...
[ "func", "checkResults", "(", "gcmResults", "[", "]", "Result", ",", "recipients", "[", "]", "string", ",", "resultsState", "multicastResultsState", ")", "(", "doRetry", "bool", ",", "toRetry", "[", "]", "string", ",", "err", "error", ")", "{", "doRetry", "...
// For a multicast send, determines which errors can be retried.
[ "For", "a", "multicast", "send", "determines", "which", "errors", "can", "be", "retried", "." ]
f387343038b10aec84c22f3809773a30630c12e8
https://github.com/googlearchive/go-gcm/blob/f387343038b10aec84c22f3809773a30630c12e8/gcm.go#L558-L575
136,181
googlearchive/go-gcm
gcm.go
SendXmpp
func SendXmpp(senderId, apiKey string, m XmppMessage) (string, int, error) { c, err := newXmppGcmClient(senderId, apiKey) if err != nil { return "", 0, fmt.Errorf("error creating xmpp client>%v", err) } return c.send(m) }
go
func SendXmpp(senderId, apiKey string, m XmppMessage) (string, int, error) { c, err := newXmppGcmClient(senderId, apiKey) if err != nil { return "", 0, fmt.Errorf("error creating xmpp client>%v", err) } return c.send(m) }
[ "func", "SendXmpp", "(", "senderId", ",", "apiKey", "string", ",", "m", "XmppMessage", ")", "(", "string", ",", "int", ",", "error", ")", "{", "c", ",", "err", ":=", "newXmppGcmClient", "(", "senderId", ",", "apiKey", ")", "\n", "if", "err", "!=", "n...
// SendXmpp sends a message using the XMPP GCM connection server.
[ "SendXmpp", "sends", "a", "message", "using", "the", "XMPP", "GCM", "connection", "server", "." ]
f387343038b10aec84c22f3809773a30630c12e8
https://github.com/googlearchive/go-gcm/blob/f387343038b10aec84c22f3809773a30630c12e8/gcm.go#L578-L584
136,182
dnsimple/dnsimple-go
dnsimple/oauth.go
ExchangeAuthorizationForToken
func (s *OauthService) ExchangeAuthorizationForToken(authorization *ExchangeAuthorizationRequest) (*AccessToken, error) { path := versioned("/oauth/access_token") req, err := s.client.NewRequest("POST", path, authorization) if err != nil { return nil, err } resp, err := s.client.httpClient.Do(req) if err != n...
go
func (s *OauthService) ExchangeAuthorizationForToken(authorization *ExchangeAuthorizationRequest) (*AccessToken, error) { path := versioned("/oauth/access_token") req, err := s.client.NewRequest("POST", path, authorization) if err != nil { return nil, err } resp, err := s.client.httpClient.Do(req) if err != n...
[ "func", "(", "s", "*", "OauthService", ")", "ExchangeAuthorizationForToken", "(", "authorization", "*", "ExchangeAuthorizationRequest", ")", "(", "*", "AccessToken", ",", "error", ")", "{", "path", ":=", "versioned", "(", "\"", "\"", ")", "\n\n", "req", ",", ...
// ExchangeAuthorizationForToken exchanges the short-lived authorization code for an access token // you can use to authenticate your API calls.
[ "ExchangeAuthorizationForToken", "exchanges", "the", "short", "-", "lived", "authorization", "code", "for", "an", "access", "token", "you", "can", "use", "to", "authenticate", "your", "API", "calls", "." ]
7f63b6276b126cfe51ee03cb5fa41c87267ed2c7
https://github.com/dnsimple/dnsimple-go/blob/7f63b6276b126cfe51ee03cb5fa41c87267ed2c7/dnsimple/oauth.go#L67-L92
136,183
dnsimple/dnsimple-go
dnsimple/oauth.go
AuthorizeURL
func (s *OauthService) AuthorizeURL(clientID string, options *AuthorizationOptions) string { uri, _ := url.Parse(strings.Replace(s.client.BaseURL, "api.", "", 1)) uri.Path = "/oauth/authorize" query := uri.Query() query.Add("client_id", clientID) query.Add("response_type", "code") uri.RawQuery = query.Encode() ...
go
func (s *OauthService) AuthorizeURL(clientID string, options *AuthorizationOptions) string { uri, _ := url.Parse(strings.Replace(s.client.BaseURL, "api.", "", 1)) uri.Path = "/oauth/authorize" query := uri.Query() query.Add("client_id", clientID) query.Add("response_type", "code") uri.RawQuery = query.Encode() ...
[ "func", "(", "s", "*", "OauthService", ")", "AuthorizeURL", "(", "clientID", "string", ",", "options", "*", "AuthorizationOptions", ")", "string", "{", "uri", ",", "_", ":=", "url", ".", "Parse", "(", "strings", ".", "Replace", "(", "s", ".", "client", ...
// AuthorizeURL generates the URL to authorize an user for an application via the OAuth2 flow.
[ "AuthorizeURL", "generates", "the", "URL", "to", "authorize", "an", "user", "for", "an", "application", "via", "the", "OAuth2", "flow", "." ]
7f63b6276b126cfe51ee03cb5fa41c87267ed2c7
https://github.com/dnsimple/dnsimple-go/blob/7f63b6276b126cfe51ee03cb5fa41c87267ed2c7/dnsimple/oauth.go#L103-L113
136,184
dnsimple/dnsimple-go
dnsimple/webhook/webhook.go
Parse
func Parse(payload []byte) (Event, error) { action, err := ParseName(payload) if err != nil { return nil, err } return switchEvent(action, payload) }
go
func Parse(payload []byte) (Event, error) { action, err := ParseName(payload) if err != nil { return nil, err } return switchEvent(action, payload) }
[ "func", "Parse", "(", "payload", "[", "]", "byte", ")", "(", "Event", ",", "error", ")", "{", "action", ",", "err", ":=", "ParseName", "(", "payload", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "retu...
// Parse takes a payload and attempts to deserialize the payload into an event type // that matches the event action in the payload. If no direct match is found, then a DefaultEvent is returned. // // Parse returns type is an Event interface. Therefore, you must perform typecasting // to access any event-specific field...
[ "Parse", "takes", "a", "payload", "and", "attempts", "to", "deserialize", "the", "payload", "into", "an", "event", "type", "that", "matches", "the", "event", "action", "in", "the", "payload", ".", "If", "no", "direct", "match", "is", "found", "then", "a", ...
7f63b6276b126cfe51ee03cb5fa41c87267ed2c7
https://github.com/dnsimple/dnsimple-go/blob/7f63b6276b126cfe51ee03cb5fa41c87267ed2c7/dnsimple/webhook/webhook.go#L81-L88
136,185
dnsimple/dnsimple-go
dnsimple/dnsimple.go
Do
func (c *Client) Do(req *http.Request, obj interface{}) (*http.Response, error) { if c.Debug { log.Printf("Executing request (%v): %#v", req.URL, req) } resp, err := c.httpClient.Do(req) if err != nil { return nil, err } defer resp.Body.Close() if c.Debug { log.Printf("Response received: %#v", resp) } ...
go
func (c *Client) Do(req *http.Request, obj interface{}) (*http.Response, error) { if c.Debug { log.Printf("Executing request (%v): %#v", req.URL, req) } resp, err := c.httpClient.Do(req) if err != nil { return nil, err } defer resp.Body.Close() if c.Debug { log.Printf("Response received: %#v", resp) } ...
[ "func", "(", "c", "*", "Client", ")", "Do", "(", "req", "*", "http", ".", "Request", ",", "obj", "interface", "{", "}", ")", "(", "*", "http", ".", "Response", ",", "error", ")", "{", "if", "c", ".", "Debug", "{", "log", ".", "Printf", "(", "...
// Do sends an API request and returns the API response. // // The API response is JSON decoded and stored in the value pointed by obj, // or returned as an error if an API error has occurred. // If obj implements the io.Writer interface, the raw response body will be written to obj, // without attempting to decode it.
[ "Do", "sends", "an", "API", "request", "and", "returns", "the", "API", "response", ".", "The", "API", "response", "is", "JSON", "decoded", "and", "stored", "in", "the", "value", "pointed", "by", "obj", "or", "returned", "as", "an", "error", "if", "an", ...
7f63b6276b126cfe51ee03cb5fa41c87267ed2c7
https://github.com/dnsimple/dnsimple-go/blob/7f63b6276b126cfe51ee03cb5fa41c87267ed2c7/dnsimple/dnsimple.go#L207-L238
136,186
dnsimple/dnsimple-go
dnsimple/dnsimple.go
RateLimit
func (r *Response) RateLimit() int { value, _ := strconv.Atoi(r.HttpResponse.Header.Get("X-RateLimit-Limit")) return value }
go
func (r *Response) RateLimit() int { value, _ := strconv.Atoi(r.HttpResponse.Header.Get("X-RateLimit-Limit")) return value }
[ "func", "(", "r", "*", "Response", ")", "RateLimit", "(", ")", "int", "{", "value", ",", "_", ":=", "strconv", ".", "Atoi", "(", "r", ".", "HttpResponse", ".", "Header", ".", "Get", "(", "\"", "\"", ")", ")", "\n", "return", "value", "\n", "}" ]
// RateLimit returns the maximum amount of requests this account can send in an hour.
[ "RateLimit", "returns", "the", "maximum", "amount", "of", "requests", "this", "account", "can", "send", "in", "an", "hour", "." ]
7f63b6276b126cfe51ee03cb5fa41c87267ed2c7
https://github.com/dnsimple/dnsimple-go/blob/7f63b6276b126cfe51ee03cb5fa41c87267ed2c7/dnsimple/dnsimple.go#L250-L253
136,187
dnsimple/dnsimple-go
dnsimple/dnsimple.go
RateLimitReset
func (r *Response) RateLimitReset() time.Time { value, _ := strconv.ParseInt(r.HttpResponse.Header.Get("X-RateLimit-Reset"), 10, 64) return time.Unix(value, 0) }
go
func (r *Response) RateLimitReset() time.Time { value, _ := strconv.ParseInt(r.HttpResponse.Header.Get("X-RateLimit-Reset"), 10, 64) return time.Unix(value, 0) }
[ "func", "(", "r", "*", "Response", ")", "RateLimitReset", "(", ")", "time", ".", "Time", "{", "value", ",", "_", ":=", "strconv", ".", "ParseInt", "(", "r", ".", "HttpResponse", ".", "Header", ".", "Get", "(", "\"", "\"", ")", ",", "10", ",", "64...
// RateLimitReset returns when the throttling window will be reset for this account.
[ "RateLimitReset", "returns", "when", "the", "throttling", "window", "will", "be", "reset", "for", "this", "account", "." ]
7f63b6276b126cfe51ee03cb5fa41c87267ed2c7
https://github.com/dnsimple/dnsimple-go/blob/7f63b6276b126cfe51ee03cb5fa41c87267ed2c7/dnsimple/dnsimple.go#L262-L265
136,188
capnm/sysinfo
sysinfo.go
String
func (si SI) String() string { // XXX: Is the copy of SI done atomic? Not sure. // Without an outer lock this may print a junk. return fmt.Sprintf("uptime\t\t%v\nload\t\t%2.2f %2.2f %2.2f\nprocs\t\t%d\n"+ "ram total\t%d kB\nram free\t%d kB\nram buffer\t%d kB\n"+ "swap total\t%d kB\nswap free\t%d kB", //"hig...
go
func (si SI) String() string { // XXX: Is the copy of SI done atomic? Not sure. // Without an outer lock this may print a junk. return fmt.Sprintf("uptime\t\t%v\nload\t\t%2.2f %2.2f %2.2f\nprocs\t\t%d\n"+ "ram total\t%d kB\nram free\t%d kB\nram buffer\t%d kB\n"+ "swap total\t%d kB\nswap free\t%d kB", //"hig...
[ "func", "(", "si", "SI", ")", "String", "(", ")", "string", "{", "// XXX: Is the copy of SI done atomic? Not sure.", "// Without an outer lock this may print a junk.", "return", "fmt", ".", "Sprintf", "(", "\"", "\\t", "\\t", "\\n", "\\t", "\\t", "\\n", "\\t", "\\t"...
// Make the "fmt" Stringer interface happy.
[ "Make", "the", "fmt", "Stringer", "interface", "happy", "." ]
5909a53897f32d198d9c81e3417f6d25ecfd2229
https://github.com/capnm/sysinfo/blob/5909a53897f32d198d9c81e3417f6d25ecfd2229/sysinfo.go#L94-L106
136,189
fuyufjh/splunk-hec-go
client.go
WaitForAcknowledgementWithContext
func (hec *Client) WaitForAcknowledgementWithContext(ctx context.Context) error { // Make our own copy of the list of acknowledgement IDs and remove them // from the client while we check them. hec.ackMux.Lock() ackIDs := hec.ackIDs hec.ackIDs = nil hec.ackMux.Unlock() if len(ackIDs) == 0 { return nil } en...
go
func (hec *Client) WaitForAcknowledgementWithContext(ctx context.Context) error { // Make our own copy of the list of acknowledgement IDs and remove them // from the client while we check them. hec.ackMux.Lock() ackIDs := hec.ackIDs hec.ackIDs = nil hec.ackMux.Unlock() if len(ackIDs) == 0 { return nil } en...
[ "func", "(", "hec", "*", "Client", ")", "WaitForAcknowledgementWithContext", "(", "ctx", "context", ".", "Context", ")", "error", "{", "// Make our own copy of the list of acknowledgement IDs and remove them", "// from the client while we check them.", "hec", ".", "ackMux", "...
// WaitForAcknowledgementWithContext blocks until the Splunk indexer has // acknowledged that all previously submitted data has been successfully // indexed or if the provided context is cancelled. This requires the HEC token // configuration in Splunk to have indexer acknowledgement enabled.
[ "WaitForAcknowledgementWithContext", "blocks", "until", "the", "Splunk", "indexer", "has", "acknowledged", "that", "all", "previously", "submitted", "data", "has", "been", "successfully", "indexed", "or", "if", "the", "provided", "context", "is", "cancelled", ".", "...
10df423a9f3633e5395eaf8132da3a257251b189
https://github.com/fuyufjh/splunk-hec-go/blob/10df423a9f3633e5395eaf8132da3a257251b189/client.go#L187-L243
136,190
fuyufjh/splunk-hec-go
client.go
WaitForAcknowledgement
func (hec *Client) WaitForAcknowledgement() error { ctx, cancel := context.WithTimeout(context.Background(), defaultAcknowledgementTimeout) defer cancel() return hec.WaitForAcknowledgementWithContext(ctx) }
go
func (hec *Client) WaitForAcknowledgement() error { ctx, cancel := context.WithTimeout(context.Background(), defaultAcknowledgementTimeout) defer cancel() return hec.WaitForAcknowledgementWithContext(ctx) }
[ "func", "(", "hec", "*", "Client", ")", "WaitForAcknowledgement", "(", ")", "error", "{", "ctx", ",", "cancel", ":=", "context", ".", "WithTimeout", "(", "context", ".", "Background", "(", ")", ",", "defaultAcknowledgementTimeout", ")", "\n", "defer", "cance...
// WaitForAcknowledgement blocks until the Splunk indexer has acknowledged // that all previously submitted data has been successfully indexed or if the // default acknowledgement timeout is reached. This requires the HEC token // configuration in Splunk to have indexer acknowledgement enabled.
[ "WaitForAcknowledgement", "blocks", "until", "the", "Splunk", "indexer", "has", "acknowledged", "that", "all", "previously", "submitted", "data", "has", "been", "successfully", "indexed", "or", "if", "the", "default", "acknowledgement", "timeout", "is", "reached", "...
10df423a9f3633e5395eaf8132da3a257251b189
https://github.com/fuyufjh/splunk-hec-go/blob/10df423a9f3633e5395eaf8132da3a257251b189/client.go#L249-L253
136,191
u-root/dhcp4
packet.go
NewPacket
func NewPacket(op OpCode) *Packet { return &Packet{ Op: op, HType: 1, /* ethernet */ Options: make(Options), } }
go
func NewPacket(op OpCode) *Packet { return &Packet{ Op: op, HType: 1, /* ethernet */ Options: make(Options), } }
[ "func", "NewPacket", "(", "op", "OpCode", ")", "*", "Packet", "{", "return", "&", "Packet", "{", "Op", ":", "op", ",", "HType", ":", "1", ",", "/* ethernet */", "Options", ":", "make", "(", "Options", ")", ",", "}", "\n", "}" ]
// NewPacket returns a new DHCP packet with the given op code.
[ "NewPacket", "returns", "a", "new", "DHCP", "packet", "with", "the", "given", "op", "code", "." ]
03363dc71ec82763595440b4b2c3e5f69f47a4e0
https://github.com/u-root/dhcp4/blob/03363dc71ec82763595440b4b2c3e5f69f47a4e0/packet.go#L87-L93
136,192
u-root/dhcp4
packet.go
MarshalBinary
func (p *Packet) MarshalBinary() ([]byte, error) { b := uio.NewBigEndianBuffer(make([]byte, 0, minPacketLen)) b.Write8(uint8(p.Op)) b.Write8(p.HType) // HLen b.Write8(uint8(len(p.CHAddr))) b.Write8(p.Hops) b.WriteBytes(p.TransactionID[:]) b.Write16(p.Secs) var flags uint16 if p.Broadcast { flags |= flagBr...
go
func (p *Packet) MarshalBinary() ([]byte, error) { b := uio.NewBigEndianBuffer(make([]byte, 0, minPacketLen)) b.Write8(uint8(p.Op)) b.Write8(p.HType) // HLen b.Write8(uint8(len(p.CHAddr))) b.Write8(p.Hops) b.WriteBytes(p.TransactionID[:]) b.Write16(p.Secs) var flags uint16 if p.Broadcast { flags |= flagBr...
[ "func", "(", "p", "*", "Packet", ")", "MarshalBinary", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "b", ":=", "uio", ".", "NewBigEndianBuffer", "(", "make", "(", "[", "]", "byte", ",", "0", ",", "minPacketLen", ")", ")", "\n", "b", ...
// MarshalBinary writes the packet to binary.
[ "MarshalBinary", "writes", "the", "packet", "to", "binary", "." ]
03363dc71ec82763595440b4b2c3e5f69f47a4e0
https://github.com/u-root/dhcp4/blob/03363dc71ec82763595440b4b2c3e5f69f47a4e0/packet.go#L105-L144
136,193
u-root/dhcp4
packet.go
ParsePacket
func ParsePacket(q []byte) (*Packet, error) { var pkt Packet if err := (&pkt).UnmarshalBinary(q); err != nil { return nil, err } return &pkt, nil }
go
func ParsePacket(q []byte) (*Packet, error) { var pkt Packet if err := (&pkt).UnmarshalBinary(q); err != nil { return nil, err } return &pkt, nil }
[ "func", "ParsePacket", "(", "q", "[", "]", "byte", ")", "(", "*", "Packet", ",", "error", ")", "{", "var", "pkt", "Packet", "\n", "if", "err", ":=", "(", "&", "pkt", ")", ".", "UnmarshalBinary", "(", "q", ")", ";", "err", "!=", "nil", "{", "ret...
// ParsePacket parses a DHCP4 packet from q.
[ "ParsePacket", "parses", "a", "DHCP4", "packet", "from", "q", "." ]
03363dc71ec82763595440b4b2c3e5f69f47a4e0
https://github.com/u-root/dhcp4/blob/03363dc71ec82763595440b4b2c3e5f69f47a4e0/packet.go#L147-L153
136,194
u-root/dhcp4
packet.go
UnmarshalBinary
func (p *Packet) UnmarshalBinary(q []byte) error { b := uio.NewBigEndianBuffer(q) p.Op = OpCode(b.Read8()) p.HType = b.Read8() hlen := b.Read8() p.Hops = b.Read8() b.ReadBytes(p.TransactionID[:]) p.Secs = b.Read16() flags := b.Read16() if flags&flagBroadcast != 0 { p.Broadcast = true } p.CIAddr = make(n...
go
func (p *Packet) UnmarshalBinary(q []byte) error { b := uio.NewBigEndianBuffer(q) p.Op = OpCode(b.Read8()) p.HType = b.Read8() hlen := b.Read8() p.Hops = b.Read8() b.ReadBytes(p.TransactionID[:]) p.Secs = b.Read16() flags := b.Read16() if flags&flagBroadcast != 0 { p.Broadcast = true } p.CIAddr = make(n...
[ "func", "(", "p", "*", "Packet", ")", "UnmarshalBinary", "(", "q", "[", "]", "byte", ")", "error", "{", "b", ":=", "uio", ".", "NewBigEndianBuffer", "(", "q", ")", "\n\n", "p", ".", "Op", "=", "OpCode", "(", "b", ".", "Read8", "(", ")", ")", "\...
// UnmarshalBinary reads the packet from binary.
[ "UnmarshalBinary", "reads", "the", "packet", "from", "binary", "." ]
03363dc71ec82763595440b4b2c3e5f69f47a4e0
https://github.com/u-root/dhcp4/blob/03363dc71ec82763595440b4b2c3e5f69f47a4e0/packet.go#L156-L214
136,195
u-root/dhcp4
options.go
Unmarshal
func (o *Options) Unmarshal(buf *uio.Lexer) error { *o = make(Options) var end bool for buf.Has(1) { // 1 byte: option code // 1 byte: option length n // n bytes: data code := OptionCode(buf.Read8()) if code == Pad { continue } else if code == End { end = true break } if !buf.Has(1) { r...
go
func (o *Options) Unmarshal(buf *uio.Lexer) error { *o = make(Options) var end bool for buf.Has(1) { // 1 byte: option code // 1 byte: option length n // n bytes: data code := OptionCode(buf.Read8()) if code == Pad { continue } else if code == End { end = true break } if !buf.Has(1) { r...
[ "func", "(", "o", "*", "Options", ")", "Unmarshal", "(", "buf", "*", "uio", ".", "Lexer", ")", "error", "{", "*", "o", "=", "make", "(", "Options", ")", "\n\n", "var", "end", "bool", "\n", "for", "buf", ".", "Has", "(", "1", ")", "{", "// 1 byt...
// Unmarshal fills opts with option codes and corresponding values from an // input byte slice. // // It is used with various different types to enable parsing of both top-level // options. If options data is malformed, it returns ErrInvalidOptions or // io.ErrUnexpectedEOF.
[ "Unmarshal", "fills", "opts", "with", "option", "codes", "and", "corresponding", "values", "from", "an", "input", "byte", "slice", ".", "It", "is", "used", "with", "various", "different", "types", "to", "enable", "parsing", "of", "both", "top", "-", "level",...
03363dc71ec82763595440b4b2c3e5f69f47a4e0
https://github.com/u-root/dhcp4/blob/03363dc71ec82763595440b4b2c3e5f69f47a4e0/options.go#L70-L122
136,196
u-root/dhcp4
options.go
Marshal
func (o Options) Marshal(b *uio.Lexer) { for _, c := range o.sortedKeys() { code := OptionCode(c) data := o[code] // RFC 3396: If more than 256 bytes of data are given, the // option is simply listed multiple times. for len(data) > 0 { // 1 byte: option code b.Write8(uint8(code)) // Some DHCPv4 op...
go
func (o Options) Marshal(b *uio.Lexer) { for _, c := range o.sortedKeys() { code := OptionCode(c) data := o[code] // RFC 3396: If more than 256 bytes of data are given, the // option is simply listed multiple times. for len(data) > 0 { // 1 byte: option code b.Write8(uint8(code)) // Some DHCPv4 op...
[ "func", "(", "o", "Options", ")", "Marshal", "(", "b", "*", "uio", ".", "Lexer", ")", "{", "for", "_", ",", "c", ":=", "range", "o", ".", "sortedKeys", "(", ")", "{", "code", ":=", "OptionCode", "(", "c", ")", "\n", "data", ":=", "o", "[", "c...
// Marshal writes options into the provided Buffer sorted by option codes.
[ "Marshal", "writes", "options", "into", "the", "provided", "Buffer", "sorted", "by", "option", "codes", "." ]
03363dc71ec82763595440b4b2c3e5f69f47a4e0
https://github.com/u-root/dhcp4/blob/03363dc71ec82763595440b4b2c3e5f69f47a4e0/options.go#L125-L160
136,197
u-root/dhcp4
options.go
sortedKeys
func (o Options) sortedKeys() []int { // Send all values for a given key var codes []int for k := range o { codes = append(codes, int(k)) } sort.Sort(sort.IntSlice(codes)) return codes }
go
func (o Options) sortedKeys() []int { // Send all values for a given key var codes []int for k := range o { codes = append(codes, int(k)) } sort.Sort(sort.IntSlice(codes)) return codes }
[ "func", "(", "o", "Options", ")", "sortedKeys", "(", ")", "[", "]", "int", "{", "// Send all values for a given key", "var", "codes", "[", "]", "int", "\n", "for", "k", ":=", "range", "o", "{", "codes", "=", "append", "(", "codes", ",", "int", "(", "...
// sortedKeys returns an ordered slice of option keys from the Options map, for // use in serializing options to binary.
[ "sortedKeys", "returns", "an", "ordered", "slice", "of", "option", "keys", "from", "the", "Options", "map", "for", "use", "in", "serializing", "options", "to", "binary", "." ]
03363dc71ec82763595440b4b2c3e5f69f47a4e0
https://github.com/u-root/dhcp4/blob/03363dc71ec82763595440b4b2c3e5f69f47a4e0/options.go#L164-L173
136,198
u-root/dhcp4
dhcp4client/client.go
New
func New(iface netlink.Link, opts ...ClientOpt) (*Client, error) { c := &Client{ iface: iface, timeout: 10 * time.Second, retry: 3, } for _, opt := range opts { if err := opt(c); err != nil { return nil, err } } if c.conn == nil { var err error c.conn, err = NewPacketUDPConn(iface.Attrs().Na...
go
func New(iface netlink.Link, opts ...ClientOpt) (*Client, error) { c := &Client{ iface: iface, timeout: 10 * time.Second, retry: 3, } for _, opt := range opts { if err := opt(c); err != nil { return nil, err } } if c.conn == nil { var err error c.conn, err = NewPacketUDPConn(iface.Attrs().Na...
[ "func", "New", "(", "iface", "netlink", ".", "Link", ",", "opts", "...", "ClientOpt", ")", "(", "*", "Client", ",", "error", ")", "{", "c", ":=", "&", "Client", "{", "iface", ":", "iface", ",", "timeout", ":", "10", "*", "time", ".", "Second", ",...
// New creates a new DHCP client that sends and receives packets on the given // interface.
[ "New", "creates", "a", "new", "DHCP", "client", "that", "sends", "and", "receives", "packets", "on", "the", "given", "interface", "." ]
03363dc71ec82763595440b4b2c3e5f69f47a4e0
https://github.com/u-root/dhcp4/blob/03363dc71ec82763595440b4b2c3e5f69f47a4e0/dhcp4client/client.go#L53-L74
136,199
u-root/dhcp4
dhcp4client/client.go
WithConn
func WithConn(conn net.PacketConn) ClientOpt { return func(c *Client) error { c.conn = conn return nil } }
go
func WithConn(conn net.PacketConn) ClientOpt { return func(c *Client) error { c.conn = conn return nil } }
[ "func", "WithConn", "(", "conn", "net", ".", "PacketConn", ")", "ClientOpt", "{", "return", "func", "(", "c", "*", "Client", ")", "error", "{", "c", ".", "conn", "=", "conn", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// WithConn configures the packet connection to use.
[ "WithConn", "configures", "the", "packet", "connection", "to", "use", "." ]
03363dc71ec82763595440b4b2c3e5f69f47a4e0
https://github.com/u-root/dhcp4/blob/03363dc71ec82763595440b4b2c3e5f69f47a4e0/dhcp4client/client.go#L104-L109