anchor dict | positive dict | negative dict |
|---|---|---|
{
"audio": "",
"image": "",
"text": "func (r *RPCWrapper) RemoteCall(contextID string, methodName string, req *Request, resp *Response) error {\n\n\trpcClient, err := r.GetRPCClient(contextID)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tdigest := hmac.New(sha256.New, []byte(rpcClient.Secret))\n\thash, err := pay... | {
"audio": "",
"image": "",
"text": " err\n\t}\n\n\tif _, err := digest.Write(hash); err != nil {\n\t\treturn err\n\t}\n\n\treq.HashAuth = digest.Sum(nil)\n\n\treturn rpcClient.Client.Call(methodName, req, resp)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " req.onlyMultipartForm() {\n\t\tbody, err := marshalMultipartForm(req.multipartForm, req.multipartFormBoundary)\n\t\tif err != nil {\n\t\t\treturn []byte(err.Error())\n\t\t}\n\t\treturn body\n\t}\n\treturn req.bodyBytes()\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (r *RPCWrapper) CheckValidity(req *Request, secret string) bool {\n\n\tdigest := hmac.New(sha256.New, []byte(secret))\n\n\thash, err := payloadHash(req.Payload)\n\tif err != nil {\n\t\treturn false\n\t}\n\n\tif",
"video": ""
} | {
"audio": "",
"image": "",
"text": " _, err := digest.Write(hash); err != nil {\n\t\treturn false\n\t}\n\n\treturn hmac.Equal(req.HashAuth, digest.Sum(nil))\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\tm := hmac.New(sha256.New, key)\n\tm.Write(msg)\n\treturn m.Sum(nil)[:size]\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (r *RPCWrapper) StartServer(ctx context.Context, protocol string, path string, handler interface{}) error {\n\n\tif len(path) == 0 {\n\t\tzap.L().Fatal(\"Sock param not passed in environment\")\n\t}\n\n\t// Register RPC Type\n\tRegisterTypes()\n\n\t// Register handlers\n\... | {
"audio": "",
"image": "",
"text": "\n\n\t\tzap.L().Debug(\"Socket path already exists: removing\", zap.String(\"path\", path))\n\n\t\tif rerr := os.Remove(path); rerr != nil {\n\t\t\treturn fmt.Errorf(\"unable to delete existing socket path %s: %s\", path, rerr)\n\t\t}\n\t}\n\n\t// Get listener\n\tlisten, err :... | {
"audio": "",
"image": "",
"text": "\t\tfilepath.Walk(rootPath, func(path string, info os.FileInfo, err error) error {\n\t\t\t\tmatched, err := filepath.Match(\"*.json\", info.Name())\n\t\t\t\tif err != nil {\n\t\t\t\t\twarn(err)\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\tif matched {\n\t\t\t\t\tc <- path\n\t\t\t... |
{
"audio": "",
"image": "",
"text": "func (r *RPCWrapper) DestroyRPCClient(contextID string) {\n\tr.Lock()\n\tdefer r.Unlock()\n\n\trpcHdl, err := r.rpcClientMap.Get(contextID)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tif err = rpcHdl.(*RPCHdl).Client.Close(); err != nil {\n\t\tzap.L().Warn(\"Failed to close chann... | {
"audio": "",
"image": "",
"text": "\t\t\tzap.Error(err),\n\t\t)\n\t}\n\n\tif err = os.Remove(rpcHdl.(*RPCHdl).Channel); err != nil {\n\t\tzap.L().Debug(\"Failed to remove channel - already closed\",\n\t\t\tzap.String(\"contextID\", contextID),\n\t\t\tzap.Error(err),\n\t\t)\n\t}\n\n\tif err = r.rpcClientMap.Remo... | {
"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 (r *RPCWrapper) ContextList() []string {\n\tkeylist := r.rpcClientMap.KeyList()\n\tcontextArray := []string{}\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tfor _, key := range keylist {\n\t\tif kstring, ok := key.(string); ok {\n\t\t\tcontextArray = append(contextArray, kstring)\n\t\t}\n\t}\n\treturn contextArray\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\tname, notary.MinThreshold, len(delegationKeys))\n\n\t// Defaulting to threshold of 1, since we don't allow for larger thresholds at the moment.\n\ttdJSON, err := json.Marshal(&changelist.TUFDelegation{\n\t\tNewThreshold: notary.MinThreshold,\n\t\tAddKeys: data.KeyList... |
{
"audio": "",
"image": "",
"text": "func (r *RPCWrapper) ProcessMessage(req *Request, secret string) bool {",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\n\treturn r.CheckValidity(req, secret)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t}\n\treturn func(req *http.Request, ctx *ProxyCtx) bool {\n\t\t_, ok := hostSet[req.URL.Host]\n\t\treturn ok\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func payloadHash(payload interface{}) ([]byte, error) {\n\thash, err := hashstructure.Hash(payload, nil)\n\tif err != nil {\n\t\treturn []byte{}, err\n\t}\n\n\tbuf :=",
"video": ""
} | {
"audio": "",
"image": "",
"text": " make([]byte, 8)\n\tbinary.BigEndian.PutUint64(buf, hash)\n\treturn buf, nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " dispatch table based on the registered commands.\n\tfor msg, fn := range commands {\n\t\tthisFn := fn\n\t\tfsm.apply[msg] = func(buf []byte, index uint64) interface{} {\n\t\t\treturn thisFn(fsm, buf, index)\n\t\t}\n\t}\n\n\treturn fsm, nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func RegisterTypes() {\n\n\tgob.Register(&secrets.CompactPKIPublicSecrets{})\n\tgob.Register(&pkitokens.PKIJWTVerifier{})\n\tgob.Register(&oidc.TokenVerifier{})\n\tgob.RegisterName(\"go.aporeto.io/trireme-lib/controller/internal/enforcer/utils/rpcwrapper.Init_Request_Payload\"... | {
"audio": "",
"image": "",
"text": "\tgob.RegisterName(\"go.aporeto.io/trireme-lib/controller/internal/enforcer/utils/rpcwrapper.SetTargetNetworks_Payload\", *(&SetTargetNetworksPayload{}))\n\tgob.RegisterName(\"go.aporeto.io/trireme-lib/controller/internal/enforcer/utils/rpcwrapper.EnableIPTablesPacketTracing_P... | {
"audio": "",
"image": "",
"text": " gob.NewEncoder(buf)\n\terr := enc.Encode(obj)\n\tif err != nil {\n\t\treturn []byte(\"\"), err\n\t}\n\treturn buf.Bytes(), nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func New() Registerer {\n\n\treturn ®isterer{\n\t\thandlers:",
"video": ""
} | {
"audio": "",
"image": "",
"text": " map[common.PUType]map[common.Event]common.EventHandler{},\n\t}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t\tlevel: level,\n\t\tpropagate: true,\n\t\thandlers: NewListSet(),\n\t\tmanager: nil,\n\t}\n\treturn object\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (r *registerer) RegisterProcessor(puType common.PUType, ep processor.Processor) error {\n\n\tif _, ok := r.handlers[puType]; ok {\n\t\treturn fmt.Errorf(\"Processor already registered for this PU type %d \", puType)\n\t}\n\n\tr.handlers[puType] = map[common.Event]common.E... | {
"audio": "",
"image": "",
"text": "\n\tr.addHandler(puType, common.EventCreate, ep.Create)\n\tr.addHandler(puType, common.EventDestroy, ep.Destroy)\n\tr.addHandler(puType, common.EventPause, ep.Pause)\n\tr.addHandler(puType, common.EventResync, ep.Resync)\n\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\t// TODO v6 needs to be handled.\n\t\tif len(ep.Gateway()) > 0 {\n\t\t\treturn false\n\t\t}\n\t\tfor _, r := range ep.StaticRoutes() {\n\t\t\tif r.Destination != nil && r.Destination.String() == \"0.0.0.0/0\" {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\tneedGW = true\n\t}\n... |
{
"audio": "",
"image": "",
"text": "func (d *Datapath) processApplicationTCPPacket(tcpPacket *packet.Packet, context *pucontext.PUContext, conn *connection.TCPConnection) (interface{}, error) {\n\n\tif conn == nil {\n\t\treturn nil, nil\n\t}\n\n\t// State machine based on the flags\n\tswitch tcpPacket.GetTCPFlag... | {
"audio": "",
"image": "",
"text": "\n\tcase packet.TCPAckMask:\n\t\treturn nil, d.processApplicationAckPacket(tcpPacket, context, conn)\n\n\tcase packet.TCPSynAckMask:\n\t\treturn nil, d.processApplicationSynAckPacket(tcpPacket, context, conn)\n\tdefault:\n\t\treturn nil, nil\n\t}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t// If this ack packet is from client, Did we see an Application Syn packet before?\n\tconn, err = d.appOrigConnectionTracker.GetReset(hash, 0)\n\tif err == nil {\n\t\tif uerr := updateTimer(d.appOrigConnectionTracker, hash, conn.(*connection.TCPConnection)); uerr != nil {\n\... |
{
"audio": "",
"image": "",
"text": "func (d *Datapath) processApplicationSynPacket(tcpPacket *packet.Packet, context *pucontext.PUContext, conn *connection.TCPConnection) (interface{}, error) {\n\n\t// If the packet is not in target networks then look into the external services application cache to\n\t// make a ... | {
"audio": "",
"image": "",
"text": " nil, fmt.Errorf(\"No acls found for external services. Dropping application syn packet\")\n\t}\n\n\tif policy, err := context.RetrieveCachedExternalFlowPolicy(tcpPacket.DestinationAddress().String() + \":\" + strconv.Itoa(int(tcpPacket.DestPort()))); err == nil {\n\t\td.appOr... | {
"audio": "",
"image": "",
"text": "\t// If this ack packet is from client, Did we see an Application Syn packet before?\n\tconn, err = d.appOrigConnectionTracker.GetReset(hash, 0)\n\tif err == nil {\n\t\tif uerr := updateTimer(d.appOrigConnectionTracker, hash, conn.(*connection.TCPConnection)); uerr != nil {\n\... |
{
"audio": "",
"image": "",
"text": "func (d *Datapath) processApplicationSynAckPacket(tcpPacket *packet.Packet, context *pucontext.PUContext, conn *connection.TCPConnection) error {\n\n\t// if the traffic belongs to the same pu, let it go\n\tif conn.GetState() == connection.TCPData && conn.IsLoopbackConnection()... | {
"audio": "",
"image": "",
"text": "\tif err1 != nil || err2 != nil {\n\t\t\tzap.L().Debug(\"Failed to remove cache entries\")\n\t\t}\n\n\t\treturn nil\n\t}\n\n\t// We now process packets that need authorization options\n\n\t// Create TCP Option\n\ttcpOptions := d.createTCPAuthenticationOption([]byte{})\n\n\tcla... | {
"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) processNetworkTCPPacket(tcpPacket *packet.Packet, context *pucontext.PUContext, conn *connection.TCPConnection) (action interface{}, claims *tokens.ConnectionClaims, err error) {\n\n\tif conn == nil {\n\t\treturn nil, nil, nil\n\t}\n\n\t// Update connection ... | {
"audio": "",
"image": "",
"text": " tcpPacket)\n\n\tcase packet.TCPAckMask:\n\t\treturn d.processNetworkAckPacket(context, conn, tcpPacket)\n\n\tcase packet.TCPSynAckMask:\n\t\treturn d.processNetworkSynAckPacket(context, conn, tcpPacket)\n\n\tdefault: // Ignore any other packet\n\t\treturn nil, nil, nil\n\t}\n... | {
"audio": "",
"image": "",
"text": "\t// If this ack packet is from client, Did we see an Application Syn packet before?\n\tconn, err = d.appOrigConnectionTracker.GetReset(hash, 0)\n\tif err == nil {\n\t\tif uerr := updateTimer(d.appOrigConnectionTracker, hash, conn.(*connection.TCPConnection)); uerr != nil {\n\... |
{
"audio": "",
"image": "",
"text": "func (d *Datapath) createTCPAuthenticationOption(token []byte) []byte {\n\n\ttokenLen := uint8(len(token))\n\toptions := []byte{packet.TCPAuthenticationOption, enforcerconstants.TCPAuthenticationOptionBaseLen +",
"video": ""
} | {
"audio": "",
"image": "",
"text": " tokenLen, 0, 0}\n\n\tif tokenLen != 0 {\n\t\toptions = append(options, token...)\n\t}\n\n\treturn options\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " len(src))\n\ts.Init(file, []byte(src), nil, 1)\n\tfor {\n\t\tfilePos, tok, _ := s.Scan()\n\t\ttc <- &sep{int(filePos) - file.Base(), tok}\n\t\tif tok == token.EOF {\n\t\t\tclose(tc)\n\t\t\tbreak\n\t\t}\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (d *Datapath) appSynRetrieveState(p *packet.Packet) (*connection.TCPConnection, error) {\n\n\tcontext, err := d.contextFromIP(true, p.Mark, p.SourcePort(), packet.IPProtocolTCP)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif conn, err",
"video": ""
} | {
"audio": "",
"image": "",
"text": " := d.appOrigConnectionTracker.GetReset(p.L4FlowHash(), 0); err == nil {\n\t\treturn conn.(*connection.TCPConnection), nil\n\t}\n\treturn connection.NewTCPConnection(context, p), nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t// If this ack packet is from client, Did we see an Application Syn packet before?\n\tconn, err = d.appOrigConnectionTracker.GetReset(hash, 0)\n\tif err == nil {\n\t\tif uerr := updateTimer(d.appOrigConnectionTracker, hash, conn.(*connection.TCPConnection)); uerr != nil {\n\... |
{
"audio": "",
"image": "",
"text": "func (d *Datapath) appRetrieveState(p *packet.Packet) (*connection.TCPConnection, error) {\n\thash := p.L4FlowHash()\n\n\t// If this ack packet is from Server, Did we see a network Syn for this server PU?\n\tconn, err := d.appReplyConnectionTracker.GetReset(hash, 0)\n\tif err ... | {
"audio": "",
"image": "",
"text": "\t// If this ack packet is from client, Did we see an Application Syn packet before?\n\tconn, err = d.appOrigConnectionTracker.GetReset(hash, 0)\n\tif err == nil {\n\t\tif uerr := updateTimer(d.appOrigConnectionTracker, hash, conn.(*connection.TCPConnection)); uerr != nil {\n\... | {
"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) netSynRetrieveState(p *packet.Packet) (*connection.TCPConnection, error) {\n\n\tcontext, err := d.contextFromIP(false, p.Mark, p.DestPort(), packet.IPProtocolTCP)\n\tif err == nil {\n\t\tif conn, err := d.netOrigConnectionTracker.GetReset(p.L4FlowHash(), 0);... | {
"audio": "",
"image": "",
"text": " p.CheckTCPAuthenticationOption(enforcerconstants.TCPAuthenticationOptionBaseLen); err != nil {\n\t\t\tzap.L().Error(\"Syn received with tcp option not set\", zap.Error(err))\n\t\t\treturn nil, errNonPUTraffic\n\t\t}\n\n\t\tif err = p.TCPDataDetach(enforcerconstants.TCPAuthent... | {
"audio": "",
"image": "",
"text": "\t// If this ack packet is from client, Did we see an Application Syn packet before?\n\tconn, err = d.appOrigConnectionTracker.GetReset(hash, 0)\n\tif err == nil {\n\t\tif uerr := updateTimer(d.appOrigConnectionTracker, hash, conn.(*connection.TCPConnection)); uerr != nil {\n\... |
{
"audio": "",
"image": "",
"text": "func (d *Datapath) netSynAckRetrieveState(p *packet.Packet) (*connection.TCPConnection, error) {\n\n\tconn, err := d.sourcePortConnectionCache.GetReset(p.SourcePortHash(packet.PacketTypeNetwork), 0)\n\tif err",
"video": ""
} | {
"audio": "",
"image": "",
"text": " != nil {\n\t\treturn nil, errNonPUTraffic\n\t}\n\n\treturn conn.(*connection.TCPConnection), nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t// If this ack packet is from client, Did we see an Application Syn packet before?\n\tconn, err = d.appOrigConnectionTracker.GetReset(hash, 0)\n\tif err == nil {\n\t\tif uerr := updateTimer(d.appOrigConnectionTracker, hash, conn.(*connection.TCPConnection)); uerr != nil {\n\... |
{
"audio": "",
"image": "",
"text": "func (d *Datapath) netRetrieveState(p *packet.Packet) (*connection.TCPConnection, error) {\n\thash := p.L4FlowHash()\n\n\t// Did we see a network syn/ack packet? (PU is a client)\n\tconn, err := d.netReplyConnectionTracker.GetReset(hash, 0)\n\tif err == nil {\n\t\tif err = upd... | {
"audio": "",
"image": "",
"text": " state.\n\tif p.GetTCPFlags()&packet.TCPSynAckMask == packet.TCPAckMask {\n\t\t// Let's try if its an existing connection\n\t\tcontext, cerr := d.contextFromIP(false, p.Mark, p.DestPort(), packet.IPProtocolTCP)\n\t\tif cerr != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tconn = co... | {
"audio": "",
"image": "",
"text": "\t// If this ack packet is from client, Did we see an Application Syn packet before?\n\tconn, err = d.appOrigConnectionTracker.GetReset(hash, 0)\n\tif err == nil {\n\t\tif uerr := updateTimer(d.appOrigConnectionTracker, hash, conn.(*connection.TCPConnection)); uerr != nil {\n\... |
{
"audio": "",
"image": "",
"text": "func updateTimer(c cache.DataStore, hash string, conn *connection.TCPConnection) error {\n\tconn.RLock()",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tdefer conn.RUnlock()\n\n\tif conn.ServiceConnection && conn.TimeOut > 0 {\n\t\treturn c.SetTimeOut(hash, conn.TimeOut)\n\t}\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\treturn c.withRetry(ctx, func(conn *zk.Conn) error {\n\t\terr := conn.AddAuth(scheme, auth)\n\t\treturn err\n\t})\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (d *Datapath) releaseFlow(context *pucontext.PUContext, report *policy.FlowPolicy, action *policy.FlowPolicy, tcpPacket *packet.Packet) {\n\n\tif err := d.appOrigConnectionTracker.Remove(tcpPacket.L4ReverseFlowHash()); err != nil {\n\t\tzap.L().Debug(\"Failed to clean cac... | {
"audio": "",
"image": "",
"text": " nil {\n\t\tzap.L().Debug(\"Failed to clean cache sourcePortConnectionCache\", zap.Error(err))\n\t}\n\n\tif err := d.conntrack.UpdateNetworkFlowMark(\n\t\ttcpPacket.SourceAddress(),\n\t\ttcpPacket.DestinationAddress(),\n\t\ttcpPacket.IPProto(),\n\t\ttcpPacket.SourcePort(),\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 *Datapath) releaseUnmonitoredFlow(tcpPacket *packet.Packet) {\n\n\tzap.L().Debug(\"Releasing flow\", zap.String(\"flow\", tcpPacket.L4FlowHash()))\n\tif err := d.conntrack.UpdateNetworkFlowMark(\n\t\ttcpPacket.SourceAddress(),\n\t\ttcpPacket.DestinationAddress(),\n\t\t... | {
"audio": "",
"image": "",
"text": "\n\t\ttcpPacket.DestPort(),\n\t\tconstants.DefaultConnMark,\n\t); err != nil && !netlink.IsNotExist(errors.Cause(err)) {\n\t\tzap.L().Error(\"Failed to update conntrack table\", zap.Error(err))\n\t}\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 NewMockSupervisor(ctrl *gomock.Controller) *MockSupervisor {\n\tmock := &MockSupervisor{ctrl: ctrl}\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tmock.recorder = &MockSupervisorMockRecorder{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 (m *MockSupervisor) Supervise(contextID string, puInfo *policy.PUInfo)",
"video": ""
} | {
"audio": "",
"image": "",
"text": " error {\n\tret := m.ctrl.Call(m, \"Supervise\", contextID, puInfo)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " string, _ string) (string, error) {\n\treturn \"\", nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (mr *MockSupervisorMockRecorder) Supervise(contextID, puInfo interface{}) *gomock.Call {\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Supervise\",",
"video": ""
} | {
"audio": "",
"image": "",
"text": " reflect.TypeOf((*MockSupervisor)(nil).Supervise), contextID, puInfo)\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 *MockSupervisor) Unsupervise(contextID string) error {\n\tret := m.ctrl.Call(m,",
"video": ""
} | {
"audio": "",
"image": "",
"text": " \"Unsupervise\", contextID)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " error {\n\tret := m.ctrl.Call(m, \"RunScript\", scriptName, options)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (m *MockSupervisor) SetTargetNetworks(cfg *runtime.Configuration) error {\n\tret",
"video": ""
} | {
"audio": "",
"image": "",
"text": " := m.ctrl.Call(m, \"SetTargetNetworks\", 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 NewMockImplementor(ctrl *gomock.Controller) *MockImplementor {\n\tmock := &MockImplementor{ctrl: ctrl}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tmock.recorder = &MockImplementorMockRecorder{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 (m *MockImplementor) ConfigureRules(version int, contextID string, containerInfo *policy.PUInfo)",
"video": ""
} | {
"audio": "",
"image": "",
"text": " error {\n\tret := m.ctrl.Call(m, \"ConfigureRules\", version, contextID, containerInfo)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " string, _ string) (string, error) {\n\treturn \"\", nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (mr *MockImplementorMockRecorder) ConfigureRules(version, contextID, containerInfo interface{}) *gomock.Call {\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock,",
"video": ""
} | {
"audio": "",
"image": "",
"text": " \"ConfigureRules\", reflect.TypeOf((*MockImplementor)(nil).ConfigureRules), version, contextID, containerInfo)\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 *MockImplementor) DeleteRules(version int, context, tcpPorts, udpPorts, mark, uid, proxyPort string, puType common.PUType) error {\n\tret := m.ctrl.Call(m, \"DeleteRules\", version,",
"video": ""
} | {
"audio": "",
"image": "",
"text": " context, tcpPorts, udpPorts, mark, uid, proxyPort, puType)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " error {\n\tret := m.ctrl.Call(m, \"Detach\", arg0, arg1)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (mr *MockImplementorMockRecorder) DeleteRules(version, context, tcpPorts, udpPorts, mark, uid, proxyPort, puType interface{}) *gomock.Call {\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock,",
"video": ""
} | {
"audio": "",
"image": "",
"text": " \"DeleteRules\", reflect.TypeOf((*MockImplementor)(nil).DeleteRules), version, context, tcpPorts, udpPorts, mark, uid, proxyPort, puType)\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 *MockImplementor) ACLProvider() aclprovider.IptablesProvider {\n\tret := m.ctrl.Call(m, \"ACLProvider\")\n\tret0, _ :=",
"video": ""
} | {
"audio": "",
"image": "",
"text": " ret[0].(aclprovider.IptablesProvider)\n\treturn ret0\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"GetAckFrame\", arg0)\n\tret0, _ := ret[0].(*wire.AckFrame)\n\treturn ret0\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func NewEventServer(address string, registerer registerer.Registerer) (*EventServer, error) {\n\n\t// Cleanup the socket first.\n\tif _, err := os.Stat(address); err == nil {\n\t\tif err := os.Remove(address); err != nil {\n\t\t\treturn",
"video": ""
} | {
"audio": "",
"image": "",
"text": " nil, fmt.Errorf(\"Cannot create clean up socket: %s\", err)\n\t\t}\n\t}\n\n\treturn &EventServer{\n\t\tsocketPath: address,\n\t\tregisterer: registerer,\n\t}, nil\n}",
"video": ""
} | {
"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 (e *EventServer) ServeHTTP(w http.ResponseWriter,",
"video": ""
} | {
"audio": "",
"image": "",
"text": " r *http.Request) {\n\te.create(w, r)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " w http.ResponseWriter, r *http.Request) {\n\tc.Handler.ServeHTTP(w, r)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (e *EventServer) Run(ctx context.Context) error {\n\n\t// Create the handler\n\te.server = &http.Server{\n\t\tHandler: e,\n\t}\n\n\t// Start a custom listener\n\taddr, _ := net.ResolveUnixAddr(\"unix\", e.socketPath)\n\tnl, err := net.ListenUnix(\"unix\", addr)\n\tif err ... | {
"audio": "",
"image": "",
"text": " the socket accessible to all users: %s\", err)\n\t}\n\n\tlistener := &UIDListener{nl}\n\n\t// Start serving HTTP requests in the background\n\tgo e.server.Serve(listener) // nolint\n\n\t// Listen for context cancellation to close the socket.\n\tgo func() {\n\t\t<-ctx.Done()\n... | {
"audio": "",
"image": "",
"text": "\n\t\t\t// addr - comes from the closure\n\t\t\t// timeout - is ignored since we are connecting in a non-blocking configuration\n\t\t\tc, err := net.DialTimeout(unixProtocol, addr, 0)\n\t\t\tif err != nil {\n\t\t\t\tklog.Errorf(\"failed to create connection to unix socket: %s,... |
{
"audio": "",
"image": "",
"text": "func (e *EventServer) create(w http.ResponseWriter, r *http.Request) {\n\tevent := &common.EventInfo{}\n\tdefer r.Body.Close() // nolint\n\n\tif err := json.NewDecoder(r.Body).Decode(event); err != nil {\n\t\thttp.Error(w, \"Invalid request\", http.StatusBadRequest)\n\t\tretur... | {
"audio": "",
"image": "",
"text": " err := validateEvent(event); err != nil {\n\t\thttp.Error(w, fmt.Sprintf(\"Bad request: %s\", err), http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tif err := e.processEvent(r.Context(), event); err != nil {\n\t\tzap.L().Error(\"Error in processing event\", zap.Error(err), zap.Re... | {
"audio": "",
"image": "",
"text": "\tif r.Method == \"GET\" {\n\t\t\terr = r.ParseForm()\n\t\t\tif err != nil {\n\t\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tfor str, _ := range r.Form {\n\t\t\t\tdat = []byte(str)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\t// par... |
{
"audio": "",
"image": "",
"text": "func (e *EventServer) processEvent(ctx context.Context, eventInfo *common.EventInfo) (err error) {\n\n\tif e.registerer == nil {\n\t\treturn fmt.Errorf(\"No registered handlers\")\n\t}\n\n\tf, err :=",
"video": ""
} | {
"audio": "",
"image": "",
"text": " e.registerer.GetHandler(eventInfo.PUType, eventInfo.EventType)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Handler not found: %s\", err)\n\t}\n\n\treturn f(ctx, eventInfo)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " f, s.LineNumber)\n\tif e.Error() == \"\" {\n\t\treturn prefix\n\t}\n\treturn fmt.Sprint(prefix, \" \", e.Error())\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func validateUser(r *http.Request, event *common.EventInfo) error {\n\n\t// Find the calling user.\n\tparts := strings.Split(r.RemoteAddr, \":\")\n\tif len(parts) != 3 {\n\t\treturn fmt.Errorf(\"Invalid user context\")\n\t}\n\n\t// Accept all requests from root users\n\tif par... | {
"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": " event is embedded into a\n\t// chunk\n\tif h.Size >= ChunkSize {\n\t\treturn fmt.Errorf(\"Too big event\")\n\t}\n\t// An event cannot be smaller than its header since the event size include the\n\t// size of the header\n\tif h.Size < EventHeaderSize {\n\t\treturn fmt.Errorf(\... |
{
"audio": "",
"image": "",
"text": "func validateTypes(event *common.EventInfo) error {\n\n\tregexStrings := regexp.MustCompile(\"^[a-zA-Z0-9_:.$%/-]{0,256}$\")\n\tregexNS := regexp.MustCompile(\"^[a-zA-Z0-9/-]{0,128}$\")\n\tregexCgroup := regexp.MustCompile(\"^/trireme/(uid/){0,1}[a-zA-Z0-9_:.$%]{1,64}$\")\n\n\... | {
"audio": "",
"image": "",
"text": "\t\treturn fmt.Errorf(\"Invalid cgroup format: %s\", event.Cgroup)\n\t}\n\n\tif !regexNS.Match([]byte(event.NS)) {\n\t\treturn fmt.Errorf(\"Namespace is not of the right format\")\n\t}\n\n\tfor k, v := range event.IPs {\n\t\tif !regexStrings.Match([]byte(k)) {\n\t\t\treturn fm... | {
"audio": "",
"image": "",
"text": "\n\t\t}\n\t}\n\n\tif event.EventType == common.EventStop || event.EventType == common.EventDestroy {\n\t\tregStop := regexp.MustCompile(\"^/trireme/[a-zA-Z0-9_]{1,11}$\")\n\t\tif event.Cgroup != \"\" && !regStop.Match([]byte(event.Cgroup)) {\n\t\t\treturn fmt.Errorf(\"Cgroup i... |
{
"audio": "",
"image": "",
"text": "func validateEvent(event *common.EventInfo) error {\n\n\tif event.EventType == common.EventCreate || event.EventType == common.EventStart {\n\t\tif event.HostService {\n\t\t\tif event.NetworkOnlyTraffic {\n\t\t\t\tif event.Name == \"\" {\n\t\t\t\t\treturn fmt.Errorf(\"Service ... | {
"audio": "",
"image": "",
"text": "\n\t\t}\n\t}\n\n\tif event.EventType == common.EventStop || event.EventType == common.EventDestroy {\n\t\tregStop := regexp.MustCompile(\"^/trireme/[a-zA-Z0-9_]{1,11}$\")\n\t\tif event.Cgroup != \"\" && !regStop.Match([]byte(event.Cgroup)) {\n\t\t\treturn fmt.Errorf(\"Cgroup i... | {
"audio": "",
"image": "",
"text": "\n\t\t\treturn event, err\n\t\t}\n\t\tif event == xpp.StartTag {\n\t\t\tbreak\n\t\t}\n\n\t\tif event == xpp.EndDocument {\n\t\t\treturn event, fmt.Errorf(\"Failed to find root node before document end.\")\n\t\t}\n\t}\n\treturn\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (i *Instance) createPortSet(contextID string, puInfo *policy.PUInfo) error {\n\n\tif i.mode == constants.RemoteContainer {\n\t\treturn nil\n\t}\n\n\tusername := puInfo.Runtime.Options().UserID\n\tprefix := \"\"\n\n\tif username != \"\" {\n\t\tprefix = uidPortSetPrefix\n\t... | {
"audio": "",
"image": "",
"text": "\n\t}\n\n\tportSetName := puPortSetName(contextID, prefix)\n\n\tif puseterr := i.createPUPortSet(portSetName); puseterr != nil {\n\t\treturn puseterr\n\t}\n\n\ti.contextIDToPortSetMap.AddOrUpdate(contextID, portSetName)\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " make([]*packageACL, len(legacyRoles)),\n\t}\n\tif n.prefix == \"\" {\n\t\tc.prefix = name\n\t} else {\n\t\tc.prefix = n.prefix + \"/\" + name\n\t}\n\tn.children[name] = c\n\treturn c\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (i *Instance) deletePortSet(contextID string) error {\n\n\tif i.mode == constants.RemoteContainer {\n\t\treturn nil\n\t}\n\n\tportSetName := i.getPortSet(contextID)\n\tif portSetName == \"\" {\n\t\treturn fmt.Errorf(\"Failed to find port set\")\n\t}\n\n\tips := ipset.IPSe... | {
"audio": "",
"image": "",
"text": "\tif err := i.contextIDToPortSetMap.Remove(contextID); err != nil {\n\t\tzap.L().Debug(\"portset not found for the contextID\", zap.String(\"contextID\", contextID))\n\t}\n\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " err != nil {\n\t\treturn fmt.Errorf(\"failed to destroy session: %s\", err)\n\t}\n\treturn nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (i *Instance) DeletePortFromPortSet(contextID string, port string) error {\n\tportSetName := i.getPortSet(contextID)\n\tif portSetName == \"\" {\n\t\treturn fmt.Errorf(\"unable to get portset for contextID %s\", contextID)\n\t}\n\n\tips := ipset.IPSet{\n\t\tName: portSetN... | {
"audio": "",
"image": "",
"text": " _, err := strconv.Atoi(port); err != nil {\n\t\treturn fmt.Errorf(\"invalid port: %s\", err)\n\t}\n\n\tif err := ips.Del(port); err != nil {\n\t\treturn fmt.Errorf(\"unable to delete port from portset: %s\", err)\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 NewCollector() Collector {\n\treturn &collectorImpl{\n\t\tFlows: map[string]*collector.FlowRecord{},\n\t\tUsers: ",
"video": ""
} | {
"audio": "",
"image": "",
"text": " map[string]*collector.UserRecord{},\n\t\tProcessedUsers: map[string]bool{},\n\t\tDatapathPacketReports: []*collector.PacketReport{},\n\t}\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 DefaultMetadataExtractor(info *types.ContainerJSON) (*policy.PURuntime, error) {\n\n\t// trigger new build\n\ttags := policy.NewTagStore()\n\t// TODO: Remove OLDTAGS\n\ttags.AppendKeyValue(\"@sys:image\", info.Config.Image)\n\ttags.AppendKeyValue(\"@sys:name\", info.Name)... | {
"audio": "",
"image": "",
"text": "\tif len(strings.TrimSpace(k)) == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tvalue := v\n\t\tif len(v) == 0 {\n\t\t\tvalue = \"<empty>\"\n\t\t}\n\t\tif !strings.HasPrefix(k, UserLabelPrefix) {\n\t\t\ttags.AppendKeyValue(UserLabelPrefix+k, value)\n\t\t} else {\n\t\t\ttags.AppendKeyValue(k... | {
"audio": "",
"image": "",
"text": " info.Key == vm.Reference() {\n\t\t\tlog.Printf(\"[DEBUG] Found HA config info for VM %q in cluster %q\", vm.Name(), cluster.Name())\n\t\t\treturn &info, nil\n\t\t}\n\t}\n\n\tlog.Printf(\"[DEBUG] No HA config info found for VM %q in cluster %q\", vm.Name(), cluster.Name())\n\t... |
{
"audio": "",
"image": "",
"text": "func hostModeOptions(dockerInfo *types.ContainerJSON) *policy.OptionsType {\n\n\toptions := policy.OptionsType{\n\t\tCgroupName: strconv.Itoa(dockerInfo.State.Pid),\n\t\tCgroupMark: strconv.FormatUint(cgnetcls.MarkVal(), 10),\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t}\n\n\tfor p := range dockerInfo.Config.ExposedPorts {\n\t\tif p.Proto() == \"tcp\" {\n\t\t\ts, err := portspec.NewPortSpecFromString(p.Port(), nil)\n\t\t\tif err != nil {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\toptions.Services = append(options.Services, common.Service{\n\t\t\t... | {
"audio": "",
"image": "",
"text": "\n\tworksheet.PageSetUp = nil\n\tf.Sheet[path] = worksheet\n\ttoRels := \"xl/worksheets/_rels/sheet\" + strconv.Itoa(to) + \".xml.rels\"\n\tfromRels := \"xl/worksheets/_rels/sheet\" + strconv.Itoa(from) + \".xml.rels\"\n\t_, ok := f.XLSX[fromRels]\n\tif ok {\n\t\tf.XLSX[toRels... |
{
"audio": "",
"image": "",
"text": "func StatsFlowHash(r *FlowRecord) string {\n\thash := xxhash.New()\n\thash.Write([]byte(r.Source.ID)) // nolint errcheck\n\thash.Write([]byte(r.Destination.ID)) // nolint errcheck\n\tport := make([]byte, 2)\n\tbinary.BigEndian.PutUint16(port, r.Destination.Port)\n\thash.W... | {
"audio": "",
"image": "",
"text": " // nolint errcheck\n\thash.Write([]byte(r.ObservedAction.String())) // nolint errcheck\n\thash.Write([]byte(r.DropReason)) // nolint errcheck\n\thash.Write([]byte(r.Destination.URI)) // nolint errcheck\n\n\treturn fmt.Sprintf(\"%d\", hash.Sum64())... | {
"audio": "",
"image": "",
"text": "\thash.Write(bytes)\n\thash.Write([]byte(pipelineInfo.Pipeline.Name))\n\thash.Write([]byte(pipelineInfo.ID))\n\thash.Write([]byte(strconv.Itoa(int(pipelineInfo.Version))))\n\n\t// Note in 1.5.0 this function was called HashPipelineID, it's now called\n\t// HashPipelineName but... |
{
"audio": "",
"image": "",
"text": "func StatsUserHash(r *UserRecord) error {\n\t// Order matters for the hash function loop\n\tsort.Strings(r.Claims)\n\thash := xxhash.New()\n\tfor i := 0; i < len(r.Claims); i++ {\n\t\tif strings.HasPrefix(r.Claims[i], \"sub\") {\n\t\t\tcontinue\n\t\t}\n\t\tif",
"video": ""
} | {
"audio": "",
"image": "",
"text": " _, err := hash.Write([]byte(r.Claims[i])); err != nil {\n\t\t\treturn fmt.Errorf(\"Cannot create hash\")\n\t\t}\n\t}\n\tr.ID = fmt.Sprintf(\"%d\", hash.Sum64())\n\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t\tfiles <- jobs[i]\n\t}\n\tclose(files)\n\n\tfor i := 0; i < workload; i++ {\n\t\tr := <-results\n\t\tif r == nil {\n\t\t\toffset++\n\t\t\tcontinue\n\t\t} else {\n\t\t\tset[i-offset] = *r\n\t\t}\n\t}\n\n\treturn set[:(workload - offset)], nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func NewPortCache(name string) *PortCache {\n\treturn &PortCache{\n\t\tports: ",
"video": ""
} | {
"audio": "",
"image": "",
"text": " cache.NewCache(name),\n\t\tranges: []*portspec.PortSpec{},\n\t}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " string {\n\tif legacyName, ok := systemNameMap[c.Name]; ok {\n\t\treturn legacyName\n\t}\n\treturn c.Name\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (p *PortCache) AddPortSpec(s *portspec.PortSpec) {\n\tif s.Min == s.Max {\n\t\tp.ports.AddOrUpdate(s.Min, s)\n\t} else {\n\t\t// Remove the range if it exists\n\t\tp.Remove(s) // nolint\n\t\t//",
"video": ""
} | {
"audio": "",
"image": "",
"text": " Insert the portspec\n\t\tp.Lock()\n\t\tp.ranges = append([]*portspec.PortSpec{s}, p.ranges...)\n\t\tp.Unlock()\n\t}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\t\tmin = mid + 1\n\t\t} else {\n\t\t\tmax = mid\n\t\t}\n\t}\n\tif max < 0 || s.Set[min].Less(q) {\n\t\treturn len(s.Set), false // q is the new largest value\n\t}\n\treturn min, s.Set[min].Contains(q)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (p *PortCache) AddPortSpecToEnd(s *portspec.PortSpec) {\n\n\t// Remove the range if it exists\n\tp.Remove(s) // nolint",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\n\tp.Lock()\n\tp.ranges = append(p.ranges, s)\n\tp.Unlock()\n\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\treturn func(p *ProgressBar) {\n\t\tp.config.width = s\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (p *PortCache) AddUnique(s *portspec.PortSpec) error {\n\tp.Lock()\n\tdefer p.Unlock()\n\n\tif s.Min == s.Max {\n\t\tif err, _ := p.ports.Get(s.Min); err != nil {\n\t\t\treturn fmt.Errorf(\"Port already exists: %s\", err)\n\t\t}\n\t}\n\n\tfor _, r := range p.ranges {\n\t\... | {
"audio": "",
"image": "",
"text": "\t\treturn fmt.Errorf(\"Overlap detected: %d %d\", r.Max, r.Min)\n\t}\n\n\tif s.Min == s.Max {\n\t\treturn p.ports.Add(s.Min, s)\n\t}\n\n\tp.ranges = append(p.ranges, s)\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " out.Y <= min {\n\t\ty = min\n\t} else {\n\t\ty = max\n\t}\n\tx := in.X + dx*(y-in.Y)/dy\n\tp.X, p.Y = x, y\n\tp.DeltaX, p.DeltaY = math.NaN(), math.NaN()\n\treturn\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (p *PortCache) GetSpecValueFromPort(port uint16) (interface{}, error) {\n\tif spec, err := p.ports.Get(port); err == nil {\n\t\treturn spec.(*portspec.PortSpec).Value(), nil\n\t}\n\n\tp.Lock()\n\tdefer p.Unlock()\n\tfor _, s := range p.ranges {\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\tif s.Min <= port && port < s.Max {\n\t\t\treturn s.Value(), nil\n\t\t}\n\t}\n\n\treturn nil, fmt.Errorf(\"No match for port %d\", port)\n}",
"video": ""
} | {
"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 *PortCache) Remove(s *portspec.PortSpec) error {\n\n\tif s.Min == s.Max {\n\t\treturn p.ports.Remove(s.Min)\n\t}\n\n\tp.Lock()\n\tdefer p.Unlock()\n\tfor i, r := range p.ranges {\n\t\tif r.Min == s.Min && r.Max == s.Max {\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\t\tleft := p.ranges[:i]\n\t\t\tright := p.ranges[i+1:]\n\t\t\tp.ranges = append(left, right...)\n\t\t\treturn nil\n\t\t}\n\t}\n\n\treturn fmt.Errorf(\"port not found\")\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " out.Y <= min {\n\t\ty = min\n\t} else {\n\t\ty = max\n\t}\n\tx := in.X + dx*(y-in.Y)/dy\n\tp.X, p.Y = x, y\n\tp.DeltaX, p.DeltaY = math.NaN(), math.NaN()\n\treturn\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (p *PortCache) RemoveStringPorts(ports string) error {\n\n\ts, err := portspec.NewPortSpecFromString(ports, nil)\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn p.Remove(s)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\treturn func(p *Prompt) error {\n\t\tp.keyBindMode = m\n\t\treturn nil\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func NewMockRemoteIntf(ctrl *gomock.Controller) *MockRemoteIntf {\n\tmock := &MockRemoteIntf{ctrl: ctrl}\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tmock.recorder = &MockRemoteIntfMockRecorder{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 (m *MockRemoteIntf) InitEnforcer(req rpcwrapper.Request, resp *rpcwrapper.Response) error {\n\tret",
"video": ""
} | {
"audio": "",
"image": "",
"text": " := m.ctrl.Call(m, \"InitEnforcer\", req, resp)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t}\n\treturn func(req *http.Request, ctx *ProxyCtx) bool {\n\t\t_, ok := hostSet[req.URL.Host]\n\t\treturn ok\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (mr *MockRemoteIntfMockRecorder) InitEnforcer(req, resp interface{}) *gomock.Call {\n\treturn",
"video": ""
} | {
"audio": "",
"image": "",
"text": " mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"InitEnforcer\", reflect.TypeOf((*MockRemoteIntf)(nil).InitEnforcer), req, resp)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " (resp *http.Response, err error) {\n\treturn pool.DoWithParams(req, DoParams{Timeout: timeout})\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (e *enforcer) Run(ctx context.Context) error {\n\n\tif e.proxy != nil {\n\t\tif err := e.proxy.Run(ctx); err != nil {\n\t\t\treturn err\n\t\t}\n\t}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\n\tif e.transport != nil {\n\t\tif err := e.transport.Run(ctx); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif e.secrets != nil {\n\t\tif err := e.secrets.Run(ctx); err != nil {\n\t\t\treturn err\n\t\t}\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 (e *enforcer) Enforce(contextID string, puInfo *policy.PUInfo) error {\n\n\tif e.transport != nil {\n\t\tif err := e.transport.Enforce(contextID, puInfo); err != nil {\n\t\t\treturn fmt.Errorf(\"unable to enforce in nfq: %s\", err)\n\t\t}\n\t}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\n\tif e.proxy != nil {\n\t\tif err := e.proxy.Enforce(context.Background(), contextID, puInfo); err != nil {\n\t\t\treturn fmt.Errorf(\"unable to enforce in proxy: %s\", err)\n\t\t}\n\t}\n\n\tif e.secrets != nil {\n\t\tif err := e.secrets.Enforce(puInfo); err != nil {\n\t\t... | {
"audio": "",
"image": "",
"text": " string, e error) {\n\tr, e := dh.createDockerfileArchive(dockerfile)\n\tif e != nil {\n\t\treturn \"\", e\n\t}\n\treturn dh.Build(r, opts)\n\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (e *enforcer) Unenforce(contextID string) error {\n\n\tvar perr, nerr, serr error\n\tif e.proxy != nil {\n\t\tif perr = e.proxy.Unenforce(context.Background(), contextID); perr != nil {\n\t\t\tzap.L().Error(\"Failed to unenforce contextID in proxy\",\n\t\t\t\tzap.String(\... | {
"audio": "",
"image": "",
"text": "\tif e.secrets != nil {\n\t\tif serr = e.secrets.Unenforce(contextID); nerr != nil {\n\t\t\tzap.L().Error(\"Failed to unenforce contextID in transport\",\n\t\t\t\tzap.String(\"ContextID\", contextID),\n\t\t\t\tzap.Error(nerr),\n\t\t\t)\n\t\t}\n\t}\n\n\tif perr != nil || nerr !... | {
"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 (e *enforcer) UpdateSecrets(secrets secrets.Secrets) error {\n\tif e.proxy != nil {\n\t\tif err := e.proxy.UpdateSecrets(secrets); err != nil {\n\t\t\treturn err\n\t",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t}\n\t}\n\n\tif e.transport != nil {\n\t\tif err := e.transport.UpdateSecrets(secrets); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif e.secrets != nil {\n\t\tif err := e.secrets.UpdateSecrets(secrets); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}",
"vi... | {
"audio": "",
"image": "",
"text": " {\n\treturn s.coreClientSet.Secrets(s.namespace)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (e *enforcer) EnableDatapathPacketTracing(contextID string, direction packettracing.TracingDirection, interval time.Duration) error {",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\treturn e.transport.EnableDatapathPacketTracing(contextID, direction, interval)\n\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " *HandshakeOptions) {\n\t\topts.Interval = interval\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func New(\n\tmutualAuthorization bool,\n\tfqConfig *fqconfig.FilterQueue,\n\tcollector collector.EventCollector,\n\tservice packetprocessor.PacketProcessor,\n\tsecrets secrets.Secrets,\n\tserverID string,\n\tvalidity time.Duration,\n\tmode constants.ModeType,\n\tprocMountPoint... | {
"audio": "",
"image": "",
"text": "\t\tserverID,\n\t\tvalidity,\n\t\tservice,\n\t\tsecrets,\n\t\tmode,\n\t\tprocMountPoint,\n\t\texternalIPCacheTimeout,\n\t\tpacketLogs,\n\t\ttokenAccessor,\n\t\tpuFromContextID,\n\t\tcfg,\n\t)\n\n\ttcpProxy, err := applicationproxy.NewAppProxy(tokenAccessor, collector, puFromCo... | {
"audio": "",
"image": "",
"text": " {\n\treturn s.coreClientSet.Secrets(s.namespace)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (h HeaderBytes) extractHeaderAttribute(mask uint32) uint32 {\n\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tdata := binary.LittleEndian.Uint32(h)\n\n\treturn data & mask\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tb.setBits(uint32(bucket)*uint32(b.bucketSize), uint32(b.bucketSize), uint32(value))\n\treturn b\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (ct CompressionType) toMask() compressionTypeMask {\n\n\tswitch ct {\n\tcase CompressionTypeV1:\n\t\treturn compressionTypeV1Mask\n\tcase CompressionTypeV2:\n\t",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\treturn compressionTypeV2Mask\n\tdefault:\n\t\treturn compressionTypeNoneMask\n\t}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tdefer cancel()\n\n\tch := make(chan error, 1) // not block tryRunTiming\n\tgo tryRunTiming(ct, fn, ch)\n\n\tselect {\n\tcase <-ct.Done():\n\t\terr = ct.Err()\n\tcase err = <-ch:\n\t}\n\treturn\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (cm compressionTypeMask) toType() CompressionType {\n\n\tswitch cm {\n\tcase compressionTypeV1Mask:\n\t\treturn CompressionTypeV1\n\tcase compressionTypeV2Mask:\n\t",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\treturn CompressionTypeV2\n\tdefault:\n\t\treturn CompressionTypeNone\n\t}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tdefer cm.mtx.RUnlock()\n\n\treturn cm.pending[inKey]\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func String2CompressionType(s string) CompressionType {\n\n\tswitch s {\n\tcase CompressionTypeV1.toString():\n\t\treturn CompressionTypeV1",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tcase CompressionTypeV2.toString():\n\t\treturn CompressionTypeV2\n\tdefault:\n\t\treturn CompressionTypeNone\n\t}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t\tswitch pos[0] {\n\t\tcase IteratorBegin:\n\t\t\ts.Begin()\n\t\tcase IteratorEnd:\n\t\t\ts.End()\n\t\tdefault:\n\t\t\tpanic(\"unknown ShapeIndexIteratorPos value\")\n\t\t}\n\t}\n\n\treturn s\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func newReconciler(mgr manager.Manager, handler *config.ProcessorConfig, metadataExtractor extractors.PodMetadataExtractor, netclsProgrammer extractors.PodNetclsProgrammer, nodeName string, enableHostPods bool) *ReconcilePod {\n\treturn &ReconcilePod{\n\t\tclient: m... | {
"audio": "",
"image": "",
"text": " handler,\n\t\tmetadataExtractor: metadataExtractor,\n\t\tnetclsProgrammer: netclsProgrammer,\n\t\tnodeName: nodeName,\n\t\tenableHostPods: enableHostPods,\n\n\t\t// TODO: might move into configuration\n\t\thandlePUEventTimeout: 5 * time.Second,\n\t\tmetadataE... | {
"audio": "",
"image": "",
"text": " {\n\t\tif ch == subCh {\n\t\t\tmgr.subscribers = append(mgr.subscribers[:i], mgr.subscribers[i+1:]...)\n\t\t\tlog.Infof(\"%v unsubscribed from settings updates\", subCh)\n\t\t\treturn\n\t\t}\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func addController(mgr manager.Manager, r *ReconcilePod, eventsCh <-chan event.GenericEvent) error {\n\t// Create a new controller\n\tc, err := controller.New(\"trireme-pod-controller\", mgr, controller.Options{Reconciler: r})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// we... | {
"audio": "",
"image": "",
"text": "\n\t\t&source.Kind{Type: &corev1.Pod{}},\n\t\t&handler.EnqueueRequestsFromMapFunc{ToRequests: mapper},\n\t); err != nil {\n\t\treturn err\n\t}\n\n\t// we pass in a custom channel for events generated by resync\n\tif err := c.Watch(\n\t\t&source.Channel{Source: eventsCh},\n\t\t... | {
"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 NewProcessor(s secrets.Secrets, trustedCertificate *x509.Certificate)",
"video": ""
} | {
"audio": "",
"image": "",
"text": " *Processor {\n\treturn &Processor{\n\t\taporetoJWT: servicetokens.NewVerifier(s, trustedCertificate),\n\t}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\treturn s.coreClientSet.Secrets(s.namespace)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (p *Processor) UpdateSecrets(s secrets.Secrets, trustedCertificate",
"video": ""
} | {
"audio": "",
"image": "",
"text": " *x509.Certificate) {\n\tp.aporetoJWT.UpdateSecrets(s, trustedCertificate)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\treturn s.coreClientSet.Secrets(s.namespace)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (p *Processor) AddOrUpdateService(apis *urisearch.APICache, serviceType policy.UserAuthorizationTypeValues, handler usertokens.Verifier, mappings map[string]string) {\n\tp.Lock()\n\tdefer p.Unlock()\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tp.apis = apis\n\tp.userTokenMappings = mappings\n\tp.userTokenHandler = handler\n\tp.userAuthorizationType = serviceType\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tdefer p.Unlock()\n\n\tp.apis = apis\n\treturn nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (p *Processor) UpdateServiceAPIs(apis *urisearch.APICache) error {\n\tp.Lock()",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tdefer p.Unlock()\n\n\tp.apis = apis\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\treturn func(p *Prompt) error {\n\t\tp.keyBindMode = m\n\t\treturn nil\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (p *Processor) DecodeUserClaims(name, userToken string, certs []*x509.Certificate, r *http.Request) ([]string, bool, string, error) {\n\n\tswitch p.userAuthorizationType {\n\tcase policy.UserAuthorizationMutualTLS, policy.UserAuthorizationJWT:\n\t\t// First parse any inco... | {
"audio": "",
"image": "",
"text": "\t\t\treturn attributes, false, userToken, fmt.Errorf(\"Unable to decode JWT: %s\", err)\n\t\t\t}\n\t\t\tattributes = append(attributes, jwtAttributes...)\n\t\t}\n\n\t\treturn attributes, false, userToken, nil\n\n\tcase policy.UserAuthorizationOIDC:\n\t\t// Now we can parse th... | {
"audio": "",
"image": "",
"text": "\t}\n\tfor _, chain := range tlsState.VerifiedChains {\n\t\tsubjects := []string{}\n\t\tfor _, cert := range chain {\n\t\t\tsubjects = append(subjects, cert.Subject.CommonName)\n\t\t}\n\t\tverifiedChain = append(verifiedChain, strings.Join(subjects, \",\"))\n\t}\n\n\tlog.G(ctx... |
{
"audio": "",
"image": "",
"text": "func (p *Processor) DecodeAporetoClaims(aporetoToken string, publicKey string) (string, []string, error) {\n\tif len(aporetoToken) == 0 || p.aporetoJWT == nil {\n\t\treturn \"\", []string{}, nil\n\t}\n\n\t// Finally we can parse the Aporeto token.\n\tid, scopes, profile, err",... | {
"audio": "",
"image": "",
"text": " := p.aporetoJWT.ParseToken(aporetoToken, publicKey)\n\tif err != nil {\n\t\treturn \"\", []string{}, fmt.Errorf(\"Invalid Aporeto Token: %s\", err)\n\t}\n\treturn id, append(profile, scopes...), nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " string, _ string) (string, error) {\n\treturn \"\", nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (p *Processor) Callback(w http.ResponseWriter, r *http.Request) {\n\tp.RLock()\n\tdefer p.RUnlock()\n\n\t// Validate the JWT token through the handler.\n\ttoken, originURL, status, err := p.userTokenHandler.Callback(r)\n\tif err != nil {\n\t\thttp.Error(w, fmt.Sprintf(\"I... | {
"audio": "",
"image": "",
"text": " transmit the information in the return payload for applications\n\t// that choose to use it directly without a cookie.\n\tdata, err := json.MarshalIndent(cookie, \" \", \" \")\n\tif err != nil {\n\t\thttp.Error(w, \"Bad data\", http.StatusInternalServerError)\n\t\treturn\n\t}... | {
"audio": "",
"image": "",
"text": "\tValue: value,\n\t\tHttpOnly: true,\n\t\tPath: \"/\",\n\t}\n\n\t// Only set a cookie to be persistent (endure beyond the browser session)\n\t// if auth duration is greater than zero\n\tif c.Lifespan > 0 {\n\t\tcookie.Expires = exp\n\t}\n\thttp.SetCookie(w, &cookie)\n}"... |
{
"audio": "",
"image": "",
"text": "func (p *Processor) Check(method, uri string, claims []string) (bool, bool) {\n\tp.RLock()\n\tdefer p.RUnlock()\n\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\treturn p.apis.FindAndMatchScope(method, uri, claims)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " make(chan bool, 1),\n\t}\n\tp.routines = append(p.routines, newRoutine)\n\tp.waitGroup.Add(1)\n\tGo(func() {\n\t\tgoroutine(newRoutine.stop)\n\t\tp.waitGroup.Done()\n\t})\n\tp.lock.Unlock()\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (p *Processor) RedirectURI(originURL string) string {",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tp.RLock()\n\tdefer p.RUnlock()\n\n\treturn p.userTokenHandler.IssueRedirect(originURL)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " *Parameter {\n\tp.data.CollectionFormat = format.String()\n\treturn p\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (p *Processor) UpdateRequestHeaders(r *http.Request, claims []string) {\n\tp.RLock()\n\tdefer p.RUnlock()\n\n\tif len(p.userTokenMappings) == 0 {\n\t\treturn\n\t}\n\n\tfor _, claim := range claims {\n\t",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tparts := strings.SplitN(claim, \"=\", 2)\n\t\tif header, ok := p.userTokenMappings[parts[0]]; ok && len(parts) == 2 {\n\t\t\tr.Header.Add(header, parts[1])\n\t\t}\n\t}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " p := range points {\n\t\tb.Extend(p.Point())\n\t}\n\n\tq := New(b, len(points))\n\n\tfor _, p := range points {\n\t\tq.Insert(p)\n\t}\n\n\treturn q\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func NewFilterQueueWithDefaults() *FilterQueue {\n\treturn NewFilterQueue(\n\t\tDefaultQueueSeperation,",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t\tDefaultMarkValue,\n\t\tDefaultQueueStart,\n\t\tDefaultNumberOfQueues,\n\t\tDefaultNumberOfQueues,\n\t\tDefaultQueueSize,\n\t\tDefaultQueueSize,\n\t)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " -1 {\n\t\treturn formulaTable[fmtForms(FormsTable[idx].Value)]\n\t}\n\treturn func(n int) int {\n\t\treturn n\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func hasSynced(sync chan struct{}, controller kubecache.Controller) {\n\tfor {\n\t\tif controller.HasSynced() {\n\t\t",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tsync <- struct{}{}\n\t\t\treturn\n\t\t}\n\t\t<-time.After(100 * time.Millisecond)\n\t}\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 (n *NFQParser) Synchronize() error {\n\n\tn.Lock()\n\tdefer n.Unlock()\n\n\tdata, err := ioutil.ReadFile(n.filePath)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tn.nfqStr = string(data)\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tscanner := bufio.NewScanner(bytes.NewReader(data))\n\tfor scanner.Scan() {\n\t\tline := scanner.Text()\n\t\tlineParts := strings.Fields(line)\n\t\tnewNFQ := makeNFQLayout(lineParts)\n\n\t\tn.contents[newNFQ.QueueNum] = newNFQ\n\t}\n\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " n.send(n.sub, data); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\tn.activated = true\n\treturn nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (n *NFQParser) RetrieveByQueue(queueNum string) *NFQLayout {\n\n\tn.Lock()",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tdefer n.Unlock()\n\n\tcontent, ok := n.contents[queueNum]\n\tif ok {\n\t\treturn &content\n\t}\n\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " make(chan struct{}),\n\t\tleadershipBroadcast: watch.NewQueue(),\n\t\tkeyRotator: opts.KeyRotator,\n\t}\n\tn.memoryStore = store.NewMemoryStore(n)\n\n\tif opts.ClockSource == nil {\n\t\tn.ticker = clock.NewClock().NewTicker(opts.TickInterval)\n\t} else {\n\t\tn.ticke... |
{
"audio": "",
"image": "",
"text": "func (n *NFQParser) RetrieveAll() map[string]NFQLayout {\n\n\tn.Lock()",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tdefer n.Unlock()\n\n\treturn n.contents\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " make(chan struct{}),\n\t\tleadershipBroadcast: watch.NewQueue(),\n\t\tkeyRotator: opts.KeyRotator,\n\t}\n\tn.memoryStore = store.NewMemoryStore(n)\n\n\tif opts.ClockSource == nil {\n\t\tn.ticker = clock.NewClock().NewTicker(opts.TickInterval)\n\t} else {\n\t\tn.ticke... |
{
"audio": "",
"image": "",
"text": "func (n *NFQParser) String() string {\n\n\tn.Lock()",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tdefer n.Unlock()\n\n\treturn n.nfqStr\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " make(chan struct{}),\n\t\tleadershipBroadcast: watch.NewQueue(),\n\t\tkeyRotator: opts.KeyRotator,\n\t}\n\tn.memoryStore = store.NewMemoryStore(n)\n\n\tif opts.ClockSource == nil {\n\t\tn.ticker = clock.NewClock().NewTicker(opts.TickInterval)\n\t} else {\n\t\tn.ticke... |
{
"audio": "",
"image": "",
"text": "func NewMockProcessor(ctrl *gomock.Controller) *MockProcessor {\n\tmock := &MockProcessor{ctrl: ctrl}\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tmock.recorder = &MockProcessorMockRecorder{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 (m *MockProcessor) Start(ctx context.Context, eventInfo *common.EventInfo)",
"video": ""
} | {
"audio": "",
"image": "",
"text": " error {\n\tret := m.ctrl.Call(m, \"Start\", ctx, eventInfo)\n\tret0, _ := ret[0].(error)\n\treturn ret0\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 (mr *MockProcessorMockRecorder) Start(ctx, eventInfo interface{}) *gomock.Call {",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Start\", reflect.TypeOf((*MockProcessor)(nil).Start), ctx, eventInfo)\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 NewTagStoreFromMap(tags map[string]string) *TagStore {\n\tt := &TagStore{make([]string, len(tags))}\n\ti := 0\n\tfor k, v",
"video": ""
} | {
"audio": "",
"image": "",
"text": " := range tags {\n\t\tt.Tags[i] = k + \"=\" + v\n\t\ti++\n\t}\n\treturn t\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t\t\tlabels := map[string]string{}\n\t\t\tfor k, v := range dims {\n\t\t\t\tlabels[k] = v\n\t\t\t}\n\t\t\tfor k, v := range d.Tags {\n\t\t\t\tlabels[k] = v\n\t\t\t}\n\t\t\trval[d.Name] = append(rval[d.Name], datapointLabels{&d, labels})\n\t\t}\n\t}\n\n\treturn rval\n}",
"... |
{
"audio": "",
"image": "",
"text": "func (t *TagStore) Copy() *TagStore {\n\n\tc := make([]string,",
"video": ""
} | {
"audio": "",
"image": "",
"text": " len(t.Tags))\n\n\tcopy(c, t.Tags)\n\n\treturn &TagStore{c}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " make([]string, len(tn.tag))\n\tcopy(out, tn.tag)\n\treturn out\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (t *TagStore) Get(key string) (string, bool) {\n\n\tfor _, kv := range t.Tags {\n\t\tparts := strings.SplitN(kv, \"=\", 2)\n\t\tif len(parts) != 2 {\n\t\t\tcontinue\n\t\t}\n\t",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tif key == parts[0] {\n\t\t\treturn parts[1], true\n\t\t}\n\t}\n\n\treturn \"\", false\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tfor _, pair := range requestList {\n\t\tv := strings.SplitN(pair, \"=\", 2)\n\t\treq.Header[v[0]] = v[1]\n\t}\n\n\treturn req, nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (t *TagStore) Merge(m *TagStore) (merged int) {\n\n\tfor _, kv := range m.Tags {\n\t\tparts := strings.SplitN(kv, \"=\", 2)\n\t\tif len(parts) != 2 {\n\t\t\tcontinue\n\t\t}\n\t",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tif _, ok := t.Get(parts[0]); !ok {\n\t\t\tt.AppendKeyValue(parts[0], parts[1])\n\t\t\tmerged++\n\t\t}\n\t}\n\treturn merged\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tresult[pos] = found\n\t\t\treturn nil\n\t\t})\n\t\ti++\n\t}\n\tif err := g.Wait(); err != nil {\n\t\tlog.Errorf(\"memory-idx: failed to FindTagValues: orgId=%d tag=%s prefix=%s expressions=%v from=%d limit=%d. %s\", orgId, tag, pre... |
{
"audio": "",
"image": "",
"text": "func (t *TagStore) AppendKeyValue(key, value string) {\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tt.Tags = append(t.Tags, key+\"=\"+value)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\tif index%2 == 0 {\n\t\t\tkey = value.String()\n\t\t} else {\n\t\t\thash.Set(key, value.Bytes())\n\t\t}\n\t}\n\treturn hash, nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (t *TriremeRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {\n\n\tres, err := t.RoundTripper.RoundTrip(req)\n\tif err != nil || res == nil {\n\t\treturn res, err\n\t}\n\n\tdata := req.Context().Value(statsContextKey)\n\tif data == nil {\n\t\treturn res,... | {
"audio": "",
"image": "",
"text": " ok := data.(*connectionState)\n\tif ok && state.cookie == nil {\n\t\treturn res, nil\n\t}\n\n\tif v := state.cookie.String(); v != \"\" {\n\t\tres.Header.Add(\"Set-Cookie\", v)\n\t}\n\n\treturn res, nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " CreateRETSVersioner(retsVersion),\n\t\tGetSessionID: CreateSessionIDer(client.Jar),\n\t}).Request\n\t// 1) apply default headers first (outermost wrapping)\n\theaders := func(ctx context.Context, req *http.Request) (*http.Response, error) {\n\t\treq.Header.Set(UserAgent... |
{
"audio": "",
"image": "",
"text": "func (u *UIDMonitor) Resync(ctx context.Context)",
"video": ""
} | {
"audio": "",
"image": "",
"text": " error {\n\treturn u.proc.Resync(ctx, 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 NewMockDebugClient(ctrl *gomock.Controller) *MockDebugClient {\n\tmock := &MockDebugClient{ctrl: ctrl}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tmock.recorder = &MockDebugClientMockRecorder{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 (m *MockDebugClient) Run(ctx context.Context) error",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\tret := m.ctrl.Call(m, \"Run\", ctx)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " func(ctx context.Context) error {\n\t\treturn UpdateTenant(ctx, config)\n\t}\n}",
"video": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.