Implement first client command

The client can now talk to the old Perl signer implementation. Running
socat has been documented in README.md. Commonly used I/O code has been
moved to the shared/io.go file.
This commit is contained in:
Jan Dittberner 2020-04-17 19:38:54 +02:00
parent 5aa557c9aa
commit 65855152ce
6 changed files with 287 additions and 84 deletions

View file

@ -22,6 +22,8 @@ type SignerRequest struct {
Content3 string
}
const protocolVersion = 1
func SignerRequestFromData(lengthBytes []byte, blockData []byte, checkSum byte) (*SignerRequest, error) {
headerLength := decode24BitLength(blockData[0:3])
headerBytes := blockData[3 : 3+headerLength]
@ -76,5 +78,9 @@ func (r SignerRequest) Serialize() []byte {
}
func NewNulRequest() *SignerRequest {
return &SignerRequest{Version: 1, Action: ActionNul, Content1: time.Now().UTC().Format("010203042006.05")}
return &SignerRequest{
Version: protocolVersion,
Action: ActionNul,
Content1: time.Now().UTC().Format("010203042006.05"),
}
}