{"action":"created","comment":{"url":"https://api.github.com/repos/rtty122333/Foldex/pulls/comments/65857191","id":65857191,"diff_hunk":"@@ -0,0 +1,78 @@\n+import socket\n+from twisted.protocols.portforward import ProxyFactory\n+from twisted.internet.protocol import Protocol,Factory\n+from twisted.internet import reactor\n+from twisted.internet.endpoints import TCP4ServerEndpoint\n+\n+def findFreePort():\n+    \"\"\"\n+    get a random avalible port\n+    \"\"\"\n+    try:\n+        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n+        s.bind(('localhost', 0))\n+        addr, port = s.getsockname()\n+        s.close()\n+    except socket.error as msg:\n+        log.error(msg)\n+        s.close()\n+    else:\n+        return port\n+\n+class Singleton(object):\n+    def __new__(cls, *args, **kwargs):\n+        if not hasattr(cls, '_inst'):\n+            cls._inst=super(Singleton, cls).__new__(cls, *args, **kwargs)\n+        return cls._inst\n+\n+class Proxy():\n+\n+    def __init__(self, dest_ip, dest_port, local_ip=''):\n+        self.tmpport = findFreePort()\n+        self.new_proxy = ProxyFactory(dest_ip, dest_port)\n+        self.endpoint = TCP4ServerEndpoint(reactor, self.tmpport)\n+        self.endpoint.listen(self.new_proxy)\n+\n+    def getport(self):\n+        return self.tmpport\n+\n+class ForwardInst(Singleton):\n+\n+    def __init__(self):\n+        self.forwardlist = {}\n+\n+    def addProxy(self, dest_ip, dest_port, local_ip=''):\n+        self.proxyinst = Proxy(dest_ip, dest_port, local_ip)\n+        self.tmpport = self.proxyinst.getport()\n+        self.forwardlist[self.tmpport] = self.proxyinst\n+        return self.tmpport\n+\n+    def deleteProxy(self, locolport):","path":"server/twist_forward.py","position":50,"original_position":50,"commit_id":"84f0dfa09711f9f0fa89229aac1d5f5a847339a3","original_commit_id":"84f0dfa09711f9f0fa89229aac1d5f5a847339a3","user":{"login":"solarsail","id":3445141,"avatar_url":"https://avatars.githubusercontent.com/u/3445141?v=3","gravatar_id":"","url":"https://api.github.com/users/solarsail","html_url":"https://github.com/solarsail","followers_url":"https://api.github.com/users/solarsail/followers","following_url":"https://api.github.com/users/solarsail/following{/other_user}","gists_url":"https://api.github.com/users/solarsail/gists{/gist_id}","starred_url":"https://api.github.com/users/solarsail/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/solarsail/subscriptions","organizations_url":"https://api.github.com/users/solarsail/orgs","repos_url":"https://api.github.com/users/solarsail/repos","events_url":"https://api.github.com/users/solarsail/events{/privacy}","received_events_url":"https://api.github.com/users/solarsail/received_events","type":"User","site_admin":false},"body":"参数拼错了","created_at":"2016-06-06T09:03:12Z","updated_at":"2016-06-06T09:03:12Z","html_url":"https://github.com/rtty122333/Foldex/pull/17#discussion_r65857191","pull_request_url":"https://api.github.com/repos/rtty122333/Foldex/pulls/17","_links":{"self":{"href":"https://api.github.com/repos/rtty122333/Foldex/pulls/comments/65857191"},"html":{"href":"https://github.com/rtty122333/Foldex/pull/17#discussion_r65857191"},"pull_request":{"href":"https://api.github.com/repos/rtty122333/Foldex/pulls/17"}}},"pull_request":{"url":"https://api.github.com/repos/rtty122333/Foldex/pulls/17","id":72674393,"html_url":"https://github.com/rtty122333/Foldex/pull/17","diff_url":"https://github.com/rtty122333/Foldex/pull/17.diff","patch_url":"https://github.com/rtty122333/Foldex/pull/17.patch","issue_url":"https://api.github.com/repos/rtty122333/Foldex/issues/17","number":17,"state":"open","locked":false,"title":"change port forward to twisted","user":{"login":"rtty122333","id":4454630,"avatar_url":"https://avatars.githubusercontent.com/u/4454630?v=3","gravatar_id":"","url":"https://api.github.com/users/rtty122333","html_url":"https://github.com/rtty122333","followers_url":"https://api.github.com/users/rtty122333/followers","following_url":"https://api.github.com/users/rtty122333/following{/other_user}","gists_url":"https://api.github.com/users/rtty122333/gists{/gist_id}","starred_url":"https://api.github.com/users/rtty122333/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rtty122333/subscriptions","organizations_url":"https://api.github.com/users/rtty122333/orgs","repos_url":"https://api.github.com/users/rtty122333/repos","events_url":"https://api.github.com/users/rtty122333/events{/privacy}","received_events_url":"https://api.github.com/users/rtty122333/received_events","type":"User","site_admin":false},"body":"#11 @solarsail \r\n\r\n把端口转发功能切换到用twisted的portforward实现\r\n\r\n测试方法：\r\n\r\n启动foldex.py，用客户端连接虚拟机。","created_at":"2016-06-06T08:45:57Z","updated_at":"2016-06-06T09:03:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"241e424b37e9782291acc9a52374e5032d6a5d1e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/rtty122333/Foldex/pulls/17/commits","review_comments_url":"https://api.github.com/repos/rtty122333/Foldex/pulls/17/comments","review_comment_url":"https://api.github.com/repos/rtty122333/Foldex/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rtty122333/Foldex/issues/17/comments","statuses_url":"https://api.github.com/repos/rtty122333/Foldex/statuses/84f0dfa09711f9f0fa89229aac1d5f5a847339a3","head":{"label":"rtty122333:twisted_forward","ref":"twisted_forward","sha":"84f0dfa09711f9f0fa89229aac1d5f5a847339a3","user":{"login":"rtty122333","id":4454630,"avatar_url":"https://avatars.githubusercontent.com/u/4454630?v=3","gravatar_id":"","url":"https://api.github.com/users/rtty122333","html_url":"https://github.com/rtty122333","followers_url":"https://api.github.com/users/rtty122333/followers","following_url":"https://api.github.com/users/rtty122333/following{/other_user}","gists_url":"https://api.github.com/users/rtty122333/gists{/gist_id}","starred_url":"https://api.github.com/users/rtty122333/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rtty122333/subscriptions","organizations_url":"https://api.github.com/users/rtty122333/orgs","repos_url":"https://api.github.com/users/rtty122333/repos","events_url":"https://api.github.com/users/rtty122333/events{/privacy}","received_events_url":"https://api.github.com/users/rtty122333/received_events","type":"User","site_admin":false},"repo":{"id":54438004,"name":"Foldex","full_name":"rtty122333/Foldex","owner":{"login":"rtty122333","id":4454630,"avatar_url":"https://avatars.githubusercontent.com/u/4454630?v=3","gravatar_id":"","url":"https://api.github.com/users/rtty122333","html_url":"https://github.com/rtty122333","followers_url":"https://api.github.com/users/rtty122333/followers","following_url":"https://api.github.com/users/rtty122333/following{/other_user}","gists_url":"https://api.github.com/users/rtty122333/gists{/gist_id}","starred_url":"https://api.github.com/users/rtty122333/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rtty122333/subscriptions","organizations_url":"https://api.github.com/users/rtty122333/orgs","repos_url":"https://api.github.com/users/rtty122333/repos","events_url":"https://api.github.com/users/rtty122333/events{/privacy}","received_events_url":"https://api.github.com/users/rtty122333/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rtty122333/Foldex","description":"","fork":false,"url":"https://api.github.com/repos/rtty122333/Foldex","forks_url":"https://api.github.com/repos/rtty122333/Foldex/forks","keys_url":"https://api.github.com/repos/rtty122333/Foldex/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rtty122333/Foldex/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rtty122333/Foldex/teams","hooks_url":"https://api.github.com/repos/rtty122333/Foldex/hooks","issue_events_url":"https://api.github.com/repos/rtty122333/Foldex/issues/events{/number}","events_url":"https://api.github.com/repos/rtty122333/Foldex/events","assignees_url":"https://api.github.com/repos/rtty122333/Foldex/assignees{/user}","branches_url":"https://api.github.com/repos/rtty122333/Foldex/branches{/branch}","tags_url":"https://api.github.com/repos/rtty122333/Foldex/tags","blobs_url":"https://api.github.com/repos/rtty122333/Foldex/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rtty122333/Foldex/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rtty122333/Foldex/git/refs{/sha}","trees_url":"https://api.github.com/repos/rtty122333/Foldex/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rtty122333/Foldex/statuses/{sha}","languages_url":"https://api.github.com/repos/rtty122333/Foldex/languages","stargazers_url":"https://api.github.com/repos/rtty122333/Foldex/stargazers","contributors_url":"https://api.github.com/repos/rtty122333/Foldex/contributors","subscribers_url":"https://api.github.com/repos/rtty122333/Foldex/subscribers","subscription_url":"https://api.github.com/repos/rtty122333/Foldex/subscription","commits_url":"https://api.github.com/repos/rtty122333/Foldex/commits{/sha}","git_commits_url":"https://api.github.com/repos/rtty122333/Foldex/git/commits{/sha}","comments_url":"https://api.github.com/repos/rtty122333/Foldex/comments{/number}","issue_comment_url":"https://api.github.com/repos/rtty122333/Foldex/issues/comments{/number}","contents_url":"https://api.github.com/repos/rtty122333/Foldex/contents/{+path}","compare_url":"https://api.github.com/repos/rtty122333/Foldex/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rtty122333/Foldex/merges","archive_url":"https://api.github.com/repos/rtty122333/Foldex/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rtty122333/Foldex/downloads","issues_url":"https://api.github.com/repos/rtty122333/Foldex/issues{/number}","pulls_url":"https://api.github.com/repos/rtty122333/Foldex/pulls{/number}","milestones_url":"https://api.github.com/repos/rtty122333/Foldex/milestones{/number}","notifications_url":"https://api.github.com/repos/rtty122333/Foldex/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rtty122333/Foldex/labels{/name}","releases_url":"https://api.github.com/repos/rtty122333/Foldex/releases{/id}","deployments_url":"https://api.github.com/repos/rtty122333/Foldex/deployments","created_at":"2016-03-22T02:11:42Z","updated_at":"2016-03-24T08:33:50Z","pushed_at":"2016-06-06T08:51:34Z","git_url":"git://github.com/rtty122333/Foldex.git","ssh_url":"git@github.com:rtty122333/Foldex.git","clone_url":"https://github.com/rtty122333/Foldex.git","svn_url":"https://github.com/rtty122333/Foldex","homepage":null,"size":44,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":5,"forks":1,"open_issues":5,"watchers":0,"default_branch":"master"}},"base":{"label":"rtty122333:dev","ref":"dev","sha":"340621ec6021d6349b89ca31ec763feeb4d8b7c7","user":{"login":"rtty122333","id":4454630,"avatar_url":"https://avatars.githubusercontent.com/u/4454630?v=3","gravatar_id":"","url":"https://api.github.com/users/rtty122333","html_url":"https://github.com/rtty122333","followers_url":"https://api.github.com/users/rtty122333/followers","following_url":"https://api.github.com/users/rtty122333/following{/other_user}","gists_url":"https://api.github.com/users/rtty122333/gists{/gist_id}","starred_url":"https://api.github.com/users/rtty122333/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rtty122333/subscriptions","organizations_url":"https://api.github.com/users/rtty122333/orgs","repos_url":"https://api.github.com/users/rtty122333/repos","events_url":"https://api.github.com/users/rtty122333/events{/privacy}","received_events_url":"https://api.github.com/users/rtty122333/received_events","type":"User","site_admin":false},"repo":{"id":54438004,"name":"Foldex","full_name":"rtty122333/Foldex","owner":{"login":"rtty122333","id":4454630,"avatar_url":"https://avatars.githubusercontent.com/u/4454630?v=3","gravatar_id":"","url":"https://api.github.com/users/rtty122333","html_url":"https://github.com/rtty122333","followers_url":"https://api.github.com/users/rtty122333/followers","following_url":"https://api.github.com/users/rtty122333/following{/other_user}","gists_url":"https://api.github.com/users/rtty122333/gists{/gist_id}","starred_url":"https://api.github.com/users/rtty122333/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rtty122333/subscriptions","organizations_url":"https://api.github.com/users/rtty122333/orgs","repos_url":"https://api.github.com/users/rtty122333/repos","events_url":"https://api.github.com/users/rtty122333/events{/privacy}","received_events_url":"https://api.github.com/users/rtty122333/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rtty122333/Foldex","description":"","fork":false,"url":"https://api.github.com/repos/rtty122333/Foldex","forks_url":"https://api.github.com/repos/rtty122333/Foldex/forks","keys_url":"https://api.github.com/repos/rtty122333/Foldex/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rtty122333/Foldex/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rtty122333/Foldex/teams","hooks_url":"https://api.github.com/repos/rtty122333/Foldex/hooks","issue_events_url":"https://api.github.com/repos/rtty122333/Foldex/issues/events{/number}","events_url":"https://api.github.com/repos/rtty122333/Foldex/events","assignees_url":"https://api.github.com/repos/rtty122333/Foldex/assignees{/user}","branches_url":"https://api.github.com/repos/rtty122333/Foldex/branches{/branch}","tags_url":"https://api.github.com/repos/rtty122333/Foldex/tags","blobs_url":"https://api.github.com/repos/rtty122333/Foldex/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rtty122333/Foldex/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rtty122333/Foldex/git/refs{/sha}","trees_url":"https://api.github.com/repos/rtty122333/Foldex/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rtty122333/Foldex/statuses/{sha}","languages_url":"https://api.github.com/repos/rtty122333/Foldex/languages","stargazers_url":"https://api.github.com/repos/rtty122333/Foldex/stargazers","contributors_url":"https://api.github.com/repos/rtty122333/Foldex/contributors","subscribers_url":"https://api.github.com/repos/rtty122333/Foldex/subscribers","subscription_url":"https://api.github.com/repos/rtty122333/Foldex/subscription","commits_url":"https://api.github.com/repos/rtty122333/Foldex/commits{/sha}","git_commits_url":"https://api.github.com/repos/rtty122333/Foldex/git/commits{/sha}","comments_url":"https://api.github.com/repos/rtty122333/Foldex/comments{/number}","issue_comment_url":"https://api.github.com/repos/rtty122333/Foldex/issues/comments{/number}","contents_url":"https://api.github.com/repos/rtty122333/Foldex/contents/{+path}","compare_url":"https://api.github.com/repos/rtty122333/Foldex/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rtty122333/Foldex/merges","archive_url":"https://api.github.com/repos/rtty122333/Foldex/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rtty122333/Foldex/downloads","issues_url":"https://api.github.com/repos/rtty122333/Foldex/issues{/number}","pulls_url":"https://api.github.com/repos/rtty122333/Foldex/pulls{/number}","milestones_url":"https://api.github.com/repos/rtty122333/Foldex/milestones{/number}","notifications_url":"https://api.github.com/repos/rtty122333/Foldex/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rtty122333/Foldex/labels{/name}","releases_url":"https://api.github.com/repos/rtty122333/Foldex/releases{/id}","deployments_url":"https://api.github.com/repos/rtty122333/Foldex/deployments","created_at":"2016-03-22T02:11:42Z","updated_at":"2016-03-24T08:33:50Z","pushed_at":"2016-06-06T08:51:34Z","git_url":"git://github.com/rtty122333/Foldex.git","ssh_url":"git@github.com:rtty122333/Foldex.git","clone_url":"https://github.com/rtty122333/Foldex.git","svn_url":"https://github.com/rtty122333/Foldex","homepage":null,"size":44,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":5,"forks":1,"open_issues":5,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rtty122333/Foldex/pulls/17"},"html":{"href":"https://github.com/rtty122333/Foldex/pull/17"},"issue":{"href":"https://api.github.com/repos/rtty122333/Foldex/issues/17"},"comments":{"href":"https://api.github.com/repos/rtty122333/Foldex/issues/17/comments"},"review_comments":{"href":"https://api.github.com/repos/rtty122333/Foldex/pulls/17/comments"},"review_comment":{"href":"https://api.github.com/repos/rtty122333/Foldex/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rtty122333/Foldex/pulls/17/commits"},"statuses":{"href":"https://api.github.com/repos/rtty122333/Foldex/statuses/84f0dfa09711f9f0fa89229aac1d5f5a847339a3"}}}}
{"actor":{"display_login":"solarsail"}}