anchor dict | positive dict | negative dict |
|---|---|---|
{
"audio": "",
"image": "",
"text": "func (r *Registry) Unregister(puID string) error {\n\tr.Lock()\n\tdefer r.Unlock()\n\n\tdelete(r.indexByName, puID)\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tr.indexByPort.DeleteByID(puID, true)\n\tr.indexByPort.DeleteByID(puID, false)\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " bool) (Client, error)) {\n\tr.clientMu.Lock()\n\tdefer r.clientMu.Unlock()\n\n\tr.clientFuncs[stream] = f\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (r *Registry) RetrieveServiceByID(id string) (*ServiceContext, error) {\n\tr.Lock()\n\tdefer r.Unlock()\n\n\tsvc, ok := r.indexByName[id]\n\tif",
"video": ""
} | {
"audio": "",
"image": "",
"text": " !ok {\n\t\treturn nil, fmt.Errorf(\"Service not found: %s\", id)\n\t}\n\n\treturn svc, nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " bool) (Client, error)) {\n\tr.clientMu.Lock()\n\tdefer r.clientMu.Unlock()\n\n\tr.clientFuncs[stream] = f\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (r *Registry) RetrieveExposedServiceContext(ip net.IP, port int, host string) (*PortContext, error) {\n\tr.Lock()\n\tdefer r.Unlock()\n\n\tdata := r.indexByPort.Find(ip, port, host, true)\n\tif data == nil {\n\t\treturn nil, fmt.Errorf(\"Service information not found: %s ... | {
"audio": "",
"image": "",
"text": " %s\", ip.String(), port, host)\n\t}\n\n\tportContext, ok := data.(*PortContext)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"Internal server error\")\n\t}\n\n\treturn portContext, nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\treturn fmt.Errorf(\"Record data not in expected format: '_id' is not string.\")\n\t}\n\tr.RecordID = recordID\n\tr.Data = jsonMap\n\treturn nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (r *Registry) updateExposedPortAssociations(sctx *ServiceContext, service *policy.ApplicationService, secrets secrets.Secrets) error {\n\n\t// Do All the basic validations first.\n\tif service.PrivateNetworkInfo == nil {\n\t\treturn fmt.Errorf(\"Private network is require... | {
"audio": "",
"image": "",
"text": " sctx.PUContext,\n\t\t},\n\t\ttrue,\n\t); err != nil {\n\t\treturn fmt.Errorf(\"Possible port overlap: %s\", err)\n\t}\n\n\tif service.Type == policy.ServiceHTTP && service.PublicNetworkInfo != nil {\n\t\tif err := r.indexByPort.Add(\n\t\t\tservice.PublicNetworkInfo,\n... | {
"audio": "",
"image": "",
"text": "\tif err != nil {\n\t\treturn 0, nil, fmt.Errorf(\"failed querying service for node %q: %s\", nodeName, err)\n\t}\n\n\treturn idx, service, nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (r *Registry) updateExposedServices(sctx *ServiceContext, secrets secrets.Secrets) error {\n\n\tfor _, service := range sctx.PU.Policy.ExposedServices() {\n\t\tif service.Type != policy.ServiceHTTP && service.Type != policy.ServiceTCP {\n\t\t\tcontinue\n\t",
"video": ""... | {
"audio": "",
"image": "",
"text": "\t}\n\t\tif err := r.updateExposedPortAssociations(sctx, service, secrets); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " Option {\n\treturn func(opts *options) error {\n\t\topts.Service = service\n\t\treturn nil\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (r *Registry) updateDependentServices(sctx *ServiceContext) error {\n\n\tfor _, service := range sctx.PU.Policy.DependentServices() {\n\n\t\tif len(service.CACert) != 0 {\n\t\t\tsctx.RootCA = append(sctx.RootCA, service.CACert)\n\t\t}\n\n\t\tserviceData := &DependentServi... | {
"audio": "",
"image": "",
"text": "\n\t\t}\n\n\t\tif err := sctx.dependentServiceCache.Add(\n\t\t\tservice.NetworkInfo,\n\t\t\tsctx.PU.ContextID,\n\t\t\tserviceData,\n\t\t\tfalse,\n\t\t); err != nil {\n\t\t\treturn fmt.Errorf(\"Possible overlap in dependent services: %s\", err)\n\t\t}\n\n\t}\n\n\treturn nil\n}"... | {
"audio": "",
"image": "",
"text": " Option {\n\treturn func(opts *options) error {\n\t\topts.Service = service\n\t\treturn nil\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (d *Datapath) resync(newPortMap map[string]map[string]bool) {\n\tiptablesInstance := iptablesctrl.GetInstance()\n\tif iptablesInstance == nil {\n\t\treturn\n\t}\n\n\tfor k, vs := range d.puToPortsMap {\n\t\tm := newPortMap[k]\n\n\t\tfor v := range vs {\n\t\t\tif m == nil ... | {
"audio": "",
"image": "",
"text": " || !m[v] {\n\t\t\t\tportSpec, err := portspec.NewPortSpecFromString(v, k)\n\t\t\t\tif err != nil {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\td.contextIDFromTCPPort.AddPortSpec(portSpec)\n\t\t\t\terr = iptablesInstance.AddPortToPortSet(k, v)\n\t\t\t\tif err != nil {\n\t\t\t\t\tz... | {
"audio": "",
"image": "",
"text": " \"\" {\n\t\treturn errors.New(\"missing content type\")\n\t}\n\n\tif d.Timestamp == nil {\n\t\treturn errors.New(\"missing timestamp\")\n\t}\n\tfor k, v := range d.GetTags() {\n\t\tif err := types.ValidateTag(k, v); err != nil {\n\t\t\treturn fmt.Errorf(\"invalid tag %q: %v\"... |
{
"audio": "",
"image": "",
"text": "func FlattenClaim(key string, claim interface{}) []string {\n\tattributes := []string{}\n\tif slice, ok := claim.([]string); ok {\n\t\tfor _, data := range slice {\n\t\t\tattributes = append(attributes, key+\"=\"+data)\n\t\t}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t}\n\tif attr, ok := claim.(string); ok {\n\t\tattributes = append(attributes, key+\"=\"+attr)\n\t}\n\tif kv, ok := claim.(map[string]interface{}); ok {\n\t\tfor ikey, ivalue := range kv {\n\t\t\tif attr, ok := ivalue.(string); ok {\n\t\t\t\tattributes = append(attributes, ... | {
"audio": "",
"image": "",
"text": " []string\n\tfor _, h := range hosts {\n\t\tfor _, p := range paths {\n\t\t\tpatterns = append(patterns, h+p)\n\t\t}\n\t}\n\treturn patterns, nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (d *DockerMonitor) SetupConfig(registerer registerer.Registerer, cfg interface{}) (err error) {\n\n\tdefaultConfig := DefaultConfig()\n\n\tif cfg == nil {\n\t\tcfg = defaultConfig\n\t}\n\n\tdockerConfig, ok := cfg.(*Config)\n\tif !ok {\n\t\treturn fmt.Errorf(\"Invalid con... | {
"audio": "",
"image": "",
"text": "\tfor i := 0; i < d.numberOfQueues; i++ {\n\t\td.eventnotifications[i] = make(chan *events.Message, 1000)\n\t\td.stopprocessor[i] = make(chan bool)\n\t}\n\n\t// Add handlers for the events that we know how to process\n\td.addHandler(EventCreate, d.handleCreateEvent)\n\td.addHa... | {
"audio": "",
"image": "",
"text": "\td.t[1] = 0\n\td.f[0] = 0\n\td.f[1] = 0\n\td.nx = 0\n\tif d.isKeyed {\n\t\td.Write(d.paddedKey[:])\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (d *DockerMonitor) Run(ctx context.Context) error {\n\n\tif err := d.config.IsComplete(); err != nil {\n\t\treturn fmt.Errorf(\"docker: %s\", err)\n\t}\n\n\terr := d.waitForDockerDaemon(ctx)\n\tif err != nil {\n\t\tzap.L().Error(\"Docker daemon is not running - skipping c... | {
"audio": "",
"image": "",
"text": "\t// Syncing all Existing containers depending on MonitorSetting\n\t\tif err := d.resyncContainers(ctx, containers); err != nil {\n\t\t\tzap.L().Error(\"Unable to sync existing containers\", zap.Error(err))\n\t\t}\n\t} else {\n\t\t// Starting the eventListener and wait to hear... | {
"audio": "",
"image": "",
"text": " since we don't need it and we don't want to cache an\n\t// image being there if it has possibly been manually deleted (outside of\n\t// Nomad).\n\tif _, ok := d.pullFutures[image]; ok {\n\t\tdelete(d.pullFutures, image)\n\t}\n\n\t// If we are cleaning up, we increment the ref... |
{
"audio": "",
"image": "",
"text": "func (d *DockerMonitor) sendRequestToQueue(r *events.Message) {\n\n\tkey0 := uint64(256203161)\n\tkey1 := uint64(982451653)\n\n\tkey := d.getHashKey(r)\n\th :=",
"video": ""
} | {
"audio": "",
"image": "",
"text": " siphash.Hash(key0, key1, []byte(key))\n\n\td.eventnotifications[int(h%uint64(d.numberOfQueues))] <- r\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " agree with \"mask\".\n\tmask := uint64(d.lsb() << 1)\n\tmask = ^(mask + (mask << 1))\n\tidMasked := (uint64(d) & mask)\n\treturn ((uint64(a)&mask) == idMasked &&\n\t\t(uint64(b)&mask) == idMasked &&\n\t\t(uint64(c)&mask) == idMasked &&\n\t\t!d.isFace())\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (d *DockerMonitor) eventProcessors(ctx context.Context) {\n\n\tfor i := 0; i < d.numberOfQueues; i++ {\n\t\tgo func(i int) {\n\t\t\tfor {\n\t\t\t\tselect {\n\t\t\t\tcase event := <-d.eventnotifications[i]:\n\t\t\t\t\tif f, ok := d.handlers[Event(event.Action)]; ok {\n\t\t... | {
"audio": "",
"image": "",
"text": "\t\t\t\tzap.String(\"action\", event.Action),\n\t\t\t\t\t\t\t\tzap.Error(err),\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\tcase <-ctx.Done():\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t}(i)\n\t}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " := func() error {\n\t\t\tfor i := range indices {\n\t\t\t\terr := bt.readyWorker(\n\t\t\t\t\tgroupCtx, id, bcache, rp, bps, pathsFromRoot, makeSync,\n\t\t\t\t\ti, level, &lock, oldPtrs, donePtrs)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn... |
{
"audio": "",
"image": "",
"text": "func (d *DockerMonitor) eventListener(ctx context.Context, listenerReady chan struct{}) {\n\n\tf := filters.NewArgs()\n\tf.Add(\"type\", \"container\")\n\toptions := types.EventsOptions{\n\t\tFilters: f,\n\t}\n\n\tmessages, errs := d.dockerClient.Events(context.Background(), o... | {
"audio": "",
"image": "",
"text": "\t\tzap.String(\"action\", message.Action),\n\t\t\t\tzap.String(\"ID\", message.ID),\n\t\t\t)\n\t\t\td.sendRequestToQueue(&message)\n\n\t\tcase err := <-errs:\n\t\t\tif err != nil && err != io.EOF {\n\t\t\t\tzap.L().Warn(\"Received docker event error\",\n\t\t\t\t\tzap.Error(er... | {
"audio": "",
"image": "",
"text": "\n\t\tp.Event = pipe.Event\n\t} else {\n\t\tp.Err = make(chan error)\n\t\tp.Event = make(chan events.Event, 10) // buffer the event channel\n\t}\n\n\treturn p\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (d *DockerMonitor) Resync(ctx context.Context) error {\n\n\tif !d.syncAtStart || d.config.Policy == nil {\n\t\tzap.L().Debug(\"No synchronization of containers performed\")\n\t\treturn nil\n\t}\n\n\tzap.L().Debug(\"Syncing all existing containers\")\n\n\toptions := types.... | {
"audio": "",
"image": "",
"text": "\n\tcontainers, err := d.dockerClient.ContainerList(ctx, options)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to get container list: %s\", err)\n\t}\n\n\treturn d.resyncContainers(ctx, containers)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\ts.context = config.GetContext\n\t}\n\tif s.debug == nil {\n\t\ts.debug = fuse.Debug\n\t}\n\tif s.context == nil {\n\t\ts.context = context.Background\n\t}\n\treturn s\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (d *DockerMonitor) resyncContainersByOrder(ctx context.Context, containers []types.Container, syncHost bool) error {\n\tfor _, c := range containers {\n\t\tcontainer, err := d.dockerClient.ContainerInspect(ctx, c.ID)\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\n\t\tif (... | {
"audio": "",
"image": "",
"text": "\truntime.SetPUType(common.LinuxProcessPU)\n\t\t}\n\n\t\truntime.SetOptions(runtime.Options())\n\n\t\tif err := d.config.Policy.HandlePUEvent(ctx, puID, event, runtime); err != nil {\n\t\t\tzap.L().Error(\"Unable to sync existing Container\",\n\t\t\t\tzap.String(\"dockerID\", ... | {
"audio": "",
"image": "",
"text": " dest := range container.HostConfig.Tmpfs {\n\t\tif dest == path {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (d *DockerMonitor) setupHostMode(puID string, runtimeInfo policy.RuntimeReader, dockerInfo *types.ContainerJSON) (err error) {\n\n\tpausePUID := puID\n\tif dockerInfo.HostConfig.NetworkMode == constants.DockerHostMode {\n\t\tif err = d.netcls.Creategroup(puID); err != nil... | {
"audio": "",
"image": "",
"text": " found\")\n\t\t}\n\n\t\tmark, _ := strconv.ParseUint(markval, 10, 32)\n\t\tif err := d.netcls.AssignMark(puID, mark); err != nil {\n\t\t\treturn err\n\t\t}\n\t} else {\n\t\t// Add the container pid that is linked to hostnet to\n\t\t// the cgroup of the parent container.\n\n\t\... | {
"audio": "",
"image": "",
"text": " PIDs of the user are gone, we can delete the user context.\n\tif err := u.config.Policy.HandlePUEvent(ctx, userID, common.EventStop, runtime); err != nil {\n\t\tzap.L().Warn(\"Failed to stop trireme PU \",\n\t\t\tzap.String(\"puID\", puID),\n\t\t\tzap.Error(err),\n\t\t)\n\t}\... |
{
"audio": "",
"image": "",
"text": "func (d *DockerMonitor) extractMetadata(dockerInfo *types.ContainerJSON) (*policy.PURuntime, error) {\n\n\tif dockerInfo == nil {\n\t\treturn nil, errors.New(\"docker info is empty\")\n\t}\n\n\tif d.metadataExtractor != nil {\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\treturn d.metadataExtractor(dockerInfo)\n\t}\n\n\treturn extractors.DefaultMetadataExtractor(dockerInfo)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " err := cmd.Output()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"%s: %v\", strings.Join(args, \" \"), err)\n\t}\n\tvar d describe\n\tif yaml.Unmarshal(data, &d); err != nil {\n\t\treturn nil, fmt.Errorf(\"unmarshal gcloud: %v\", err)\n\t}\n\n\tif d.Endpoint == \"\" {\n\t\... |
{
"audio": "",
"image": "",
"text": "func (d *DockerMonitor) handleCreateEvent(ctx context.Context, event *events.Message) error {\n\n\tpuID, err := puIDFromDockerID(event.ID)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcontainer, err := d.retrieveDockerInfo(ctx, event)\n\tif err != nil {\n\t\treturn err\n\t}\n\... | {
"audio": "",
"image": "",
"text": " constants.DockerHostMode {\n\t\toptions := hostModeOptions(container)\n\t\toptions.PolicyExtensions = runtime.Options().PolicyExtensions\n\t\truntime.SetOptions(*options)\n\t\truntime.SetPUType(common.LinuxProcessPU)\n\t}\n\n\truntime.SetOptions(runtime.Options())\n\n\treturn... | {
"audio": "",
"image": "",
"text": " since we don't need it and we don't want to cache an\n\t// image being there if it has possibly been manually deleted (outside of\n\t// Nomad).\n\tif _, ok := d.pullFutures[image]; ok {\n\t\tdelete(d.pullFutures, image)\n\t}\n\n\t// If we are cleaning up, we increment the ref... |
{
"audio": "",
"image": "",
"text": "func (d *DockerMonitor) handleStartEvent(ctx context.Context, event *events.Message) error {\n\n\tcontainer, err := d.retrieveDockerInfo(ctx, event)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif !container.State.Running {\n\t\treturn nil\n\t}\n\n\tpuID, err := puIDFromDocker... | {
"audio": "",
"image": "",
"text": "\t\t}\n\t\t\td.config.Collector.CollectContainerEvent(&collector.ContainerRecord{\n\t\t\t\tContextID: event.ID,\n\t\t\t\tIPAddress: nil,\n\t\t\t\tTags: nil,\n\t\t\t\tEvent: collector.ContainerFailed,\n\t\t\t})\n\t\t\treturn fmt.Errorf(\"unable to start container becau... | {
"audio": "",
"image": "",
"text": " PIDs of the user are gone, we can delete the user context.\n\tif err := u.config.Policy.HandlePUEvent(ctx, userID, common.EventStop, runtime); err != nil {\n\t\tzap.L().Warn(\"Failed to stop trireme PU \",\n\t\t\tzap.String(\"puID\", puID),\n\t\t\tzap.Error(err),\n\t\t)\n\t}\... |
{
"audio": "",
"image": "",
"text": "func (d *DockerMonitor) handleDestroyEvent(ctx context.Context, event *events.Message) error {\n\n\tpuID, err := puIDFromDockerID(event.ID)\n\tif err != nil {\n\t\treturn err\n\t}\n\truntime := policy.NewPURuntimeWithDefaults()\n\truntime.SetOptions(runtime.Options())\n\n\terr... | {
"audio": "",
"image": "",
"text": " handle delete event\",\n\t\t\tzap.Error(err),\n\t\t)\n\t}\n\n\tif err := d.netcls.DeleteCgroup(puID); err != nil {\n\t\tzap.L().Warn(\"Failed to clean netcls group\",\n\t\t\tzap.String(\"puID\", puID),\n\t\t\tzap.Error(err),\n\t\t)\n\t}\n\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " PIDs of the user are gone, we can delete the user context.\n\tif err := u.config.Policy.HandlePUEvent(ctx, userID, common.EventStop, runtime); err != nil {\n\t\tzap.L().Warn(\"Failed to stop trireme PU \",\n\t\t\tzap.String(\"puID\", puID),\n\t\t\tzap.Error(err),\n\t\t)\n\t}\... |
{
"audio": "",
"image": "",
"text": "func (d *DockerMonitor) handlePauseEvent(ctx context.Context, event *events.Message) error {\n\tzap.L().Info(\"UnPause Event for nativeID\", zap.String(\"ID\", event.ID))\n\n\tpuID, err := puIDFromDockerID(event.ID)\n\tif err != nil {\n\t\treturn err\n\t}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\n\truntime := policy.NewPURuntimeWithDefaults()\n\truntime.SetOptions(runtime.Options())\n\n\treturn d.config.Policy.HandlePUEvent(ctx, puID, tevents.EventPause, runtime)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t}\n\n\tfor {\n\t\tselect {\n\t\tcase event := <-eventq:\n\t\t\tif !r.matchevent(event) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tswitch event.Action {\n\t\t\tcase \"start\":\n\t\t\t\treturn nil\n\t\t\t}\n\t\tcase <-ctx.Done():\n\t\t\treturn ctx.Err()\n\t\tcase <-r.closed:\n\t\t\... |
{
"audio": "",
"image": "",
"text": "func (d *DockerMonitor) handleUnpauseEvent(ctx context.Context, event *events.Message) error {\n\n\tpuID, err := puIDFromDockerID(event.ID)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\truntime := policy.NewPURuntimeWithDefaults()\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\truntime.SetOptions(runtime.Options())\n\n\treturn d.config.Policy.HandlePUEvent(ctx, puID, tevents.EventUnpause, runtime)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t}\n\n\tfor {\n\t\tselect {\n\t\tcase event := <-eventq:\n\t\t\tif !r.matchevent(event) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tswitch event.Action {\n\t\t\tcase \"start\":\n\t\t\t\treturn nil\n\t\t\t}\n\t\tcase <-ctx.Done():\n\t\t\treturn ctx.Err()\n\t\tcase <-r.closed:\n\t\t\... |
{
"audio": "",
"image": "",
"text": "func (d *DockerMonitor) waitForDockerDaemon(ctx context.Context) (err error) {\n\n\tdone := make(chan bool)\n\tgo func() {\n\t\tfor errg := d.setupDockerDaemon(); errg != nil; {\n\t\t\tzap.L().Debug(\"Unable to init docker client. Retrying...\", zap.Error(errg))\n\t\t\t<-time.... | {
"audio": "",
"image": "",
"text": " <- true\n\t}()\n\n\tselect {\n\tcase <-ctx.Done():\n\t\treturn nil\n\tcase <-time.After(dockerInitializationWait):\n\t\treturn fmt.Errorf(\"Unable to connect to docker daemon\")\n\tcase <-done:\n\t}\n\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " err := extractRulesFromTemplate(tmpl, cfg)\n\tif err != nil {\n\t\tzap.L().Warn(\"unable to extract rules\", zap.Error(err))\n\t}\n\treturn rules\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func NewSecrets(s PublicSecrets) (Secrets, error) {\n\tswitch s.SecretsType() {\n\tcase PKICompactType:\n\t\tt := s.(*CompactPKIPublicSecrets)\n\t\treturn NewCompactPKIWithTokenCA(t.Key,",
"video": ""
} | {
"audio": "",
"image": "",
"text": " t.Certificate, t.CA, t.TokenCAs, t.Token, t.Compressed)\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"Unsupported type\")\n\t}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\tswitch t := t.(type) {\n\t\tcase xml.StartElement:\n\t\t\treturn t, nil\n\t\t}\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func NewTable() *ServiceCache {\n\treturn &ServiceCache{\n\t\tlocal: map[int]map[uint32]entryList{},\n\t\tremote: map[int]map[uint32]entryList{},",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t\tremoteHosts: map[string]entryList{},\n\t\tlocalHosts: map[string]entryList{},\n\t}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " tests...just set it nil explicitly\n\tif len(newTable.Entries) == 0 {\n\t\tnewTable.Entries = nil\n\t}\n\n\tif updateStorage {\n\t\t// Update the mount table\n\t\tif err := c.persistMounts(ctx, newTable, &entry.Local); err != nil {\n\t\t\tc.logger.Error(\"failed to remove ent... |
{
"audio": "",
"image": "",
"text": "func (s *ServiceCache) Add(e *common.Service, id string, data interface{}, local bool) error {\n\ts.Lock()\n\tdefer s.Unlock()\n\n\trecord := &entry{\n\t\tports: e.Ports,\n\t",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tdata: data,\n\t\tid: id,\n\t}\n\tif err := s.addPorts(e, record, local); err != nil {\n\t\treturn err\n\t}\n\n\tif err := s.addHostService(e, record, local); err != nil {\n\t\treturn err\n\t}\n\n\treturn s.addIPService(e, record, local)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\ts.Lock()\n\tdefer s.Unlock()\n\n\ts.data = data\n\treturn s.updateEncodedData()\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (s *ServiceCache) Find(ip net.IP, port int, host string, local bool) interface{} {\n\ts.RLock()\n\tdefer s.RUnlock()",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\n\tif host != \"\" {\n\t\tif data := s.findHost(host, port, local); data != nil {\n\t\t\treturn data\n\t\t}\n\t}\n\n\treturn s.findIP(ip, port, local)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t}\n\t\tif i == 2 {\n\t\t\ts = strings.ToUpper(s)\n\t\t}\n\t\tif ip := c.Request().Header().Get(s); ip != \"\" {\n\t\t\treturn net.ParseIP(strings.Split(ip, \", \")[0])\n\t\t}\n\t}\n\n\taddr := c.Request().RemoteAddr\n\taddr, _, _ = net.SplitHostPort(addr)\n\treturn net.Parse... |
{
"audio": "",
"image": "",
"text": "func (s *ServiceCache) FindListeningServicesForPU(id string) (interface{}, *portspec.PortSpec) {\n\ts.RLock()",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tdefer s.RUnlock()\n\n\tfor _, spec := range s.localPorts {\n\t\tif spec.id == id {\n\t\t\treturn spec.data, spec.ports\n\t\t}\n\t}\n\treturn nil, nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " (interface{}, error)) *Init {\n\treturn ini.Branch(func() (interface{}, error) {\n\t\treturn ini.withTimeout(timeout, f)\n\t})\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (s *ServiceCache) DeleteByID(id string, local bool) {\n\ts.Lock()\n\tdefer s.Unlock()\n\n\thosts := s.remoteHosts\n\tprefixes := s.remote\n\tif local {\n\t\thosts = s.localHosts\n\t\tprefixes = s.local\n\t}\n\n\tif local {\n\t\ts.localPorts = deleteMatchingPorts(s.localPo... | {
"audio": "",
"image": "",
"text": "\t}\n\n\tfor l, prefix := range prefixes {\n\t\tfor ip, ports := range prefix {\n\t\t\tprefix[ip] = deleteMatchingPorts(ports, id)\n\t\t\tif len(prefix[ip]) == 0 {\n\t\t\t\tdelete(prefix, ip)\n\t\t\t}\n\t\t}\n\t\tif len(prefix) == 0 {\n\t\t\tdelete(prefixes, l)\n\t\t}\n\t}\n}"... | {
"audio": "",
"image": "",
"text": " s.WITGs {\n\t\twitg.SpaceTemplateID = s.Template.ID\n\t}\n\tfor _, wib := range s.WIBs {\n\t\twib.SpaceTemplateID = s.Template.ID\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (s *ServiceCache) addPorts(e *common.Service, record *entry, local bool) error {\n\tif !local {\n\t\treturn nil\n\t}\n\n\tfor _, spec := range s.localPorts {",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t\tif spec.ports.Overlaps(e.Ports) {\n\t\t\treturn fmt.Errorf(\"service port overlap in the global port list: %+v %s\", e.Addresses, e.Ports.String())\n\t\t}\n\t}\n\n\ts.localPorts = append(s.localPorts, record)\n\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\t\tif s == \"wss\" {\n\t\t\t\treturn s\n\t\t\t}\n\t\t}\n\t\treturn \"ws\"\n\t}\n\tfor _, s := range a.EffectiveSchemes() {\n\t\tif s == \"https\" {\n\t\t\treturn s\n\t\t}\n\t}\n\treturn \"http\"\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (s *ProxyInfo) Supervise(contextID string, puInfo",
"video": ""
} | {
"audio": "",
"image": "",
"text": " *policy.PUInfo) error {\n\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " string, _ string) (string, error) {\n\treturn \"\", nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func NewMockMonitor(ctrl *gomock.Controller) *MockMonitor {\n\tmock := &MockMonitor{ctrl: ctrl}\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tmock.recorder = &MockMonitorMockRecorder{mock}\n\treturn mock\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\tmock := &MockDockerMetadataClient{ctrl: ctrl}\n\tmock.recorder = &MockDockerMetadataClientMockRecorder{mock}\n\treturn mock\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func NewMockImplementation(ctrl *gomock.Controller) *MockImplementation {\n\tmock := &MockImplementation{ctrl:",
"video": ""
} | {
"audio": "",
"image": "",
"text": " ctrl}\n\tmock.recorder = &MockImplementationMockRecorder{mock}\n\treturn mock\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " sync,\n\t}\n\n\tcontroller.logger.Log(\"info\", \"setting up event handlers\")\n\n\t// ----- EVENT HANDLERS for HelmRelease resources change ---------\n\tfhrInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{\n\t\tAddFunc: func(new interface{}) {\n... |
{
"audio": "",
"image": "",
"text": "func (m *MockImplementation) SetupConfig(registerer registerer.Registerer, cfg",
"video": ""
} | {
"audio": "",
"image": "",
"text": " interface{}) error {\n\tret := m.ctrl.Call(m, \"SetupConfig\", registerer, cfg)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " func(cfg *config) {\n\t\tcfg.runtimeCfg = c\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (mr *MockImplementationMockRecorder) SetupConfig(registerer, cfg interface{}) *gomock.Call {\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"SetupConfig\",",
"video": ""
} | {
"audio": "",
"image": "",
"text": " reflect.TypeOf((*MockImplementation)(nil).SetupConfig), registerer, cfg)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"ChangeConnectionID\", reflect.TypeOf((*MockCryptoSetup)(nil).ChangeConnectionID), arg0)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (m *MockImplementation) SetupHandlers(c",
"video": ""
} | {
"audio": "",
"image": "",
"text": " *config.ProcessorConfig) {\n\tm.ctrl.Call(m, \"SetupHandlers\", c)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\t\"nobody\",\n\t\tfalse,\n\t\tfunc(e Export) UserMapping { return e.MapRoot },\n\t\tfunc(e Export, m UserMapping) { e.MapRoot = m })\n\n\treturn api.ExportUpdate(ctx, c.API, nex)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (mr *MockImplementationMockRecorder) SetupHandlers(c interface{}) *gomock.Call {\n\treturn",
"video": ""
} | {
"audio": "",
"image": "",
"text": " mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"SetupHandlers\", reflect.TypeOf((*MockImplementation)(nil).SetupHandlers), c)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t\treturn nil, ErrInvalidParams()\n\t}\n\n\tmr.m.RLock()\n\tmd, ok := mr.r[r.Method]\n\tmr.m.RUnlock()\n\tif !ok {\n\t\treturn nil, ErrMethodNotFound()\n\t}\n\n\treturn md.Handler, nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (i *goIpsetProvider) NewIpset(name string, hasht string, p *ipset.Params) (Ipset,",
"video": ""
} | {
"audio": "",
"image": "",
"text": " error) {\n\treturn ipset.New(name, hasht, p)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " string, _ string) (string, error) {\n\treturn \"\", nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (i *goIpsetProvider) GetIpset(name string) Ipset {\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\treturn &ipset.IPSet{\n\t\tName: name,\n\t}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tif i := strings.LastIndex(name, \".\"); i >= 0 {\n\t\tname = name[0:i]\n\t}\n\treturn name\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (i *goIpsetProvider) DestroyAll(prefix string) error {\n\n\tsets, err := i.ListIPSets()\n\tif err != nil {\n\t\treturn ipset.DestroyAll()\n\t}\n\n\tfor _, s := range sets {\n\t\tif !strings.HasPrefix(s, prefix) {\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\t\tcontinue\n\t\t}\n\t\tips := i.GetIpset(s)\n\t\tif err := ips.Destroy(); err != nil {\n\t\t\treturn ipset.DestroyAll()\n\t\t}\n\t}\n\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " err != nil {\n\t\t\treturn esResp, err\n\t\t}\n\t}\n\n\tif req.api == \"_bulk\" && esResp.Errors {\n\t\tfor _, item := range esResp.Items {\n\t\t\tfor _, i := range item {\n\t\t\t\tif i.Error != \"\" {\n\t\t\t\t\treturn esResp, &SearchError{i.Error, i.Status}\n\t\t\t\t}\n\t\t... |
{
"audio": "",
"image": "",
"text": "func (m *monitors) UpdateConfiguration(ctx context.Context, config *config.MonitorConfig) error {\n\t//",
"video": ""
} | {
"audio": "",
"image": "",
"text": " Monitor configuration cannot change at this time.\n\t// TODO:\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " func(ctx context.Context) error {\n\t\treturn UpdateTenant(ctx, config)\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (m *monitors) Resync(ctx context.Context) error {\n\n\tfailure := false\n\tvar errs string\n\n\tfor _, i := range m.monitors {\n\t\tif err := i.Resync(ctx); err != nil {\n\t\t\terrs = errs + err.Error()",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t\t\tfailure = true\n\t\t}\n\t}\n\n\tif failure {\n\t\treturn fmt.Errorf(\"Monitor resync failed: %s\", errs)\n\t}\n\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " func(ctx context.Context) error {\n\t\treturn UpdateTenant(ctx, config)\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (d *Datapath) Enforce(contextID string, puInfo *policy.PUInfo) error {\n\n\t// Always create a new PU context\n\tpu, err := pucontext.NewPU(contextID, puInfo, d.ExternalIPCacheTimeout)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error creating new pu: %s\", err)\n\t}\n\n\... | {
"audio": "",
"image": "",
"text": " err != nil {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// check for host pu and add its ports to the end.\n\t\t\tif puInfo.Runtime.PUType() == common.HostPU {\n\t\t\t\td.contextIDFromUDPPort.AddPortSpecToEnd(portSpec)\n\t\t\t} else {\n\t\t\t\td.contextIDFromUDPPort.AddPortSpec(port... | {
"audio": "",
"image": "",
"text": " address instead\")\n\tdefault:\n\t\t_, err := common.ParseIPv4(d.Ipv4)\n\t\tif err != nil {\n\t\t\treturn status.Errorf(codes.InvalidArgument, \"invalid IPv4 address %q\", d.Ipv4)\n\t\t}\n\t\t_, err = common.ParseMAC48(d.MacAddress)\n\t\tif err != nil {\n\t\t\treturn status.E... |
{
"audio": "",
"image": "",
"text": "func (d *Datapath) Unenforce(contextID string) error {\n\n\tvar err error\n\n\tpuContext, err := d.puFromContextID.Get(contextID)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"contextid not found in enforcer: %s\", err)\n\t}\n\n\t// Cleanup the IP based lookup\n\tpu := puContext... | {
"audio": "",
"image": "",
"text": " port),\n\t\t\t\tzap.Error(err),\n\t\t\t)\n\t\t}\n\t}\n\n\tfor _, port := range pu.UDPPorts() {\n\t\tif err := d.contextIDFromUDPPort.RemoveStringPorts(port); err != nil {\n\t\t\tzap.L().Debug(\"Unable to remove cache entry during unenforcement\",\n\t\t\t\tzap.String(\"UDPPort... | {
"audio": "",
"image": "",
"text": " PIDs of the user are gone, we can delete the user context.\n\tif err := u.config.Policy.HandlePUEvent(ctx, userID, common.EventStop, runtime); err != nil {\n\t\tzap.L().Warn(\"Failed to stop trireme PU \",\n\t\t\tzap.String(\"puID\", puID),\n\t\t\tzap.Error(err),\n\t\t)\n\t}\... |
{
"audio": "",
"image": "",
"text": "func (d *Datapath) SetTargetNetworks(cfg *runtime.Configuration) error {\n\n\tnetworks := cfg.TCPTargetNetworks\n\n\tif len(networks) ==",
"video": ""
} | {
"audio": "",
"image": "",
"text": " 0 {\n\t\tnetworks = []string{\"0.0.0.0/1\", \"128.0.0.0/1\"}\n\t}\n\n\td.targetNetworks = acls.NewACLCache()\n\ttargetacl := createPolicy(networks)\n\treturn d.targetNetworks.AddRuleList(targetacl)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " func(cfg *config) {\n\t\tcfg.runtimeCfg = c\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (d *Datapath) Run(ctx context.Context) error {\n\n\tzap.L().Debug(\"Start enforcer\", zap.Int(\"mode\", int(d.mode)))\n\n\tif d.conntrack == nil {\n\t\tconntrackClient, err := flowtracking.NewClient(ctx)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t\td.conntrack = conntrackClient\n\t}\n\n\td.startApplicationInterceptor(ctx)\n\td.startNetworkInterceptor(ctx)\n\n\tgo d.nflogger.Run(ctx)\n\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " beginning.\n\tif conn.GetState() == connection.UDPReceiverSendSynAck {\n\t\tconn.SynAckStop()\n\t}\n\n\t// Only start the retransmission timer once. Not on every packet.\n\tif err := d.writeWithRetransmit(udpPacket.GetBuffer(0), conn, conn.SynAckChannel()); err != nil {\n\t\t... |
{
"audio": "",
"image": "",
"text": "func (d *Datapath) contextFromIP(app bool, mark string, port uint16, protocol uint8) (*pucontext.PUContext, error) {\n\n\tif d.puFromIP != nil {\n\t\treturn d.puFromIP, nil\n\t}\n\n\tif app {\n\t\tpu, err := d.puFromMark.Get(mark)\n\t\tif err != nil {\n\t\t\tzap.L().Error(\"Un... | {
"audio": "",
"image": "",
"text": "\n\t\tcontextID, err := d.contextIDFromUDPPort.GetSpecValueFromPort(port)\n\t\tif err != nil {\n\t\t\tzap.L().Debug(\"Could not find PU context for UDP server port \", zap.Uint16(\"port\", port))\n\t\t\treturn nil, errPortNotFound\n\t\t}\n\n\t\tpu, err := d.puFromContextID.Get... | {
"audio": "",
"image": "",
"text": " beginning.\n\tif conn.GetState() == connection.UDPReceiverSendSynAck {\n\t\tconn.SynAckStop()\n\t}\n\n\t// Only start the retransmission timer once. Not on every packet.\n\tif err := d.writeWithRetransmit(udpPacket.GetBuffer(0), conn, conn.SynAckChannel()); err != nil {\n\t\t... |
{
"audio": "",
"image": "",
"text": "func (s *netCls) AssignMark(cgroupname string, mark uint64) error {\n\n\t_, err := os.Stat(filepath.Join(basePath, s.TriremePath, cgroupname))\n\tif os.IsNotExist(err) {\n\t\treturn fmt.Errorf(\"cgroup does not exist: %s\", err)\n\t}\n\n\t//16 is the base since the mark file e... | {
"audio": "",
"image": "",
"text": "\n\tif err := ioutil.WriteFile(filepath.Join(basePath, s.TriremePath, cgroupname, markFile), []byte(markval), 0644); err != nil {\n\t\treturn fmt.Errorf(\"failed to write to net_cls.classid file for new cgroup: %s\", err)\n\t}\n\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " osInterface.Glob(filepath.Join(legacyContainerLogsDir, fmt.Sprintf(\"*.%s\", legacyLogSuffix)))\n\tfor _, logSymlink := range logSymlinks {\n\t\tif _, err := osInterface.Stat(logSymlink); os.IsNotExist(err) {\n\t\t\terr := osInterface.Remove(logSymlink)\n\t\t\tif err != nil {... |
{
"audio": "",
"image": "",
"text": "func (s *netCls) AddProcess(cgroupname string, pid int) error {\n\n\t_, err := os.Stat(filepath.Join(basePath, s.TriremePath, cgroupname))\n\tif os.IsNotExist(err) {\n\t\treturn fmt.Errorf(\"cannot add process. cgroup does not",
"video": ""
} | {
"audio": "",
"image": "",
"text": " exist: %s\", err)\n\t}\n\n\tPID := []byte(strconv.Itoa(pid))\n\tif err := syscall.Kill(pid, 0); err != nil {\n\t\treturn nil\n\t}\n\n\tif err := ioutil.WriteFile(filepath.Join(basePath, s.TriremePath, cgroupname, procs), PID, 0644); err != nil {\n\t\treturn fmt.Errorf(\"canno... | {
"audio": "",
"image": "",
"text": " osInterface.Glob(filepath.Join(legacyContainerLogsDir, fmt.Sprintf(\"*.%s\", legacyLogSuffix)))\n\tfor _, logSymlink := range logSymlinks {\n\t\tif _, err := osInterface.Stat(logSymlink); os.IsNotExist(err) {\n\t\t\terr := osInterface.Remove(logSymlink)\n\t\t\tif err != nil {... |
{
"audio": "",
"image": "",
"text": "func (s *netCls) RemoveProcess(cgroupname string, pid int) error {\n\n\t_, err := os.Stat(filepath.Join(basePath, s.TriremePath, cgroupname))\n\tif os.IsNotExist(err) {\n\t\treturn fmt.Errorf(\"cannot clean up process. cgroup does not exist: %s\", err)\n\t}\n\n\tdata, err := i... | {
"audio": "",
"image": "",
"text": "\tif !strings.Contains(string(data), strconv.Itoa(pid)) {\n\t\treturn errors.New(\"cannot cleanup process. process is not a part of this cgroup\")\n\t}\n\n\tif err := ioutil.WriteFile(filepath.Join(basePath, procs), []byte(strconv.Itoa(pid)), 0644); err != nil {\n\t\treturn fm... | {
"audio": "",
"image": "",
"text": " osInterface.Glob(filepath.Join(legacyContainerLogsDir, fmt.Sprintf(\"*.%s\", legacyLogSuffix)))\n\tfor _, logSymlink := range logSymlinks {\n\t\tif _, err := osInterface.Stat(logSymlink); os.IsNotExist(err) {\n\t\t\terr := osInterface.Remove(logSymlink)\n\t\t\tif err != nil {... |
{
"audio": "",
"image": "",
"text": "func (s *netCls) DeleteCgroup(cgroupname string) error {\n\n\t_, err := os.Stat(filepath.Join(basePath, s.TriremePath, cgroupname))\n\tif os.IsNotExist(err) {\n\t\tzap.L().Debug(\"Group already deleted\", zap.Error(err))\n\t\treturn nil\n\t}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\n\terr = os.Remove(filepath.Join(basePath, s.TriremePath, cgroupname))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to delete cgroup %s: %s\", cgroupname, err)\n\t}\n\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " PIDs of the user are gone, we can delete the user context.\n\tif err := u.config.Policy.HandlePUEvent(ctx, userID, common.EventStop, runtime); err != nil {\n\t\tzap.L().Warn(\"Failed to stop trireme PU \",\n\t\t\tzap.String(\"puID\", puID),\n\t\t\tzap.Error(err),\n\t\t)\n\t}\... |
{
"audio": "",
"image": "",
"text": "func (s *netCls) Deletebasepath(cgroupName string) bool {\n\n\tif cgroupName == s.TriremePath {\n\t\tif err := os.Remove(filepath.Join(basePath, cgroupName)); err != nil {\n\t\t\tzap.L().Error(\"Error",
"video": ""
} | {
"audio": "",
"image": "",
"text": " when removing Trireme Base Path\", zap.Error(err))\n\t\t}\n\t\treturn true\n\t}\n\n\treturn false\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " PIDs of the user are gone, we can delete the user context.\n\tif err := u.config.Policy.HandlePUEvent(ctx, userID, common.EventStop, runtime); err != nil {\n\t\tzap.L().Warn(\"Failed to stop trireme PU \",\n\t\t\tzap.String(\"puID\", puID),\n\t\t\tzap.Error(err),\n\t\t)\n\t}\... |
{
"audio": "",
"image": "",
"text": "func (s *netCls) ListCgroupProcesses(cgroupname string) ([]string, error) {\n\n\t_, err := os.Stat(filepath.Join(basePath, s.TriremePath, cgroupname))\n\n\tif os.IsNotExist(err) {\n\t\treturn []string{}, fmt.Errorf(\"cgroup %s does not exist: %s\", cgroupname, err)\n\t}\n\n\td... | {
"audio": "",
"image": "",
"text": "\n\t\treturn []string{}, fmt.Errorf(\"cannot read procs file: %s\", err)\n\t}\n\n\tprocs := []string{}\n\n\tfor _, line := range strings.Split(string(data), \"\\n\") {\n\t\tif len(line) > 0 {\n\t\t\tprocs = append(procs, line)\n\t\t}\n\t}\n\n\treturn procs, nil\n}",
"video":... | {
"audio": "",
"image": "",
"text": " osInterface.Glob(filepath.Join(legacyContainerLogsDir, fmt.Sprintf(\"*.%s\", legacyLogSuffix)))\n\tfor _, logSymlink := range logSymlinks {\n\t\tif _, err := osInterface.Stat(logSymlink); os.IsNotExist(err) {\n\t\t\terr := osInterface.Remove(logSymlink)\n\t\t\tif err != nil {... |
{
"audio": "",
"image": "",
"text": "func (s *netCls) ListAllCgroups(path string) []string {\n\n\tcgroups, err := ioutil.ReadDir(filepath.Join(basePath, s.TriremePath, path))\n\tif err != nil {\n\t\treturn []string{}\n\t}\n\n\tnames := make([]string,",
"video": ""
} | {
"audio": "",
"image": "",
"text": " len(cgroups))\n\tfor i := 0; i < len(cgroups); i++ {\n\t\tnames[i] = cgroups[i].Name()\n\t}\n\n\treturn names\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t}\n\t\tif path == s.path {\n\t\t\treturn nil\n\t\t}\n\t\tname := strings.TrimPrefix(path, s.path+string(filepath.Separator))\n\t\tif !strings.HasPrefix(name, prefix) {\n\t\t\treturn nil\n\t\t}\n\t\tfiles = append(files, name)\n\t\treturn nil\n\t}); err != nil {\n\t\treturn n... |
{
"audio": "",
"image": "",
"text": "func NewDockerCgroupNetController() Cgroupnetcls {\n\n\tcontroller := &netCls{\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\tmarkchan: make(chan uint64),\n\t\tReleaseAgentPath: \"\",\n\t\tTriremePath: \"\",\n\t}\n\n\treturn controller\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " sync,\n\t}\n\n\tcontroller.logger.Log(\"info\", \"setting up event handlers\")\n\n\t// ----- EVENT HANDLERS for HelmRelease resources change ---------\n\tfhrInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{\n\t\tAddFunc: func(new interface{}) {\n... |
{
"audio": "",
"image": "",
"text": "func NewCgroupNetController(triremepath string, releasePath string) Cgroupnetcls {\n\tif !mounted {\n\t\tmounted = true\n\t\tif err := mountCgroupController(); err != nil {\n\t\t\tzap.L().Error(\"Unable to mount net_cls controller - Linux process isolation not possible\",\n\t\... | {
"audio": "",
"image": "",
"text": "\tReleaseAgentPath: binpath,\n\t\tTriremePath: \"\",\n\t}\n\n\tif releasePath != \"\" {\n\t\tcontroller.ReleaseAgentPath = releasePath\n\t}\n\n\tif triremepath != \"\" {\n\t\tcontroller.TriremePath = triremepath\n\t}\n\n\treturn controller\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " err := extractRulesFromTemplate(tmpl, cfg)\n\tif err != nil {\n\t\tzap.L().Warn(\"unable to extract rules\", zap.Error(err))\n\t}\n\treturn rules\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func NewVerifier(s secrets.Secrets, globalCertificate *x509.Certificate) *Verifier {\n\treturn &Verifier{\n\t\tsecrets: s,\n\t\tglobalCert: globalCertificate,\n\t\t// tokenCache will cache",
"video": ""
} | {
"audio": "",
"image": "",
"text": " the token results to accelerate performance\n\t\ttokenCache: gcache.New(2048).LRU().Expiration(20 * time.Second).Build(),\n\t}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\treturn s.coreClientSet.Secrets(s.namespace)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (p *Verifier) UpdateSecrets(s secrets.Secrets, globalCert *x509.Certificate) {\n\tp.Lock()",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tdefer p.Unlock()\n\n\tp.secrets = s\n\tp.globalCert = globalCert\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\treturn func(p *ProgressBar) {\n\t\tp.config.width = s\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func CreateAndSign(server string, profile, scopes []string, id string, validity time.Duration, gkey interface{}) (string, error) {\n\tkey, ok := gkey.(*ecdsa.PrivateKey)\n\tif !ok {\n\t\treturn \"\", fmt.Errorf(\"Not a valid private key format\")\n\t}\n\tif token, err := local... | {
"audio": "",
"image": "",
"text": " id,\n\t\t},\n\t\tProfile: profile,\n\t\tScopes: scopes,\n\t}\n\n\ttoken, err := jwt.NewWithClaims(jwt.SigningMethodES256, claims).SignedString(key)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tlocalCache.AddOrUpdate(id, token)\n\treturn token, nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " string, _ string) (string, error) {\n\treturn \"\", nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func generateContextID(eventInfo *common.EventInfo) (string, error) {\n\n\tif eventInfo.PUID == \"\" {\n\t\treturn \"\", errors.New(\"puid is",
"video": ""
} | {
"audio": "",
"image": "",
"text": " empty from event info\")\n\t}\n\n\tif len(eventInfo.PUID) < 12 {\n\t\treturn \"\", errors.New(\"puid smaller than 12 characters\")\n\t}\n\n\treturn eventInfo.PUID[:12], nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " string, _ string) (string, error) {\n\treturn \"\", nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func NewClient(ctx context.Context) (*Client, error) {\n\tc, err := conntrack.Dial(&netlink.Config{})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"flow",
"video": ""
} | {
"audio": "",
"image": "",
"text": " tracker is unable to dial netlink: %s\", err)\n\t}\n\n\tclient := &Client{conn: c}\n\tgo func() {\n\t\t<-ctx.Done()\n\t\tclient.conn.Close() // nolint errcheck\n\t}()\n\n\treturn client, nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " func(ctx context.Context) error {\n\t\treturn UpdateTenant(ctx, config)\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (c *Client) UpdateApplicationFlowMark(ipSrc, ipDst net.IP, protonum uint8, srcport, dstport uint16, newmark uint32) error {\n\n\tf :=",
"video": ""
} | {
"audio": "",
"image": "",
"text": " conntrack.NewFlow(protonum, 0, ipSrc, ipDst, srcport, dstport, 0, newmark)\n\n\treturn c.conn.Update(f)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\treturn func(c echo.Context) error {\n\t\t\tif config.Skipper(c) {\n\t\t\t\treturn next.Handle(c)\n\t\t\t}\n\t\t\tip, _, _ := net.SplitHostPort(c.RealIP())\n\t\t\t//show simple forbidden text\n\t\t\tif !config.Filter().Allowed(ip) {\n\t\t\t\treturn echo.ErrForbidden\n\t\t\t... |
{
"audio": "",
"image": "",
"text": "func newReplyFlow(proto uint8, status conntrack.StatusFlag, srcAddr, destAddr net.IP, srcPort, destPort uint16, timeout, mark uint32) conntrack.Flow {\n\n\tvar f conntrack.Flow\n\n\tf.Status.Value = status\n\n\tf.Timeout = timeout\n\tf.Mark = mark\n\n\t// Set up TupleReply wit... | {
"audio": "",
"image": "",
"text": "\tf.TupleReply.IP.SourceAddress = srcAddr\n\tf.TupleReply.IP.DestinationAddress = destAddr\n\tf.TupleReply.Proto.SourcePort = srcPort\n\tf.TupleReply.Proto.DestinationPort = destPort\n\tf.TupleReply.Proto.Protocol = proto\n\n\treturn f\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " status.FromError(err)\n\tp.f(\"%s\", st.Message())\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (c *MonitorConfig) String() string {\n\tbuf := fmt.Sprintf(\"MergeTags:[%s] \", strings.Join(c.MergeTags, \",\"))\n\tbuf += fmt.Sprintf(\"Common:%+v \", c.Common)\n\tbuf += fmt.Sprintf(\"Monitors:{\")\n\tfor k,",
"video": ""
} | {
"audio": "",
"image": "",
"text": " v := range c.Monitors {\n\t\tbuf += fmt.Sprintf(\"{%d:%+v},\", k, v)\n\t}\n\tbuf += fmt.Sprintf(\"}\")\n\treturn buf\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tbuf.WriteString(fmt.Sprintf(\"%s-\", strings.ToLower(protocol)))\n\tbuf.WriteString(fmt.Sprintf(\"%t-\", self))\n\n\treturn fmt.Sprintf(\"rule-%d\", hashcode.String(buf.String()))\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (c *ProcessorConfig) IsComplete() error {\n\n\tif c.Collector == nil {\n\t\treturn fmt.Errorf(\"Missing configuration: collector\")\n\t}\n\n\tif c.Policy ==",
"video": ""
} | {
"audio": "",
"image": "",
"text": " nil {\n\t\treturn fmt.Errorf(\"Missing configuration: puHandler\")\n\t}\n\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\treturn func(c *config) {\n\t\tc.tracerOptions.Collector.Host = satelliteHost\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (c *collectorImpl) CollectFlowEvent(record *collector.FlowRecord) {\n\n\thash := collector.StatsFlowHash(record)\n\n\t// If flow event doesn't have a count make it equal to 1. At",
"video": ""
} | {
"audio": "",
"image": "",
"text": " least one flow is collected\n\tif record.Count == 0 {\n\t\trecord.Count = 1\n\t}\n\n\tc.Lock()\n\tdefer c.Unlock()\n\n\tif r, ok := c.Flows[hash]; ok {\n\t\tr.Count = r.Count + record.Count\n\t\treturn\n\t}\n\n\tc.Flows[hash] = record\n\n\tc.Flows[hash].Tags = record.Tags\n}"... | {
"audio": "",
"image": "",
"text": "\t\treturn err\n\t}\n\n\ttxn, err1 := h.sctx.Context.Txn(true)\n\tif err1 != nil {\n\t\treturn err1\n\t}\n\trecord.CreateTime = types.Time{\n\t\tTime: types.FromGoTime(oracle.GetTimeFromTS(txn.StartTS())),\n\t\tType: mysql.TypeDatetime,\n\t\tFsp: 3,\n\t}\n\trecord.UpdateTime ... |
{
"audio": "",
"image": "",
"text": "func (c *collectorImpl) CollectUserEvent(record *collector.UserRecord) {\n\tif err := collector.StatsUserHash(record); err != nil {\n\t\tzap.L().Error(\"Cannot store user record\", zap.Error(err))\n\t\treturn\n\t}\n\n\tc.Lock()\n\tdefer c.Unlock()\n\n\tif",
"video": ""
} | {
"audio": "",
"image": "",
"text": " _, ok := c.ProcessedUsers[record.ID]; !ok {\n\t\tc.Users[record.ID] = record\n\t\tc.ProcessedUsers[record.ID] = true\n\t}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " err := extractRulesFromTemplate(tmpl, cfg)\n\tif err != nil {\n\t\tzap.L().Warn(\"unable to extract rules\", zap.Error(err))\n\t}\n\treturn rules\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (c *collectorImpl) CollectPacketEvent(report *collector.PacketReport) {\n\t//We will leave this unimplemented\n\t// trace event collection in done from the main enforcer\n\tc.Lock()",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tdefer c.Unlock()\n\tzap.L().Debug(\"Collected Packet Event\")\n\tc.DatapathPacketReports = append(c.DatapathPacketReports, report)\n\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t// the monitoring goroutine may be in a select on the lockCh, so we need to\n\t// wait for it to return before changing the value.\n\tc.monitorWG.Wait()\n\tc.lockCh = nil\n\n\t// This is only cleanup, and will fail if the lock was immediately taken by\n\t// another client, s... |
{
"audio": "",
"image": "",
"text": "func NewKubeClient(kubeconfig string) (*kubernetes.Clientset, error) {\n\tconfig, err := clientcmd.BuildConfigFromFlags(\"\", kubeconfig)\n\tif err != nil {\n\t",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\treturn nil, fmt.Errorf(\"Error Building config from Kubeconfig: %v\", err)\n\t}\n\n\treturn kubernetes.NewForConfig(config)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\tcase err != nil:\n\t\t\treturn nil, err\n\t\t}\n\t\tcli.kubeNamespace = configNamespace\n\t}\n\n\tconfig, err := clientConfig.ClientConfig()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tcli.kubeConfig = config\n\n\tclientSet, err := kubeclient.NewForConfig(config)\n\tif... |
{
"audio": "",
"image": "",
"text": "func (m *KubernetesMonitor) CreateLocalPodController(namespace string,\n\taddFunc func(addedApiStruct *api.Pod) error, deleteFunc func(deletedApiStruct *api.Pod) error, updateFunc func(oldApiStruct, updatedApiStruct *api.Pod) error) (kubecache.Store, kubecache.Controller) {\n\... | {
"audio": "",
"image": "",
"text": " interface{}) {\n\t\t\tif err := deleteFunc(deletedApiStruct.(*api.Pod)); err != nil {\n\t\t\t\tzap.L().Error(\"Error while handling Delete Pod\", zap.Error(err))\n\t\t\t}\n\t\t},\n\t\tfunc(oldApiStruct, updatedApiStruct interface{}) {\n\t\t\tif err := updateFunc(oldApiStruct.... | {
"audio": "",
"image": "",
"text": " !deleted && !volumeutil.IsPodTerminated(pod, pod.Status) && pod.Spec.NodeName != \"\" {\n\t\treturn\n\t}\n\n\tklog.V(4).Infof(\"Got event on pod %s/%s\", pod.Namespace, pod.Name)\n\n\t// Enqueue all PVCs that the pod uses\n\tfor _, volume := range pod.Spec.Volumes {\n\t\tif v... |
{
"audio": "",
"image": "",
"text": "func (m *KubernetesMonitor) Pod(podName string, namespace string) (*api.Pod, error) {\n\ttargetPod, err := m.kubeClient.CoreV1().Pods(namespace).Get(podName, metav1.GetOptions{})\n\tif err != nil {\n\t",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\treturn nil, fmt.Errorf(\"error getting Kubernetes labels & IP for pod %v : %v \", podName, err)\n\t}\n\treturn targetPod, nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " NamespaceByID(ctx, nsID, m.core)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif leaseNS != nil {\n\t\t\tctx = namespace.ContextWithNamespace(ctx, leaseNS)\n\t\t}\n\t} else {\n\t\tctx = namespace.ContextWithNamespace(ctx, namespace.RootNamespace)\n\t}\n\treturn m.l... |
{
"audio": "",
"image": "",
"text": "func DialMarkedWithContext(ctx context.Context, network string, addr string, mark",
"video": ""
} | {
"audio": "",
"image": "",
"text": " int) (net.Conn, error) {\n\treturn nil, nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " (string, string, string, error) {\n\treturn api.SendMessageContext(context.Background(), channelID, MsgOptionUnfurl(timestamp, unfurls), MsgOptionCompose(options...))\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func NewSocketListener(ctx context.Context, port string, mark int)",
"video": ""
} | {
"audio": "",
"image": "",
"text": " (net.Listener, error) {\n\treturn nil, nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " a.baseToken.token,\n\t\tlifetime: lifetime,\n\t\trefreshCb: func(ctx context.Context, prev *internal.Token) (*internal.Token, error) {\n\t\t\treturn a.baseToken.renewToken(ctx, prev, nil)\n\t\t},\n\t})\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (p *ProxiedConnection) GetOriginalDestination() (net.IP, int) {\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\treturn p.originalIP, p.originalPort\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\treturn func(c echo.Context) error {\n\t\t\tif config.Skipper(c) {\n\t\t\t\treturn next.Handle(c)\n\t\t\t}\n\t\t\tip, _, _ := net.SplitHostPort(c.RealIP())\n\t\t\t//show simple forbidden text\n\t\t\tif !config.Filter().Allowed(ip) {\n\t\t\t\treturn echo.ErrForbidden\n\t\t\t... |
{
"audio": "",
"image": "",
"text": "func (c UIDConnection) Read(b []byte) (n int, err error)",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\treturn c.nc.Read(b)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " (n int, err error) {\n\treturn 0, f.err\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (c UIDConnection) RemoteAddr() net.Addr {\n\n\tuidAddr := &UIDAddr{\n\t\tNetworkAddress: c.nc.RemoteAddr().Network(),\n\t}\n\n\tf, err := c.nc.File()\n\tif err != nil {\n\t\tuidAddr.Address = \"NotAvailable\"\n\t}\n\tdefer f.Close() // nolint\n\n\tcred, err := syscall.Get... | {
"audio": "",
"image": "",
"text": "\t\tuidAddr.Address = \"NotAvailable\"\n\t}\n\n\tuidAddr.Address = strconv.Itoa(int(cred.Uid)) + \":\" + strconv.Itoa(int(cred.Gid)) + \":\" + strconv.Itoa(int(cred.Pid))\n\n\treturn uidAddr\n\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t//\n\t\tif pe, ok := err.(*os.PathError); ok {\n\t\t\tswitch pe.Err {\n\t\t\tcase syscall.ENODEV:\n\t\t\t\terr = io.EOF\n\n\t\t\tcase syscall.EINTR:\n\t\t\t\terr = nil\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\t\tif err != nil {\n\t\t\tc.putInMessage(m)\n\t\t\tm = nil\n\t\t\tret... |
{
"audio": "",
"image": "",
"text": "func (c UIDConnection) SetDeadline(t time.Time) error {\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\treturn c.nc.SetDeadline(t)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\treturn nil, err\n\t\t}\n\t\tc.SetDeadline(time.Now().Add(time.Duration(secs) * time.Second))\n\t\treturn c, nil\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (c UIDConnection) SetReadDeadline(t time.Time) error {\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\treturn c.nc.SetReadDeadline(t)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " stop it.\n\tt.timer = time.AfterFunc(time.Hour, func() {\n\t\tw.Assert()\n\t})\n\tt.timer.Stop()\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (c UIDConnection) SetWriteDeadline(t time.Time) error {\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\treturn c.nc.SetWriteDeadline(t)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " stop it.\n\tt.timer = time.AfterFunc(time.Hour, func() {\n\t\tw.Assert()\n\t})\n\tt.timer.Stop()\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func newPortAction(tcpport string, policy *policy.FlowPolicy) (*portAction, error) {\n\n\tp := &portAction{}\n\tif strings.Contains(tcpport, \":\") {\n\t\tparts := strings.Split(tcpport, \":\")\n\t\tif len(parts) != 2 {\n\t\t\treturn nil, fmt.Errorf(\"invalid port: %s\", tcppo... | {
"audio": "",
"image": "",
"text": "\t\t\treturn nil, err\n\t\t}\n\t\tp.max = uint16(port)\n\n\t} else {\n\t\tport, err := strconv.Atoi(tcpport)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tp.min = uint16(port)\n\t\tp.max = p.min\n\t}\n\n\tif p.min > p.max {\n\t\treturn nil, errors.New(\"min port is... | {
"audio": "",
"image": "",
"text": " nil\n\t}\n\n\t// Check for explicitly specified port.\n\thost, portString, err := utils.SplitHostPort(servername)\n\tif err != nil {\n\t\treturn \"\", defaultPort, trace.Wrap(err)\n\t}\n\n\tport, err := strconv.Atoi(portString)\n\tif err != nil {\n\t\treturn \"\", defaultPort... |
{
"audio": "",
"image": "",
"text": "func DefaultHostMetadataExtractor(event *common.EventInfo) (*policy.PURuntime, error) {\n\n\truntimeTags := policy.NewTagStore()\n\n\tfor _, tag := range event.Tags {\n\t\tparts := strings.SplitN(tag, \"=\", 2)\n\t\tif len(parts) != 2 {\n\t\t\treturn nil, fmt.Errorf(\"invalid ... | {
"audio": "",
"image": "",
"text": " event.PUID,\n\t\tCgroupMark: strconv.FormatUint(cgnetcls.MarkVal(), 10),\n\t\tServices: event.Services,\n\t}\n\n\truntimeIps := policy.ExtendedMap{\"bridge\": \"0.0.0.0/0\"}\n\n\treturn policy.NewPURuntime(event.Name, int(event.PID), \"\", runtimeTags, runtimeIps, event.PUT... | {
"audio": "",
"image": "",
"text": " := strings.SplitN(string(decoded), \":\", 2)\n\tif len(arr) != 2 {\n\t\treturn \"\", \"\", errors.Errorf(\"Invalid auth configuration file\")\n\t}\n\tpassword := strings.Trim(arr[1], \"\\x00\")\n\treturn arr[0], password, nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func ProcessInfo(pid int32) []string {\n\tuserdata := []string{}\n\n\tp, err := process.NewProcess(pid)\n\tif err != nil {\n\t\treturn userdata\n\t}\n\n\tuids, err := p.Uids()\n\tif err != nil {\n\t\treturn userdata\n\t}\n\n\tgroups, err := p.Gids()\n\tif err != nil {\n\t\tret... | {
"audio": "",
"image": "",
"text": " nil {\n\t\treturn userdata\n\t}\n\n\tgids, err := userid.GroupIds()\n\tif err != nil {\n\t\treturn userdata\n\t}\n\n\tfor i := 0; i < len(gids); i++ {\n\t\tuserdata = append(userdata, \"gids:\"+gids[i])\n\t\tgroup, err := user.LookupGroupId(gids[i])\n\t\tif err != nil {\n\t\t... | {
"audio": "",
"image": "",
"text": " err := p.Uids()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Unknown user ID\")\n\t}\n\n\tmatch := false\n\tfor _, uid := range uids {\n\t\tif strconv.Itoa(int(uid)) == parts[0] {\n\t\t\tmatch = true\n\t\t}\n\t}\n\n\tif !match {\n\t\treturn fmt.Errorf(\"Invalid user - no acces... |
{
"audio": "",
"image": "",
"text": "func libs(binpath string) []string {\n\tf, err := elf.Open(binpath)\n\tif err != nil {\n\t\treturn",
"video": ""
} | {
"audio": "",
"image": "",
"text": " []string{}\n\t}\n\tlibraries, _ := f.ImportedLibraries()\n\treturn libraries\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// open file at output path and truncate\n\tf, err := os.OpenFile(outputPath, os.O_RDWR, 0644)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer f.Close()\n\tf.Truncate(0)\n\n\t// render template to output path\n\terr = t.Execute(f, data)\n\t... |
{
"audio": "",
"image": "",
"text": "func IsHostPU(runtime policy.RuntimeReader, mode constants.ModeType) bool {\n\n\tif runtime ==",
"video": ""
} | {
"audio": "",
"image": "",
"text": " nil {\n\t\treturn false\n\t}\n\n\tif mode != constants.LocalServer {\n\t\treturn false\n\t}\n\n\treturn runtime.PUType() == common.HostPU\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " new(runtime.MemStats)\n\truntime.ReadMemStats(s)\n\treturn s\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func NewAppProxy(tp tokenaccessor.TokenAccessor, c collector.EventCollector, puFromID cache.DataStore, certificate *tls.Certificate, s secrets.Secrets) (*AppProxy, error) {\n\n\tsystemPool, err := x509.SystemCertPool()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif ok :=... | {
"audio": "",
"image": "",
"text": "\n\t\treturn nil, fmt.Errorf(\"error while adding provided CA\")\n\t}\n\n\treturn &AppProxy{\n\t\tcollector: c,\n\t\ttokenaccessor: tp,\n\t\tsecrets: s,\n\t\tpuFromID: puFromID,\n\t\tcert: certificate,\n\t\tclients: cache.NewCache(\"clients\"),\n\... | {
"audio": "",
"image": "",
"text": " {\n\treturn s.coreClientSet.Secrets(s.namespace)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (p *AppProxy) Unenforce(ctx context.Context, puID string) error {\n\tp.Lock()\n\tdefer p.Unlock()\n\n\t// Remove pu from registry\n\tif err := p.registry.Unregister(puID); err != nil {\n\t\treturn err\n\t}\n\n\t// Find the correct client.\n\tc, err := p.clients.Get(puID)\... | {
"audio": "",
"image": "",
"text": " int(t)), zap.Error(err))\n\t\t}\n\t\tif err := server.ShutDown(); err != nil {\n\t\t\tzap.L().Debug(\"Unable to shutdown client server\", zap.Error(err))\n\t\t}\n\t}\n\n\t// Terminate the connection multiplexer.\n\tclient.protomux.Close()\n\n\t// Remove the client from the ca... | {
"audio": "",
"image": "",
"text": " entire graph\n\t\terr := mdag.FetchGraph(ctx, c, p.dserv)\n\t\tp.lock.Lock()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif p.recursePin.Has(c) {\n\t\t\treturn nil\n\t\t}\n\n\t\tif p.directPin.Has(c) {\n\t\t\tp.directPin.Remove(c)\n\t\t}\n\n\t\tp.recursePin.Add(c)\n\... |
{
"audio": "",
"image": "",
"text": "func (p *AppProxy) UpdateSecrets(secret secrets.Secrets) error {\n\tp.Lock()",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tdefer p.Unlock()\n\tp.secrets = secret\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " := range serviceaccount.Secrets {\n\t\tnames.Insert(secret.Name)\n\t}\n\treturn names\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (p *AppProxy) registerAndRun(ctx context.Context, puID string, ltype common.ListenerType, mux *protomux.MultiplexedListener, caPool *x509.CertPool, appproxy bool) (ServerInterface, error) {\n\tvar listener net.Listener\n\tvar err error\n\n\t// Create a new sub-ordinate li... | {
"audio": "",
"image": "",
"text": "\n\t// Start the corresponding proxy\n\tswitch ltype {\n\tcase common.HTTPApplication, common.HTTPSApplication, common.HTTPNetwork, common.HTTPSNetwork:\n\t\tc := httpproxy.NewHTTPProxy(p.collector, puID, caPool, appproxy, proxyMarkInt, p.secrets, p.registry)\n\t\treturn c, c.... | {
"audio": "",
"image": "",
"text": " mux creates problem in unit tests\n\tc.mux.Handle(\"/\", crossdock.Handler(c.Behaviors, true))\n\n\tlistener, err := net.Listen(\"tcp\", c.ClientHostPort)\n\tif err != nil {\n\t\treturn err\n\t}\n\tc.listener = listener\n\tc.ClientHostPort = listener.Addr().String() // overri... |
{
"audio": "",
"image": "",
"text": "func (p *AppProxy) processCertificateUpdates(puInfo *policy.PUInfo, client *clientData, caPool *x509.CertPool) (bool, error) {\n\n\t// If there are certificates provided, we will need to update them for the\n\t// services. If the certificates are nil, we ignore them.\n\tcertPE... | {
"audio": "",
"image": "",
"text": "\tzap.L().Warn(\"Failed to add Services CA\")\n\t\t}\n\t}\n\n\t// Create the TLS certificate\n\ttlsCert, err := tls.X509KeyPair([]byte(certPEM), []byte(keyPEM))\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"Invalid certificates: %s\", err)\n\t}\n\n\tfor _, server := range... | {
"audio": "",
"image": "",
"text": " since we don't need it and we don't want to cache an\n\t// image being there if it has possibly been manually deleted (outside of\n\t// Nomad).\n\tif _, ok := d.pullFutures[image]; ok {\n\t\tdelete(d.pullFutures, image)\n\t}\n\n\t// If we are cleaning up, we increment the ref... |
{
"audio": "",
"image": "",
"text": "func (d *Datapath) startNetworkInterceptor(ctx context.Context) {\n\tvar err error\n\n\tnfq := make([]nfqueue.Verdict, d.filterQueue.GetNumNetworkQueues())\n\n\tfor i := uint16(0); i < d.filterQueue.GetNumNetworkQueues(); i++ {\n\t\t// Initialize all the queues\n\t\tnfq[i], er... | {
"audio": "",
"image": "",
"text": " d.filterQueue.GetNetworkQueueStart()+i, d.filterQueue.GetNetworkQueueSize(), nfqueue.NfDefaultPacketSize, networkCallback, errorCallback, d)\n\t\t\t\t<-time.After(3 * time.Second)\n\t\t\t}\n\t\t\tif err != nil {\n\t\t\t\tzap.L().Fatal(\"Unable to initialize netfilter queue\",... | {
"audio": "",
"image": "",
"text": "\t}\n\td.cols--\n\td.headers = append(d.headers[:colIndex], d.headers[colIndex+1:]...)\n\t// remove the column\n\tfor i := range d.data {\n\t\td.data[i] = append(d.data[i][:colIndex], d.data[i][colIndex+1:]...)\n\t}\n\treturn nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (d *Datapath) startApplicationInterceptor(ctx context.Context) {\n\tvar err error\n\n\tnfq := make([]nfqueue.Verdict, d.filterQueue.GetNumApplicationQueues())\n\n\tfor i := uint16(0); i < d.filterQueue.GetNumApplicationQueues(); i++ {\n\t\tnfq[i], err = nfqueue.CreateAndS... | {
"audio": "",
"image": "",
"text": " d.filterQueue.GetApplicationQueueStart()+i, d.filterQueue.GetApplicationQueueSize(), nfqueue.NfDefaultPacketSize, appCallBack, errorCallback, d)\n\t\t\t\t<-time.After(3 * time.Second)\n\t\t\t}\n\t\t\tif err != nil {\n\t\t\t\tzap.L().Fatal(\"Unable to initialize netfilter queu... | {
"audio": "",
"image": "",
"text": " payload {\n\t\tif v < 48 || v >= 120 {\n\t\t\tp.SetErr(context, \"data byte\")\n\t\t\treturn nil\n\t\t}\n\n\t\td := v - 48\n\t\tif d > 40 {\n\t\t\td -= 8\n\t\t}\n\n\t\tfor i := 5; i >= 0 && resultIndex < len(result); i-- {\n\t\t\tresult[resultIndex] = (d >> uint(i)) & 1\n\t\t... |
{
"audio": "",
"image": "",
"text": "func NewPURuntime(name string, pid int, nsPath string, tags *TagStore, ips ExtendedMap, puType common.PUType, options *OptionsType) *PURuntime {\n\n\tif tags == nil {\n\t\ttags = NewTagStore()\n\t}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\n\tif ips == nil {\n\t\tips = ExtendedMap{}\n\t}\n\n\tif options == nil {\n\t\toptions = &OptionsType{}\n\t}\n\n\treturn &PURuntime{\n\t\tpuType: puType,\n\t\ttags: tags,\n\t\tips: ips,\n\t\toptions: options,\n\t\tpid: pid,\n\t\tnsPath: nsPath,\n\t\tname: na... | {
"audio": "",
"image": "",
"text": " error) {\n\tvar tags []string\n\tif tag != \"\" {\n\t\ttags = []string{tag}\n\t}\n\treturn h.service(service, tags, passingOnly, q, true)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (r *PURuntime) MarshalJSON() ([]byte, error) {\n\treturn json.Marshal(&PURuntimeJSON{\n\t\tPUType: r.puType,\n\t",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tPid: r.pid,\n\t\tNSPath: r.nsPath,\n\t\tName: r.name,\n\t\tIPAddresses: r.ips,\n\t\tTags: r.tags,\n\t\tOptions: r.options,\n\t})\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " nil {\n\t\treturn r\n\t}\n\tr.body, err = json.Marshal(v)\n\tif err != nil {\n\t\tr.err = err\n\t\treturn r\n\t}\n\treturn r\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (r *PURuntime) UnmarshalJSON(param []byte) error {\n\ta := &PURuntimeJSON{}\n\tif err := json.Unmarshal(param, &a); err != nil {\n\t\treturn err\n\t}\n\tr.pid = a.Pid\n\tr.nsPath = a.NSPath\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tr.name = a.Name\n\tr.ips = a.IPAddresses\n\tr.tags = a.Tags\n\tr.options = a.Options\n\tr.puType = a.PUType\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " v != nil {\n\t\tjson.Unmarshal(*v, &a.Key)\n\t\tjson.Unmarshal(*v, &a.KeyNumber)\n\t}\n\tif v, ok := aggs[\"doc_count\"]; ok && v != nil {\n\t\tjson.Unmarshal(*v, &a.DocCount)\n\t}\n\ta.Aggregations = aggs\n\treturn nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (r *PURuntime) Pid() int {\n\tr.Lock()\n\tdefer",
"video": ""
} | {
"audio": "",
"image": "",
"text": " r.Unlock()\n\n\treturn r.pid\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " bool) (Client, error)) {\n\tr.clientMu.Lock()\n\tdefer r.clientMu.Unlock()\n\n\tr.clientFuncs[stream] = f\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (r *PURuntime) SetPid(pid int) {\n\tr.Lock()\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tdefer r.Unlock()\n\n\tr.pid = pid\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " bool) (Client, error)) {\n\tr.clientMu.Lock()\n\tdefer r.clientMu.Unlock()\n\n\tr.clientFuncs[stream] = f\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (r *PURuntime) NSPath() string {\n\tr.Lock()\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tdefer r.Unlock()\n\n\treturn r.nsPath\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " bool) (Client, error)) {\n\tr.clientMu.Lock()\n\tdefer r.clientMu.Unlock()\n\n\tr.clientFuncs[stream] = f\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (r *PURuntime) SetNSPath(nsPath string) {\n\tr.Lock()\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tdefer r.Unlock()\n\n\tr.nsPath = nsPath\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " bool) (Client, error)) {\n\tr.clientMu.Lock()\n\tdefer r.clientMu.Unlock()\n\n\tr.clientFuncs[stream] = f\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (r *PURuntime) SetOptions(options OptionsType) {\n\tr.Lock()\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tdefer r.Unlock()\n\n\tr.options = &options\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " bool) (Client, error)) {\n\tr.clientMu.Lock()\n\tdefer r.clientMu.Unlock()\n\n\tr.clientFuncs[stream] = f\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (r *PURuntime) Name() string {\n\tr.Lock()\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tdefer r.Unlock()\n\n\treturn r.name\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " bool) (Client, error)) {\n\tr.clientMu.Lock()\n\tdefer r.clientMu.Unlock()\n\n\tr.clientFuncs[stream] = f\n}",
"video": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.