diff options
author | noamsml@chromium.org <noamsml@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-09 23:04:00 +0000 |
---|---|---|
committer | noamsml@chromium.org <noamsml@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-09 23:04:00 +0000 |
commit | 8ac76459e39ccaadb11c72384b66382f33e1294d (patch) | |
tree | 77323bc13c942cab19dc0462b7fdac6cff38b4f1 | |
parent | 533f0de0fc40cb838c8ca32b83775fc41864e859 (diff) | |
download | chromium_src-8ac76459e39ccaadb11c72384b66382f33e1294d.zip chromium_src-8ac76459e39ccaadb11c72384b66382f33e1294d.tar.gz chromium_src-8ac76459e39ccaadb11c72384b66382f33e1294d.tar.bz2 |
Add random number to A record domain for GCP prototype
Since multiple prototypes running on the same network will collide with each
other, append a random number to the domain for the A record.
BUG=
Review URL: https://codereview.chromium.org/98893005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@239586 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | cloud_print/gcp20/prototype/printer.cc | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/cloud_print/gcp20/prototype/printer.cc b/cloud_print/gcp20/prototype/printer.cc index d9c00b7..1d758f7 100644 --- a/cloud_print/gcp20/prototype/printer.cc +++ b/cloud_print/gcp20/prototype/printer.cc @@ -4,6 +4,7 @@ #include "cloud_print/gcp20/prototype/printer.h" +#include <limits.h> #include <stdio.h> #include <string> #include <vector> @@ -15,6 +16,7 @@ #include "base/guid.h" #include "base/json/json_reader.h" #include "base/json/json_writer.h" +#include "base/rand_util.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" @@ -36,7 +38,7 @@ const uint32 kTtlDefault = 60*60; // in seconds const char kServiceType[] = "_privet._tcp.local"; const char kSecondaryServiceType[] = "_printer._sub._privet._tcp.local"; const char kServiceNamePrefixDefault[] = "first_gcp20_device"; -const char kServiceDomainNameDefault[] = "my-privet-device.local"; +const char kServiceDomainNameFormatDefault[] = "my-privet-device%d.local"; const char kPrinterName[] = "Google GCP2.0 Prototype"; const char kPrinterDescription[] = "Printer emulator"; @@ -841,8 +843,11 @@ bool Printer::StartDnsServer() { std::string service_name_prefix = command_line_reader::ReadServiceNamePrefix(net::IPAddressToString(ip) + kServiceNamePrefixDefault); + std::string service_domain_name = - command_line_reader::ReadDomainName(kServiceDomainNameDefault); + command_line_reader::ReadDomainName( + base::StringPrintf(kServiceDomainNameFormatDefault, + base::RandInt(0, INT_MAX))); ServiceParameters params(kServiceType, kSecondaryServiceType, service_name_prefix, |