| 123 | } |
| 124 | |
| 125 | public Map<String, Object> toJson() { |
| 126 | Map<String, Object> m = new HashMap<>(); |
| 127 | |
| 128 | if (proxyType != ProxyType.UNSPECIFIED) { |
| 129 | m.put(PROXY_TYPE, proxyType.toString()); |
| 130 | } |
| 131 | if (httpProxy != null) { |
| 132 | m.put(HTTP_PROXY, httpProxy); |
| 133 | } |
| 134 | if (noProxy != null) { |
| 135 | m.put(NO_PROXY, List.of(noProxy.split(",\\s*"))); |
| 136 | } |
| 137 | if (sslProxy != null) { |
| 138 | m.put(SSL_PROXY, sslProxy); |
| 139 | } |
| 140 | if (socksProxy != null) { |
| 141 | m.put(SOCKS_PROXY, socksProxy); |
| 142 | } |
| 143 | if (socksVersion != null) { |
| 144 | m.put(SOCKS_VERSION, socksVersion); |
| 145 | } |
| 146 | if (socksUsername != null) { |
| 147 | m.put(SOCKS_USERNAME, socksUsername); |
| 148 | } |
| 149 | if (socksPassword != null) { |
| 150 | m.put(SOCKS_PASSWORD, socksPassword); |
| 151 | } |
| 152 | if (proxyAutoconfigUrl != null) { |
| 153 | m.put(PROXY_AUTOCONFIG_URL, proxyAutoconfigUrl); |
| 154 | } |
| 155 | if (autodetect) { |
| 156 | m.put(AUTODETECT, true); |
| 157 | } |
| 158 | return m; |
| 159 | } |
| 160 | |
| 161 | /** |
| 162 | * Gets the {@link ProxyType}. This can signal if set to use a direct connection (without proxy), |