diff --git a/auth/on_notify.go b/auth/on_notify.go index c05280e..82fbf12 100644 --- a/auth/on_notify.go +++ b/auth/on_notify.go @@ -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 { diff --git a/central/client/client.go b/central/client/client.go index ed25f67..0ac44e6 100644 --- a/central/client/client.go +++ b/central/client/client.go @@ -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 diff --git a/central/client/protocol/notification.go b/central/client/protocol/notification.go index 0f93fa7..c369e41 100644 --- a/central/client/protocol/notification.go +++ b/central/client/protocol/notification.go @@ -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"` } diff --git a/overflow_probes b/overflow_probes new file mode 100755 index 0000000..6c509c0 Binary files /dev/null and b/overflow_probes differ diff --git a/probe/probe.go b/probe/probe.go index 1f38375..b002f5e 100644 --- a/probe/probe.go +++ b/probe/probe.go @@ -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: