mirror of
https://gitee.com/IrisVega/frp.git
synced 2024-11-01 22:31:29 +08:00
server plugin: set version and op in http request query (#1707)
This commit is contained in:
parent
a4b105dedb
commit
809f517db8
@ -22,7 +22,7 @@ HTTP path can be configured for each manage plugin in frps. We'll assume for thi
|
|||||||
A request to the RPC server will look like:
|
A request to the RPC server will look like:
|
||||||
|
|
||||||
```
|
```
|
||||||
POST /handler
|
POST /handler?version=0.1.0&op=Login
|
||||||
{
|
{
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"op": "Login",
|
"op": "Login",
|
||||||
|
@ -21,6 +21,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -78,7 +79,10 @@ func (p *httpPlugin) do(ctx context.Context, r *Request, res *Response) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
req, err := http.NewRequest("POST", p.url, bytes.NewReader(buf))
|
v := url.Values{}
|
||||||
|
v.Set("version", r.Version)
|
||||||
|
v.Set("op", r.Op)
|
||||||
|
req, err := http.NewRequest("POST", p.url+"?"+v.Encode(), bytes.NewReader(buf))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,10 @@ func (m *Manager) Register(p Plugin) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *Manager) Login(content *LoginContent) (*LoginContent, error) {
|
func (m *Manager) Login(content *LoginContent) (*LoginContent, error) {
|
||||||
|
if len(m.loginPlugins) == 0 {
|
||||||
|
return content, nil
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
res = &Response{
|
res = &Response{
|
||||||
Reject: false,
|
Reject: false,
|
||||||
@ -85,6 +89,10 @@ func (m *Manager) Login(content *LoginContent) (*LoginContent, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *Manager) NewProxy(content *NewProxyContent) (*NewProxyContent, error) {
|
func (m *Manager) NewProxy(content *NewProxyContent) (*NewProxyContent, error) {
|
||||||
|
if len(m.newProxyPlugins) == 0 {
|
||||||
|
return content, nil
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
res = &Response{
|
res = &Response{
|
||||||
Reject: false,
|
Reject: false,
|
||||||
@ -115,6 +123,10 @@ func (m *Manager) NewProxy(content *NewProxyContent) (*NewProxyContent, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *Manager) Ping(content *PingContent) (*PingContent, error) {
|
func (m *Manager) Ping(content *PingContent) (*PingContent, error) {
|
||||||
|
if len(m.pingPlugins) == 0 {
|
||||||
|
return content, nil
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
res = &Response{
|
res = &Response{
|
||||||
Reject: false,
|
Reject: false,
|
||||||
@ -145,6 +157,10 @@ func (m *Manager) Ping(content *PingContent) (*PingContent, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *Manager) NewWorkConn(content *NewWorkConnContent) (*NewWorkConnContent, error) {
|
func (m *Manager) NewWorkConn(content *NewWorkConnContent) (*NewWorkConnContent, error) {
|
||||||
|
if len(m.newWorkConnPlugins) == 0 {
|
||||||
|
return content, nil
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
res = &Response{
|
res = &Response{
|
||||||
Reject: false,
|
Reject: false,
|
||||||
|
Loading…
Reference in New Issue
Block a user