Add client version as argument
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Jake Walker 2022-08-05 11:15:05 +01:00
parent 357282c0e4
commit 158189ae7d
2 changed files with 3 additions and 5 deletions

View file

@ -14,8 +14,6 @@ import (
"git.vh7.uk/jakew/echo-go/crypto"
)
const EchoVersion = "3.17"
func randomHex(n int) (string, error) {
b := make([]byte, n)
if _, err := rand.Read(b); err != nil {
@ -141,7 +139,7 @@ func (c *Client) Receive() ([]RawMessage, error) {
return messages, nil
}
func (c *Client) HandshakeLoop(password string) error {
func (c *Client) HandshakeLoop(clientVersion string, password string) error {
log.Println("sending server info request")
err := c.SendPlain(ReqServerInfo, nil, nil, nil)
if err != nil {
@ -175,7 +173,7 @@ func (c *Client) HandshakeLoop(password string) error {
data, err := json.Marshal([]string{
c.Username,
password,
EchoVersion,
clientVersion,
})
if err != nil {
return err

View file

@ -8,7 +8,7 @@ func TestCanConnect(t *testing.T) {
t.Fatalf("failed to create client: %v", err)
}
err = client.handshakeLoop("mypassword")
err = client.HandshakeLoop("mypassword", "4.0.0")
if err != nil {
t.Fatalf("failed to run handshake loop: %v", err)
}