|
|
|
@ -27,9 +27,10 @@ import (
|
|
|
|
|
"sync"
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
"git.cacert.org/cacert-gosigner/pkg/messages"
|
|
|
|
|
"github.com/justincpresley/go-cobs"
|
|
|
|
|
"github.com/shamaton/msgpackgen/msgpack"
|
|
|
|
|
|
|
|
|
|
"git.cacert.org/cacert-gosigner/pkg/messages"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const cobsDelimiter = 0x00
|
|
|
|
@ -94,7 +95,7 @@ func (c *clientSimulator) handleInput(ctx context.Context) error {
|
|
|
|
|
default:
|
|
|
|
|
count, err := os.Stdin.Read(buf)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
return fmt.Errorf("reading input failed: %w", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if count == 0 {
|
|
|
|
@ -107,7 +108,7 @@ func (c *clientSimulator) handleInput(ctx context.Context) error {
|
|
|
|
|
|
|
|
|
|
err = cobs.Verify(data, cobsConfig)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
return fmt.Errorf("frame verification failed: %w", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
c.responses <- cobs.Decode(data, cobsConfig)
|
|
|
|
@ -157,7 +158,7 @@ func (c *clientSimulator) Run() error {
|
|
|
|
|
var inputError, commandError error
|
|
|
|
|
|
|
|
|
|
go func(inputErr error) {
|
|
|
|
|
inputError = c.handleInput(ctx)
|
|
|
|
|
_ = c.handleInput(ctx)
|
|
|
|
|
|
|
|
|
|
cancel()
|
|
|
|
|
|
|
|
|
@ -165,7 +166,7 @@ func (c *clientSimulator) Run() error {
|
|
|
|
|
}(inputError)
|
|
|
|
|
|
|
|
|
|
go func(commandErr error) {
|
|
|
|
|
commandErr = c.handleCommands(ctx)
|
|
|
|
|
_ = c.handleCommands(ctx)
|
|
|
|
|
|
|
|
|
|
cancel()
|
|
|
|
|
|
|
|
|
|