id stringlengths 2 7 | text stringlengths 17 51.2k | title stringclasses 1 value |
|---|---|---|
c181400 | certPool.AppendCertsFromPEM(ca); !err {
return nil, errors.New("could not append CA Certificate to CertPool")
}
return certPool, nil
} | |
c181401 | if o.AuthErrorHandler != nil {
h = o.AuthErrorHandler
}
return &Auth{
opt: o,
authErrHandler: http.HandlerFunc(h),
}
} | |
c181402 | leaf certs is possible. For now, only validate
// one cert, and make sure it matches the first peer certificate
if r.TLS.PeerCertificates != nil {
if !bytes.Equal(r.TLS.PeerCertificates[0].Raw, r.TLS.VerifiedChains[0][0].Raw) {
return errors.New("first peer certificate not first verified chain leaf")
}
}
return nil
} | |
c181403 | }
}
// Validate CN
if len(a.opt.AllowedCNs) > 0 {
err := a.ValidateCN(r.TLS.VerifiedChains[0][0])
if err != nil {
a.authErrHandler.ServeHTTP(w, r)
return err
}
}
return nil
} | |
c181404 |
failed = append(failed, verifiedCert.Subject.CommonName)
}
return fmt.Errorf("cert failed CN validation for %v, Allowed: %v", failed, a.opt.AllowedCNs)
} | |
c181405 | }
failed = append(failed, clientOU)
}
}
return fmt.Errorf("cert failed OU validation for %v, Allowed: %v", failed, a.opt.AllowedOUs)
} | |
c181406 | += 2
}
if x >= 1<<8 {
x >>= 8
n += 1
}
return n
} | |
c181407 | newVaultClient, err := vaultclient.NewClient(newClientConfig)
if err != nil {
panic(err)
}
newConfig := Config{
// Dependencies.
VaultClient: newVaultClient,
}
return newConfig
} | |
c181408 | nil, microerror.Maskf(invalidConfigError, "Vault client must not be empty")
}
return newCertSigner, nil
} | |
c181409 | microerror.Maskf(invalidConfigError, "Vault address must not be empty")
}
if newVaultFactory.AdminToken == "" {
return nil, microerror.Maskf(invalidConfigError, "Vault admin token must not be empty")
}
return newVaultFactory, nil
} | |
c181410 | newVaultClient, err := vaultclient.NewClient(newClientConfig)
if err != nil {
panic(err)
}
newConfig := ServiceConfig{
// Dependencies.
VaultClient: newVaultClient,
}
return newConfig
} | |
c181411 | }
newService := &service{
ServiceConfig: config,
}
return newService, nil
} | |
c181412 | != nil {
return microerror.Mask(err)
}
if mounted {
err = sysBackend.Unmount(s.MountPKIPath(clusterID))
if err != nil {
return microerror.Mask(err)
}
}
return nil
} | |
c181413 |
if cause != nil && strings.Contains(cause.Error(), "no handler for route") {
return true
}
return false
} | |
c181414 | empty")
}
service := &service{
vaultClient: config.VaultClient,
pkiMountpoint: config.PKIMountpoint,
}
return service, nil
} | |
c181415 |
_, err := logicalStore.Write(fmt.Sprintf("%s/roles/%s", s.pkiMountpoint, params.Name), data)
if err != nil {
return microerror.Mask(err)
}
return nil
} | |
c181416 | nil,
RuntimeProcessingFrequency: 200 * time.Millisecond,
SummaryBuffer: 1,
}
} | |
c181417 |
err = config.runWorker()
if err != nil {
panic(err)
}
} | |
c181418 | range initpaths {
matches, err := filepath.Glob(path)
if err != nil {
continue
}
paths = append(paths, matches...)
}
if dir_notify {
w.syncAddPaths(paths...)
} else {
for _, path := range paths {
w.paths[path] = watchPath(path)
}
}
return
} | |
c181419 | }
w.notify_chan = make(chan *Notification, NotificationBufLen)
go w.watch(w.notify_chan)
return w.notify_chan
} | |
c181420 | w.add_chan != nil {
close(w.add_chan)
}
} | |
c181421 | != nil && len(w.paths) > 0
} | |
c181422 | }
if w.auto_watch && w.notify_chan != nil {
for _, path := range paths {
wi := watchPath(path)
w.addPaths(wi)
}
} else if w.auto_watch {
w.syncAddPaths(paths...)
} else {
for _, path := range paths {
w.paths[path] = watchPath(path)
}
}
} | |
c181423 | }
if wi.LastEvent == NOEXIST && w.auto_watch {
delete(w.paths, wi.Path)
}
if len(w.paths) == 0 {
w.Stop()
}
}
}
} | |
c181424 | 0)
for path, _ := range w.paths {
paths = append(paths, path)
}
return
} | |
c181425 | if w.paths == nil {
return
}
for _, wi := range w.paths {
state = append(state, *wi.Notification())
}
return
} | |
c181426 | // check err after checking context to fail fast if unconfigured
if err != nil {
*errptr = err
}
} | |
c181427 | !ok {
return nil
}
return *errptr
} | |
c181428 | r *http.Request) {
var err error
ctx := context.WithValue(r.Context(), errorKey, &err)
next.ServeHTTP(w, r.WithContext(ctx))
if err != nil {
h(w, r, err)
}
})
}
} | |
c181429 |
err := h.ServeHTTP(w, r)
Store(r, err)
})
} | |
c181430 | != nil {
Store(r, PanicError{
value: v,
stack: stack(1),
})
}
}()
next.ServeHTTP(w, r)
})
}
} | |
c181431 | {
log.Fatalf("request: %s", err)
}
r := resp.Body
i := 0
buff := make([]byte, 32*1024)
for {
n, err := r.Read(buff)
if err != nil {
break
}
i++
log.Printf("#%d: %s", i, sizestr.ToString(int64(n)))
}
r.Close()
log.Printf("closed")
} | |
c181432 | log.Printf("[velox] sync handler error: %s", err)
} else {
conn.Wait()
}
})
} | |
c181433 | != nil {
goto disconnected
}
case <-c.connectedCh:
goto disconnected
}
}
disconnected:
c.connected = false
c.Close()
//unblock waiters
c.waiter.Done()
}()
//non-blocking wait on connection
go func() {
if err := c.transport.wait(); err != nil {
//log error?
}
close(c.connectedCh)
}()
//now connected, consumer can connection.Wait()
return nil
} | |
c181434 |
//send (transports responsiblity to enforce timeouts)
return c.transport.send(upd)
} | |
c181435 |
n := len(s.conns)
s.connMut.Unlock()
return n
} | |
c181436 | 1) {
go s.gopush()
return true
}
//if already pushing, mark queued
atomic.StoreUint32(&s.push.queued, 1)
return false
} | |
c181437 | l.Lock()
}
newBytes, err := json.Marshal(s.gostruct)
if hasLock {
l.Unlock()
}
if err != nil {
log.Printf("velox: marshal failed: %s", err)
return
}
//if changed, then calculate change set
if !bytes.Equal(s.data.bytes, newBytes) {
//calculate change set from last version
ops, _ := jsonpatch.CreatePatch(s.data.bytes, newBytes)
if len(s.data.bytes) > 0 && len(ops) > 0 {
//changes! bump version
s.data.mut.Lock()
s.data.delta, _ = json.Marshal(ops)
s.data.bytes = newBytes
s.data.version++
s.data.mut.Unlock()
}
}
//send this new change to each subscriber
s.connMut.Lock()
for _, c := range s.conns {
if c.version != s.data.version {
go c.push()
}
}
s.connMut.Unlock()
//defered cleanup()
} | |
c181438 |
log.Println("[info] Server", server.Address(), "connected")
}
loggers[i] = logger
logger.Send([]byte{})
}
return &OutForward{
loggers: loggers,
sent: 0,
}, nil
} | |
c181439 | := err.(Signal); ok {
log.Println("[info]", err)
return
} else {
log.Println("[warning]", err)
break
}
}
}
// re open file
var err error
f, err = t.newTrailFile(SEEK_HEAD, c)
if err != nil {
if _, ok := err.(Signal); ok {
log.Println("[info]", err)
} else {
log.Println("[error]", err)
}
return
}
}
} | |
c181440 | config.MaxRetry = defaultMaxRetry
}
f = &Fluent{
Config: config,
reconnecting: false,
cancelReconnect: make(chan bool),
}
err = f.connect()
return
} | |
c181441 | defer f.mu.Unlock()
} else {
return
}
if f.conn != nil {
f.conn.Close()
f.conn = nil
}
return
} | |
c181442 | f.mu.Unlock()
return f.reconnecting
} | |
c181443 | }
resolved := fmt.Sprintf(format, addr, port)
log.Printf("[info] Connect to %s (%s)", f.Server, resolved)
f.conn, err = net.DialTimeout("tcp", resolved, f.Config.Timeout)
f.recordError(err)
return
} | |
c181444 | ""}
n := ¬ifier{Config: config}
return n
} | |
c181445 | := &Config{title, message, 5000, ""}
n := &nullNotifier{Config: config}
return n
} | |
c181446 |
option(opt)(c)
}
return c.generate()
} | |
c181447 | append(opts, Issuer(id))
return New(opts...)
} | |
c181448 |
return func(c *configuration) {
c.subject = &value
}
} | |
c181449 | *configuration) {
c.priv = &value
}
} | |
c181450 |
return func(c *configuration) {
c.notBefore = &value
}
} | |
c181451 |
return func(c *configuration) {
c.notAfter = &value
}
} | |
c181452 | c.issuingCertificateURL = append(c.issuingCertificateURL, value...)
}
} | |
c181453 | c.ocspServer = append(c.ocspServer, value...)
}
} | |
c181454 | updateC: newClient(fmt.Sprintf(apiBaseURI, apiKey)),
}
user, err := toReturn.GetMe()
if err != nil {
return nil, err
}
toReturn.ID = user.User.ID
toReturn.Name = user.User.FirstName
toReturn.Username = *user.User.Username
err = toReturn.removeWebhook()
if err != nil {
return nil, err
}
toReturn.wg.Add(1)
go toReturn.updateLoop()
return &toReturn, nil
} | |
c181455 | file)
if err != nil {
return nil, nil, err
}
updateFunc := func(w http.ResponseWriter, r *http.Request) {
bytes, err := ioutil.ReadAll(r.Body)
if err != nil {
toReturn.Updates <- BotUpdate{err: err}
return
}
update := &Update{}
err = json.Unmarshal(bytes, update)
if err != nil {
toReturn.Updates <- BotUpdate{err: err}
return
}
toReturn.Updates <- BotUpdate{update: *update}
}
return &toReturn, updateFunc, nil
} | |
c181456 | <-api.closed:
return
default:
}
close(api.closed)
api.wg.Wait()
} | |
c181457 | check(&resp.baseResponse)
if err != nil {
return nil, err
}
return resp, nil
} | |
c181458 | bot(update.Update(), api)
}
}
}()
// Ensure a clean shutdown.
shutdown := make(chan os.Signal)
signal.Notify(shutdown, syscall.SIGINT, syscall.SIGTERM)
go func() {
<-shutdown
close(closing)
}()
fmt.Println("Bot started. Press CTRL-C to close...")
// Wait for the signal.
<-closing
fmt.Println("Closing...")
// Always close the API first, let it clean up the update loop.
// This might take a while.
api.Close()
close(closed)
wg.Wait()
} | |
c181459 | %s\n", update.Error())
continue
}
bot(update.Update(), api)
}
}
}()
http.HandleFunc("/"+apiKey, handler)
fmt.Println("Starting webhook...")
go func() {
log.Fatal(http.ListenAndServeTLS("0.0.0.0:"+fmt.Sprint(webhookPort), pubkey, privkey, nil))
}()
// Ensure a clean shutdown.
shutdown := make(chan os.Signal)
signal.Notify(shutdown, syscall.SIGINT, syscall.SIGTERM)
go func() {
<-shutdown
close(closing)
}()
fmt.Println("Bot started. Press CTRL-C to close...")
// Wait for the signal.
<-closing
fmt.Println("Closing...")
// Always close the API first.
api.Close()
close(closed)
wg.Wait()
} | |
c181460 | api,
Recipient: recipient,
},
},
Text: text,
ParseMode: ModeDefault,
}
} | |
c181461 | outgoingMessageBase: outgoingMessageBase{
outgoingBase: outgoingBase{
api: api,
Recipient: recipient,
},
},
Latitude: latitude,
Longitude: longitude,
}
} | |
c181462 | api,
Recipient: recipient,
},
},
Latitude: latitude,
Longitude: longitude,
Title: title,
Address: address,
}
} | |
c181463 |
Recipient: recipient,
},
},
outgoingFileBase: outgoingFileBase{
fileName: fileName,
r: reader,
},
}
} | |
c181464 |
Recipient: recipient,
},
},
outgoingFileBase: outgoingFileBase{
fileID: fileID,
},
}
} | |
c181465 |
Recipient: recipient,
},
},
outgoingFileBase: outgoingFileBase{
fileName: fileName,
r: reader,
},
}
} | |
c181466 |
Recipient: recipient,
},
},
outgoingFileBase: outgoingFileBase{
fileID: fileID,
},
}
} | |
c181467 | api,
Recipient: recipient,
},
},
outgoingFileBase: outgoingFileBase{
fileName: fileName,
r: reader,
},
}
} | |
c181468 | api,
Recipient: recipient,
},
},
outgoingFileBase: outgoingFileBase{
fileID: fileID,
},
}
} | |
c181469 |
Recipient: recipient,
},
},
outgoingFileBase: outgoingFileBase{
fileName: fileName,
r: reader,
},
}
} | |
c181470 |
Recipient: recipient,
},
},
outgoingFileBase: outgoingFileBase{
fileID: fileID,
},
}
} | |
c181471 |
Recipient: recipient,
},
},
outgoingFileBase: outgoingFileBase{
fileName: fileName,
r: reader,
},
}
} | |
c181472 |
Recipient: recipient,
},
},
outgoingFileBase: outgoingFileBase{
fileID: fileID,
},
}
} | |
c181473 | api,
Recipient: recipient,
},
},
outgoingFileBase: outgoingFileBase{
fileName: fileName,
r: reader,
},
}
} | |
c181474 | api,
Recipient: recipient,
},
},
outgoingFileBase: outgoingFileBase{
fileID: fileID,
},
}
} | |
c181475 | api,
Recipient: recipient,
},
},
FromChatID: NewRecipientFromChat(origin),
MessageID: messageID,
}
} | |
c181476 | {
return &OutgoingChatAction{
outgoingBase: outgoingBase{
api: api,
Recipient: recipient,
},
Action: action,
}
} | |
c181477 | {
return &OutgoingUserProfilePhotosRequest{
api: api,
UserID: userID,
}
} | |
c181478 | *OutgoingKickChatMember {
return &OutgoingKickChatMember{
api: api,
Recipient: chat,
UserID: userID,
}
} | |
c181479 |
api: api,
Recipient: chat,
UserID: userID,
}
} | |
c181480 | {
return &OutgoingCallbackQueryResponse{
api: api,
CallbackQueryID: queryID,
}
} | |
c181481 | &InlineQueryAnswer{
api: api,
QueryID: queryID,
Results: results,
}
} | |
c181482 | nil {
return NewChatMember
} else if m.LeftChatMember != nil {
return LeftChatMember
} else if m.NewChatTitle != nil {
return NewChatTitle
} else if m.NewChatPhoto != nil {
return NewChatPhoto
} else if m.DeleteChatPhoto {
return DeletedChatPhoto
} else if m.GroupChatCreated {
return GroupChatCreated
} else if m.SupergroupChatCreated {
return SupergroupChatCreated
} else if m.ChannelChatCreated {
return ChannelChatCreated
} else if m.MigrateToChatID != nil {
return MigrationToSupergroup
} else if m.MigrateFromChatID != nil {
return MigrationFromGroup
} else if m.Venue != nil {
return VenueMessage
} else if m.PinnedMessage != nil {
return PinnedMessage
}
return UnknownMessage
} | |
c181483 | else if u.ChosenInlineResult != nil {
return ChosenInlineResultUpdate
}
return UnknownUpdate
} | |
c181484 | toReturn = fmt.Sprintf("%d", *r.ChatID)
}
return []byte(toReturn), nil
} | |
c181485 | toReturn["url"] = ow.URL
}
return querystring(toReturn)
} | |
c181486 |
//Channel
toReturn["chat_id"] = fmt.Sprint(*op.Recipient.ChannelID)
} else {
toReturn["chat_id"] = fmt.Sprint(*op.Recipient.ChatID)
}
return querystring(toReturn)
} | |
c181487 |
if op.replyToMessageIDSet {
toReturn["reply_to_message_id"] = fmt.Sprint(op.ReplyToMessageID)
}
if op.replyMarkupSet {
b, err := json.Marshal(op.ReplyMarkup)
if err != nil {
panic(err)
}
toReturn["reply_markup"] = string(b)
}
if op.DisableNotification {
toReturn["disable_notification"] = fmt.Sprint(op.DisableNotification)
}
return querystring(toReturn)
} | |
c181488 | fmt.Sprint(oa.Duration)
}
if oa.Performer != "" {
toReturn["performer"] = oa.Performer
}
if oa.Title != "" {
toReturn["title"] = oa.Title
}
return querystring(toReturn)
} | |
c181489 | toReturn["caption"] = op.Caption
}
return querystring(toReturn)
} | |
c181490 |
if op.Offset != 0 {
toReturn["offset"] = fmt.Sprint(op.Offset)
}
if op.Limit != 0 {
toReturn["limit"] = fmt.Sprint(op.Limit)
}
return querystring(toReturn)
} | |
c181491 |
toReturn["duration"] = fmt.Sprint(ov.Duration)
}
return querystring(toReturn)
} | |
c181492 | toReturn["duration"] = fmt.Sprint(ov.Duration)
}
return querystring(toReturn)
} | |
c181493 |
InlineQueryResultBase: InlineQueryResultBase{
Type: ArticleResult,
ID: id,
},
Title: title,
Text: text,
}
} | |
c181494 |
InlineQueryResultBase: InlineQueryResultBase{
Type: PhotoResult,
ID: id,
},
PhotoURL: photoURL,
ThumbURL: thumbURL,
}
} | |
c181495 |
InlineQueryResultBase: InlineQueryResultBase{
Type: GifResult,
ID: id,
},
GifURL: gifURL,
ThumbURL: thumbURL,
}
} | |
c181496 |
InlineQueryResultBase: InlineQueryResultBase{
Type: PhotoResult,
ID: id,
},
Mpeg4URL: mpeg4URL,
ThumbURL: thumbURL,
}
} | |
c181497 | },
VideoURL: videoURL,
MIMEType: mimeType,
ThumbURL: thumbURL,
Title: title,
Text: text,
}
} | |
c181498 | err := op.api.c.postJSON(getUserProfilePhotos, resp, op)
if err != nil {
return nil, err
}
err = check(&resp.baseResponse)
if err != nil {
return nil, err
}
return resp, nil
} | |
c181499 | err := oc.api.c.postJSON(sendChatAction, resp, oc)
if err != nil {
return err
}
return check(resp)
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.