{"action":"created","comment":{"url":"https://api.github.com/repos/mc-server/MCServer/pulls/comments/22882532","id":22882532,"diff_hunk":"@@ -0,0 +1,1259 @@\n+\n+// Network.cpp\n+\n+// Implements the classes used for the Network API\n+\n+#include \"Globals.h\"\n+#include \"Network.h\"\n+#include <event2/event.h>\n+#include <event2/thread.h>\n+#include <event2/bufferevent.h>\n+#include <event2/dns.h>\n+#include <event2/listener.h>\n+#include <thread>\n+#include \"Event.h\"\n+#include \"CriticalSection.h\"\n+\n+\n+\n+\n+\n+////////////////////////////////////////////////////////////////////////////////\n+// Class definitions:\n+\n+/** Holds information about an in-progress Hostname-to-IP lookup. */\n+class cHostnameLookup\n+{\n+\t/** The callbacks to call for resolved names / errors. */\n+\tcNetwork::cResolveNameCallbacksPtr m_Callbacks;\n+\n+\t/** The hostname that was queried (needed for the callbacks). */\n+\tAString m_Hostname;\n+\n+\tstatic void Callback(int a_ErrCode, struct evutil_addrinfo * a_Addr, void * a_Self);\n+\n+public:\n+\tcHostnameLookup(const AString & a_Hostname, cNetwork::cResolveNameCallbacksPtr a_Callbacks);\n+};\n+typedef SharedPtr<cHostnameLookup> cHostnameLookupPtr;\n+typedef std::vector<cHostnameLookupPtr> cHostnameLookupPtrs;\n+\n+\n+\n+\n+\n+/** Holds information about an in-progress IP-to-Hostname lookup. */\n+class cIPLookup\n+{\n+\t/** The callbacks to call for resolved names / errors. */\n+\tcNetwork::cResolveNameCallbacksPtr m_Callbacks;\n+\n+\t/** The IP that was queried (needed for the callbacks). */\n+\tAString m_IP;\n+\n+\tstatic void Callback(int a_Result, char a_Type, int a_Count, int a_Ttl, void * a_Addresses, void * a_Self);\n+\n+public:\n+\tcIPLookup(const AString & a_IP, cNetwork::cResolveNameCallbacksPtr a_Callbacks);\n+};\n+typedef SharedPtr<cIPLookup> cIPLookupPtr;\n+typedef std::vector<cIPLookupPtr> cIPLookupPtrs;\n+\n+\n+\n+\n+\n+// fwd:\n+class cServerHandleImpl;\n+\n+\n+\n+\n+\n+/** Implements the cTCPLink details so that it can represent the single connection between two endpoints. */\n+class cTCPLinkImpl:\n+\tpublic cTCPLink\n+{\n+\ttypedef cTCPLink super;\n+\tfriend class cServerHandleImpl;\n+\n+public:\n+\t/** Creates a new link to be queued to connect to a specified host:port.\n+\tUsed for outgoing connections created using cNetwork::Connect().\n+\tCall Connect() first, before using the link. */\n+\tcTCPLinkImpl(const cCallbacksPtr a_LinkCallbacks);\n+\n+\t/** Creates a new link based on the given socket.\n+\tUsed for connections accepted in a server using cNetwork::Listen().\n+\ta_Address and a_AddrLen describe the remote peer that has connected. */\n+\tcTCPLinkImpl(evutil_socket_t a_Socket, cCallbacksPtr a_LinkCallbacks, cServerHandleImpl * a_Server, const sockaddr * a_Address, int a_AddrLen);","path":"src/OSSupport/Network.cpp","position":89,"original_position":89,"commit_id":"8ec845071cbef50e8e2150f02b4b6a5b4ce70528","original_commit_id":"8ec845071cbef50e8e2150f02b4b6a5b4ce70528","user":{"login":"worktycho","id":2102806,"avatar_url":"https://avatars.githubusercontent.com/u/2102806?v=3","gravatar_id":"","url":"https://api.github.com/users/worktycho","html_url":"https://github.com/worktycho","followers_url":"https://api.github.com/users/worktycho/followers","following_url":"https://api.github.com/users/worktycho/following{/other_user}","gists_url":"https://api.github.com/users/worktycho/gists{/gist_id}","starred_url":"https://api.github.com/users/worktycho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/worktycho/subscriptions","organizations_url":"https://api.github.com/users/worktycho/orgs","repos_url":"https://api.github.com/users/worktycho/repos","events_url":"https://api.github.com/users/worktycho/events{/privacy}","received_events_url":"https://api.github.com/users/worktycho/received_events","type":"User","site_admin":false},"body":"It would probably be better if this constructor was private and cNetwork::Connect was moved to this class.\r\n","created_at":"2015-01-13T18:27:42Z","updated_at":"2015-01-13T18:27:42Z","html_url":"https://github.com/mc-server/MCServer/pull/1701#discussion_r22882532","pull_request_url":"https://api.github.com/repos/mc-server/MCServer/pulls/1701","_links":{"self":{"href":"https://api.github.com/repos/mc-server/MCServer/pulls/comments/22882532"},"html":{"href":"https://github.com/mc-server/MCServer/pull/1701#discussion_r22882532"},"pull_request":{"href":"https://api.github.com/repos/mc-server/MCServer/pulls/1701"}}},"pull_request":{"url":"https://api.github.com/repos/mc-server/MCServer/pulls/1701","id":27091413,"html_url":"https://github.com/mc-server/MCServer/pull/1701","diff_url":"https://github.com/mc-server/MCServer/pull/1701.diff","patch_url":"https://github.com/mc-server/MCServer/pull/1701.patch","issue_url":"https://api.github.com/repos/mc-server/MCServer/issues/1701","number":1701,"state":"open","locked":false,"title":"LibEvent-based socket API","user":{"login":"madmaxoft","id":4388386,"avatar_url":"https://avatars.githubusercontent.com/u/4388386?v=3","gravatar_id":"","url":"https://api.github.com/users/madmaxoft","html_url":"https://github.com/madmaxoft","followers_url":"https://api.github.com/users/madmaxoft/followers","following_url":"https://api.github.com/users/madmaxoft/following{/other_user}","gists_url":"https://api.github.com/users/madmaxoft/gists{/gist_id}","starred_url":"https://api.github.com/users/madmaxoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/madmaxoft/subscriptions","organizations_url":"https://api.github.com/users/madmaxoft/orgs","repos_url":"https://api.github.com/users/madmaxoft/repos","events_url":"https://api.github.com/users/madmaxoft/events{/privacy}","received_events_url":"https://api.github.com/users/madmaxoft/received_events","type":"User","site_admin":false},"body":"DO NOT MERGE YET!\r\n\r\nThis is a work-in-progress to implement a LibEvent-based socket API that both the C++ part and Lua plugins could use. The PR has been created as a platform for (early) code review; for discussion please use the forum thread:\r\nhttp://forum.mc-server.org/showthread.php?tid=1700\r\n\r\nWill fix #1352 ","created_at":"2015-01-09T10:31:31Z","updated_at":"2015-01-13T18:27:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b3f73427933d4656e1aa33db9df4edf5b27e2bf4","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mc-server/MCServer/pulls/1701/commits","review_comments_url":"https://api.github.com/repos/mc-server/MCServer/pulls/1701/comments","review_comment_url":"https://api.github.com/repos/mc-server/MCServer/pulls/comments/{number}","comments_url":"https://api.github.com/repos/mc-server/MCServer/issues/1701/comments","statuses_url":"https://api.github.com/repos/mc-server/MCServer/statuses/8ec845071cbef50e8e2150f02b4b6a5b4ce70528","head":{"label":"mc-server:libevent","ref":"libevent","sha":"8ec845071cbef50e8e2150f02b4b6a5b4ce70528","user":{"login":"mc-server","id":5096476,"avatar_url":"https://avatars.githubusercontent.com/u/5096476?v=3","gravatar_id":"","url":"https://api.github.com/users/mc-server","html_url":"https://github.com/mc-server","followers_url":"https://api.github.com/users/mc-server/followers","following_url":"https://api.github.com/users/mc-server/following{/other_user}","gists_url":"https://api.github.com/users/mc-server/gists{/gist_id}","starred_url":"https://api.github.com/users/mc-server/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mc-server/subscriptions","organizations_url":"https://api.github.com/users/mc-server/orgs","repos_url":"https://api.github.com/users/mc-server/repos","events_url":"https://api.github.com/users/mc-server/events{/privacy}","received_events_url":"https://api.github.com/users/mc-server/received_events","type":"Organization","site_admin":false},"repo":{"id":11693709,"name":"MCServer","full_name":"mc-server/MCServer","owner":{"login":"mc-server","id":5096476,"avatar_url":"https://avatars.githubusercontent.com/u/5096476?v=3","gravatar_id":"","url":"https://api.github.com/users/mc-server","html_url":"https://github.com/mc-server","followers_url":"https://api.github.com/users/mc-server/followers","following_url":"https://api.github.com/users/mc-server/following{/other_user}","gists_url":"https://api.github.com/users/mc-server/gists{/gist_id}","starred_url":"https://api.github.com/users/mc-server/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mc-server/subscriptions","organizations_url":"https://api.github.com/users/mc-server/orgs","repos_url":"https://api.github.com/users/mc-server/repos","events_url":"https://api.github.com/users/mc-server/events{/privacy}","received_events_url":"https://api.github.com/users/mc-server/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mc-server/MCServer","description":"A performant C++ Minecraft Server","fork":false,"url":"https://api.github.com/repos/mc-server/MCServer","forks_url":"https://api.github.com/repos/mc-server/MCServer/forks","keys_url":"https://api.github.com/repos/mc-server/MCServer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mc-server/MCServer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mc-server/MCServer/teams","hooks_url":"https://api.github.com/repos/mc-server/MCServer/hooks","issue_events_url":"https://api.github.com/repos/mc-server/MCServer/issues/events{/number}","events_url":"https://api.github.com/repos/mc-server/MCServer/events","assignees_url":"https://api.github.com/repos/mc-server/MCServer/assignees{/user}","branches_url":"https://api.github.com/repos/mc-server/MCServer/branches{/branch}","tags_url":"https://api.github.com/repos/mc-server/MCServer/tags","blobs_url":"https://api.github.com/repos/mc-server/MCServer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mc-server/MCServer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mc-server/MCServer/git/refs{/sha}","trees_url":"https://api.github.com/repos/mc-server/MCServer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mc-server/MCServer/statuses/{sha}","languages_url":"https://api.github.com/repos/mc-server/MCServer/languages","stargazers_url":"https://api.github.com/repos/mc-server/MCServer/stargazers","contributors_url":"https://api.github.com/repos/mc-server/MCServer/contributors","subscribers_url":"https://api.github.com/repos/mc-server/MCServer/subscribers","subscription_url":"https://api.github.com/repos/mc-server/MCServer/subscription","commits_url":"https://api.github.com/repos/mc-server/MCServer/commits{/sha}","git_commits_url":"https://api.github.com/repos/mc-server/MCServer/git/commits{/sha}","comments_url":"https://api.github.com/repos/mc-server/MCServer/comments{/number}","issue_comment_url":"https://api.github.com/repos/mc-server/MCServer/issues/comments/{number}","contents_url":"https://api.github.com/repos/mc-server/MCServer/contents/{+path}","compare_url":"https://api.github.com/repos/mc-server/MCServer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mc-server/MCServer/merges","archive_url":"https://api.github.com/repos/mc-server/MCServer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mc-server/MCServer/downloads","issues_url":"https://api.github.com/repos/mc-server/MCServer/issues{/number}","pulls_url":"https://api.github.com/repos/mc-server/MCServer/pulls{/number}","milestones_url":"https://api.github.com/repos/mc-server/MCServer/milestones{/number}","notifications_url":"https://api.github.com/repos/mc-server/MCServer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mc-server/MCServer/labels{/name}","releases_url":"https://api.github.com/repos/mc-server/MCServer/releases{/id}","created_at":"2013-07-26T19:56:59Z","updated_at":"2015-01-13T11:58:21Z","pushed_at":"2015-01-13T16:48:34Z","git_url":"git://github.com/mc-server/MCServer.git","ssh_url":"git@github.com:mc-server/MCServer.git","clone_url":"https://github.com/mc-server/MCServer.git","svn_url":"https://github.com/mc-server/MCServer","homepage":"mc-server.org","size":153387,"stargazers_count":355,"watchers_count":355,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":119,"mirror_url":null,"open_issues_count":256,"forks":119,"open_issues":256,"watchers":355,"default_branch":"master"}},"base":{"label":"mc-server:master","ref":"master","sha":"52d307e3b01b733e925d51d0367995813bb283b2","user":{"login":"mc-server","id":5096476,"avatar_url":"https://avatars.githubusercontent.com/u/5096476?v=3","gravatar_id":"","url":"https://api.github.com/users/mc-server","html_url":"https://github.com/mc-server","followers_url":"https://api.github.com/users/mc-server/followers","following_url":"https://api.github.com/users/mc-server/following{/other_user}","gists_url":"https://api.github.com/users/mc-server/gists{/gist_id}","starred_url":"https://api.github.com/users/mc-server/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mc-server/subscriptions","organizations_url":"https://api.github.com/users/mc-server/orgs","repos_url":"https://api.github.com/users/mc-server/repos","events_url":"https://api.github.com/users/mc-server/events{/privacy}","received_events_url":"https://api.github.com/users/mc-server/received_events","type":"Organization","site_admin":false},"repo":{"id":11693709,"name":"MCServer","full_name":"mc-server/MCServer","owner":{"login":"mc-server","id":5096476,"avatar_url":"https://avatars.githubusercontent.com/u/5096476?v=3","gravatar_id":"","url":"https://api.github.com/users/mc-server","html_url":"https://github.com/mc-server","followers_url":"https://api.github.com/users/mc-server/followers","following_url":"https://api.github.com/users/mc-server/following{/other_user}","gists_url":"https://api.github.com/users/mc-server/gists{/gist_id}","starred_url":"https://api.github.com/users/mc-server/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mc-server/subscriptions","organizations_url":"https://api.github.com/users/mc-server/orgs","repos_url":"https://api.github.com/users/mc-server/repos","events_url":"https://api.github.com/users/mc-server/events{/privacy}","received_events_url":"https://api.github.com/users/mc-server/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mc-server/MCServer","description":"A performant C++ Minecraft Server","fork":false,"url":"https://api.github.com/repos/mc-server/MCServer","forks_url":"https://api.github.com/repos/mc-server/MCServer/forks","keys_url":"https://api.github.com/repos/mc-server/MCServer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mc-server/MCServer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mc-server/MCServer/teams","hooks_url":"https://api.github.com/repos/mc-server/MCServer/hooks","issue_events_url":"https://api.github.com/repos/mc-server/MCServer/issues/events{/number}","events_url":"https://api.github.com/repos/mc-server/MCServer/events","assignees_url":"https://api.github.com/repos/mc-server/MCServer/assignees{/user}","branches_url":"https://api.github.com/repos/mc-server/MCServer/branches{/branch}","tags_url":"https://api.github.com/repos/mc-server/MCServer/tags","blobs_url":"https://api.github.com/repos/mc-server/MCServer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mc-server/MCServer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mc-server/MCServer/git/refs{/sha}","trees_url":"https://api.github.com/repos/mc-server/MCServer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mc-server/MCServer/statuses/{sha}","languages_url":"https://api.github.com/repos/mc-server/MCServer/languages","stargazers_url":"https://api.github.com/repos/mc-server/MCServer/stargazers","contributors_url":"https://api.github.com/repos/mc-server/MCServer/contributors","subscribers_url":"https://api.github.com/repos/mc-server/MCServer/subscribers","subscription_url":"https://api.github.com/repos/mc-server/MCServer/subscription","commits_url":"https://api.github.com/repos/mc-server/MCServer/commits{/sha}","git_commits_url":"https://api.github.com/repos/mc-server/MCServer/git/commits{/sha}","comments_url":"https://api.github.com/repos/mc-server/MCServer/comments{/number}","issue_comment_url":"https://api.github.com/repos/mc-server/MCServer/issues/comments/{number}","contents_url":"https://api.github.com/repos/mc-server/MCServer/contents/{+path}","compare_url":"https://api.github.com/repos/mc-server/MCServer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mc-server/MCServer/merges","archive_url":"https://api.github.com/repos/mc-server/MCServer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mc-server/MCServer/downloads","issues_url":"https://api.github.com/repos/mc-server/MCServer/issues{/number}","pulls_url":"https://api.github.com/repos/mc-server/MCServer/pulls{/number}","milestones_url":"https://api.github.com/repos/mc-server/MCServer/milestones{/number}","notifications_url":"https://api.github.com/repos/mc-server/MCServer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mc-server/MCServer/labels{/name}","releases_url":"https://api.github.com/repos/mc-server/MCServer/releases{/id}","created_at":"2013-07-26T19:56:59Z","updated_at":"2015-01-13T11:58:21Z","pushed_at":"2015-01-13T16:48:34Z","git_url":"git://github.com/mc-server/MCServer.git","ssh_url":"git@github.com:mc-server/MCServer.git","clone_url":"https://github.com/mc-server/MCServer.git","svn_url":"https://github.com/mc-server/MCServer","homepage":"mc-server.org","size":153387,"stargazers_count":355,"watchers_count":355,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":119,"mirror_url":null,"open_issues_count":256,"forks":119,"open_issues":256,"watchers":355,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mc-server/MCServer/pulls/1701"},"html":{"href":"https://github.com/mc-server/MCServer/pull/1701"},"issue":{"href":"https://api.github.com/repos/mc-server/MCServer/issues/1701"},"comments":{"href":"https://api.github.com/repos/mc-server/MCServer/issues/1701/comments"},"review_comments":{"href":"https://api.github.com/repos/mc-server/MCServer/pulls/1701/comments"},"review_comment":{"href":"https://api.github.com/repos/mc-server/MCServer/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/mc-server/MCServer/pulls/1701/commits"},"statuses":{"href":"https://api.github.com/repos/mc-server/MCServer/statuses/8ec845071cbef50e8e2150f02b4b6a5b4ce70528"}}}}