id stringlengths 2 7 | text stringlengths 17 51.2k | title stringclasses 1
value |
|---|---|---|
c11800 | name))
return
}
clusterName := ""
if s.list != nil {
clusterName = s.list.ClusterName()
}
// Everything went fine, we found entries for this service.
// Send the json back.
svcInstances := make(map[string][]*service.Service)
svcInstances[name] = instances
result := ApiServices{
Services: svcInstanc... | |
c11801 | LastUpdated: s.state.Servers[member.Name].LastUpdated,
ServiceCount: len(s.state.Servers[member.Name].Services),
}
} else {
members[member.Name] = &ApiServer{
Name: member.Name,
LastUpdated: time.Unix(0, 0),
ServiceCount: 0,
}
}
}
result := ApiServices{
Service... | |
c11802 |
response.Header().Set("Content-Type", "application/json")
response.Header().Set("Access-Control-Allow-Origin", "*")
response.Header().Set("Access-Control-Allow-Methods", "GET")
response.Write(s.state.Encode())
return
} | |
c11803 | response.WriteHeader(500)
response.Write([]byte("Interval server error"))
return
}
response.Header().Set("Content-Type", "application/json")
response.WriteHeader(status)
response.Write(jsonBytes)
} | |
c11804 |
url := fmt.Sprintf("http://%v:%v%v", m.DefaultCheckHost, port.Port, defaultCheckEndpoint)
return &Check{
ID: svc.ID,
Type: "HttpGet",
Args: url,
Status: FAILED,
Command: &HttpGetCmd{},
}
} | |
c11805 |
}
// Setup some other parts of the check that don't come from discovery
check.ID = svc.ID
check.Command = m.GetCommandNamed(check.Type)
check.Status = FAILED
return check
} | |
c11806 |
"host": func() string { return m.DefaultCheckHost },
"container": func() string { return svc.Hostname },
}
t, err := template.New("check").Funcs(funcMap).Parse(check.Args)
if err != nil {
log.Errorf("Unable to parse check Args: '%s'", check.Args)
return check.Args
}
var output bytes.Buffer
t.Execu... | |
c11807 | svc.ID)
check = m.defaultCheckForService(svc)
}
check.Args = m.templateCheckArgs(check, svc)
return check
} | |
c11808 | prevents us from storing up checks forever. This is the only
// way we'll find out about a service going away.
for _, check := range m.Checks {
for _, svc := range services {
// Continue if we have a matching service/check pair
if svc.ID == check.ID {
continue OUTER
}
}
// Remove checks ... | |
c11809 | time.Now().UTC()
services = append(services, target.Service)
}
return services
} | |
c11810 | listener := ChangeListener{
Name: target.Service.ListenerName(),
Url: fmt.Sprintf("http://%s:%d/sidecar/update", d.Hostname, target.ListenPort),
}
listeners = append(listeners, listener)
}
}
return listeners
} | |
c11811 | log.Errorf("StaticDiscovery cannot parse: %s", err.Error())
looper.Done(nil)
}
} | |
c11812 | if err != nil {
log.Errorf("ParseConfig(): Unable to get random bytes (%s)", err.Error())
return nil, err
}
target.Service.ID = string(idBytes)
target.Service.Created = time.Now().UTC()
// We _can_ export services for a 3rd party. If we don't specify
// the hostname, then it's for this host.
if tar... | |
c11813 | {
log.Errorf("RandomBytes(): Error %s", err.Error())
return nil, err
}
encoded := make([]byte, count*2)
hex.Encode(encoded, raw)
return encoded, nil
} | |
c11814 | response.Header().Set("Access-Control-Allow-Methods", "GET")
return
} | |
c11815 |
}
}
})
}()
clusterName := ""
if s.list != nil {
clusterName = s.list.ClusterName()
}
result := SDSResult{
Env: clusterName,
Hosts: instances,
Service: name,
}
jsonBytes, err := result.MarshalJSON()
defer ffjson.Pool(jsonBytes)
if err != nil {
log.Errorf("Error marshaling state in r... | |
c11816 |
jsonBytes, err := result.MarshalJSON()
defer ffjson.Pool(jsonBytes)
if err != nil {
log.Errorf("Error marshaling state in servicesHandler: %s", err.Error())
sendJsonError(response, 500, "Internal server error")
return
}
response.Write(jsonBytes)
} | |
c11817 | err := result.MarshalJSON()
defer ffjson.Pool(jsonBytes)
if err != nil {
log.Errorf("Error marshaling state in servicesHandler: %s", err.Error())
sendJsonError(response, 500, "Internal server error")
return
}
response.Write(jsonBytes)
} | |
c11818 | := net.LookupHost(hostname)
if err != nil {
return "", err
}
return addrs[0], nil
} | |
c11819 | address,
LastCheckIn: svc.Updated.String(),
Port: port.Port,
Revision: svc.Version(),
Service: SvcName(svc.Name, port.ServicePort),
ServiceRepoName: svc.Image,
Tags: map[string]string{},
}
}
}
return nil
} | |
c11820 | Name: SvcName(svcName, port.ServicePort),
Type: "sds", // use Sidecar's SDS endpoint for the hosts
ConnectTimeoutMs: 500,
LBType: "round_robin", // TODO figure this out!
ServiceName: SvcName(svcName, port.ServicePort),
})
}
}
return clusters
} | |
c11821 | the ports and generate a named listener for
// each port.
for _, port := range svc.Ports {
// Only listen on ServicePorts
if port.ServicePort < 1 {
continue
}
listeners = append(listeners, s.EnvoyListenerFromService(svc, port.ServicePort))
}
}
return listeners
} | |
c11822 | name, ServiceNameSeparator, port)
} | |
c11823 | strconv.ParseInt(parts[1], 10, 64)
if err != nil {
return "", -1, fmt.Errorf("%s", "Unable to parse port!")
}
return svcName, svcPort, nil
} | |
c11824 | router.HandleFunc("/listeners/{service_cluster}/{service_node}", wrap(s.listenersHandler)).Methods("GET")
router.HandleFunc("/listeners", wrap(s.listenersHandler)).Methods("GET")
router.HandleFunc("/{path}", s.optionsHandler).Methods("OPTIONS")
return router
} | |
c11825 | 0,
Type: "http",
Command: &HttpGetCmd{},
MaxCount: 1,
Status: UNKNOWN,
}
return &check
} | |
c11826 |
if status == HEALTHY {
check.Count = 0
return
}
check.Count = check.Count + 1
if check.Count >= check.MaxCount {
check.Status = FAILED
}
} | |
c11827 | DefaultCheckHost: defaultCheckHost,
DefaultCheckEndpoint: defaultCheckEndpoint,
}
return &monitor
} | |
c11828 | health check: %s (ID: %s), Args: %s", check.Type, check.ID, check.Args)
m.Checks[check.ID] = check
} | |
c11829 | no longer
// needed. Assumes we're only health checking _our own_ services.
m.RLock()
if _, ok := m.Checks[svc.ID]; ok {
svc.Status = m.Checks[svc.ID].ServiceStatus()
} else {
svc.Status = service.UNKNOWN
}
m.RUnlock()
} | |
c11830 |
check.UpdateStatus(result.status, result.err)
case <-time.After(m.CheckInterval - 1*time.Millisecond):
log.Errorf("Error, check %s timed out! (%v)", check.ID, check.Args)
check.UpdateStatus(UNKNOWN, errors.New("Timed out!"))
}
}(check, resultChan) // copy check pointer for the goroutine
}
... | |
c11831 |
toMatch := []byte(container.Names[0])
matches := r.expression.FindSubmatch(toMatch)
if len(matches) < 1 {
svcName = container.Image
} else {
svcName = string(matches[1])
}
return svcName
} | |
c11832 | for label, value := range container.Labels {
if label == d.Label {
return value
}
}
log.Debugf(
"Found container with no '%s' label: %s (%s), returning '%s'", d.Label,
container.ID, container.Names[0], container.Image,
)
return container.Image
} | |
c11833 | return j.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start)
} | |
c11834 | := j.MarshalJSONBuf(&buf)
if err != nil {
return nil, err
}
return buf.Bytes(), nil
} | |
c11835 | continue
}
d.state.ServiceMsgs <- *entry
}
}()
d.Started = true
d.StartedAt = time.Now().UTC()
} | |
c11836 | (5 * time.Second))
if d.StartedAt.Before(gracePeriod) {
log.Warnf("All messages were too long to fit! No broadcasts!")
}
// There could be a scenario here where one hugely long broadcast could
// get stuck forever and prevent anything else from going out. There
// may be a better way to handle this. Scan... | |
c11837 | > 1 {
return parts[1]
}
return parts[0]
} | |
c11838 | svc.Updated = time.Now().UTC()
svc.Hostname = hostname
svc.Status = ALIVE
if _, ok := container.Labels["ProxyMode"]; ok {
svc.ProxyMode = container.Labels["ProxyMode"]
} else {
svc.ProxyMode = "http"
}
svc.Ports = make([]Port, 0)
for _, port := range container.Ports {
if port.PublicPort != 0 {
svc.P... | |
c11839 | err := strconv.Atoi(svcPort)
if err != nil {
log.Errorf("Error converting label value for %s to integer: %s",
svcPortLabel,
err.Error(),
)
return returnPort
}
// Everything was good, set the service port
returnPort.ServicePort = int64(svcPortInt)
}
return returnPort
} | |
c11840 | return 0.0
}
probs = append(probs, prob)
weights = append(weights, a.getWeight(method, prob))
}
// ignore the error since we force the length of probs
// and the weights to be equal
weighted, _ := probs.WeightedMean(weights)
// if all the weights are zero, then our weighted mean
// function attempts to d... | |
c11841 | If they do, we upweight them substantially.
if exists(name, dynamicWeights) {
if prob > 0.8 {
weight = 5.0
} else {
weight = 0.5
}
}
return weight
} | |
c11842 | at least as big as the active size
// note that this penalty might be overly severe for some tests
if refSize < minRefSize {
return nil, nil, fmt.Errorf("Reference size must be at least as big as active size")
}
// return reference and active windows
return vector[n-activeSize-refSize : n-activeSize], vector[n... | |
c11843 | - 1) / (math.Pow(base, 1) - 1)
} | |
c11844 |
min := math.Min(reference.Min(), active.Min())
max := math.Max(reference.Max(), active.Max())
interpolated := interpolate(min, max, n1+n2)
// Then we apply the distribution function over the interpolated data.
activeDist := interpolated.Apply(activeEcdf)
refDist := interpolated.Apply(refEcdf)
// Find the max... | |
c11845 | 1
for i < npoints {
interp[i] = interp[i-1] + step
i++
}
return interp
} | |
c11846 | for i := 0; i < l; i++ {
d, err := marshalValue(options, v.Index(i))
if err != nil {
return nil, err
}
dest[i] = d
}
return dest, nil
}
if k == reflect.Map {
mapKeys := v.MapKeys()
if len(mapKeys) == 0 {
return nil, nil
}
if mapKeys[0].Kind() != reflect.String {
return nil, Marshal... | |
c11847 | innerKey {
return true
}
}
return false
} | |
c11848 | b) {
return true
}
}
return false
} | |
c11849 | {
return strconv.Itoa(e.Code) + ":" + e.Message
} | |
c11850 | make(map[int]*RPCResponse, 0)
for _, r := range res {
resMap[r.ID] = r
}
return resMap
} | |
c11851 |
if r.ID == id {
return r
}
}
return nil
} | |
c11852 | nil {
return true
}
}
return false
} | |
c11853 | from %s", RPCResponse.Result)
}
i, err := val.Int64()
if err != nil {
return 0, err
}
return i, nil
} | |
c11854 | float64 from %s", RPCResponse.Result)
}
f, err := val.Float64()
if err != nil {
return 0, err
}
return f, nil
} | |
c11855 | not parse bool from %s", RPCResponse.Result)
}
return val, nil
} | |
c11856 | not parse string from %s", RPCResponse.Result)
}
return val, nil
} | |
c11857 | make(map[uint16]batchEntry),
replayCache: make(map[HashPrefix]struct{}),
}
} | |
c11858 |
for seqNum, entry := range b.entries {
if err := fn(seqNum, &entry.hashPrefix, entry.cltv); err != nil {
return err
}
}
return nil
} | |
c11859 | // Copy bytes to sharedHash
copy(sharedHash[:], h.Sum(nil))
return &sharedHash
} | |
c11860 | make(map[HashPrefix]uint32)
return nil
} | |
c11861 | == nil {
return errReplayLogNotStarted
}
rl.batches = nil
rl.entries = nil
return nil
} | |
c11862 | nil {
return 0, errReplayLogNotStarted
}
cltv, exists := rl.entries[*hash]
if !exists {
return 0, ErrLogEntryNotFound
}
return cltv, nil
} | |
c11863 | {
return errReplayLogNotStarted
}
_, exists := rl.entries[*hash]
if exists {
return ErrReplayedPacket
}
rl.entries[*hash] = cltv
return nil
} | |
c11864 | return errReplayLogNotStarted
}
delete(rl.entries, *hash)
return nil
} | |
c11865 | }
// An error would be bad because we have already updated the entries
// map, but no errors other than ErrReplayedPacket should occur.
return err
})
if err != nil {
return nil, err
}
replays.Merge(batch.ReplaySet)
rl.batches[string(batch.ID)] = replays
}
batch.ReplaySet = replays
batch.IsC... | |
c11866 | binKey, err := hex.DecodeString(args[2])
if len(binKey) != 32 || err != nil {
log.Fatalf("Argument not a valid hex private key")
}
hexBytes, _ := ioutil.ReadAll(os.Stdin)
binMsg, err := hex.DecodeString(strings.TrimSpace(string(hexBytes)))
if err != nil {
log.Fatalf("Error decoding message: %s", err)... | |
c11867 | binary.BigEndian, hd.OutgoingCltv); err != nil {
return err
}
if _, err := w.Write(hd.ExtraBytes[:]); err != nil {
return err
}
if _, err := w.Write(hd.HMAC[:]); err != nil {
return err
}
return nil
} | |
c11868 | binary.BigEndian, &hd.OutgoingCltv); err != nil {
return err
}
if _, err := io.ReadFull(r, hd.ExtraBytes[:]); err != nil {
return err
}
if _, err := io.ReadFull(r, hd.HMAC[:]); err != nil {
return err
}
return nil
} | |
c11869 | //
// We begin with just the session private key x, so that base case
// c_0 = x. At the beginning of each iteration, the previous blinding
// factor is aggregated into the modular product, and used as the scalar
// value in deriving the hop ephemeral keys and shared secrets.
var cachedBlindingFactor big.Int
cac... | |
c11870 | nil, err
}
copy(mixHeader[:], hopDataBuf.Bytes())
// Once the packet for this hop has been assembled, we'll
// re-encrypt the packet by XOR'ing with a stream of bytes
// generated using our shared secret.
xor(mixHeader[:], mixHeader[:], streamBytes[:routingInfoSize])
// If this is the "last" hop, then ... | |
c11871 | slice[num+i] = slice[i]
}
for i := 0; i < num; i++ {
slice[i] = 0
}
} | |
c11872 | return err
}
if _, err := w.Write(f.RoutingInfo[:]); err != nil {
return err
}
if _, err := w.Write(f.HeaderMAC[:]); err != nil {
return err
}
return nil
} | |
c11873 | btcec.S256())
if err != nil {
return ErrInvalidOnionKey
}
if _, err := io.ReadFull(r, f.RoutingInfo[:]); err != nil {
return err
}
if _, err := io.ReadFull(r, f.HeaderMAC[:]); err != nil {
return err
}
return nil
} | |
c11874 | nodeID,
nodeAddr: nodeAddr,
onionKey: &btcec.PrivateKey{
PublicKey: ecdsa.PublicKey{
Curve: btcec.S256(),
X: nodeKey.X,
Y: nodeKey.Y,
},
D: nodeKey.D,
},
log: log,
}
} | |
c11875 | // out the per-hop data so we can derive the specified forwarding
// instructions.
var hopData HopData
if err := hopData.Decode(bytes.NewReader(hopInfo[:])); err != nil {
return nil, nil, err
}
// With the necessary items extracted, we'll copy of the onion packet
// for the next node, snipping off our per-hop... | |
c11876 | the route.
var action ProcessCode = MoreHops
if bytes.Compare(zeroHMAC[:], outerHopData.HMAC[:]) == 0 {
action = ExitNode
}
// Finally, we'll return a fully processed packet with the outer most
// hop data (where the primary forwarding instructions lie) and the
// inner most onion packet that we unwrapped.
r... | |
c11877 |
rs, err := t.router.log.PutBatch(t.batch)
return t.packets, rs, err
} | |
c11878 | nil || o.NodePub.Y == nil
} | |
c11879 | var mac [HMACSize]byte
copy(mac[:], h[:HMACSize])
return mac
} | |
c11880 | key[:])
if err != nil {
panic(err)
}
output := make([]byte, numBytes)
cipher.XORKeyStream(output, output)
return output
} | |
c11881 |
if !btcec.S256().IsOnCurve(dhKey.X, dhKey.Y) {
return sharedSecret, ErrInvalidOnionKey
}
// Compute our shared secret.
sharedSecret = generateSharedSecret(dhKey, r.onionKey)
return sharedSecret, nil
} | |
c11882 | btcec.S256().ScalarMult(pub.X, pub.Y, priv.D.Bytes())
return sha256.Sum256(s.SerializeCompressed())
} | |
c11883 | rest
// of the loop. Otherwise, we'll use the next shared secret in
// line.
if sender != nil || i > len(sharedSecrets)-1 {
sharedSecret = dummySecret
} else {
sharedSecret = sharedSecrets[i]
}
// With the shared secret, we'll now strip off a layer of
// encryption from the encrypted error payload... | |
c11884 | hash.Write(data)
h := hash.Sum(nil)
data = append(h, data...)
}
return onionEncrypt(&o.sharedSecret, data)
} | |
c11885 |
return nil, err
}
return &OnionErrorEncrypter{
sharedSecret: sharedSecret,
}, nil
} | |
c11886 | err := w.Write(o.sharedSecret[:])
return err
} | |
c11887 | err := io.ReadFull(r, o.sharedSecret[:])
return err
} | |
c11888 |
var pubKeyData [btcec.PubKeyBytesLenCompressed]byte
if _, err := r.Read(pubKeyData[:]); err != nil {
return err
}
pubKey, err := btcec.ParsePubKey(pubKeyData[:], btcec.S256())
if err != nil {
return err
}
c.PaymentPath[i] = pubKey
}
return nil
} | |
c11889 | uint8(len(c.PaymentPath))
if _, err := w.Write(pathLength[:]); err != nil {
return err
}
for _, pubKey := range c.PaymentPath {
if _, err := w.Write(pubKey.SerializeCompressed()); err != nil {
return err
}
}
return nil
} | |
c11890 | ok := rs.replays[idx]
return ok
} | |
c11891 | := range rs2.replays {
rs.Add(seqNum)
}
} | |
c11892 | {
err := binary.Write(w, binary.BigEndian, seqNum)
if err != nil {
return err
}
}
return nil
} | |
c11893 | switch err {
case nil:
// Successful read, proceed.
case io.EOF:
return nil
default:
// Can return ErrShortBuffer or ErrUnexpectedEOF.
return err
}
// Add this decoded sequence number to the set.
rs.Add(seqNum)
}
} | |
c11894 | *raven.Http) {
hook.client.SetHttpContext(h)
} | |
c11895 | return hook.client.SetIgnoreErrors(errs)
} | |
c11896 | return hook.client.SetSampleRate(rate)
} | |
c11897 | map[string]string) {
hook.client.SetTagsContext(t)
} | |
c11898 | *raven.User) {
hook.client.SetUserContext(u)
} | |
c11899 |
return (b1 << 4) | b2, b1 != 255 && b2 != 255
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.