From 2d14b373ac9ef900b12160ba64bafdcc0530f1dc Mon Sep 17 00:00:00 2001 From: "dilmah@chromium.org" Date: Tue, 10 May 2011 16:48:44 +0000 Subject: Websocket to TCP proxy running in a separate thread (only on ChromeOS). With this webproxy: authorized extensions can connect to ws://127.0.0.1:10101/tcpproxy, pass authorization_token:hostname:port: in first frame, then webproxy establishes TCP connection to hostname:port and forwards any subsequent communication. Subsequent communication between extension and webproxy is base64-encoded. TODO(dilmah): remove this temporary solution, get rid of separate thread and listening socket, instead provide the same functionality via hooks into websocket layer. BUG=chromium-os:9667 TEST=Manual Review URL: http://codereview.chromium.org/6801008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@84795 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/chromeos/web_socket_proxy.h | 46 ++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 chrome/browser/chromeos/web_socket_proxy.h (limited to 'chrome/browser/chromeos/web_socket_proxy.h') diff --git a/chrome/browser/chromeos/web_socket_proxy.h b/chrome/browser/chromeos/web_socket_proxy.h new file mode 100644 index 0000000..9f15cbc --- /dev/null +++ b/chrome/browser/chromeos/web_socket_proxy.h @@ -0,0 +1,46 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_CHROMEOS_WEB_SOCKET_PROXY_H_ +#define CHROME_BROWSER_CHROMEOS_WEB_SOCKET_PROXY_H_ + +#include +#include + +#include "base/basictypes.h" + +struct sockaddr; + +namespace chromeos { + +class WebSocketProxy { + public: + static const size_t kReadBufferLimit = 6 * 1024 * 1024; + + // Limits incoming websocket headers in initial stage of connection. + static const size_t kHeaderLimit = 32 * 1024; + + // Limits number of simultaneously open connections. + static const size_t kConnPoolLimit = 1000; + + WebSocketProxy( + const std::vector& allowed_origins, + struct sockaddr* addr, int addr_len); + ~WebSocketProxy(); + + // Do not call it twice. + void Run(); + + // Terminates running server (should be called on a different thread). + void Shutdown(); + + private: + void* impl_; + + DISALLOW_COPY_AND_ASSIGN(WebSocketProxy); +}; + +} // namespace chromeos + +#endif // CHROME_BROWSER_CHROMEOS_WEB_SOCKET_PROXY_H_ -- cgit v1.1