Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(269)

Side by Side Diff: tools/skiaserve/skiaserve.cpp

Issue 1756903002: debugger: Only bind to the localhost address by default. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "Request.h" 8 #include "Request.h"
9 #include "Response.h" 9 #include "Response.h"
10 10
11 #include "SkCommandLineFlags.h" 11 #include "SkCommandLineFlags.h"
12 12
13 #include "microhttpd.h" 13 #include "microhttpd.h"
14 14
15 #include "urlhandlers/UrlHandler.h" 15 #include "urlhandlers/UrlHandler.h"
16 #include <sys/socket.h> 16 #include <sys/socket.h>
17 #include <arpa/inet.h>
17 18
18 using namespace Response; 19 using namespace Response;
19 20
20 // To get image decoders linked in we have to do the below magic 21 // To get image decoders linked in we have to do the below magic
21 #include "SkForceLinking.h" 22 #include "SkForceLinking.h"
22 #include "SkImageDecoder.h" 23 #include "SkImageDecoder.h"
23 __SK_FORCE_IMAGE_DECODER_LINKING; 24 __SK_FORCE_IMAGE_DECODER_LINKING;
24 25
25 DEFINE_int32(port, 8888, "The port to listen on."); 26 DEFINE_int32(port, 8888, "The port to listen on.");
27 DEFINE_string(address, "localhost", "The address to bind to.");
26 28
27 class UrlManager { 29 class UrlManager {
28 public: 30 public:
29 UrlManager() { 31 UrlManager() {
30 // Register handlers 32 // Register handlers
31 fHandlers.push_back(new RootHandler); 33 fHandlers.push_back(new RootHandler);
32 fHandlers.push_back(new PostHandler); 34 fHandlers.push_back(new PostHandler);
33 fHandlers.push_back(new ImgHandler); 35 fHandlers.push_back(new ImgHandler);
34 fHandlers.push_back(new ClipAlphaHandler); 36 fHandlers.push_back(new ClipAlphaHandler);
35 fHandlers.push_back(new EnableGPUHandler); 37 fHandlers.push_back(new EnableGPUHandler);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 upload_data_size); 77 upload_data_size);
76 if (MHD_NO == result) { 78 if (MHD_NO == result) {
77 fprintf(stderr, "Invalid method and / or url: %s %s\n", method, url); 79 fprintf(stderr, "Invalid method and / or url: %s %s\n", method, url);
78 } 80 }
79 return result; 81 return result;
80 } 82 }
81 83
82 int skiaserve_main() { 84 int skiaserve_main() {
83 Request request(SkString("/data")); // This simple server has one request 85 Request request(SkString("/data")); // This simple server has one request
84 86
87 struct sockaddr_in address;
88 address.sin_family = AF_INET;
89 address.sin_port = htons(FLAGS_port);
90 inet_pton(AF_INET, FLAGS_address[0], &address.sin_addr);
91
92 printf("Visit http://%s:%d in your browser.\n", FLAGS_address[0], FLAGS_port );
93
85 struct MHD_Daemon* daemon; 94 struct MHD_Daemon* daemon;
86 // TODO Add option to bind this strictly to an address, e.g. localhost, for security. 95 // TODO Add option to bind this strictly to an address, e.g. localhost, for security.
87 daemon = MHD_start_daemon(MHD_USE_SELECT_INTERNALLY, FLAGS_port, nullptr, nu llptr, 96 daemon = MHD_start_daemon(MHD_USE_SELECT_INTERNALLY, FLAGS_port, nullptr, nu llptr,
88 &answer_to_connection, &request, 97 &answer_to_connection, &request,
98 MHD_OPTION_SOCK_ADDR, &address,
89 MHD_OPTION_END); 99 MHD_OPTION_END);
90 if (NULL == daemon) { 100 if (NULL == daemon) {
91 return 1; 101 return 1;
92 } 102 }
93 103
94 getchar(); 104 getchar();
95 MHD_stop_daemon(daemon); 105 MHD_stop_daemon(daemon);
96 return 0; 106 return 0;
97 } 107 }
98 108
99 #if !defined SK_BUILD_FOR_IOS 109 #if !defined SK_BUILD_FOR_IOS
100 int main(int argc, char** argv) { 110 int main(int argc, char** argv) {
101 SkCommandLineFlags::Parse(argc, argv); 111 SkCommandLineFlags::Parse(argc, argv);
102 return skiaserve_main(); 112 return skiaserve_main();
103 } 113 }
104 #endif 114 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698