ing
This commit is contained in:
parent
b1eb6aa5f6
commit
6e88452b1b
|
@ -9,7 +9,7 @@ import (
|
|||
"git.loafle.net/overflow/overflow_probes/central/api/module"
|
||||
)
|
||||
|
||||
func (h *authHandlers) onNotify(method string, params interface{}) {
|
||||
func (h *authHandlers) onNotify(method string, params []string) {
|
||||
switch method {
|
||||
case module.NoAuthProbeService_AcceptNoAuthProbe:
|
||||
h.onNoAuthProbeAccept(params)
|
||||
|
@ -21,10 +21,9 @@ func (h *authHandlers) onNotify(method string, params interface{}) {
|
|||
|
||||
}
|
||||
|
||||
func (h *authHandlers) onNoAuthProbeAccept(params interface{}) {
|
||||
func (h *authHandlers) onNoAuthProbeAccept(params []string) {
|
||||
var err error
|
||||
ps := params.([]string)
|
||||
probeID := ps[0]
|
||||
probeID := params[0]
|
||||
|
||||
if lfcc.Exists(h.probeConfigPath) {
|
||||
if err = lfcc.Load(&h.probeConfig, h.probeConfigPath); nil != err {
|
||||
|
@ -40,7 +39,7 @@ func (h *authHandlers) onNoAuthProbeAccept(params interface{}) {
|
|||
h.acceptedChan <- true
|
||||
}
|
||||
|
||||
func (h *authHandlers) onNoAuthProbeDeny(params interface{}) {
|
||||
func (h *authHandlers) onNoAuthProbeDeny(params []string) {
|
||||
n := time.Now()
|
||||
h.noAuthConfig.DenyDate = &n
|
||||
if err := lfcc.Save(h.noAuthConfig, h.noAuthConfigPath, true); nil != err {
|
||||
|
|
|
@ -19,7 +19,7 @@ const (
|
|||
)
|
||||
|
||||
type (
|
||||
OnNotifyFunc func(method string, params interface{})
|
||||
OnNotifyFunc func(method string, params []string)
|
||||
OnCloseFunc func(code int, text string)
|
||||
)
|
||||
|
||||
|
@ -33,7 +33,7 @@ var ErrShutdown = errors.New("connection is shut down")
|
|||
|
||||
type Call struct {
|
||||
Method string // The name of the service and method to call.
|
||||
Args interface{} // The argument to the function (*struct).
|
||||
Args []string // The argument to the function (*struct).
|
||||
Result interface{} // The reply from the function (*struct).
|
||||
Error error // After completion, the error status.
|
||||
Done chan *Call // Strobes when call is complete.
|
||||
|
@ -52,8 +52,8 @@ func (c *Call) done() {
|
|||
|
||||
type Client interface {
|
||||
Dial(url string, header http.Header, readBufSize int, writeBufSize int) (*http.Response, error)
|
||||
Call(method string, args interface{}, result interface{}) error
|
||||
Notify(method string, args interface{}) error
|
||||
Call(method string, args []string, result interface{}) error
|
||||
Notify(method string, args []string) error
|
||||
OnNotify(cb OnNotifyFunc)
|
||||
OnClose(cb OnCloseFunc)
|
||||
Shutdown(ctx context.Context) error
|
||||
|
@ -103,12 +103,12 @@ func (c *client) Dial(url string, header http.Header, readBufSize int, writeBufS
|
|||
return res, nil
|
||||
}
|
||||
|
||||
func (c *client) Call(method string, args interface{}, result interface{}) error {
|
||||
func (c *client) Call(method string, args []string, result interface{}) error {
|
||||
call := <-c.goCall(method, args, result, make(chan *Call, 1)).Done
|
||||
return call.Error
|
||||
}
|
||||
|
||||
func (c *client) Notify(method string, args interface{}) error {
|
||||
func (c *client) Notify(method string, args []string) error {
|
||||
c.sendMutex.Lock()
|
||||
defer c.sendMutex.Unlock()
|
||||
|
||||
|
@ -146,7 +146,7 @@ func (c *client) Shutdown(ctx context.Context) error {
|
|||
// the invocation. The done channel will signal when the call is complete by returning
|
||||
// the same Call object. If done is nil, Go will allocate a new channel.
|
||||
// If non-nil, done must be buffered or Go will deliberately crash.
|
||||
func (c *client) goCall(method string, args interface{}, result interface{}, done chan *Call) *Call {
|
||||
func (c *client) goCall(method string, args []string, result interface{}, done chan *Call) *Call {
|
||||
call := new(Call)
|
||||
call.Method = method
|
||||
call.Args = args
|
||||
|
|
|
@ -2,6 +2,6 @@ package protocol
|
|||
|
||||
type Notification struct {
|
||||
Header
|
||||
Method string `json:"method"`
|
||||
Params interface{} `json:"params,omitempty"`
|
||||
Method string `json:"method"`
|
||||
Params []string `json:"params,omitempty"`
|
||||
}
|
||||
|
|
BIN
overflow_probes
Executable file
BIN
overflow_probes
Executable file
Binary file not shown.
|
@ -113,7 +113,7 @@ func (p *probe) connectToCentral() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (p *probe) onNotify(method string, params interface{}) {
|
||||
func (p *probe) onNotify(method string, params []string) {
|
||||
switch method {
|
||||
case module.NoAuthProbeService_AcceptNoAuthProbe:
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user