diff options
author | David Pursehouse <dpursehouse@collab.net> | 2019-11-09 10:21:23 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2019-11-09 10:21:23 +0000 |
commit | 2670ff6833f56685db24b18116ffcc3ebbe9866e (patch) | |
tree | 8569a48815634c44ec6b1fd39b0ddab8a08476a1 | |
parent | 4afb317458d25cb677fca60ae349d40e1b813df1 (diff) | |
parent | 0d3ad3f3522989b577ee2edbaceb05f84291c224 (diff) |
Merge "Merge branch 'stable-2.16' into stable-3.0" into stable-3.0
-rw-r--r-- | java/com/google/gerrit/pgm/init/InitHttpd.java | 55 | ||||
m--------- | plugins/replication | 0 |
2 files changed, 50 insertions, 5 deletions
diff --git a/java/com/google/gerrit/pgm/init/InitHttpd.java b/java/com/google/gerrit/pgm/init/InitHttpd.java index d08bca03b8..027a3acb05 100644 --- a/java/com/google/gerrit/pgm/init/InitHttpd.java +++ b/java/com/google/gerrit/pgm/init/InitHttpd.java @@ -60,22 +60,67 @@ class InitHttpd implements InitStep { public void run() throws IOException, InterruptedException { ui.header("HTTP Daemon"); + boolean anySsl = false; + // If any listenUrls are present, validate whether it can be parsed as URL. + String[] listenUrls = httpd.getList("listenUrl"); + for (String listenUrl : listenUrls) { + if (listenUrl != null && !listenUrl.isEmpty()) { + try { + final URI u = toURI(listenUrl); + if (u.getScheme().startsWith("https")) { + anySsl = true; + } + } catch (URISyntaxException e) { + System.err.println( + String.format( + "warning: invalid httpd.listenUrl entry: '%s'. Gerrit may not be able to start.", + listenUrl)); + } + } + } + + if (listenUrls.length > 1) { + // Because we will return early here, we will warn about steps otherwise being covered. + if (!ui.isBatch()) { + System.err.println( + "Interactive configuration is not supported with multiple entries of " + + "httpd.listenUrl."); + } + if (anySsl) { + System.err.println( + "Generating self-signed SSL certificates is not supported with multiple " + + "entries of httpd.listenUrl."); + } + String canonicalWebUrlDefaultString = ""; + if (listenUrls[0] != null && !listenUrls[0].isEmpty()) { + try { + canonicalWebUrlDefaultString = new URI(listenUrls[0]).toString(); + } catch (URISyntaxException e) { + // Should not happen, but log it anyway + System.err.println( + String.format("warning: invalid httpd.listenUrl entry: '%s'", listenUrls[0])); + } + } + gerrit.string("Canonical URL", "canonicalWebUrl", canonicalWebUrlDefaultString); + return; + } + boolean proxy = false; boolean ssl = false; String address = "*"; int port = -1; String context = "/"; - String listenUrl = httpd.get("listenUrl"); - if (listenUrl != null && !listenUrl.isEmpty()) { + + if (listenUrls.length > 0 && listenUrls[0] != null && !listenUrls[0].isEmpty()) { try { - final URI uri = toURI(listenUrl); + final URI uri = toURI(listenUrls[0]); proxy = uri.getScheme().startsWith("proxy-"); ssl = uri.getScheme().endsWith("https"); - address = isAnyAddress(new URI(listenUrl)) ? "*" : uri.getHost(); + address = isAnyAddress(new URI(listenUrls[0])) ? "*" : uri.getHost(); port = uri.getPort(); context = uri.getPath(); } catch (URISyntaxException e) { - System.err.println("warning: invalid httpd.listenUrl " + listenUrl); + System.err.println("warning: invalid httpd.listenUrl " + listenUrls[0]); } } diff --git a/plugins/replication b/plugins/replication -Subproject 43b244b98b715b51ff8dcc81ecc11f8aa7cd071 +Subproject 57ee8678552b74d2323eed5e2425b27e3e2a7d2 |