类 ProxyConfig
java.lang.Object
io.agentscope.core.model.transport.ProxyConfig
Configuration for HTTP and SOCKS proxy.
This class provides a unified configuration for both HTTP and SOCKS proxies, supporting optional authentication and bypass rules.
Usage examples:
// Simple HTTP proxy
ProxyConfig proxy = ProxyConfig.http("proxy.example.com", 8080);
// HTTP proxy with authentication
ProxyConfig proxy = ProxyConfig.http("proxy.example.com", 8080, "user", "pass");
// SOCKS5 proxy with authentication
ProxyConfig proxy = ProxyConfig.socks5("socks.example.com", 1080, "user", "pass");
// Using builder for advanced configuration
ProxyConfig proxy = ProxyConfig.builder()
.type(ProxyType.HTTP)
.host("proxy.example.com")
.port(8080)
.username("user")
.password("pass")
.nonProxyHosts(Set.of("localhost", "*.internal.com"))
.build();
-
嵌套类概要
嵌套类 -
方法概要
修饰符和类型方法说明static ProxyConfig.Builderbuilder()Create a new builder for ProxyConfig.booleangetHost()Get the proxy server hostname or IP address.Get the set of hosts that should bypass the proxy.Get the authentication password.intgetPort()Get the proxy server port.Get the socket address for this proxy.getType()Get the proxy type.Get the authentication username.booleanCheck if authentication credentials are configured.inthashCode()static ProxyConfigCreate a simple HTTP proxy configuration without authentication.static ProxyConfigCreate an HTTP proxy configuration with authentication.booleanshouldBypass(String hostname) Check if the given hostname should bypass the proxy.static ProxyConfigCreate a simple SOCKS4 proxy configuration.static ProxyConfigCreate a simple SOCKS5 proxy configuration without authentication.static ProxyConfigCreate a SOCKS5 proxy configuration with authentication.Convert this configuration to aProxyinstance.toString()
-
方法详细资料
-
http
Create a simple HTTP proxy configuration without authentication.- 参数:
host- proxy server hostname or IP addressport- proxy server port- 返回:
- a new ProxyConfig instance
-
http
Create an HTTP proxy configuration with authentication.- 参数:
host- proxy server hostname or IP addressport- proxy server portusername- authentication usernamepassword- authentication password- 返回:
- a new ProxyConfig instance
-
socks4
Create a simple SOCKS4 proxy configuration.Note: SOCKS4 does not support authentication.
- 参数:
host- proxy server hostname or IP addressport- proxy server port- 返回:
- a new ProxyConfig instance
-
socks5
Create a simple SOCKS5 proxy configuration without authentication.- 参数:
host- proxy server hostname or IP addressport- proxy server port- 返回:
- a new ProxyConfig instance
-
socks5
Create a SOCKS5 proxy configuration with authentication.Note: SOCKS5 authentication is only supported when using OkHttp-based transport implementations. JDK HttpClient does not support SOCKS5 authentication.
- 参数:
host- proxy server hostname or IP addressport- proxy server portusername- authentication usernamepassword- authentication password- 返回:
- a new ProxyConfig instance
-
builder
Create a new builder for ProxyConfig.- 返回:
- a new Builder instance
-
getType
Get the proxy type.- 返回:
- the proxy type
-
getHost
Get the proxy server hostname or IP address.- 返回:
- the proxy host
-
getPort
public int getPort()Get the proxy server port.- 返回:
- the proxy port
-
getUsername
Get the authentication username.- 返回:
- the username, or null if no authentication is configured
-
getPassword
Get the authentication password.- 返回:
- the password, or null if no authentication is configured
-
getNonProxyHosts
Get the set of hosts that should bypass the proxy.The set may contain exact hostnames (e.g., "localhost") or wildcard patterns (e.g., "*.internal.com", "192.168.*").
- 返回:
- the set of non-proxy hosts, or null if not configured
-
hasAuthentication
public boolean hasAuthentication()Check if authentication credentials are configured.- 返回:
- true if both username and password are set
-
shouldBypass
Check if the given hostname should bypass the proxy.- 参数:
hostname- the hostname to check- 返回:
- true if the hostname should bypass the proxy
-
toJavaProxy
Convert this configuration to aProxyinstance.- 返回:
- the Java Proxy instance
-
getSocketAddress
Get the socket address for this proxy.- 返回:
- the proxy socket address
-
toString
-
equals
-
hashCode
public int hashCode()
-