{"action":"created","comment":{"url":"https://api.github.com/repos/aporeto-inc/trireme/pulls/comments/92531898","pull_request_review_id":13048343,"id":92531898,"diff_hunk":"@@ -0,0 +1,279 @@\n+package main\n+\n+import (\n+\t\"container/list\"\n+\t\"crypto/ecdsa\"\n+\t\"errors\"\n+\t\"flag\"\n+\t\"fmt\"\n+\t\"os\"\n+\t\"os/user\"\n+\t\"sync\"\n+\t\"time\"\n+\n+\tlog \"github.com/Sirupsen/logrus\"\n+\t\"github.com/aporeto-inc/trireme/cache\"\n+\t\"github.com/aporeto-inc/trireme/collector\"\n+\t\"github.com/aporeto-inc/trireme/enforcer\"\n+\t_ \"github.com/aporeto-inc/trireme/enforcer/utils/nsenter\"\n+\t\"github.com/aporeto-inc/trireme/enforcer/utils/packet\"\n+\t\"github.com/aporeto-inc/trireme/enforcer/utils/rpc_payloads\"\n+\t\"github.com/aporeto-inc/trireme/enforcer/utils/tokens\"\n+\t\"github.com/aporeto-inc/trireme/policy\"\n+\t\"github.com/aporeto-inc/trireme/supervisor\"\n+\t\"github.com/aporeto-inc/trireme/supervisor/iptablesutils\"\n+\t\"github.com/aporeto-inc/trireme/supervisor/provider\"\n+)\n+\n+const (\n+\tipcProtocol    = \"unix\"\n+\tdefaultPath    = \"/var/run/default.sock\"\n+\tstatsContextID = \"UNUSED\"\n+)\n+\n+//CollectorImpl exported\n+type CollectorImpl struct {\n+\tFlowentries *list.List\n+\tsync.RWMutex\n+}\n+type collectorentry struct {\n+\tL4FlowHash string\n+\tentry      *enforcer.StatsPayload\n+}\n+\n+//CollectFlowEvent expoted\n+func (c *CollectorImpl) CollectFlowEvent(contextID string, tags policy.TagsMap, action string, mode string, sourceID string, tcpPacket *packet.Packet) {\n+\tl4FlowHash := tcpPacket.L4FlowHash()\n+\tpayload := &enforcer.StatsPayload{ContextID: contextID,\n+\t\tTags:   tags,\n+\t\tAction: action,\n+\t\tMode:   mode,\n+\t\tSource: sourceID,\n+\t\tPacket: tcpPacket,\n+\t}\n+\n+\tc.Lock()\n+\tc.Flowentries.PushBack(&collectorentry{L4FlowHash: l4FlowHash, entry: payload})\n+\tc.Unlock()\n+}\n+\n+//CollectContainerEvent exported\n+//This event should not be expected here in the enforcer process inside a particular container context\n+func (c *CollectorImpl) CollectContainerEvent(contextID string, ip string, tags policy.TagsMap, event string) {\n+}\n+\n+//Server exported\n+type Server struct {\n+\tMutualAuth  bool\n+\tValidity    time.Duration\n+\tSecretType  tokens.SecretsType\n+\tContextID   string\n+\tCAPEM       []byte\n+\tPublicPEM   []byte\n+\tPrivatePEM  []byte\n+\trpcchannel  string\n+\trpchdl      *rpcWrapper.RPCWrapper\n+\tStatsClient *rpcWrapper.RPCWrapper\n+\tEnforcer    enforcer.PolicyEnforcer\n+\tCollector   collector.EventCollector\n+\tSupervisor  supervisor.Supervisor\n+}\n+\n+type StatsClient struct {\n+\tcollector *CollectorImpl\n+\ts         *Server\n+\tFlowCache *cache.Cache\n+\tRpchdl    *rpcWrapper.RPCWrapper\n+}\n+\n+func (s *StatsClient) SendStats() {\n+\t//We are connected and lets pack and ship\n+\trpcpayload := new(rpcWrapper.StatsPayload)\n+\tvar request rpcWrapper.Request\n+\tvar response rpcWrapper.Response\n+\trpcpayload.NumFlows = 0\n+\tstarttime := time.Now()\n+\tfor {\n+\n+\t\ts.collector.Lock()\n+\t\tif !(s.collector.Flowentries.Len() > 0) {\n+\t\t\ts.collector.Unlock()\n+\t\t\t//starttime = time.Now()\n+\t\t\tcontinue\n+\t\t}\n+\t\ts.collector.Unlock()\n+\t\telement := s.collector.Flowentries.Remove(s.collector.Flowentries.Front())\n+\t\t//Now we can proceed lock free flowcache is not shared\n+\t\t_, err := s.FlowCache.Get(element.(*collectorentry).L4FlowHash)\n+\t\tif err != nil {\n+\t\t\t//this is new flow add it to our rpc payload\n+\t\t\trpcpayload.NumFlows = rpcpayload.NumFlows + 1\n+\t\t\trpcpayload.Flows = append(rpcpayload.Flows, *element.(*collectorentry).entry)\n+\n+\t\t} else {\n+\t\t\t//Do nothing since we have added this flow already","path":"cmd/remote_enforcer.go","position":114,"original_position":114,"commit_id":"2f722ed568d3d9276a2d7260d20e36d08777649f","original_commit_id":"49292874a185462d623728df35e66e2b04038e52","user":{"login":"Dogild","id":2860781,"avatar_url":"https://avatars.githubusercontent.com/u/2860781?v=3","gravatar_id":"","url":"https://api.github.com/users/Dogild","html_url":"https://github.com/Dogild","followers_url":"https://api.github.com/users/Dogild/followers","following_url":"https://api.github.com/users/Dogild/following{/other_user}","gists_url":"https://api.github.com/users/Dogild/gists{/gist_id}","starred_url":"https://api.github.com/users/Dogild/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Dogild/subscriptions","organizations_url":"https://api.github.com/users/Dogild/orgs","repos_url":"https://api.github.com/users/Dogild/repos","events_url":"https://api.github.com/users/Dogild/events{/privacy}","received_events_url":"https://api.github.com/users/Dogild/received_events","type":"User","site_admin":false},"body":"Why do you need an else then :)","created_at":"2016-12-15T02:14:08Z","updated_at":"2016-12-15T02:25:09Z","html_url":"https://github.com/aporeto-inc/trireme/pull/105#discussion_r92531898","pull_request_url":"https://api.github.com/repos/aporeto-inc/trireme/pulls/105","_links":{"self":{"href":"https://api.github.com/repos/aporeto-inc/trireme/pulls/comments/92531898"},"html":{"href":"https://github.com/aporeto-inc/trireme/pull/105#discussion_r92531898"},"pull_request":{"href":"https://api.github.com/repos/aporeto-inc/trireme/pulls/105"}}},"pull_request":{"url":"https://api.github.com/repos/aporeto-inc/trireme/pulls/105","id":98061718,"html_url":"https://github.com/aporeto-inc/trireme/pull/105","diff_url":"https://github.com/aporeto-inc/trireme/pull/105.diff","patch_url":"https://github.com/aporeto-inc/trireme/pull/105.patch","issue_url":"https://api.github.com/repos/aporeto-inc/trireme/issues/105","number":105,"state":"open","locked":false,"title":"Merge remote datapath","user":{"login":"amitlimaye","id":8889471,"avatar_url":"https://avatars.githubusercontent.com/u/8889471?v=3","gravatar_id":"","url":"https://api.github.com/users/amitlimaye","html_url":"https://github.com/amitlimaye","followers_url":"https://api.github.com/users/amitlimaye/followers","following_url":"https://api.github.com/users/amitlimaye/following{/other_user}","gists_url":"https://api.github.com/users/amitlimaye/gists{/gist_id}","starred_url":"https://api.github.com/users/amitlimaye/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amitlimaye/subscriptions","organizations_url":"https://api.github.com/users/amitlimaye/orgs","repos_url":"https://api.github.com/users/amitlimaye/repos","events_url":"https://api.github.com/users/amitlimaye/events{/privacy}","received_events_url":"https://api.github.com/users/amitlimaye/received_events","type":"User","site_admin":false},"body":"Merging trireme remote enforcer to mainline ","created_at":"2016-12-14T23:58:22Z","updated_at":"2016-12-15T02:25:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e77415155dd34dc68fd1d3b761d73f22c8cafbbd","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/aporeto-inc/trireme/pulls/105/commits","review_comments_url":"https://api.github.com/repos/aporeto-inc/trireme/pulls/105/comments","review_comment_url":"https://api.github.com/repos/aporeto-inc/trireme/pulls/comments{/number}","comments_url":"https://api.github.com/repos/aporeto-inc/trireme/issues/105/comments","statuses_url":"https://api.github.com/repos/aporeto-inc/trireme/statuses/2f722ed568d3d9276a2d7260d20e36d08777649f","head":{"label":"aporeto-inc:merge_remote_datapath","ref":"merge_remote_datapath","sha":"2f722ed568d3d9276a2d7260d20e36d08777649f","user":{"login":"aporeto-inc","id":15617796,"avatar_url":"https://avatars.githubusercontent.com/u/15617796?v=3","gravatar_id":"","url":"https://api.github.com/users/aporeto-inc","html_url":"https://github.com/aporeto-inc","followers_url":"https://api.github.com/users/aporeto-inc/followers","following_url":"https://api.github.com/users/aporeto-inc/following{/other_user}","gists_url":"https://api.github.com/users/aporeto-inc/gists{/gist_id}","starred_url":"https://api.github.com/users/aporeto-inc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aporeto-inc/subscriptions","organizations_url":"https://api.github.com/users/aporeto-inc/orgs","repos_url":"https://api.github.com/users/aporeto-inc/repos","events_url":"https://api.github.com/users/aporeto-inc/events{/privacy}","received_events_url":"https://api.github.com/users/aporeto-inc/received_events","type":"Organization","site_admin":false},"repo":{"id":71510166,"name":"trireme","full_name":"aporeto-inc/trireme","owner":{"login":"aporeto-inc","id":15617796,"avatar_url":"https://avatars.githubusercontent.com/u/15617796?v=3","gravatar_id":"","url":"https://api.github.com/users/aporeto-inc","html_url":"https://github.com/aporeto-inc","followers_url":"https://api.github.com/users/aporeto-inc/followers","following_url":"https://api.github.com/users/aporeto-inc/following{/other_user}","gists_url":"https://api.github.com/users/aporeto-inc/gists{/gist_id}","starred_url":"https://api.github.com/users/aporeto-inc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aporeto-inc/subscriptions","organizations_url":"https://api.github.com/users/aporeto-inc/orgs","repos_url":"https://api.github.com/users/aporeto-inc/repos","events_url":"https://api.github.com/users/aporeto-inc/events{/privacy}","received_events_url":"https://api.github.com/users/aporeto-inc/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aporeto-inc/trireme","description":"Simple, scalable and secure application segmentation","fork":false,"url":"https://api.github.com/repos/aporeto-inc/trireme","forks_url":"https://api.github.com/repos/aporeto-inc/trireme/forks","keys_url":"https://api.github.com/repos/aporeto-inc/trireme/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aporeto-inc/trireme/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aporeto-inc/trireme/teams","hooks_url":"https://api.github.com/repos/aporeto-inc/trireme/hooks","issue_events_url":"https://api.github.com/repos/aporeto-inc/trireme/issues/events{/number}","events_url":"https://api.github.com/repos/aporeto-inc/trireme/events","assignees_url":"https://api.github.com/repos/aporeto-inc/trireme/assignees{/user}","branches_url":"https://api.github.com/repos/aporeto-inc/trireme/branches{/branch}","tags_url":"https://api.github.com/repos/aporeto-inc/trireme/tags","blobs_url":"https://api.github.com/repos/aporeto-inc/trireme/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aporeto-inc/trireme/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aporeto-inc/trireme/git/refs{/sha}","trees_url":"https://api.github.com/repos/aporeto-inc/trireme/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aporeto-inc/trireme/statuses/{sha}","languages_url":"https://api.github.com/repos/aporeto-inc/trireme/languages","stargazers_url":"https://api.github.com/repos/aporeto-inc/trireme/stargazers","contributors_url":"https://api.github.com/repos/aporeto-inc/trireme/contributors","subscribers_url":"https://api.github.com/repos/aporeto-inc/trireme/subscribers","subscription_url":"https://api.github.com/repos/aporeto-inc/trireme/subscription","commits_url":"https://api.github.com/repos/aporeto-inc/trireme/commits{/sha}","git_commits_url":"https://api.github.com/repos/aporeto-inc/trireme/git/commits{/sha}","comments_url":"https://api.github.com/repos/aporeto-inc/trireme/comments{/number}","issue_comment_url":"https://api.github.com/repos/aporeto-inc/trireme/issues/comments{/number}","contents_url":"https://api.github.com/repos/aporeto-inc/trireme/contents/{+path}","compare_url":"https://api.github.com/repos/aporeto-inc/trireme/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aporeto-inc/trireme/merges","archive_url":"https://api.github.com/repos/aporeto-inc/trireme/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aporeto-inc/trireme/downloads","issues_url":"https://api.github.com/repos/aporeto-inc/trireme/issues{/number}","pulls_url":"https://api.github.com/repos/aporeto-inc/trireme/pulls{/number}","milestones_url":"https://api.github.com/repos/aporeto-inc/trireme/milestones{/number}","notifications_url":"https://api.github.com/repos/aporeto-inc/trireme/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aporeto-inc/trireme/labels{/name}","releases_url":"https://api.github.com/repos/aporeto-inc/trireme/releases{/id}","deployments_url":"https://api.github.com/repos/aporeto-inc/trireme/deployments","created_at":"2016-10-20T22:41:40Z","updated_at":"2016-12-14T06:34:22Z","pushed_at":"2016-12-15T02:25:09Z","git_url":"git://github.com/aporeto-inc/trireme.git","ssh_url":"git@github.com:aporeto-inc/trireme.git","clone_url":"https://github.com/aporeto-inc/trireme.git","svn_url":"https://github.com/aporeto-inc/trireme","homepage":"https://trireme.io","size":20364,"stargazers_count":94,"watchers_count":94,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":5,"forks":9,"open_issues":5,"watchers":94,"default_branch":"master"}},"base":{"label":"aporeto-inc:master","ref":"master","sha":"e4dc5713f59674807cadbb83078032022302ce84","user":{"login":"aporeto-inc","id":15617796,"avatar_url":"https://avatars.githubusercontent.com/u/15617796?v=3","gravatar_id":"","url":"https://api.github.com/users/aporeto-inc","html_url":"https://github.com/aporeto-inc","followers_url":"https://api.github.com/users/aporeto-inc/followers","following_url":"https://api.github.com/users/aporeto-inc/following{/other_user}","gists_url":"https://api.github.com/users/aporeto-inc/gists{/gist_id}","starred_url":"https://api.github.com/users/aporeto-inc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aporeto-inc/subscriptions","organizations_url":"https://api.github.com/users/aporeto-inc/orgs","repos_url":"https://api.github.com/users/aporeto-inc/repos","events_url":"https://api.github.com/users/aporeto-inc/events{/privacy}","received_events_url":"https://api.github.com/users/aporeto-inc/received_events","type":"Organization","site_admin":false},"repo":{"id":71510166,"name":"trireme","full_name":"aporeto-inc/trireme","owner":{"login":"aporeto-inc","id":15617796,"avatar_url":"https://avatars.githubusercontent.com/u/15617796?v=3","gravatar_id":"","url":"https://api.github.com/users/aporeto-inc","html_url":"https://github.com/aporeto-inc","followers_url":"https://api.github.com/users/aporeto-inc/followers","following_url":"https://api.github.com/users/aporeto-inc/following{/other_user}","gists_url":"https://api.github.com/users/aporeto-inc/gists{/gist_id}","starred_url":"https://api.github.com/users/aporeto-inc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aporeto-inc/subscriptions","organizations_url":"https://api.github.com/users/aporeto-inc/orgs","repos_url":"https://api.github.com/users/aporeto-inc/repos","events_url":"https://api.github.com/users/aporeto-inc/events{/privacy}","received_events_url":"https://api.github.com/users/aporeto-inc/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aporeto-inc/trireme","description":"Simple, scalable and secure application segmentation","fork":false,"url":"https://api.github.com/repos/aporeto-inc/trireme","forks_url":"https://api.github.com/repos/aporeto-inc/trireme/forks","keys_url":"https://api.github.com/repos/aporeto-inc/trireme/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aporeto-inc/trireme/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aporeto-inc/trireme/teams","hooks_url":"https://api.github.com/repos/aporeto-inc/trireme/hooks","issue_events_url":"https://api.github.com/repos/aporeto-inc/trireme/issues/events{/number}","events_url":"https://api.github.com/repos/aporeto-inc/trireme/events","assignees_url":"https://api.github.com/repos/aporeto-inc/trireme/assignees{/user}","branches_url":"https://api.github.com/repos/aporeto-inc/trireme/branches{/branch}","tags_url":"https://api.github.com/repos/aporeto-inc/trireme/tags","blobs_url":"https://api.github.com/repos/aporeto-inc/trireme/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aporeto-inc/trireme/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aporeto-inc/trireme/git/refs{/sha}","trees_url":"https://api.github.com/repos/aporeto-inc/trireme/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aporeto-inc/trireme/statuses/{sha}","languages_url":"https://api.github.com/repos/aporeto-inc/trireme/languages","stargazers_url":"https://api.github.com/repos/aporeto-inc/trireme/stargazers","contributors_url":"https://api.github.com/repos/aporeto-inc/trireme/contributors","subscribers_url":"https://api.github.com/repos/aporeto-inc/trireme/subscribers","subscription_url":"https://api.github.com/repos/aporeto-inc/trireme/subscription","commits_url":"https://api.github.com/repos/aporeto-inc/trireme/commits{/sha}","git_commits_url":"https://api.github.com/repos/aporeto-inc/trireme/git/commits{/sha}","comments_url":"https://api.github.com/repos/aporeto-inc/trireme/comments{/number}","issue_comment_url":"https://api.github.com/repos/aporeto-inc/trireme/issues/comments{/number}","contents_url":"https://api.github.com/repos/aporeto-inc/trireme/contents/{+path}","compare_url":"https://api.github.com/repos/aporeto-inc/trireme/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aporeto-inc/trireme/merges","archive_url":"https://api.github.com/repos/aporeto-inc/trireme/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aporeto-inc/trireme/downloads","issues_url":"https://api.github.com/repos/aporeto-inc/trireme/issues{/number}","pulls_url":"https://api.github.com/repos/aporeto-inc/trireme/pulls{/number}","milestones_url":"https://api.github.com/repos/aporeto-inc/trireme/milestones{/number}","notifications_url":"https://api.github.com/repos/aporeto-inc/trireme/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aporeto-inc/trireme/labels{/name}","releases_url":"https://api.github.com/repos/aporeto-inc/trireme/releases{/id}","deployments_url":"https://api.github.com/repos/aporeto-inc/trireme/deployments","created_at":"2016-10-20T22:41:40Z","updated_at":"2016-12-14T06:34:22Z","pushed_at":"2016-12-15T02:25:09Z","git_url":"git://github.com/aporeto-inc/trireme.git","ssh_url":"git@github.com:aporeto-inc/trireme.git","clone_url":"https://github.com/aporeto-inc/trireme.git","svn_url":"https://github.com/aporeto-inc/trireme","homepage":"https://trireme.io","size":20364,"stargazers_count":94,"watchers_count":94,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":5,"forks":9,"open_issues":5,"watchers":94,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/aporeto-inc/trireme/pulls/105"},"html":{"href":"https://github.com/aporeto-inc/trireme/pull/105"},"issue":{"href":"https://api.github.com/repos/aporeto-inc/trireme/issues/105"},"comments":{"href":"https://api.github.com/repos/aporeto-inc/trireme/issues/105/comments"},"review_comments":{"href":"https://api.github.com/repos/aporeto-inc/trireme/pulls/105/comments"},"review_comment":{"href":"https://api.github.com/repos/aporeto-inc/trireme/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/aporeto-inc/trireme/pulls/105/commits"},"statuses":{"href":"https://api.github.com/repos/aporeto-inc/trireme/statuses/2f722ed568d3d9276a2d7260d20e36d08777649f"}}}}
{"actor":{"display_login":"Dogild"}}