| Index: net/web2socket_proxy/web2socket_main.cc
|
| diff --git a/net/web2socket_proxy/web2socket_main.cc b/net/web2socket_proxy/web2socket_main.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..b12caea6f9a80e16197702c93c2840daadc7e68a
|
| --- /dev/null
|
| +++ b/net/web2socket_proxy/web2socket_main.cc
|
| @@ -0,0 +1,56 @@
|
| +// Copyright (c) 2010 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.
|
| +
|
| +#include <stdio.h>
|
| +#include <stdlib.h>
|
| +#include <string.h>
|
| +
|
| +#include <netinet/in.h>
|
| +#include <unistd.h>
|
| +
|
| +#include "web2socket.h"
|
| +
|
| +static void bailout() {
|
| + fprintf(stderr,
|
| + "Options:\n"
|
| + " -p port\tSpecifies port (in 1-65535 range) to listen. Mandatory.\n"
|
| + " -L\tListens loopback network interface.\n");
|
| + exit(1);
|
| +}
|
| +
|
| +int main(int ac, char *av[]) {
|
| + int c;
|
| + int port = 0;
|
| + bool loopback = false;
|
| + if (ac <= 0)
|
| + bailout();
|
| + while ((c = getopt(ac, av, "p:L")) != -1) {
|
| + switch(c) {
|
| + case 'p': {
|
| + port = atoi(optarg);
|
| + break;
|
| + }
|
| + case 'L': {
|
| + loopback = true;
|
| + break;
|
| + }
|
| + default: {
|
| + bailout();
|
| + }
|
| + }
|
| + }
|
| + if (port < 1 || port >= 1 << 16)
|
| + bailout();
|
| +
|
| + struct sockaddr_in sa;
|
| + memset(&sa, 0, sizeof(sa));
|
| + sa.sin_family = AF_INET;
|
| + sa.sin_port = htons(port);
|
| + sa.sin_addr.s_addr = loopback ? htonl(INADDR_LOOPBACK) : htonl(INADDR_ANY);
|
| +
|
| + RunWeb2SocketServer(std::string(),
|
| + static_cast<sockaddr*>(static_cast<void*>(&sa)),
|
| + sizeof(sa));
|
| + return 1;
|
| +}
|
|
|