{"action":"closed","number":2,"pull_request":{"url":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/pulls/2","id":56985971,"html_url":"https://github.com/lumanetworks/go-tcp-proxy/pull/2","diff_url":"https://github.com/lumanetworks/go-tcp-proxy/pull/2.diff","patch_url":"https://github.com/lumanetworks/go-tcp-proxy/pull/2.patch","issue_url":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/issues/2","number":2,"state":"closed","locked":false,"title":"Refactor to package","user":{"login":"heewa","id":232685,"avatar_url":"https://avatars.githubusercontent.com/u/232685?v=3","gravatar_id":"","url":"https://api.github.com/users/heewa","html_url":"https://github.com/heewa","followers_url":"https://api.github.com/users/heewa/followers","following_url":"https://api.github.com/users/heewa/following{/other_user}","gists_url":"https://api.github.com/users/heewa/gists{/gist_id}","starred_url":"https://api.github.com/users/heewa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/heewa/subscriptions","organizations_url":"https://api.github.com/users/heewa/orgs","repos_url":"https://api.github.com/users/heewa/repos","events_url":"https://api.github.com/users/heewa/events{/privacy}","received_events_url":"https://api.github.com/users/heewa/received_events","type":"User","site_admin":false},"body":"This should have the command behave the same, except you now need to run it like: `go run cmd/tcp-proxy/main.go`. But now you can also import and use this as a package, with all the stuff that are cmdline args in the program as parameters and settings on an instance of a `Proxy` struct (with sane defaults). Otherwise the behavior (and the meat of the code) is unchanged.\r\n\r\n```go\r\npackage some-other-project\r\n\r\nimport \"github.com/lumanetworks/go-tcp-proxy\"\r\n\r\nfunc Yay(localConnection *net.TCPConn, localAddress, remoteAddress *net.TCPAddr) {\r\n    p := proxy.New(localConnection, localAddress, remoteAddress)\r\n    p.Log.Color = true\r\n    p.Nagles = true\r\n    p.Matcher = myMatcher\r\n\r\n    p.Start()\r\n}\r\n```\r\n\r\nChanges:\r\n\r\n* split the terminal related stuff (cmdline args, input, output) into\r\n  a main file, outside the main package\r\n* put the Proxy struct into a package so external users can use it\r\n  directly\r\n* set options that affect a Proxy instance on the struct, so they're not\r\n  globals, and work for third party usage\r\n* split logging into an interface and a struct that implements it, so\r\n  external users can pass in their own to control output\r\n* unify all output through loggers","created_at":"2016-01-23T20:41:31Z","updated_at":"2016-01-24T00:05:21Z","closed_at":"2016-01-24T00:05:21Z","merged_at":"2016-01-24T00:05:21Z","merge_commit_sha":"7d20a820ffcf40d034e3282d72d515baec0572ef","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/pulls/2/commits","review_comments_url":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/pulls/2/comments","review_comment_url":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/issues/2/comments","statuses_url":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/statuses/f15e7624e3c1fd4e1873c90629c02e584bf8b26b","head":{"label":"heewa:refactor-to-package","ref":"refactor-to-package","sha":"f15e7624e3c1fd4e1873c90629c02e584bf8b26b","user":{"login":"heewa","id":232685,"avatar_url":"https://avatars.githubusercontent.com/u/232685?v=3","gravatar_id":"","url":"https://api.github.com/users/heewa","html_url":"https://github.com/heewa","followers_url":"https://api.github.com/users/heewa/followers","following_url":"https://api.github.com/users/heewa/following{/other_user}","gists_url":"https://api.github.com/users/heewa/gists{/gist_id}","starred_url":"https://api.github.com/users/heewa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/heewa/subscriptions","organizations_url":"https://api.github.com/users/heewa/orgs","repos_url":"https://api.github.com/users/heewa/repos","events_url":"https://api.github.com/users/heewa/events{/privacy}","received_events_url":"https://api.github.com/users/heewa/received_events","type":"User","site_admin":false},"repo":{"id":50224540,"name":"go-tcp-proxy","full_name":"heewa/go-tcp-proxy","owner":{"login":"heewa","id":232685,"avatar_url":"https://avatars.githubusercontent.com/u/232685?v=3","gravatar_id":"","url":"https://api.github.com/users/heewa","html_url":"https://github.com/heewa","followers_url":"https://api.github.com/users/heewa/followers","following_url":"https://api.github.com/users/heewa/following{/other_user}","gists_url":"https://api.github.com/users/heewa/gists{/gist_id}","starred_url":"https://api.github.com/users/heewa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/heewa/subscriptions","organizations_url":"https://api.github.com/users/heewa/orgs","repos_url":"https://api.github.com/users/heewa/repos","events_url":"https://api.github.com/users/heewa/events{/privacy}","received_events_url":"https://api.github.com/users/heewa/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/heewa/go-tcp-proxy","description":"A small TCP proxy written in Go","fork":true,"url":"https://api.github.com/repos/heewa/go-tcp-proxy","forks_url":"https://api.github.com/repos/heewa/go-tcp-proxy/forks","keys_url":"https://api.github.com/repos/heewa/go-tcp-proxy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/heewa/go-tcp-proxy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/heewa/go-tcp-proxy/teams","hooks_url":"https://api.github.com/repos/heewa/go-tcp-proxy/hooks","issue_events_url":"https://api.github.com/repos/heewa/go-tcp-proxy/issues/events{/number}","events_url":"https://api.github.com/repos/heewa/go-tcp-proxy/events","assignees_url":"https://api.github.com/repos/heewa/go-tcp-proxy/assignees{/user}","branches_url":"https://api.github.com/repos/heewa/go-tcp-proxy/branches{/branch}","tags_url":"https://api.github.com/repos/heewa/go-tcp-proxy/tags","blobs_url":"https://api.github.com/repos/heewa/go-tcp-proxy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/heewa/go-tcp-proxy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/heewa/go-tcp-proxy/git/refs{/sha}","trees_url":"https://api.github.com/repos/heewa/go-tcp-proxy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/heewa/go-tcp-proxy/statuses/{sha}","languages_url":"https://api.github.com/repos/heewa/go-tcp-proxy/languages","stargazers_url":"https://api.github.com/repos/heewa/go-tcp-proxy/stargazers","contributors_url":"https://api.github.com/repos/heewa/go-tcp-proxy/contributors","subscribers_url":"https://api.github.com/repos/heewa/go-tcp-proxy/subscribers","subscription_url":"https://api.github.com/repos/heewa/go-tcp-proxy/subscription","commits_url":"https://api.github.com/repos/heewa/go-tcp-proxy/commits{/sha}","git_commits_url":"https://api.github.com/repos/heewa/go-tcp-proxy/git/commits{/sha}","comments_url":"https://api.github.com/repos/heewa/go-tcp-proxy/comments{/number}","issue_comment_url":"https://api.github.com/repos/heewa/go-tcp-proxy/issues/comments{/number}","contents_url":"https://api.github.com/repos/heewa/go-tcp-proxy/contents/{+path}","compare_url":"https://api.github.com/repos/heewa/go-tcp-proxy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/heewa/go-tcp-proxy/merges","archive_url":"https://api.github.com/repos/heewa/go-tcp-proxy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/heewa/go-tcp-proxy/downloads","issues_url":"https://api.github.com/repos/heewa/go-tcp-proxy/issues{/number}","pulls_url":"https://api.github.com/repos/heewa/go-tcp-proxy/pulls{/number}","milestones_url":"https://api.github.com/repos/heewa/go-tcp-proxy/milestones{/number}","notifications_url":"https://api.github.com/repos/heewa/go-tcp-proxy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/heewa/go-tcp-proxy/labels{/name}","releases_url":"https://api.github.com/repos/heewa/go-tcp-proxy/releases{/id}","deployments_url":"https://api.github.com/repos/heewa/go-tcp-proxy/deployments","created_at":"2016-01-23T05:11:00Z","updated_at":"2016-01-23T05:11:01Z","pushed_at":"2016-01-23T20:35:19Z","git_url":"git://github.com/heewa/go-tcp-proxy.git","ssh_url":"git@github.com:heewa/go-tcp-proxy.git","clone_url":"https://github.com/heewa/go-tcp-proxy.git","svn_url":"https://github.com/heewa/go-tcp-proxy","homepage":"","size":9,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"lumanetworks:master","ref":"master","sha":"d10f3fc2097b84bcdbeaffd032f9fe75c0019ae5","user":{"login":"lumanetworks","id":5642590,"avatar_url":"https://avatars.githubusercontent.com/u/5642590?v=3","gravatar_id":"","url":"https://api.github.com/users/lumanetworks","html_url":"https://github.com/lumanetworks","followers_url":"https://api.github.com/users/lumanetworks/followers","following_url":"https://api.github.com/users/lumanetworks/following{/other_user}","gists_url":"https://api.github.com/users/lumanetworks/gists{/gist_id}","starred_url":"https://api.github.com/users/lumanetworks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lumanetworks/subscriptions","organizations_url":"https://api.github.com/users/lumanetworks/orgs","repos_url":"https://api.github.com/users/lumanetworks/repos","events_url":"https://api.github.com/users/lumanetworks/events{/privacy}","received_events_url":"https://api.github.com/users/lumanetworks/received_events","type":"Organization","site_admin":false},"repo":{"id":24621562,"name":"go-tcp-proxy","full_name":"lumanetworks/go-tcp-proxy","owner":{"login":"lumanetworks","id":5642590,"avatar_url":"https://avatars.githubusercontent.com/u/5642590?v=3","gravatar_id":"","url":"https://api.github.com/users/lumanetworks","html_url":"https://github.com/lumanetworks","followers_url":"https://api.github.com/users/lumanetworks/followers","following_url":"https://api.github.com/users/lumanetworks/following{/other_user}","gists_url":"https://api.github.com/users/lumanetworks/gists{/gist_id}","starred_url":"https://api.github.com/users/lumanetworks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lumanetworks/subscriptions","organizations_url":"https://api.github.com/users/lumanetworks/orgs","repos_url":"https://api.github.com/users/lumanetworks/repos","events_url":"https://api.github.com/users/lumanetworks/events{/privacy}","received_events_url":"https://api.github.com/users/lumanetworks/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/lumanetworks/go-tcp-proxy","description":"A small TCP proxy written in Go","fork":false,"url":"https://api.github.com/repos/lumanetworks/go-tcp-proxy","forks_url":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/forks","keys_url":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/teams","hooks_url":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/hooks","issue_events_url":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/issues/events{/number}","events_url":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/events","assignees_url":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/assignees{/user}","branches_url":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/branches{/branch}","tags_url":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/tags","blobs_url":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/git/refs{/sha}","trees_url":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/statuses/{sha}","languages_url":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/languages","stargazers_url":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/stargazers","contributors_url":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/contributors","subscribers_url":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/subscribers","subscription_url":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/subscription","commits_url":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/commits{/sha}","git_commits_url":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/git/commits{/sha}","comments_url":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/comments{/number}","issue_comment_url":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/issues/comments{/number}","contents_url":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/contents/{+path}","compare_url":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/merges","archive_url":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/downloads","issues_url":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/issues{/number}","pulls_url":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/pulls{/number}","milestones_url":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/milestones{/number}","notifications_url":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/labels{/name}","releases_url":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/releases{/id}","deployments_url":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/deployments","created_at":"2014-09-30T02:37:02Z","updated_at":"2016-01-21T14:26:29Z","pushed_at":"2016-01-24T00:05:22Z","git_url":"git://github.com/lumanetworks/go-tcp-proxy.git","ssh_url":"git@github.com:lumanetworks/go-tcp-proxy.git","clone_url":"https://github.com/lumanetworks/go-tcp-proxy.git","svn_url":"https://github.com/lumanetworks/go-tcp-proxy","homepage":"","size":9,"stargazers_count":58,"watchers_count":58,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":17,"mirror_url":null,"open_issues_count":0,"forks":17,"open_issues":0,"watchers":58,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/pulls/2"},"html":{"href":"https://github.com/lumanetworks/go-tcp-proxy/pull/2"},"issue":{"href":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/issues/2"},"comments":{"href":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/lumanetworks/go-tcp-proxy/statuses/f15e7624e3c1fd4e1873c90629c02e584bf8b26b"}},"merged":true,"mergeable":null,"mergeable_state":"unknown","merged_by":{"login":"jpillora","id":633843,"avatar_url":"https://avatars.githubusercontent.com/u/633843?v=3","gravatar_id":"","url":"https://api.github.com/users/jpillora","html_url":"https://github.com/jpillora","followers_url":"https://api.github.com/users/jpillora/followers","following_url":"https://api.github.com/users/jpillora/following{/other_user}","gists_url":"https://api.github.com/users/jpillora/gists{/gist_id}","starred_url":"https://api.github.com/users/jpillora/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jpillora/subscriptions","organizations_url":"https://api.github.com/users/jpillora/orgs","repos_url":"https://api.github.com/users/jpillora/repos","events_url":"https://api.github.com/users/jpillora/events{/privacy}","received_events_url":"https://api.github.com/users/jpillora/received_events","type":"User","site_admin":false},"comments":0,"review_comments":0,"commits":3,"additions":336,"deletions":243,"changed_files":5}}