mirror of
https://github.com/fatedier/frp.git
synced 2024-12-04 22:01:43 +01: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:
|
||||
|
||||
```
|
||||
POST /handler
|
||||
POST /handler?version=0.1.0&op=Login
|
||||
{
|
||||
"version": "0.1.0",
|
||||
"op": "Login",
|
||||
|
@ -21,6 +21,7 @@ import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
@ -78,7 +79,10 @@ func (p *httpPlugin) do(ctx context.Context, r *Request, res *Response) error {
|
||||
if err != nil {
|
||||
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 {
|
||||
return err
|
||||
}
|
||||
|
@ -55,6 +55,10 @@ func (m *Manager) Register(p Plugin) {
|
||||
}
|
||||
|
||||
func (m *Manager) Login(content *LoginContent) (*LoginContent, error) {
|
||||
if len(m.loginPlugins) == 0 {
|
||||
return content, nil
|
||||
}
|
||||
|
||||
var (
|
||||
res = &Response{
|
||||
Reject: false,
|
||||
@ -85,6 +89,10 @@ func (m *Manager) Login(content *LoginContent) (*LoginContent, error) {
|
||||
}
|
||||
|
||||
func (m *Manager) NewProxy(content *NewProxyContent) (*NewProxyContent, error) {
|
||||
if len(m.newProxyPlugins) == 0 {
|
||||
return content, nil
|
||||
}
|
||||
|
||||
var (
|
||||
res = &Response{
|
||||
Reject: false,
|
||||
@ -115,6 +123,10 @@ func (m *Manager) NewProxy(content *NewProxyContent) (*NewProxyContent, error) {
|
||||
}
|
||||
|
||||
func (m *Manager) Ping(content *PingContent) (*PingContent, error) {
|
||||
if len(m.pingPlugins) == 0 {
|
||||
return content, nil
|
||||
}
|
||||
|
||||
var (
|
||||
res = &Response{
|
||||
Reject: false,
|
||||
@ -145,6 +157,10 @@ func (m *Manager) Ping(content *PingContent) (*PingContent, error) {
|
||||
}
|
||||
|
||||
func (m *Manager) NewWorkConn(content *NewWorkConnContent) (*NewWorkConnContent, error) {
|
||||
if len(m.newWorkConnPlugins) == 0 {
|
||||
return content, nil
|
||||
}
|
||||
|
||||
var (
|
||||
res = &Response{
|
||||
Reject: false,
|
||||
|
Loading…
Reference in New Issue
Block a user