id stringlengths 2 7 | text stringlengths 17 51.2k | title stringclasses 1
value |
|---|---|---|
c164300 | s.collectAllSubs(s.root, subs)
s.RUnlock()
} | |
c164301 | if len(o.TrustedOperators) > 0 && len(o.TrustedKeys) > 0 {
return fmt.Errorf("conflicting options for 'TrustedKeys' and 'TrustedOperators'")
}
// If we have operators, fill in the trusted keys.
// FIXME(dlc) - We had TrustedKeys before TrustedOperators. The jwt.OperatorClaims
// has a DidSign(). Use that longer ... | |
c164302 | e.token.SourceFile(), e.token.Line(), e.token.Position())
} | |
c164303 | fmt.Sprintf("%s: %s", e.Source(), e.reason)
}
return e.reason
} | |
c164304 | unknown field %q", e.Source(), e.field)
} | |
c164305 | %q: %s", e.Source(), e.field, e.reason)
} | |
c164306 |
msg += err.Error() + "\n"
}
for _, err := range e.Errors() {
msg += err.Error() + "\n"
}
return msg
} | |
c164307 | := lastSeconds
// Update last sample
lastTotal = total
lastSeconds = seconds
// Adjust to current time window
total -= lt
seconds -= ls
if seconds > 0 {
atomic.StoreInt64(&ipcpu, (total*1000/ticks)/seconds)
}
time.AfterFunc(1*time.Second, periodic)
} | |
c164308 | _ = json.MarshalIndent(pm.msg, _EMPTY_, " ")
}
// Prep internal structures needed to send message.
c.pa.subject = []byte(pm.sub)
c.pa.size = len(b)
c.pa.szb = []byte(strconv.FormatInt(int64(len(b)), 10))
c.pa.reply = []byte(pm.rply)
// Add in NL
b = append(b, _CRLF_...)
c.processInboundClie... | |
c164309 | Normal client cleanup will deal with subs, etc.
s.sys.subs = nil
s.mu.Unlock()
// Send to the internal queue and mark as last.
sendq <- &pubMsg{subj, _EMPTY_, nil, nil, true}
} | |
c164310 | placing on the channel.
s.mu.Unlock()
sendq <- &pubMsg{sub, rply, si, msg, false}
s.mu.Lock()
} | |
c164311 | && s.eventsEnabled()
s.mu.Unlock()
return er
} | |
c164312 | s.mu.Lock()
defer s.mu.Unlock()
return s.eventsEnabled()
} | |
c164313 | s.sys.client != nil && s.sys.account != nil
} | |
c164314 | Bytes: atomic.LoadInt64(&r.outBytes),
},
Received: DataStats{
Msgs: atomic.LoadInt64(&r.inMsgs),
Bytes: atomic.LoadInt64(&r.inBytes),
},
Pending: int(r.out.pb),
}
r.mu.Unlock()
return rs
} | |
c164315 | Bytes: atomic.LoadInt64(&c.outBytes),
}
c.mu.Unlock()
// Gather matching inbound connections
gs.Received = DataStats{}
for _, c := range gw.in {
c.mu.Lock()
if c.gw.name == name {
gs.Received.Msgs += atomic.LoadInt64(&c.inMsgs)
gs.Received.Bytes += atomic.LoadInt64(&c.inBytes)
gs... | |
c164316 | if _, err := s.sysSubscribe(subject, s.statszReq); err != nil {
s.Errorf("Error setting up internal tracking: %v", err)
}
// Listen for ping messages that will be sent to all servers for statsz.
if _, err := s.sysSubscribe(serverStatsPingReqSubj, s.statszReq); err != nil {
s.Errorf("Error setting up internal tr... | |
c164317 |
return
}
if v, ok := s.accounts.Load(toks[accUpdateAccIndex]); ok {
s.updateAccountWithClaimJWT(v.(*Account), string(msg))
}
} | |
c164318 |
a.mu.Lock()
prev := a.strack[sid]
delete(a.strack, sid)
a.nrclients -= prev.conns
a.nrleafs -= prev.leafs
a.mu.Unlock()
return true
})
} | |
c164319 |
if len(toks) < shutdownEventTokens {
s.Debugf("Received remote server shutdown on bad subject %q", subject)
return
}
sid := toks[serverSubjectIndex]
su := s.sys.servers[sid]
if su != nil {
s.processRemoteServerShutdown(sid)
}
} | |
c164320 | su.seq {
s.Errorf("Received out of order remote server update from: %q", ms.ID)
return
}
su.seq = ms.Seq
su.ltime = time.Now()
}
} | |
c164321 |
s.mu.Lock()
defer s.mu.Unlock()
// Whip through all accounts.
s.accounts.Range(func(k, v interface{}) bool {
a := v.(*Account)
a.mu.Lock()
a.nrclients = 0
// Now clear state
clearTimer(&a.etmr)
clearTimer(&a.ctmr)
a.clients = nil
a.strack = nil
a.mu.Unlock()
return true
})
// Turn everythin... | |
c164322 | _ := s.lookupAccount(m.Account)
if acc == nil {
return
}
if nlc := acc.NumLocalConnections(); nlc > 0 {
s.mu.Lock()
s.sendAccConnsUpdate(acc, reply)
s.mu.Unlock()
}
} | |
c164323 | == "" || !s.eventsEnabled() || !s.gateway.enabled
s.mu.Unlock()
if na {
return
}
if acc, _ := s.lookupAccount(m.Account); acc != nil {
s.switchAccountToInterestMode(acc.Name)
}
} | |
c164324 | {
s.mu.Lock()
defer s.mu.Unlock()
if !s.eventsEnabled() || reply == _EMPTY_ {
return
}
s.sendStatsz(reply)
} | |
c164325 | acc.mu.Lock()
if acc.strack == nil {
acc.strack = make(map[string]sconns)
}
// This does not depend on receiving all updates since each one is idempotent.
prev := acc.strack[m.Server.ID]
acc.strack[m.Server.ID] = sconns{conns: int32(m.Conns), leafs: int32(m.LeafNodes)}
acc.nrclients += int32(m.Conns) - prev.co... | |
c164326 |
subj := fmt.Sprintf(accConnsReqSubj, a.Name)
reply := fmt.Sprintf(connsRespSubj, s.info.ID)
m := accNumConnsReq{Account: a.Name}
s.sendInternalMsg(subj, reply, &m.Server, &m)
} | |
c164327 |
m := accNumConnsReq{Account: a.Name}
s.sendInternalMsg(subj, "", &m.Server, &m)
s.mu.Unlock()
s.switchAccountToInterestMode(a.Name)
} | |
c164328 | // Set timer to fire again unless we are at zero.
a.mu.Lock()
if a.numLocalConnections() == 0 {
clearTimer(&a.etmr)
} else {
// Check to see if we have an HB running and update.
if a.ctmr == nil {
a.etmr = time.AfterFunc(eventsHBInterval, func() { s.accConnsUpdate(a) })
} else {
a.etmr.Reset(eventsHBI... | |
c164329 |
}
subj := fmt.Sprintf(accConnsEventSubj, a.Name)
s.sendAccConnsUpdate(a, subj)
} | |
c164330 | User: nameForClient(c),
Name: c.opts.Name,
Lang: c.opts.Lang,
Version: c.opts.Version,
},
}
c.mu.Unlock()
s.mu.Lock()
s.sendInternalMsg(subj, _EMPTY_, &m.Server, &m)
s.mu.Unlock()
} | |
c164331 | Sent: DataStats{
Msgs: c.inMsgs,
Bytes: c.inBytes,
},
Received: DataStats{
Msgs: c.outMsgs,
Bytes: c.outBytes,
},
Reason: reason,
}
c.mu.Unlock()
subj := fmt.Sprintf(disconnectEventSubj, c.acc.Name)
s.mu.Lock()
s.sendInternalMsg(subj, _EMPTY_, &m.Server, &m)
s.mu.Unlock()
} | |
c164332 | s.sys.client
s.mu.Unlock()
// Now create the subscription
if err := c.processSub([]byte(subject + " " + sid)); err != nil {
return nil, err
}
c.mu.Lock()
sub := c.subs[sid]
c.mu.Unlock()
return sub, nil
} | |
c164333 | if c.user != nil {
return c.user.Nkey
}
return "N/A"
} | |
c164334 | if c.acc != nil {
return c.acc.Name
}
return "N/A"
} | |
c164335 |
t.Stop()
*tp = nil
}
} | |
c164336 | if !s.eventsEnabled() {
return
}
f()
}
} | |
c164337 |
parts := strings.FieldsFunc(procName, func(c rune) bool {
return c == os.PathSeparator
})
procName = parts[len(parts)-1]
}
return procName
} | |
c164338 | connecting to syslog: %q", err.Error())
}
return &SysLogger{
writer: w,
debug: debug,
trace: trace,
}
} | |
c164339 |
log.Fatalf("error connecting to syslog: %q", err.Error())
}
return &SysLogger{
writer: w,
debug: debug,
trace: trace,
}
} | |
c164340 |
err = kill(pid, syscall.SIGKILL)
case CommandQuit:
err = kill(pid, syscall.SIGINT)
case CommandReopen:
err = kill(pid, syscall.SIGUSR1)
case CommandReload:
err = kill(pid, syscall.SIGHUP)
case commandLDMode:
err = kill(pid, syscall.SIGUSR2)
default:
err = fmt.Errorf("unknown signal %q", command)
}
r... | |
c164341 | make([]int, 0, len(pidStrs))
)
for _, pidStr := range pidStrs {
if pidStr == "" {
continue
}
pid, err := strconv.Atoi(pidStr)
if err != nil {
return nil, errors.New("unable to resolve pid, try providing one")
}
// Ignore the current process.
if pid == myPid {
continue
}
pids = append(pids,... | |
c164342 |
return lx.errorf("Unexpected EOF.")
}
lx.emit(itemEOF)
return nil
}
// At this point, the only valid item can be a key, so we back up
// and let the key lexer do the rest.
lx.backup()
lx.push(lexTopValueEnd)
return lexKeyStart
} | |
c164343 | optValTerm || r == topOptValTerm || r == topOptTerm:
lx.ignore()
return lexTop
}
return lx.errorf("Expected a top-level value to end with a new line, "+
"comment or EOF, but got '%v' instead.", r)
} | |
c164344 | lx.push(push)
}
return lexIncludeStart
}
lx.emit(itemKey)
return fallThrough
} | |
c164345 | return lexSkip(lx, lexIncludeStart)
}
lx.backup()
return lexInclude
} | |
c164346 |
lx.ignore()
return lx.pop()
}
return lexIncludeQuotedString
} | |
c164347 | lx.next()
lx.ignore()
return lx.pop()
}
return lexIncludeDubQuotedString
} | |
c164348 | lx.backup()
lx.emit(itemInclude)
return lx.pop()
case r == sqStringEnd:
lx.backup()
lx.emit(itemInclude)
lx.next()
lx.ignore()
return lx.pop()
}
return lexIncludeString
} | |
c164349 | unicode.IsDigit(r), r == '-':
return lx.errorf("Expected include value but found start of a number")
case r == '\\':
return lx.errorf("Expected include value but found escape sequence")
case isNL(r):
return lx.errorf("Expected include value but found new line")
}
lx.backup()
return lexIncludeString
} | |
c164350 | Move onto next
case r == arrayEnd:
return lexArrayEnd
}
return lx.errorf("Expected an array value terminator %q or an array "+
"terminator %q, but got '%v' instead.", arrayValTerm, arrayEnd, r)
} | |
c164351 | mapValTerm:
return lx.errorf("Unexpected map value terminator %q.", mapValTerm)
case r == mapEnd:
return lexSkip(lx, lexMapEnd)
}
lx.backup()
lx.push(lexMapValueEnd)
return lexValue
} | |
c164352 | Move onto next
case r == mapEnd:
return lexSkip(lx, lexMapEnd)
}
return lx.errorf("Expected a map value terminator %q or a map "+
"terminator %q, but got '%v' instead.", mapValTerm, mapEnd, r)
} | |
c164353 |
lx.ignore()
lx.emit(itemMapEnd)
return lx.pop()
} | |
c164354 | ||
str == "on" || str == "off" ||
str == "yes" || str == "no"
} | |
c164355 | if lx.isVariable() {
lx.emit(itemVariable)
} else {
lx.emitString()
}
return lx.pop()
case r == sqStringEnd:
lx.backup()
lx.emitString()
lx.next()
lx.ignore()
return lx.pop()
}
return lexString
} | |
c164356 | "but found '%v' instead.", r)
}
} else if f != r {
return lx.errorf("Expected '%v' in ISO8601 datetime, "+
"but found '%v' instead.", f, r)
}
}
lx.emit(itemDatetime)
return lx.pop()
} | |
c164357 |
case isNumberSuffix(r):
return lexConvenientNumber
}
lx.backup()
lx.emit(itemInteger)
return lx.pop()
} | |
c164358 |
lx.ignore()
lx.emit(itemCommentStart)
return lexComment
} | |
c164359 | {
return func(lx *lexer) stateFn {
lx.ignore()
return nextState
}
} | |
c164360 | || r == 'M' || r == 'g' || r == 'G'
} | |
c164361 |
s.startGoRoutine(func() { s.connectToRemoteLeafNode(remote) })
}
} | |
c164362 |
if o.SystemAccount == "" {
return fmt.Errorf("leaf nodes and gateways (both being defined) require a system account to also be configured")
}
return nil
} | |
c164363 |
// array when receiving async leafnode INFOs.
cfg.urls = append(cfg.urls, cfg.URL)
return cfg
} | |
c164364 | cfg.urls[0]) {
first := cfg.urls[0]
copy(cfg.urls, cfg.urls[1:])
cfg.urls[len(cfg.urls)-1] = first
}
cfg.curURL = cfg.urls[0]
return cfg.curURL
} | |
c164365 | defer cfg.RUnlock()
return cfg.curURL
} | |
c164366 | = append([]string(nil), s.leafNodeInfo.LeafNodeURLs...)
}
return &clone
} | |
c164367 |
s.leafNodeInfo.LeafNodeURLs = append(s.leafNodeInfo.LeafNodeURLs, urlStr)
s.generateLeafNodeInfoJSON()
return true
} | |
c164368 | 1
if i != last {
urls[i] = urls[last]
}
s.leafNodeInfo.LeafNodeURLs = urls[0:last]
removed = true
break
}
}
if removed {
s.generateLeafNodeInfoJSON()
}
return removed
} | |
c164369 | range s.leafs {
c.mu.Lock()
c.sendInfo(s.leafNodeInfoJSON)
c.mu.Unlock()
}
} | |
c164370 | Do not add if it's the same than the one that
// we have configured.
if urlsAreEqual(url, cfg.URL) {
continue
}
cfg.urls = append(cfg.urls, url)
}
// Add the configured one
cfg.urls = append(cfg.urls, cfg.URL)
} | |
c164371 | } else {
// Take the first from the list...
s.leafNodeInfo.Host = ips[0]
}
}
}
// Use just host:port for the IP
s.leafNodeInfo.IP = net.JoinHostPort(s.leafNodeInfo.Host, strconv.Itoa(s.leafNodeInfo.Port))
if opts.LeafNode.Advertise != _EMPTY_ {
s.Noticef("Advertise address for leafnode is set to %s"... | |
c164372 | // Create and initialize the smap since we know our bound account now.
s.initLeafNodeSmap(c)
// We are good to go, send over all the bound account subscriptions.
s.startGoRoutine(func() {
c.sendAllAccountSubs()
s.grWG.Done()
})
// Add in the leafnode here since we passed through auth at this point.
s.addLe... | |
c164373 | if e := ei.(*outsie); e != nil && e.sl != nil {
e.sl.All(&subs)
}
}
}
}
// Now walk the results and add them to our smap
c.mu.Lock()
for _, sub := range subs {
// We ignore ourselves here.
if c != sub.client {
c.leaf.smap[keyFromSub(sub)]++
}
}
// FIXME(dlc) - We need to update appropr... | |
c164374 | failed to update interest from gateway", accName)
return
}
s.updateLeafNodes(acc, sub, delta)
} | |
c164375 | range acc.clients {
if ln.kind == LEAF && ln != sub.client {
leafs = append(leafs, ln)
}
}
acc.mu.RUnlock()
for _, ln := range leafs {
ln.updateSmap(sub, delta)
}
} | |
c164376 | c.leaf.smap[key] = n
} else {
delete(c.leaf.smap, key)
}
if update {
c.sendLeafNodeSubUpdate(key, n)
}
c.mu.Unlock()
} | |
c164377 | bytes.NewBuffer(_b[:0])
c.writeLeafSub(b, key, n)
c.sendProto(b.Bytes(), false)
} | |
c164378 | key = append(key, byte(' '))
key = append(key, sub.queue...)
} else {
key = sub.subject
}
return string(key)
} | |
c164379 | max_pending.
chunks := protoChunks(b.Bytes(), MAX_PAYLOAD_SIZE)
for _, chunk := range chunks {
c.queueOutbound(chunk)
c.flushOutbound()
}
c.mu.Unlock()
} | |
c164380 | } else if sub.queue != nil {
// For a queue we need to update the weight.
atomic.StoreInt32(&osub.qw, sub.qw)
acc.sl.UpdateRemoteQSub(osub)
}
c.mu.Unlock()
// Treat leaf node subscriptions similar to a client subscription, meaning we
// send them to both routes and gateways and other leaf nodes. We also do... | |
c164381 |
// If we are routing subtract from the route map for the associated account.
srv.updateRouteSubscriptionMap(acc, sub, -1)
// Gateways
if updateGWs {
srv.gatewayUpdateSubInterest(acc.Name, sub, -1)
}
// Now check on leafnode updates for other leaf nodes.
srv.updateLeafNodes(acc, sub, -1)
return nil
} | |
c164382 | no interest, short circuit if so.
// This is the fanout scale.
if len(r.psubs)+len(r.qsubs) > 0 {
flag := pmrNoFlag
// If we have queue subs in this cluster, then if we run in gateway
// mode and the remote gateways have queue subs, then we need to
// collect the queue groups this message was sent to so that... | |
c164383 | if delim < 0 {
chunks = append(chunks, b[start:])
break
}
end := delim + LEN_CR_LF + i
chunks = append(chunks, b[start:end])
start = end
i = end + csz
}
return chunks
} | |
c164384 | clone.Permissions = u.Permissions.clone()
return clone
} | |
c164385 | *n
clone.Permissions = n.Permissions.clone()
return clone
} | |
c164386 | != nil {
clone.Deny = make([]string, len(p.Deny))
copy(clone.Deny, p.Deny)
}
return clone
} | |
c164387 | if p.Publish != nil {
clone.Publish = p.Publish.clone()
}
if p.Subscribe != nil {
clone.Subscribe = p.Subscribe.clone()
}
return clone
} | |
c164388 | warn = true
break
}
}
if warn {
// Warning about using plaintext passwords.
s.Warnf("Plaintext passwords detected, use nkeys or bcrypt.")
}
} | |
c164389 | u := range s.nkeys {
if u.Account == nil {
u.Account = s.gacc
}
}
} | |
c164390 |
if opts.Users != nil {
s.users = make(map[string]*User)
for _, u := range opts.Users {
copy := u.clone()
if u.Account != nil {
if v, ok := s.accounts.Load(u.Account.Name); ok {
copy.Account = v.(*Account)
}
}
s.users[u.Username] = copy
}
}
s.assignGlobalAccountToOrphanUse... | |
c164391 | GATEWAY:
return s.isGatewayAuthorized(c)
case LEAF:
return s.isLeafNodeAuthorized(c)
default:
return false
}
} | |
c164392 |
if err != nil {
c.Debugf("Signature not valid base64")
return false
}
}
pub, err := nkeys.FromPublicKey(juc.Subject)
if err != nil {
c.Debugf("User nkey not valid: %v", err)
return false
}
if err := pub.Verify(c.nonce, sig); err != nil {
c.Debugf("Signature not verified")
return fal... | |
c164393 | colors := true
// Check to see if stderr is being redirected and if so turn off color
// Also turn off colors if we're running on Windows where os.Stderr.Stat() returns an invalid handle-error
stat, err := os.Stderr.Stat()
if err != nil || (stat.Mode()&os.ModeCharDevice) == 0 {
colors = false
}
log = sr... | |
c164394 | a dummy
// test logger that may not implement that interface.
if l, ok := s.logging.logger.(io.Closer); ok {
if err := l.Close(); err != nil {
s.Errorf("Error closing logger: %v", err)
}
}
}
s.logging.logger = logger
s.logging.Unlock()
} | |
c164395 | := srvlog.NewFileLogger(opts.LogFile,
opts.Logtime, opts.Debug, opts.Trace, true)
s.SetLogger(fileLog, opts.Debug, opts.Trace)
s.Noticef("File log re-opened")
}
} | |
c164396 | connection is gone, too bad, we won't set TLSVersion and TLSCipher.
// Exclude clients that are still doing handshake so we don't block in
// ConnectionState().
if client.flags.isSet(handshakeComplete) && nc != nil {
conn := nc.(*tls.Conn)
cs := conn.ConnectionState()
ci.TLSVersion = tlsVersion(cs.Version)
... | |
c164397 |
}
var rtt time.Duration
if c.rtt > time.Microsecond && c.rtt < time.Millisecond {
rtt = c.rtt.Truncate(time.Microsecond)
} else {
rtt = c.rtt.Truncate(time.Millisecond)
}
return rtt.String()
} | |
c164398 | limit,
CID: cid,
State: state,
}
s.mu.Lock()
s.httpReqStats[ConnzPath]++
s.mu.Unlock()
c, err := s.Connz(connzOpts)
if err != nil {
w.WriteHeader(http.StatusBadRequest)
w.Write([]byte(err.Error()))
return
}
b, err := json.MarshalIndent(c, "", " ")
if err != nil {
s.Error... | |
c164399 | r.outBytes,
NumSubs: uint32(len(r.subs)),
Import: r.opts.Import,
Export: r.opts.Export,
}
if subs && len(r.subs) > 0 {
ri.Subs = make([]string, 0, len(r.subs))
for _, sub := range r.subs {
ri.Subs = append(ri.Subs, string(sub.subject))
}
}
switch conn := r.nc.(type) {... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.