|
|
|
@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
|
|
|
|
|
limitations under the License.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
package protocol
|
|
|
|
|
package handler
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"errors"
|
|
|
|
@ -25,9 +25,11 @@ import (
|
|
|
|
|
"github.com/shamaton/msgpackgen/msgpack"
|
|
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
|
|
|
|
|
|
"git.cacert.org/cacert-gosigner/pkg/health"
|
|
|
|
|
"git.cacert.org/cacert-gosigner/pkg/protocol"
|
|
|
|
|
|
|
|
|
|
"git.cacert.org/cacert-gosigner/internal/health"
|
|
|
|
|
"git.cacert.org/cacert-gosigner/internal/x509/revoking"
|
|
|
|
|
"git.cacert.org/cacert-gosigner/pkg/messages"
|
|
|
|
|
"git.cacert.org/cacert-gosigner/pkg/x509/revoking"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// MsgPackHandler is a Handler implementation for the msgpack serialization format.
|
|
|
|
@ -35,8 +37,8 @@ type MsgPackHandler struct {
|
|
|
|
|
logger *logrus.Logger
|
|
|
|
|
healthHandler *health.Handler
|
|
|
|
|
fetchCRLHandler *revoking.FetchCRLHandler
|
|
|
|
|
currentCommand *Command
|
|
|
|
|
currentResponse *Response
|
|
|
|
|
currentCommand *protocol.Command
|
|
|
|
|
currentResponse *protocol.Response
|
|
|
|
|
lock sync.Mutex
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -52,7 +54,7 @@ func (m *MsgPackHandler) HandleCommandAnnounce(frame []byte) error {
|
|
|
|
|
|
|
|
|
|
m.logger.WithField("announcement", &ann).Info("received command announcement")
|
|
|
|
|
|
|
|
|
|
m.currentCommand = &Command{Announce: &ann}
|
|
|
|
|
m.currentCommand = &protocol.Command{Announce: &ann}
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
@ -185,7 +187,7 @@ func (m *MsgPackHandler) handleCommand() error {
|
|
|
|
|
return fmt.Errorf("error from command handler: %w", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m.currentResponse = &Response{
|
|
|
|
|
m.currentResponse = &protocol.Response{
|
|
|
|
|
Announce: messages.BuildResponseAnnounce(responseCode, m.currentID()),
|
|
|
|
|
Response: responseData,
|
|
|
|
|
}
|
|
|
|
@ -193,8 +195,8 @@ func (m *MsgPackHandler) handleCommand() error {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *MsgPackHandler) buildErrorResponse(errMsg string) *Response {
|
|
|
|
|
return &Response{
|
|
|
|
|
func (m *MsgPackHandler) buildErrorResponse(errMsg string) *protocol.Response {
|
|
|
|
|
return &protocol.Response{
|
|
|
|
|
Announce: messages.BuildResponseAnnounce(messages.RespError, m.currentID()),
|
|
|
|
|
Response: &messages.ErrorResponse{Message: errMsg},
|
|
|
|
|
}
|
|
|
|
@ -253,7 +255,7 @@ func (m *MsgPackHandler) handleFetchCRLCommand() (*messages.FetchCRLResponse, er
|
|
|
|
|
return response, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func New(logger *logrus.Logger, handlers ...RegisterHandler) (Handler, error) {
|
|
|
|
|
func New(logger *logrus.Logger, handlers ...RegisterHandler) (protocol.Handler, error) {
|
|
|
|
|
messages.RegisterGeneratedResolver()
|
|
|
|
|
|
|
|
|
|
h := &MsgPackHandler{
|