Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
企猫商务
frp
提交
a57679f8
F
frp
项目概览
企猫商务
/
frp
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
frp
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
a57679f8
编写于
12月 08, 2019
作者:
F
fatedier
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support meta info for client and proxy
上级
df183753
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
46 addition
and
18 deletion
+46
-18
conf/frpc_full.ini
conf/frpc_full.ini
+7
-0
models/config/client_common.go
models/config/client_common.go
+8
-0
models/config/proxy.go
models/config/proxy.go
+13
-1
models/msg/msg.go
models/msg/msg.go
+16
-14
models/plugin/http2https.go
models/plugin/http2https.go
+1
-2
models/plugin/https2http.go
models/plugin/https2http.go
+1
-1
未找到文件。
conf/frpc_full.ini
浏览文件 @
a57679f8
...
...
@@ -64,6 +64,10 @@ tls_enable = true
# heartbeat_interval = 30
# heartbeat_timeout = 90
# additional meta info for client
meta_var1
=
123
meta_var2
=
234
# 'ssh' is the unique proxy name
# if user in [common] section is not empty, it will be changed to {user}.{proxy} such as 'your_name.ssh'
[ssh]
...
...
@@ -92,6 +96,9 @@ health_check_timeout_s = 3
health_check_max_failed
=
3
# every 10 seconds will do a health check
health_check_interval_s
=
10
# additional meta info for each proxy
meta_var1
=
123
meta_var2
=
234
[ssh_random]
type
=
tcp
...
...
models/config/client_common.go
浏览文件 @
a57679f8
...
...
@@ -115,6 +115,8 @@ type ClientCommonConf struct {
// before the connection is terminated, in seconds. It is not recommended
// to change this value. By default, this value is 90.
HeartBeatTimeout
int64
`json:"heartbeat_timeout"`
// Client meta info
Metas
map
[
string
]
string
`json:"metas"`
}
// GetDefaultClientConf returns a client configuration with default values.
...
...
@@ -144,6 +146,7 @@ func GetDefaultClientConf() ClientCommonConf {
TLSEnable
:
false
,
HeartBeatInterval
:
30
,
HeartBeatTimeout
:
90
,
Metas
:
make
(
map
[
string
]
string
),
}
}
...
...
@@ -294,6 +297,11 @@ func UnmarshalClientConfFromIni(content string) (cfg ClientCommonConf, err error
cfg
.
HeartBeatInterval
=
v
}
}
for
k
,
v
:=
range
conf
.
Section
(
"common"
)
{
if
strings
.
HasPrefix
(
k
,
"meta_"
)
{
cfg
.
Metas
[
strings
.
TrimPrefix
(
k
,
"meta_"
)]
=
v
}
}
return
}
...
...
models/config/proxy.go
浏览文件 @
a57679f8
...
...
@@ -130,6 +130,9 @@ type BaseProxyConf struct {
// 0 means no limit
BandwidthLimit
BandwidthQuantity
`json:"bandwidth_limit"`
// meta info for each proxy
Metas
map
[
string
]
string
`json:"metas"`
LocalSvrConf
HealthCheckConf
}
...
...
@@ -146,7 +149,8 @@ func (cfg *BaseProxyConf) compare(cmp *BaseProxyConf) bool {
cfg
.
Group
!=
cmp
.
Group
||
cfg
.
GroupKey
!=
cmp
.
GroupKey
||
cfg
.
ProxyProtocolVersion
!=
cmp
.
ProxyProtocolVersion
||
cfg
.
BandwidthLimit
.
Equal
(
&
cmp
.
BandwidthLimit
)
{
cfg
.
BandwidthLimit
.
Equal
(
&
cmp
.
BandwidthLimit
)
||
!
reflect
.
DeepEqual
(
cfg
.
Metas
,
cmp
.
Metas
)
{
return
false
}
if
!
cfg
.
LocalSvrConf
.
compare
(
&
cmp
.
LocalSvrConf
)
{
...
...
@@ -165,6 +169,7 @@ func (cfg *BaseProxyConf) UnmarshalFromMsg(pMsg *msg.NewProxy) {
cfg
.
UseCompression
=
pMsg
.
UseCompression
cfg
.
Group
=
pMsg
.
Group
cfg
.
GroupKey
=
pMsg
.
GroupKey
cfg
.
Metas
=
pMsg
.
Metas
}
func
(
cfg
*
BaseProxyConf
)
UnmarshalFromIni
(
prefix
string
,
name
string
,
section
ini
.
Section
)
error
{
...
...
@@ -212,6 +217,12 @@ func (cfg *BaseProxyConf) UnmarshalFromIni(prefix string, name string, section i
}
cfg
.
HealthCheckUrl
=
s
+
cfg
.
HealthCheckUrl
}
for
k
,
v
:=
range
section
{
if
strings
.
HasPrefix
(
k
,
"meta_"
)
{
cfg
.
Metas
[
strings
.
TrimPrefix
(
k
,
"meta_"
)]
=
v
}
}
return
nil
}
...
...
@@ -222,6 +233,7 @@ func (cfg *BaseProxyConf) MarshalToMsg(pMsg *msg.NewProxy) {
pMsg
.
UseCompression
=
cfg
.
UseCompression
pMsg
.
Group
=
cfg
.
Group
pMsg
.
GroupKey
=
cfg
.
GroupKey
pMsg
.
Metas
=
cfg
.
Metas
}
func
(
cfg
*
BaseProxyConf
)
checkForCli
()
(
err
error
)
{
...
...
models/msg/msg.go
浏览文件 @
a57679f8
...
...
@@ -62,14 +62,15 @@ var (
// When frpc start, client send this message to login to server.
type
Login
struct
{
Version
string
`json:"version"`
Hostname
string
`json:"hostname"`
Os
string
`json:"os"`
Arch
string
`json:"arch"`
User
string
`json:"user"`
PrivilegeKey
string
`json:"privilege_key"`
Timestamp
int64
`json:"timestamp"`
RunId
string
`json:"run_id"`
Version
string
`json:"version"`
Hostname
string
`json:"hostname"`
Os
string
`json:"os"`
Arch
string
`json:"arch"`
User
string
`json:"user"`
PrivilegeKey
string
`json:"privilege_key"`
Timestamp
int64
`json:"timestamp"`
RunId
string
`json:"run_id"`
Metas
map
[
string
]
string
`json:"metas"`
// Some global configures.
PoolCount
int
`json:"pool_count"`
...
...
@@ -84,12 +85,13 @@ type LoginResp struct {
// When frpc login success, send this message to frps for running a new proxy.
type
NewProxy
struct
{
ProxyName
string
`json:"proxy_name"`
ProxyType
string
`json:"proxy_type"`
UseEncryption
bool
`json:"use_encryption"`
UseCompression
bool
`json:"use_compression"`
Group
string
`json:"group"`
GroupKey
string
`json:"group_key"`
ProxyName
string
`json:"proxy_name"`
ProxyType
string
`json:"proxy_type"`
UseEncryption
bool
`json:"use_encryption"`
UseCompression
bool
`json:"use_compression"`
Group
string
`json:"group"`
GroupKey
string
`json:"group_key"`
Metas
map
[
string
]
string
`json:"metas"`
// tcp and udp only
RemotePort
int
`json:"remote_port"`
...
...
models/plugin/http2https.go
浏览文件 @
a57679f8
...
...
@@ -94,7 +94,6 @@ func NewHTTP2HTTPSPlugin(params map[string]string) (Plugin, error) {
return
p
,
nil
}
func
(
p
*
HTTP2HTTPSPlugin
)
Handle
(
conn
io
.
ReadWriteCloser
,
realConn
net
.
Conn
,
extraBufToLocal
[]
byte
)
{
wrapConn
:=
frpNet
.
WrapReadWriteCloserToConn
(
conn
,
realConn
)
p
.
l
.
PutConn
(
wrapConn
)
...
...
@@ -105,7 +104,7 @@ func (p *HTTP2HTTPSPlugin) Name() string {
}
func
(
p
*
HTTP2HTTPSPlugin
)
Close
()
error
{
if
err
:=
p
.
s
.
Close
();
err
!=
nil
{
if
err
:=
p
.
s
.
Close
();
err
!=
nil
{
return
err
}
return
nil
...
...
models/plugin/https2http.go
浏览文件 @
a57679f8
...
...
@@ -126,7 +126,7 @@ func (p *HTTPS2HTTPPlugin) Name() string {
}
func
(
p
*
HTTPS2HTTPPlugin
)
Close
()
error
{
if
err
:=
p
.
s
.
Close
();
err
!=
nil
{
if
err
:=
p
.
s
.
Close
();
err
!=
nil
{
return
err
}
return
nil
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录