mirror of
https://gitee.com/IrisVega/frp.git
synced 2024-11-01 22:31:29 +08:00
This commit is contained in:
parent
e9775bd70f
commit
22412851b4
@ -33,6 +33,8 @@ type Response struct {
|
|||||||
|
|
||||||
type LoginContent struct {
|
type LoginContent struct {
|
||||||
msg.Login
|
msg.Login
|
||||||
|
|
||||||
|
ClientAddress string `json:"client_address,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserInfo struct {
|
type UserInfo struct {
|
||||||
|
@ -335,6 +335,7 @@ func (svr *Service) handleConnection(ctx context.Context, conn net.Conn) {
|
|||||||
// server plugin hook
|
// server plugin hook
|
||||||
content := &plugin.LoginContent{
|
content := &plugin.LoginContent{
|
||||||
Login: *m,
|
Login: *m,
|
||||||
|
ClientAddress: conn.RemoteAddr().String(),
|
||||||
}
|
}
|
||||||
retContent, err := svr.pluginManager.Login(content)
|
retContent, err := svr.pluginManager.Login(content)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
@ -24,9 +24,14 @@ var _ = Describe("[Feature: Server-Plugins]", func() {
|
|||||||
|
|
||||||
It("Auth for custom meta token", func() {
|
It("Auth for custom meta token", func() {
|
||||||
localPort := f.AllocPort()
|
localPort := f.AllocPort()
|
||||||
|
|
||||||
|
clientAddressGot := false
|
||||||
handler := func(req *plugin.Request) *plugin.Response {
|
handler := func(req *plugin.Request) *plugin.Response {
|
||||||
var ret plugin.Response
|
var ret plugin.Response
|
||||||
content := req.Content.(*plugin.LoginContent)
|
content := req.Content.(*plugin.LoginContent)
|
||||||
|
if content.ClientAddress != "" {
|
||||||
|
clientAddressGot = true
|
||||||
|
}
|
||||||
if content.Metas["token"] == "123" {
|
if content.Metas["token"] == "123" {
|
||||||
ret.Unchange = true
|
ret.Unchange = true
|
||||||
} else {
|
} else {
|
||||||
@ -69,6 +74,8 @@ var _ = Describe("[Feature: Server-Plugins]", func() {
|
|||||||
|
|
||||||
framework.NewRequestExpect(f).Port(remotePort).Ensure()
|
framework.NewRequestExpect(f).Port(remotePort).Ensure()
|
||||||
framework.NewRequestExpect(f).Port(remotePort2).ExpectError(true).Ensure()
|
framework.NewRequestExpect(f).Port(remotePort2).ExpectError(true).Ensure()
|
||||||
|
|
||||||
|
framework.ExpectTrue(clientAddressGot)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user