id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c26600
} return fmt.Sprintf("(unknown %d)", rat) }
c26601
for i := 0; i < length; i += blockSize { hash := md5.New() hash.Write([]byte(secret)) if i >= blockSize { hash.Write(blocks[i-blockSize : i]) } else { hash.Write(authenticator[:]) } h := hash.Sum(nil) for j := 0; j < blockSize; j++ { blocks[i+j] ^= h[j] } } return blocks }
c26602
_, ra := range rp.attributes { hash.Write(ra.encode()) } hash.Write([]byte(secret)) h := hash.Sum(nil) var authenticator radiusAuthenticator copy(authenticator[:], h[:]) return &authenticator, nil }
c26603
Proto: seesaw.IPProtoUDP, }, Response: "accept", } }
c26604
VIPSubnets: make(map[string]*net.IPNet), Vservers: make(map[string]*Vserver), VLANs: make(map[uint16]*seesaw.VLAN), Status: seesaw.ConfigStatus{ Warnings: make([]string, 0), Attributes: make([]seesaw.ConfigMetadata, 0), }, } }
c26605
contains peer %q", c.Site, key) } c.BGPPeers[key] = peer return nil }
c26606
ok { return fmt.Errorf("Cluster %q already contains Node %q", c.Site, key) } c.Nodes[key] = node return nil }
c26607
VIP Subnet %q", c.Site, key) } c.VIPSubnets[key] = subnet return nil }
c26608
Vserver %q", c.Site, key) } c.Vservers[key] = vserver return nil }
c26609
ok { return fmt.Errorf("Cluster %q already contains VLAN %q", c.Site, key) } c.VLANs[key] = vlan return nil }
c26610
reflect.DeepEqual(c, other) }
c26611
Healthchecks: make(map[string]*Healthcheck), VIPs: make(map[string]*seesaw.VIP), Warnings: make([]string, 0), } }
c26612
VserverEntry %q", v.Name, key) } v.Entries[key] = e return nil }
c26613
contains Backend %q", v.Name, key) } v.Backends[key] = backend return nil }
c26614
Healthcheck %q", v.Name, key) } v.Healthchecks[key] = h return nil }
c26615
contains VIP %q", v.Name, key) } v.VIPs[key] = vip return nil }
c26616
proto, Healthchecks: make(map[string]*Healthcheck), } }
c26617
{ return fmt.Sprintf("%d/%s", v.Port, v.Proto) }
c26618
v.Persistence, OnePacket: v.OnePacket, HighWatermark: v.HighWatermark, LowWatermark: v.LowWatermark, LThreshold: v.LThreshold, UThreshold: v.UThreshold, } }
c26619
return &Healthcheck{ Mode: m, Type: t, Port: port, } }
c26620
err != nil { return nil, err } if err := bgp.Enable(); err != nil { bgp.Close() return nil, err } return bgp, nil }
c26621
if err != nil { return err } if cfg != nil { cfg.Config = bgpCfg } return nil }
c26622
if err != nil { return err } if neighbors != nil { neighbors.Neighbors = bgpNeighbors } return nil }
c26623
{ hl = net.IPv4len * 8 } else { hl = net.IPv6len * 8 } return net.CIDRMask(hl, hl) }
c26624
for _, line := range bgpCfg { if line == bgpStr { found = true continue } if !found || line == "!" { continue } if !strings.HasPrefix(line, " ") { break } if strings.HasPrefix(line, " network ") { n := strings.Replace(line, " network ", "", 1) vip, ipNet, err := net.ParseCIDR(n) if ...
c26625
err } defer bgp.Close() return bgp.Advertise(&net.IPNet{IP: vip, Mask: hostMask(vip)}) }
c26626
LastUpdate: now, Since: now, State: seesaw.HAUnknown, }, timeout: timeout, stateChan: make(chan seesaw.HAState, 1), statusChan: make(chan seesaw.HAStatus, 1), } }
c26627
h.statusLock.RUnlock() return h.status.State }
c26628
h.setState(seesaw.HAUnknown) } }
c26629
= false h.failoverLock.Unlock() return pending }
c26630
return nil } if peer { return fmt.Errorf("Node is not master (current state is %v)", state) } if err := h.engine.syncClient.failover(); err != nil { return err } return nil }
c26631
} log.Infof("HA state transition %v -> %v complete", state, s) } now := time.Now() h.statusLock.Lock() h.status.State = s h.status.Since = now h.status.LastUpdate = now h.statusLock.Unlock() }
c26632
s.Received h.status.Transitions = s.Transitions h.statusLock.Unlock() }
c26633
} // TODO(angusc): Make this clock-jump safe. h.statusLock.RLock() deadline := h.status.LastUpdate.Add(h.timeout) h.statusLock.RUnlock() return time.After(deadline.Sub(time.Now())) }
c26634
return errors.New("Incomplete command.") } return errors.New("Unknown command.") }
c26635
chain, cmdstr[idx:] } chain = append(chain, next) if next.function != nil { // We've reached a function. return next, nil, chain, cmdstr[idx+1:] } else { cmds = next.Subcommands } } if next != nil { return nil, next.Subcommands, chain, nil } return nil, nil, chain, nil }
c26636
ok := stateNames[s]; ok { return name } return "Unknown" }
c26637
s := range stateNames { if strings.ToLower(stateNames[s]) == name { return s } } return BGPStateUnknown }
c26638
return &BGP{ vty: NewVTY(socket), asn: asn, } }
c26639
_, err := b.vty.Command("enable") return err }
c26640
return nil, err } return strings.Split(cfg, "\n"), nil }
c26641
if err != nil { return nil, err } // TODO(jsing): Include details for advertised/received routes. return parseNeighbors(ni), nil }
c26642
fmt.Sprintf("address-family %s", family), fmt.Sprintf("%snetwork %s/%d", prefix, n.IP, prefixLen), "end", } bgpConfigLock.Lock() defer bgpConfigLock.Unlock() return b.vty.Commands(cmds) }
c26643
error { return b.network(n, true) }
c26644
error { return b.network(n, false) }
c26645
case "Updates": ms = &neighbor.Updates case "Keepalives": ms = &neighbor.Keepalives case "Route Refresh": ms = &neighbor.RouteRefresh case "Capability": ms = &neighbor.Capability case "Total": ms = &neighbor.Total msgStats = false } if ms != nil { sent, _ ...
c26646
Target: Target{ IP: ip, Port: port, Proto: seesaw.IPProtoUDP, }, } }
c26647
nil { msg = fmt.Sprintf("%s; failed to set deadline", msg) return complete(start, msg, false, err) } if _, err = conn.Write([]byte(hc.Send)); err != nil { msg = fmt.Sprintf("%s; failed to send request", msg) return complete(start, msg, false, err) } buf := make([]byte, len(hc.Receive)) n, _, err := conn...
c26648
log.Exitf("Failed to get %s for %s: %v", option, section, err) } return s }
c26649
== nil { return nil, fmt.Errorf("%s: %q is not a valid IP address", option, ipStr) } return ip, nil }
c26650
true err := r.conn.Close() r.Unlock() return err }
c26651
err := r.getIndex(true) r.RUnlock() return idx, err }
c26652
:= r.getIndex(false) r.RUnlock() return idx, err }
c26653
binary.BigEndian.PutUint64(key[:], idx) bucket := tx.Bucket(logsBucket) val := bucket.Get(key[:]) if val == nil { err = raft.ErrLogNotFound } else { err = r.decodeRaftLog(val, log) } tx.Rollback() r.RUnlock() return err }
c26654
r.StoreLogs([]*raft.Log{log}) }
c26655
} err = bucket.Put(key[:], val) if err != nil { break } } if err != nil { tx.Rollback() } else { err = tx.Commit() } r.Unlock() return err }
c26656
took %v", dur) if dur > 2*time.Second { r.log.Errorf(durTxt) } else { r.log.Noticef(durTxt) } return err }
c26657
!= nil { tx.Rollback() } else { err = tx.Commit() } r.Unlock() return err }
c26658
err = errKeyNotFound } else { // Make a copy v = append([]byte(nil), val...) } tx.Rollback() r.RUnlock() return v, err }
c26659
binary.BigEndian.PutUint64(vbytes[:], v) err := r.Set(k, vbytes[:]) return err }
c26660
vbytes, err := r.Get(k) if err == nil { v = binary.BigEndian.Uint64(vbytes) } return v, err }
c26661
:= s.unsubscribeSub(c, clientID, "unsub", sub, false, false); err != nil { return err } } c.store.Subs.Flush() } for clientID := range s.clients.getClients() { if _, err := s.clients.unregister(clientID); err != nil { return err } } sizeBuf := make([]byte, 4) // Read the snapshot size. if _, e...
c26662
return &RaftStore{Store: s, log: log} }
c26663
original limits.PerChannel[key], // so don't need to make a copy again, we own this. gs.sublist.Insert(key, val) } // Get rid of the map now. gs.limits.PerChannel = nil return nil }
c26664
// we know that the returned array is ordered from widest to narrowest, // and the only literal that there is would be the channel we are // looking up. return r[len(r)-1].(*ChannelLimits) }
c26665
c := gs.channels[channel] if c == nil { return nil } // Return a copy cl := *gs.getChannelLimits(channel) return &cl }
c26666
error { gs.Lock() err := gs.setLimits(limits) gs.Unlock() return err }
c26667
len(gs.channels) >= gs.limits.MaxChannels { return ErrTooManyChannels } return nil }
c26668
} gs.closed = true return gs.close() }
c26669
lerr } lerr = cs.Msgs.Close() if lerr != nil && err == nil { err = lerr } } return err }
c26670
gms.totalCount, gms.totalBytes gms.RUnlock() return c, b, nil }
c26671
error) { gms.RLock() first := gms.first gms.RUnlock() return first, nil }
c26672
error) { gms.RLock() last := gms.last gms.RUnlock() return last, nil }
c26673
gms.last gms.RUnlock() return first, last, nil }
c26674
error { gss.Lock() err := gss.createSub(sub) gss.Unlock() return err }
c26675
subscription has the max value. sub.ID = gss.maxSubID // Store anything. Some implementations may replace with specific // object. gss.subs[sub.ID] = emptySub return nil }
c26676
don't miss any notification // of a change in topology. Since we hold the lock, and even if there // was a notification happening now, the callback will execute only // after we are done with the initial check. nc.SetDiscoveredServersHandler(p.topologyChanged) // Now send our list and check if any server is compl...
c26677
the store, we have already checked that channel names // were valid. So this call cannot fail. p.sl.Insert(c, channelInterest) } }
c26678
cause the process to exit. If the server // is run programmatically and no logger has been set // we need to exit with the panic. p.s.log.Fatalf("Partitioning error: %v", err) // For tests if partitionsNoPanic { p.s.setLastError(err) return } panic(err) } }
c26679
:= p.s.nc.Subscribe(pubSubject, p.s.processClientPublish); err != nil { return fmt.Errorf("could not subscribe to publish subject %q, %v", channelName, err) } } return nil }
c26680
len(r) > 0 { reply.Data = []byte(c) gotError = true break } sl.Insert(c, channelInterest) } if !gotError { // Go over our channels and check with the other server sublist for _, c := range p.channels { if r := sl.Match(c); len(r) > 0 { reply.Data = []byte(c) break } } } replyBytes,...
c26681
p.isShutdown = true if p.nc != nil { p.nc.Close() } }
c26682
fmt.Errorf("parameter %q value is expected to be %v, got %v", name, kind.String(), actualKind.String()) } return nil }
c26683
reflect.String, v); err != nil { return err } opts.ClientKey = v.(string) case "client_ca", "client_cacert": if err := checkType(k, reflect.String, v); err != nil { return err } opts.ClientCA = v.(string) } } return nil }
c26684
:= parsePerChannelLimits(v, opts); err != nil { return err } default: // Check for the global limits (MaxMsgs, MaxBytes, etc..) if err := parseChannelLimits(&opts.ChannelLimits, k, name, v, true); err != nil { return err } } } return nil }
c26685
reflect.String, v); err != nil { return err } dur, err := time.ParseDuration(v.(string)) if err != nil { return err } cl.MaxAge = dur if !isGlobal && cl.MaxAge == 0 { cl.MaxAge = -1 } case "mi", "max_inactivity", "maxinactivity": if err := checkType(k, reflect.String, v); err != nil { retu...
c26686
for k, v := range limitsMap { name := strings.ToLower(k) if err := parseChannelLimits(cl, k, name, v, false); err != nil { return err } } sl := &opts.StoreLimits sl.AddPerChannel(channelName, cl) } return nil }
c26687
if resVal == nil || reflect.TypeOf(resVal).Kind() != reflect.Int64 { return 0, fmt.Errorf("%v should be a size, got '%v'", f.Name, resVal) } return resVal.(int64), nil }
c26688
append([]interface{}(nil), r...) nr = append(nr, element) s.cache[k] = nr } } }
c26689
modify the list // safely, just let it re-populate. delete(s.cache, k) } }
c26690
to our cache s.cache[subject] = result // Bound the number of entries to sublistMaxCache if len(s.cache) > slCacheMax { for k := range s.cache { delete(s.cache, k) break } } s.Unlock() return result }
c26691
sfwc = true default: n = l.nodes[t] } if n != nil { levels = append(levels, lnt{l, n, t}) l = n.next } else { l = nil } } if !s.removeFromNode(n, element) { return ErrNotFound } s.count-- for i := len(levels) - 1; i >= 0; i-- { l, n, t := levels[i].l, levels[i].n, levels[i].t if n.isEm...
c26692
l[i] = l[last] l[last] = nil l = l[:last] return shrinkAsNeeded(l), true } } return l, false }
c26693
float32(cl-ll) / float32(cl) if pFree > 0.50 { return append([]interface{}(nil), l...) } return l }
c26694
s.RUnlock() return len(s.cache) }
c26695
= time.Now() c.resetDeleteTimer(c.activity.maxInactivity) }
c26696
{ c.stan.log.Debugf("Channel %q delete timer stopped", c.name) } } }
c26697
if c.stan.debug { c.stan.log.Debugf("Channel %q delete timer set to fire in %v", c.name, newDuration) } a.timerSet = true }
c26698
Timestamp: time.Now().UnixNano(), } if c.lTimestamp > 0 && m.Timestamp < c.lTimestamp { m.Timestamp = c.lTimestamp } c.lTimestamp = m.Timestamp return m }
c26699
have this message because of channel limits. // Return nil to caller to signal this state. buf = nil } else { msgBuf = util.EnsureBufBigEnough(msgBuf, msg.Size()) n, err := msg.MarshalTo(msgBuf) if err != nil { panic(err) } buf = msgBuf[:n] } if err := s.ncsr.Publish(m.Reply, ...