frp

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 17, 2026 License: Apache-2.0 Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package frp 托管 frpc(内网穿透客户端)与 frps(服务端): 在界面中维护连接与代理列表,生成配置文件并守护外部 frp 进程。

Index

Constants

View Source
const (
	TypeTCP   = "tcp"
	TypeUDP   = "udp"
	TypeHTTP  = "http"
	TypeHTTPS = "https"
	TypeSTCP  = "stcp"
	TypeXTCP  = "xtcp"
)

代理类型。

View Source
const (
	// ProxyAppend 只追加名称不存在的代理,同名代理保持不变
	ProxyAppend = "append"
	// ProxyReplace 用导入的代理替换现有全部代理
	ProxyReplace = "replace"
)

代理导入方式。

View Source
const (
	RoleClient = "client"
	RoleServer = "server"
)

导入的角色。

View Source
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 格式)。

func ServerTOML

func ServerTOML(s ServerSettings) string

ServerTOML 生成 frps 配置文件内容。

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(客户端)配置。

func (*ClientSettings) Validate

func (c *ClientSettings) Validate() error

Validate 校验并规范化客户端配置。

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 New

func New() *Module

New 创建模块。

func (*Module) ID

func (m *Module) ID() string

ID 实现 module.Module。

func (*Module) Init

func (m *Module) Init(env module.Env) error

Init 实现 module.Module。

func (*Module) Routes

func (m *Module) Routes(r module.Router)

Routes 实现 module.Module。

func (*Module) Start

func (m *Module) Start(context.Context) error

Start 实现 module.Module。

func (*Module) Stop

func (m *Module) Stop() error

Stop 实现 module.Module。

func (*Module) Summary

func (m *Module) Summary() []module.SummaryItem

Summary 实现 module.Summarizer。

func (*Module) Title

func (m *Module) Title() string

Title 实现 module.Module。

type PortRange

type PortRange struct{ Start, End int }

PortRange 是闭区间端口范围。

func ParseAllowPorts

func ParseAllowPorts(s string) ([]PortRange, error)

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。

func (*Proxy) Validate

func (p *Proxy) Validate() error

Validate 校验并规范化代理配置。

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(服务端)配置。

func (*ServerSettings) Validate

func (s *ServerSettings) Validate() error

Validate 校验并规范化服务端配置。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL