| 1859 | } |
| 1860 | |
| 1861 | static const char *add_proxy(cmd_parms *cmd, void *dummy, const char *f1, |
| 1862 | const char *r1, const char *creds, int regex) |
| 1863 | { |
| 1864 | server_rec *s = cmd->server; |
| 1865 | proxy_server_conf *conf = |
| 1866 | (proxy_server_conf *) ap_get_module_config(s->module_config, &proxy_module); |
| 1867 | struct proxy_remote *new; |
| 1868 | char *p, *q; |
| 1869 | char *r, *f, *scheme; |
| 1870 | ap_regex_t *reg = NULL; |
| 1871 | int port; |
| 1872 | |
| 1873 | r = apr_pstrdup(cmd->pool, r1); |
| 1874 | scheme = apr_pstrdup(cmd->pool, r1); |
| 1875 | f = apr_pstrdup(cmd->pool, f1); |
| 1876 | p = strchr(r, ':'); |
| 1877 | if (p == NULL || p[1] != '/' || p[2] != '/' || p[3] == '\0') { |
| 1878 | if (regex) |
| 1879 | return "ProxyRemoteMatch: Bad syntax for a remote proxy server"; |
| 1880 | else |
| 1881 | return "ProxyRemote: Bad syntax for a remote proxy server"; |
| 1882 | } |
| 1883 | else { |
| 1884 | scheme[p-r] = 0; |
| 1885 | } |
| 1886 | q = strchr(p + 3, ':'); |
| 1887 | if (q != NULL) { |
| 1888 | if (sscanf(q + 1, "%u", &port) != 1 || port > 65535) { |
| 1889 | if (regex) |
| 1890 | return "ProxyRemoteMatch: Bad syntax for a remote proxy server (bad port number)"; |
| 1891 | else |
| 1892 | return "ProxyRemote: Bad syntax for a remote proxy server (bad port number)"; |
| 1893 | } |
| 1894 | *q = '\0'; |
| 1895 | } |
| 1896 | else |
| 1897 | port = -1; |
| 1898 | *p = '\0'; |
| 1899 | if (regex) { |
| 1900 | reg = ap_pregcomp(cmd->pool, f, AP_REG_EXTENDED); |
| 1901 | if (!reg) |
| 1902 | return "Regular expression for ProxyRemoteMatch could not be compiled."; |
| 1903 | } |
| 1904 | else |
| 1905 | if (strchr(f, ':') == NULL) |
| 1906 | ap_str_tolower(f); /* lowercase scheme */ |
| 1907 | ap_str_tolower(p + 3); /* lowercase hostname */ |
| 1908 | |
| 1909 | if (port == -1) { |
| 1910 | port = apr_uri_port_of_scheme(scheme); |
| 1911 | } |
| 1912 | |
| 1913 | new = apr_array_push(conf->proxies); |
| 1914 | new->scheme = f; |
| 1915 | new->protocol = r; |
| 1916 | new->hostname = p + 3; |
| 1917 | new->port = port; |
| 1918 | new->regexp = reg; |
no test coverage detected