ProxyConfig
public class ProxyConfig
io/agentscope/core/model/transport/ProxyConfig.java:55–439用于HTTP 和 SOCKS 代理的配置。位于 io.agentscope.core.model.transport 包。核心成员包括 http、socks4、socks5、builder、getType、getHost。
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();
`
嵌套类摘要Nested Class Summary
| 类Class | 类型Kind | 说明Description |
|---|---|---|
Builder | 类class | ProxyConfig的构建器。 Builder for ProxyConfig. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public static ProxyConfig http(String host, int port)static | 执行HTTP相关操作。 Create a simple HTTP proxy configuration without authentication. |
public static ProxyConfig http(String host, int port, String username, String password)static | 执行HTTP相关操作。 Create an HTTP proxy configuration with authentication. |
public static ProxyConfig socks4(String host, int port)static | 创建简单 SOCKS4 代理配置。 Create a simple SOCKS4 proxy configuration. |
public static ProxyConfig socks5(String host, int port)static | 执行 `socks5` 方法。 Create a simple SOCKS5 proxy configuration without authentication. |
public static ProxyConfig socks5(String host, int port, String username, String password)static | 执行 `socks5` 方法。 Create a SOCKS5 proxy configuration with authentication. |
public static Builder builder()static | 创建用于ProxyConfig的构建器。 Create a new builder for ProxyConfig. |
public ProxyType getType() | 获取代理类型。 Get the proxy type. |
public String getHost() | 获取 `getHost`。 Get the proxy server hostname or IP address. |
public int getPort() | 获取 `getPort`。 Get the proxy server port. |
public String getUsername() | 获取 `getUsername`。 Get the authentication username. |
public String getPassword() | 获取密码。 Get the authentication password. |
public Set<String> getNonProxyHosts() | 获取 `getNonProxyHosts`。 Get the set of hosts that should bypass the proxy. |
public boolean hasAuthentication() | 判断是否具有 `hasAuthentication`。 Check if authentication credentials are configured. |
public boolean shouldBypass(String hostname) | 设置该参数。 Check if the given hostname should bypass the proxy. |
public Proxy toJavaProxy() | 转换此配置到`java.net.Proxy`实例。 Convert this configuration to a `java.net.Proxy` instance. |
public InetSocketAddress getSocketAddress() | 获取 `getSocketAddress`。 Get the socket address for this proxy. |
public String toString() | 返回 `toString` 结果。 Returns the to string. |
public boolean equals(Object o) | 设置该参数。 Performs the equals operation. |
public int hashCode() | 返回 `hashCode` 结果。 Returns the hash code. |
方法详情Method Detail
http
public static ProxyConfig http(String host, int port)
执行HTTP相关操作。
Create a simple HTTP proxy configuration without authentication.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
host | String | host(类型 `String`)。proxy server hostname or IP address |
port | int | port(类型 `int`)。proxy server port |
ProxyConfigio/agentscope/core/model/transport/ProxyConfig.java:83–85http
public static ProxyConfig http(String host, int port, String username, String password)
执行HTTP相关操作。
Create an HTTP proxy configuration with authentication.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
host | String | host(类型 `String`)。proxy server hostname or IP address |
port | int | port(类型 `int`)。proxy server port |
username | String | username(类型 `String`)。authentication username |
password | String | 密码(类型 `String`)。authentication password |
ProxyConfigio/agentscope/core/model/transport/ProxyConfig.java:96–104socks4
public static ProxyConfig socks4(String host, int port)
创建简单 SOCKS4 代理配置。
Create a simple SOCKS4 proxy configuration.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
host | String | host(类型 `String`)。proxy server hostname or IP address |
port | int | port(类型 `int`)。proxy server port |
ProxyConfigio/agentscope/core/model/transport/ProxyConfig.java:115–117socks5
public static ProxyConfig socks5(String host, int port)
执行 socks5 方法。
Create a simple SOCKS5 proxy configuration without authentication.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
host | String | host(类型 `String`)。proxy server hostname or IP address |
port | int | port(类型 `int`)。proxy server port |
ProxyConfigio/agentscope/core/model/transport/ProxyConfig.java:126–128socks5
public static ProxyConfig socks5(String host, int port, String username, String password)
执行 socks5 方法。
Create a SOCKS5 proxy configuration with authentication.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
host | String | host(类型 `String`)。proxy server hostname or IP address |
port | int | port(类型 `int`)。proxy server port |
username | String | username(类型 `String`)。authentication username |
password | String | 密码(类型 `String`)。authentication password |
ProxyConfigio/agentscope/core/model/transport/ProxyConfig.java:142–150builder
public static Builder builder()
创建用于ProxyConfig的构建器。
Create a new builder for ProxyConfig.
Builderio/agentscope/core/model/transport/ProxyConfig.java:157–159getType
public ProxyType getType()
获取代理类型。
Get the proxy type.
ProxyTypeio/agentscope/core/model/transport/ProxyConfig.java:166–168getHost
public String getHost()
获取 getHost。
Get the proxy server hostname or IP address.
Stringio/agentscope/core/model/transport/ProxyConfig.java:175–177getPort
public int getPort()
获取 getPort。
Get the proxy server port.
intio/agentscope/core/model/transport/ProxyConfig.java:184–186getUsername
public String getUsername()
获取 getUsername。
Get the authentication username.
Stringio/agentscope/core/model/transport/ProxyConfig.java:193–195getPassword
public String getPassword()
获取密码。
Get the authentication password.
Stringio/agentscope/core/model/transport/ProxyConfig.java:202–204getNonProxyHosts
public Set<String> getNonProxyHosts()
获取 getNonProxyHosts。
Get the set of hosts that should bypass the proxy.
Set<String>io/agentscope/core/model/transport/ProxyConfig.java:214–216hasAuthentication
public boolean hasAuthentication()
判断是否具有 hasAuthentication。
Check if authentication credentials are configured.
booleanio/agentscope/core/model/transport/ProxyConfig.java:223–225shouldBypass
public boolean shouldBypass(String hostname)
设置该参数。
Check if the given hostname should bypass the proxy.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
hostname | String | hostname(类型 `String`)。the hostname to check |
booleanio/agentscope/core/model/transport/ProxyConfig.java:233–244toJavaProxy
public Proxy toJavaProxy()
转换此配置到java.net.Proxy实例。
Convert this configuration to a java.net.Proxy instance.
Proxyio/agentscope/core/model/transport/ProxyConfig.java:251–265getSocketAddress
public InetSocketAddress getSocketAddress()
获取 getSocketAddress。
Get the socket address for this proxy.
InetSocketAddressio/agentscope/core/model/transport/ProxyConfig.java:272–274toString
public String toString()
返回 toString 结果。
Returns the to string.
Stringio/agentscope/core/model/transport/ProxyConfig.java:299–314equals
public boolean equals(Object o)
设置该参数。
Performs the equals operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
o | Object | o(类型 `Object`)。The o. |
booleanio/agentscope/core/model/transport/ProxyConfig.java:316–331hashCode
public int hashCode()
返回 hashCode 结果。
Returns the hash code.
intio/agentscope/core/model/transport/ProxyConfig.java:333–336嵌套类详情Nested Class Detail
Builder
public static class BuilderProxyConfig的构建器。位于 io.agentscope.core.model.transport 包。核心成员包括 type、host、port、username、password、nonProxyHosts。
Builder for ProxyConfig.