AS AgentScopeAPI 手册 / API Reference

ProxyConfig

public class ProxyConfig
源码Source 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)
static

执行HTTP相关操作。

Create a simple HTTP proxy configuration without authentication.

参数Parameters
名称Name类型Type说明Description
hostStringhost(类型 `String`)。proxy server hostname or IP address
portintport(类型 `int`)。proxy server port
返回Returns ProxyConfig
一种新的ProxyConfig 实例。a new ProxyConfig instance
源码Source io/agentscope/core/model/transport/ProxyConfig.java:83–85

http

public static ProxyConfig http(String host, int port, String username, String password)
static

执行HTTP相关操作。

Create an HTTP proxy configuration with authentication.

参数Parameters
名称Name类型Type说明Description
hostStringhost(类型 `String`)。proxy server hostname or IP address
portintport(类型 `int`)。proxy server port
usernameStringusername(类型 `String`)。authentication username
passwordString密码(类型 `String`)。authentication password
返回Returns ProxyConfig
一种新的ProxyConfig 实例。a new ProxyConfig instance
源码Source io/agentscope/core/model/transport/ProxyConfig.java:96–104

socks4

public static ProxyConfig socks4(String host, int port)
static

创建简单 SOCKS4 代理配置。

Create a simple SOCKS4 proxy configuration.

参数Parameters
名称Name类型Type说明Description
hostStringhost(类型 `String`)。proxy server hostname or IP address
portintport(类型 `int`)。proxy server port
返回Returns ProxyConfig
一种新的ProxyConfig 实例。a new ProxyConfig instance
源码Source io/agentscope/core/model/transport/ProxyConfig.java:115–117

socks5

public static ProxyConfig socks5(String host, int port)
static

执行 socks5 方法。

Create a simple SOCKS5 proxy configuration without authentication.

参数Parameters
名称Name类型Type说明Description
hostStringhost(类型 `String`)。proxy server hostname or IP address
portintport(类型 `int`)。proxy server port
返回Returns ProxyConfig
一种新的ProxyConfig 实例。a new ProxyConfig instance
源码Source io/agentscope/core/model/transport/ProxyConfig.java:126–128

socks5

public static ProxyConfig socks5(String host, int port, String username, String password)
static

执行 socks5 方法。

Create a SOCKS5 proxy configuration with authentication.

参数Parameters
名称Name类型Type说明Description
hostStringhost(类型 `String`)。proxy server hostname or IP address
portintport(类型 `int`)。proxy server port
usernameStringusername(类型 `String`)。authentication username
passwordString密码(类型 `String`)。authentication password
返回Returns ProxyConfig
一种新的ProxyConfig 实例。a new ProxyConfig instance
源码Source io/agentscope/core/model/transport/ProxyConfig.java:142–150

builder

public static Builder builder()
static

创建用于ProxyConfig的构建器。

Create a new builder for ProxyConfig.

返回Returns Builder
一种新的构建器实例。a new Builder instance
源码Source io/agentscope/core/model/transport/ProxyConfig.java:157–159

getType

public ProxyType getType()

获取代理类型。

Get the proxy type.

返回Returns ProxyType
代理类型。the proxy type
源码Source io/agentscope/core/model/transport/ProxyConfig.java:166–168

getHost

public String getHost()

获取 getHost。

Get the proxy server hostname or IP address.

返回Returns String
返回字符串结果。the proxy host
源码Source io/agentscope/core/model/transport/ProxyConfig.java:175–177

getPort

public int getPort()

获取 getPort。

Get the proxy server port.

返回Returns int
返回数值结果。the proxy port
源码Source io/agentscope/core/model/transport/ProxyConfig.java:184–186

getUsername

public String getUsername()

获取 getUsername。

Get the authentication username.

返回Returns String
返回字符串结果。the username, or null if no authentication is configured
源码Source io/agentscope/core/model/transport/ProxyConfig.java:193–195

getPassword

public String getPassword()

获取密码。

Get the authentication password.

返回Returns String
返回字符串结果。the password, or null if no authentication is configured
源码Source io/agentscope/core/model/transport/ProxyConfig.java:202–204

getNonProxyHosts

public Set<String> getNonProxyHosts()

获取 getNonProxyHosts。

Get the set of hosts that should bypass the proxy.

返回Returns Set<String>
返回设置。the set of non-proxy hosts, or null if not configured
源码Source io/agentscope/core/model/transport/ProxyConfig.java:214–216

hasAuthentication

public boolean hasAuthentication()

判断是否具有 hasAuthentication。

Check if authentication credentials are configured.

返回Returns boolean
返回布尔值,表示判断结果。true if both username and password are set
源码Source io/agentscope/core/model/transport/ProxyConfig.java:223–225

shouldBypass

public boolean shouldBypass(String hostname)

设置该参数。

Check if the given hostname should bypass the proxy.

参数Parameters
名称Name类型Type说明Description
hostnameStringhostname(类型 `String`)。the hostname to check
返回Returns boolean
返回布尔值,表示判断结果。true if the hostname should bypass the proxy
源码Source io/agentscope/core/model/transport/ProxyConfig.java:233–244

toJavaProxy

public Proxy toJavaProxy()

转换此配置到java.net.Proxy实例。

Convert this configuration to a java.net.Proxy instance.

返回Returns Proxy
返回代理。the Java Proxy instance
源码Source io/agentscope/core/model/transport/ProxyConfig.java:251–265

getSocketAddress

public InetSocketAddress getSocketAddress()

获取 getSocketAddress。

Get the socket address for this proxy.

返回Returns InetSocketAddress
返回InetSocketAddress。the proxy socket address
源码Source io/agentscope/core/model/transport/ProxyConfig.java:272–274

toString

public String toString()

返回 toString 结果。

Returns the to string.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/core/model/transport/ProxyConfig.java:299–314

equals

public boolean equals(Object o)

设置该参数。

Performs the equals operation.

参数Parameters
名称Name类型Type说明Description
oObjecto(类型 `Object`)。The o.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/core/model/transport/ProxyConfig.java:316–331

hashCode

public int hashCode()

返回 hashCode 结果。

Returns the hash code.

返回Returns int
返回数值结果。Returns a numeric result.
源码Source io/agentscope/core/model/transport/ProxyConfig.java:333–336

嵌套类详情Nested Class Detail

Builder

public static class Builder

ProxyConfig的构建器。位于 io.agentscope.core.model.transport 包。核心成员包括 type、host、port、username、password、nonProxyHosts。

Builder for ProxyConfig.

基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.