{"action":"created","comment":{"url":"https://api.github.com/repos/vapor/engine/pulls/comments/76870258","id":76870258,"diff_hunk":"@@ -91,94 +99,53 @@ public final class TCPServerStream: TCPProgramStream, ServerStream {\n     }\n \n     public func accept() throws -> Stream {\n-        let next = try stream.accept()\n+\n         switch securityLayer {\n         case .none:\n-            return next\n-        case .tls:\n-            let secure = try next.makeSecret(mode: .server)\n-            try secure.stream.accept()\n+            return try stream.accept()\n+        case .tls(let provided):\n+            let config: Config\n+            if let c = provided {\n+                config = c\n+            } else {\n+                let context = try Context(mode: .server)\n+                config = try Config(context: context)\n+            }\n+\n+            let secure = try TLS.Socket(config: config, socket: stream)\n+            try secure.accept()\n             return secure\n         }\n     }\n }\n \n-import TLS\n-import SocksCore\n-import libc\n-\n-public final class TLSSocket<Socket: SocksCore.TCPInternetSocket> {\n-    public let stream: TLS.Stream\n-    public let socket: Socket\n-\n-    public init(stream: TLS.Stream, socket: Socket) {\n-        self.stream = stream\n-        self.socket = socket\n-    }\n-\n-    public convenience init(\n-        mode: TLS.Mode,\n-        socket: Socket,\n-        certificates: TLS.Certificates = .none\n-    ) throws {\n-        let stream = try TLS.Stream(\n-            mode: mode,\n-            socket: socket.descriptor,\n-            certificates: certificates\n-        )\n-        self.init(stream: stream, socket: socket)\n-    }\n-}\n-\n-/**\n-    Conform TLS Stream + Underlying socket\n-    to a TLS Socket.\n-*/\n-extension TLSSocket: Stream {\n-    public func close() throws {\n-        try stream.close()\n-        try socket.close()\n-    }\n-\n-    public var closed: Bool {\n-        return socket.closed\n-    }\n-\n-    public var peerAddress: String {\n-        return socket.peerAddress\n-    }\n-\n+extension TLS.Socket: Stream {\n     public func setTimeout(_ timeout: Double) throws {\n         try socket.setTimeout(timeout)\n     }\n \n-    public func send(_ bytes: Bytes) throws {\n-        try stream.send(bytes)\n-    }\n-\n-    public func receive(max: Int) throws -> Bytes {\n-        return try stream.receive(max: max)\n+    public var closed: Bool {\n+        return socket.closed\n     }\n \n     public func flush() throws {\n         try socket.flush()\n     }\n+\n+    public var peerAddress: String {\n+        return socket.peerAddress\n+    }\n }\n \n-extension TCPInternetSocket {\n-    /**\n-        Creates a new SSL Context and Secure Socket.\n-        - parameter mode: Client or Server\n-        - parameter certificates: SSL Certificates for the Server, use .none for Client\n-     */\n-    public func makeSecret(\n-        mode: TLS.Mode = .client,\n-        certificates: TLS.Certificates = .none\n-    ) throws -> TLSSocket<TCPInternetSocket> {\n-        return try TLSSocket(\n-            mode: mode,\n-            socket: self,\n-            certificates: certificates\n-        )\n+extension SecurityLayer: Equatable {","path":"Sources/Transport/Streams/Socks+Stream.swift","position":139,"original_position":139,"commit_id":"01e7423c3370c843c959197f2a67f07c391027d2","original_commit_id":"01e7423c3370c843c959197f2a67f07c391027d2","user":{"login":"LoganWright","id":5750489,"avatar_url":"https://avatars.githubusercontent.com/u/5750489?v=3","gravatar_id":"","url":"https://api.github.com/users/LoganWright","html_url":"https://github.com/LoganWright","followers_url":"https://api.github.com/users/LoganWright/followers","following_url":"https://api.github.com/users/LoganWright/following{/other_user}","gists_url":"https://api.github.com/users/LoganWright/gists{/gist_id}","starred_url":"https://api.github.com/users/LoganWright/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LoganWright/subscriptions","organizations_url":"https://api.github.com/users/LoganWright/orgs","repos_url":"https://api.github.com/users/LoganWright/repos","events_url":"https://api.github.com/users/LoganWright/events{/privacy}","received_events_url":"https://api.github.com/users/LoganWright/received_events","type":"User","site_admin":false},"body":"I thought we took out equatable, was that a different PR? I think we should let people deal w/ this one on their own, maybe a convenience like:\r\n\r\n```\r\nvar isNone: Bool\r\nvar isTLS: Bool\r\n```","created_at":"2016-08-30T20:13:32Z","updated_at":"2016-08-30T20:13:32Z","html_url":"https://github.com/vapor/engine/pull/38#discussion_r76870258","pull_request_url":"https://api.github.com/repos/vapor/engine/pulls/38","_links":{"self":{"href":"https://api.github.com/repos/vapor/engine/pulls/comments/76870258"},"html":{"href":"https://github.com/vapor/engine/pull/38#discussion_r76870258"},"pull_request":{"href":"https://api.github.com/repos/vapor/engine/pulls/38"}}},"pull_request":{"url":"https://api.github.com/repos/vapor/engine/pulls/38","id":82804967,"html_url":"https://github.com/vapor/engine/pull/38","diff_url":"https://github.com/vapor/engine/pull/38.diff","patch_url":"https://github.com/vapor/engine/pull/38.patch","issue_url":"https://api.github.com/repos/vapor/engine/issues/38","number":38,"state":"open","locked":false,"title":"Piping TLS.Config through","user":{"login":"czechboy0","id":2182121,"avatar_url":"https://avatars.githubusercontent.com/u/2182121?v=3","gravatar_id":"","url":"https://api.github.com/users/czechboy0","html_url":"https://github.com/czechboy0","followers_url":"https://api.github.com/users/czechboy0/followers","following_url":"https://api.github.com/users/czechboy0/following{/other_user}","gists_url":"https://api.github.com/users/czechboy0/gists{/gist_id}","starred_url":"https://api.github.com/users/czechboy0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/czechboy0/subscriptions","organizations_url":"https://api.github.com/users/czechboy0/orgs","repos_url":"https://api.github.com/users/czechboy0/repos","events_url":"https://api.github.com/users/czechboy0/events{/privacy}","received_events_url":"https://api.github.com/users/czechboy0/received_events","type":"User","site_admin":false},"body":"Depends on https://github.com/vapor/tls/pull/15, related to https://github.com/vapor/vapor/issues/541\r\n\r\nYou can see here that `SecurityLayer` being an enum makes it slightly difficult to work with. I suggest we add functions to easily create a `.tls(...)` case, something like \r\n\r\n```swift\r\nstatic func defaultTLS() -> SecurityLayer {\r\n    return .tls(TLSConfig())\r\n}\r\n```\r\n\r\nfor extra convenience. \r\n\r\n/cc @tannernelson @LoganWright ","created_at":"2016-08-25T22:33:56Z","updated_at":"2016-08-30T20:13:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3b59f5fc9c08c1252320c8e1756561534a02e406","assignee":{"login":"tannernelson","id":1342803,"avatar_url":"https://avatars.githubusercontent.com/u/1342803?v=3","gravatar_id":"","url":"https://api.github.com/users/tannernelson","html_url":"https://github.com/tannernelson","followers_url":"https://api.github.com/users/tannernelson/followers","following_url":"https://api.github.com/users/tannernelson/following{/other_user}","gists_url":"https://api.github.com/users/tannernelson/gists{/gist_id}","starred_url":"https://api.github.com/users/tannernelson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tannernelson/subscriptions","organizations_url":"https://api.github.com/users/tannernelson/orgs","repos_url":"https://api.github.com/users/tannernelson/repos","events_url":"https://api.github.com/users/tannernelson/events{/privacy}","received_events_url":"https://api.github.com/users/tannernelson/received_events","type":"User","site_admin":false},"assignees":[{"login":"tannernelson","id":1342803,"avatar_url":"https://avatars.githubusercontent.com/u/1342803?v=3","gravatar_id":"","url":"https://api.github.com/users/tannernelson","html_url":"https://github.com/tannernelson","followers_url":"https://api.github.com/users/tannernelson/followers","following_url":"https://api.github.com/users/tannernelson/following{/other_user}","gists_url":"https://api.github.com/users/tannernelson/gists{/gist_id}","starred_url":"https://api.github.com/users/tannernelson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tannernelson/subscriptions","organizations_url":"https://api.github.com/users/tannernelson/orgs","repos_url":"https://api.github.com/users/tannernelson/repos","events_url":"https://api.github.com/users/tannernelson/events{/privacy}","received_events_url":"https://api.github.com/users/tannernelson/received_events","type":"User","site_admin":false},{"login":"czechboy0","id":2182121,"avatar_url":"https://avatars.githubusercontent.com/u/2182121?v=3","gravatar_id":"","url":"https://api.github.com/users/czechboy0","html_url":"https://github.com/czechboy0","followers_url":"https://api.github.com/users/czechboy0/followers","following_url":"https://api.github.com/users/czechboy0/following{/other_user}","gists_url":"https://api.github.com/users/czechboy0/gists{/gist_id}","starred_url":"https://api.github.com/users/czechboy0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/czechboy0/subscriptions","organizations_url":"https://api.github.com/users/czechboy0/orgs","repos_url":"https://api.github.com/users/czechboy0/repos","events_url":"https://api.github.com/users/czechboy0/events{/privacy}","received_events_url":"https://api.github.com/users/czechboy0/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/vapor/engine/milestones/6","html_url":"https://github.com/vapor/engine/milestones/0.7","labels_url":"https://api.github.com/repos/vapor/engine/milestones/6/labels","id":1964056,"number":6,"title":"0.7","description":"","creator":{"login":"tannernelson","id":1342803,"avatar_url":"https://avatars.githubusercontent.com/u/1342803?v=3","gravatar_id":"","url":"https://api.github.com/users/tannernelson","html_url":"https://github.com/tannernelson","followers_url":"https://api.github.com/users/tannernelson/followers","following_url":"https://api.github.com/users/tannernelson/following{/other_user}","gists_url":"https://api.github.com/users/tannernelson/gists{/gist_id}","starred_url":"https://api.github.com/users/tannernelson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tannernelson/subscriptions","organizations_url":"https://api.github.com/users/tannernelson/orgs","repos_url":"https://api.github.com/users/tannernelson/repos","events_url":"https://api.github.com/users/tannernelson/events{/privacy}","received_events_url":"https://api.github.com/users/tannernelson/received_events","type":"User","site_admin":false},"open_issues":1,"closed_issues":1,"state":"open","created_at":"2016-08-25T23:07:33Z","updated_at":"2016-08-27T19:00:39Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/vapor/engine/pulls/38/commits","review_comments_url":"https://api.github.com/repos/vapor/engine/pulls/38/comments","review_comment_url":"https://api.github.com/repos/vapor/engine/pulls/comments{/number}","comments_url":"https://api.github.com/repos/vapor/engine/issues/38/comments","statuses_url":"https://api.github.com/repos/vapor/engine/statuses/01e7423c3370c843c959197f2a67f07c391027d2","head":{"label":"vapor:hd/tls-config","ref":"hd/tls-config","sha":"01e7423c3370c843c959197f2a67f07c391027d2","user":{"login":"vapor","id":17364220,"avatar_url":"https://avatars.githubusercontent.com/u/17364220?v=3","gravatar_id":"","url":"https://api.github.com/users/vapor","html_url":"https://github.com/vapor","followers_url":"https://api.github.com/users/vapor/followers","following_url":"https://api.github.com/users/vapor/following{/other_user}","gists_url":"https://api.github.com/users/vapor/gists{/gist_id}","starred_url":"https://api.github.com/users/vapor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vapor/subscriptions","organizations_url":"https://api.github.com/users/vapor/orgs","repos_url":"https://api.github.com/users/vapor/repos","events_url":"https://api.github.com/users/vapor/events{/privacy}","received_events_url":"https://api.github.com/users/vapor/received_events","type":"Organization","site_admin":false},"repo":{"id":62755830,"name":"engine","full_name":"vapor/engine","owner":{"login":"vapor","id":17364220,"avatar_url":"https://avatars.githubusercontent.com/u/17364220?v=3","gravatar_id":"","url":"https://api.github.com/users/vapor","html_url":"https://github.com/vapor","followers_url":"https://api.github.com/users/vapor/followers","following_url":"https://api.github.com/users/vapor/following{/other_user}","gists_url":"https://api.github.com/users/vapor/gists{/gist_id}","starred_url":"https://api.github.com/users/vapor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vapor/subscriptions","organizations_url":"https://api.github.com/users/vapor/orgs","repos_url":"https://api.github.com/users/vapor/repos","events_url":"https://api.github.com/users/vapor/events{/privacy}","received_events_url":"https://api.github.com/users/vapor/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/vapor/engine","description":"HTTP, WebSockets, Streams, SMTP, etc. Core transport layer used in https://github.com/vapor/vapor","fork":false,"url":"https://api.github.com/repos/vapor/engine","forks_url":"https://api.github.com/repos/vapor/engine/forks","keys_url":"https://api.github.com/repos/vapor/engine/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vapor/engine/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vapor/engine/teams","hooks_url":"https://api.github.com/repos/vapor/engine/hooks","issue_events_url":"https://api.github.com/repos/vapor/engine/issues/events{/number}","events_url":"https://api.github.com/repos/vapor/engine/events","assignees_url":"https://api.github.com/repos/vapor/engine/assignees{/user}","branches_url":"https://api.github.com/repos/vapor/engine/branches{/branch}","tags_url":"https://api.github.com/repos/vapor/engine/tags","blobs_url":"https://api.github.com/repos/vapor/engine/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vapor/engine/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vapor/engine/git/refs{/sha}","trees_url":"https://api.github.com/repos/vapor/engine/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vapor/engine/statuses/{sha}","languages_url":"https://api.github.com/repos/vapor/engine/languages","stargazers_url":"https://api.github.com/repos/vapor/engine/stargazers","contributors_url":"https://api.github.com/repos/vapor/engine/contributors","subscribers_url":"https://api.github.com/repos/vapor/engine/subscribers","subscription_url":"https://api.github.com/repos/vapor/engine/subscription","commits_url":"https://api.github.com/repos/vapor/engine/commits{/sha}","git_commits_url":"https://api.github.com/repos/vapor/engine/git/commits{/sha}","comments_url":"https://api.github.com/repos/vapor/engine/comments{/number}","issue_comment_url":"https://api.github.com/repos/vapor/engine/issues/comments{/number}","contents_url":"https://api.github.com/repos/vapor/engine/contents/{+path}","compare_url":"https://api.github.com/repos/vapor/engine/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vapor/engine/merges","archive_url":"https://api.github.com/repos/vapor/engine/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vapor/engine/downloads","issues_url":"https://api.github.com/repos/vapor/engine/issues{/number}","pulls_url":"https://api.github.com/repos/vapor/engine/pulls{/number}","milestones_url":"https://api.github.com/repos/vapor/engine/milestones{/number}","notifications_url":"https://api.github.com/repos/vapor/engine/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vapor/engine/labels{/name}","releases_url":"https://api.github.com/repos/vapor/engine/releases{/id}","deployments_url":"https://api.github.com/repos/vapor/engine/deployments","created_at":"2016-07-06T21:55:03Z","updated_at":"2016-08-27T15:50:27Z","pushed_at":"2016-08-30T20:09:27Z","git_url":"git://github.com/vapor/engine.git","ssh_url":"git@github.com:vapor/engine.git","clone_url":"https://github.com/vapor/engine.git","svn_url":"https://github.com/vapor/engine","homepage":"","size":8830,"stargazers_count":37,"watchers_count":37,"language":"Swift","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":4,"forks":7,"open_issues":4,"watchers":37,"default_branch":"master"}},"base":{"label":"vapor:master","ref":"master","sha":"755d7ede480e8b70035d53711a50d1c76910cca9","user":{"login":"vapor","id":17364220,"avatar_url":"https://avatars.githubusercontent.com/u/17364220?v=3","gravatar_id":"","url":"https://api.github.com/users/vapor","html_url":"https://github.com/vapor","followers_url":"https://api.github.com/users/vapor/followers","following_url":"https://api.github.com/users/vapor/following{/other_user}","gists_url":"https://api.github.com/users/vapor/gists{/gist_id}","starred_url":"https://api.github.com/users/vapor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vapor/subscriptions","organizations_url":"https://api.github.com/users/vapor/orgs","repos_url":"https://api.github.com/users/vapor/repos","events_url":"https://api.github.com/users/vapor/events{/privacy}","received_events_url":"https://api.github.com/users/vapor/received_events","type":"Organization","site_admin":false},"repo":{"id":62755830,"name":"engine","full_name":"vapor/engine","owner":{"login":"vapor","id":17364220,"avatar_url":"https://avatars.githubusercontent.com/u/17364220?v=3","gravatar_id":"","url":"https://api.github.com/users/vapor","html_url":"https://github.com/vapor","followers_url":"https://api.github.com/users/vapor/followers","following_url":"https://api.github.com/users/vapor/following{/other_user}","gists_url":"https://api.github.com/users/vapor/gists{/gist_id}","starred_url":"https://api.github.com/users/vapor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vapor/subscriptions","organizations_url":"https://api.github.com/users/vapor/orgs","repos_url":"https://api.github.com/users/vapor/repos","events_url":"https://api.github.com/users/vapor/events{/privacy}","received_events_url":"https://api.github.com/users/vapor/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/vapor/engine","description":"HTTP, WebSockets, Streams, SMTP, etc. Core transport layer used in https://github.com/vapor/vapor","fork":false,"url":"https://api.github.com/repos/vapor/engine","forks_url":"https://api.github.com/repos/vapor/engine/forks","keys_url":"https://api.github.com/repos/vapor/engine/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vapor/engine/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vapor/engine/teams","hooks_url":"https://api.github.com/repos/vapor/engine/hooks","issue_events_url":"https://api.github.com/repos/vapor/engine/issues/events{/number}","events_url":"https://api.github.com/repos/vapor/engine/events","assignees_url":"https://api.github.com/repos/vapor/engine/assignees{/user}","branches_url":"https://api.github.com/repos/vapor/engine/branches{/branch}","tags_url":"https://api.github.com/repos/vapor/engine/tags","blobs_url":"https://api.github.com/repos/vapor/engine/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vapor/engine/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vapor/engine/git/refs{/sha}","trees_url":"https://api.github.com/repos/vapor/engine/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vapor/engine/statuses/{sha}","languages_url":"https://api.github.com/repos/vapor/engine/languages","stargazers_url":"https://api.github.com/repos/vapor/engine/stargazers","contributors_url":"https://api.github.com/repos/vapor/engine/contributors","subscribers_url":"https://api.github.com/repos/vapor/engine/subscribers","subscription_url":"https://api.github.com/repos/vapor/engine/subscription","commits_url":"https://api.github.com/repos/vapor/engine/commits{/sha}","git_commits_url":"https://api.github.com/repos/vapor/engine/git/commits{/sha}","comments_url":"https://api.github.com/repos/vapor/engine/comments{/number}","issue_comment_url":"https://api.github.com/repos/vapor/engine/issues/comments{/number}","contents_url":"https://api.github.com/repos/vapor/engine/contents/{+path}","compare_url":"https://api.github.com/repos/vapor/engine/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vapor/engine/merges","archive_url":"https://api.github.com/repos/vapor/engine/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vapor/engine/downloads","issues_url":"https://api.github.com/repos/vapor/engine/issues{/number}","pulls_url":"https://api.github.com/repos/vapor/engine/pulls{/number}","milestones_url":"https://api.github.com/repos/vapor/engine/milestones{/number}","notifications_url":"https://api.github.com/repos/vapor/engine/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vapor/engine/labels{/name}","releases_url":"https://api.github.com/repos/vapor/engine/releases{/id}","deployments_url":"https://api.github.com/repos/vapor/engine/deployments","created_at":"2016-07-06T21:55:03Z","updated_at":"2016-08-27T15:50:27Z","pushed_at":"2016-08-30T20:09:27Z","git_url":"git://github.com/vapor/engine.git","ssh_url":"git@github.com:vapor/engine.git","clone_url":"https://github.com/vapor/engine.git","svn_url":"https://github.com/vapor/engine","homepage":"","size":8830,"stargazers_count":37,"watchers_count":37,"language":"Swift","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":4,"forks":7,"open_issues":4,"watchers":37,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/vapor/engine/pulls/38"},"html":{"href":"https://github.com/vapor/engine/pull/38"},"issue":{"href":"https://api.github.com/repos/vapor/engine/issues/38"},"comments":{"href":"https://api.github.com/repos/vapor/engine/issues/38/comments"},"review_comments":{"href":"https://api.github.com/repos/vapor/engine/pulls/38/comments"},"review_comment":{"href":"https://api.github.com/repos/vapor/engine/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/vapor/engine/pulls/38/commits"},"statuses":{"href":"https://api.github.com/repos/vapor/engine/statuses/01e7423c3370c843c959197f2a67f07c391027d2"}}}}
{"actor":{"display_login":"LoganWright"}}