aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/skiaserve/skiaserve.cpp
diff options
context:
space:
mode:
authorGravatar jcgregorio <jcgregorio@google.com>2016-03-02 09:03:01 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-02 09:03:01 -0800
commit855bd4415c1a26950e946cc2f8756f7e03b61637 (patch)
tree0272994a134c62ffdb618a9d7ec850ec82e90ad2 /tools/skiaserve/skiaserve.cpp
parente27456a43c96648e05be746870124d14ff479fcb (diff)
debugger: Only bind to the localhost address by default.
Also add a flag to set the address. Additionally print out the final address the user should visit in their browser. R=joshualitt,ethannicholas BUG=skia: Review URL: https://codereview.chromium.org/1756903002
Diffstat (limited to 'tools/skiaserve/skiaserve.cpp')
-rw-r--r--tools/skiaserve/skiaserve.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/tools/skiaserve/skiaserve.cpp b/tools/skiaserve/skiaserve.cpp
index 195544e83a..d4a84ac795 100644
--- a/tools/skiaserve/skiaserve.cpp
+++ b/tools/skiaserve/skiaserve.cpp
@@ -14,6 +14,7 @@
#include "urlhandlers/UrlHandler.h"
#include <sys/socket.h>
+#include <arpa/inet.h>
using namespace Response;
@@ -23,6 +24,7 @@ using namespace Response;
__SK_FORCE_IMAGE_DECODER_LINKING;
DEFINE_int32(port, 8888, "The port to listen on.");
+DEFINE_string(address, "localhost", "The address to bind to.");
class UrlManager {
public:
@@ -82,10 +84,18 @@ int answer_to_connection(void* cls, struct MHD_Connection* connection,
int skiaserve_main() {
Request request(SkString("/data")); // This simple server has one request
+ struct sockaddr_in address;
+ address.sin_family = AF_INET;
+ address.sin_port = htons(FLAGS_port);
+ inet_pton(AF_INET, FLAGS_address[0], &address.sin_addr);
+
+ printf("Visit http://%s:%d in your browser.\n", FLAGS_address[0], FLAGS_port);
+
struct MHD_Daemon* daemon;
// TODO Add option to bind this strictly to an address, e.g. localhost, for security.
daemon = MHD_start_daemon(MHD_USE_SELECT_INTERNALLY, FLAGS_port, nullptr, nullptr,
&answer_to_connection, &request,
+ MHD_OPTION_SOCK_ADDR, &address,
MHD_OPTION_END);
if (NULL == daemon) {
return 1;