Documentation
¶
Overview ¶
Package frp 托管 frpc(内网穿透客户端)与 frps(服务端): 在界面中维护连接与代理列表,生成配置文件并守护外部 frp 进程。
Index ¶
Constants ¶
const ( TypeTCP = "tcp" TypeUDP = "udp" TypeHTTP = "http" TypeHTTPS = "https" TypeSTCP = "stcp" TypeXTCP = "xtcp" )
代理类型。
const ( // ProxyAppend 只追加名称不存在的代理,同名代理保持不变 ProxyAppend = "append" // ProxyReplace 用导入的代理替换现有全部代理 ProxyReplace = "replace" )
代理导入方式。
const ( RoleClient = "client" RoleServer = "server" )
导入的角色。
const ID = "frp"
ID 是模块标识。
Variables ¶
This section is empty.
Functions ¶
func ClientTOML ¶
func ClientTOML(c ClientSettings, proxies []Proxy) string
ClientTOML 生成 frpc 配置文件内容(frp 0.52+ 的 TOML 格式)。
Types ¶
type ClientSettings ¶
type ClientSettings struct {
Enable bool `json:"enable"`
// BinPath 为空时依次在 PATH 与配置目录 bin 下查找 frpc
BinPath string `json:"binPath"`
ServerAddr string `json:"serverAddr"`
ServerPort int `json:"serverPort"`
Token string `json:"token"`
User string `json:"user"`
// Protocol 为 frpc 与 frps 之间的传输协议,留空使用 tcp
Protocol string `json:"protocol"`
}
ClientSettings 是 frpc(客户端)配置。
type ImportRequest ¶
type ImportRequest struct {
// Role 为 client(frpc)或 server(frps)
Role string `json:"role"`
Content string `json:"content"`
Apply bool `json:"apply"`
// ProxyMode 为 append 或 replace,仅客户端有效,留空等同 append
ProxyMode string `json:"proxyMode"`
}
ImportRequest 是导入请求。Apply 为 false 时只返回解析预览,不保存。
type ImportResponse ¶
type ImportResponse struct {
Applied bool `json:"applied"`
Role string `json:"role"`
Client *ClientSettings `json:"client,omitempty"`
Server *ServerSettings `json:"server,omitempty"`
Proxies []Proxy `json:"proxies"`
Warnings []string `json:"warnings"`
// Added 为实际新增的代理数量
Added int `json:"added"`
}
ImportResponse 是导入响应,密钥均已脱敏。
type ImportResult ¶
type ImportResult struct {
Role string `json:"role"`
Client *ClientSettings `json:"client,omitempty"`
Server *ServerSettings `json:"server,omitempty"`
Proxies []Proxy `json:"proxies"`
Warnings []string `json:"warnings"`
}
ImportResult 是解析结果,Warnings 列出被忽略或需要用户留意的内容。
func ParseImport ¶
func ParseImport(role, content string) (*ImportResult, error)
ParseImport 解析 frpc 或 frps 配置文本。
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
Module 是 frp 模块。
func (*Module) Summary ¶
func (m *Module) Summary() []module.SummaryItem
Summary 实现 module.Summarizer。
type PortRange ¶
type PortRange struct{ Start, End int }
PortRange 是闭区间端口范围。
func ParseAllowPorts ¶
ParseAllowPorts 解析 "6000-6100,7000" 形式的端口范围。
type Proxy ¶
type Proxy struct {
Key string `json:"key"`
Name string `json:"name"`
Type string `json:"type"`
Enable bool `json:"enable"`
LocalIP string `json:"localIp"`
LocalPort int `json:"localPort"`
// RemotePort 用于 tcp 与 udp
RemotePort int `json:"remotePort"`
// CustomDomains 与 Subdomain 用于 http 与 https
CustomDomains []string `json:"customDomains"`
Subdomain string `json:"subdomain"`
// SecretKey 用于 stcp 与 xtcp,访问端需使用相同密钥
SecretKey string `json:"secretKey"`
Remark string `json:"remark"`
}
Proxy 是一条 frpc 代理,把本地服务暴露到 frps。
type ServerSettings ¶
type ServerSettings struct {
Enable bool `json:"enable"`
BinPath string `json:"binPath"`
// BindPort 是 frpc 连接的端口
BindPort int `json:"bindPort"`
Token string `json:"token"`
// VhostHTTPPort 与 VhostHTTPSPort 为 0 时不启用 http / https 代理
VhostHTTPPort int `json:"vhostHttpPort"`
VhostHTTPSPort int `json:"vhostHttpsPort"`
// SubdomainHost 是子域名代理的根域名
SubdomainHost string `json:"subdomainHost"`
// AllowPorts 限制 frpc 可申请的远程端口,例如 "6000-6100,7000",留空不限制
AllowPorts string `json:"allowPorts"`
// 控制台端口为 0 时关闭
DashboardPort int `json:"dashboardPort"`
DashboardAddr string `json:"dashboardAddr"`
DashboardUser string `json:"dashboardUser"`
DashboardPwd string `json:"dashboardPwd"`
}
ServerSettings 是 frps(服务端)配置。