Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

golang ParseURLResponse function does not handle URLs correctly #90

Closed
burgerdev opened this issue May 24, 2021 · 1 comment
Closed
Labels
go Go implementation of GLOME

Comments

@burgerdev
Copy link
Collaborator

The function ParseURLResponse does not accept URLs, only paths. Providing a URL as input does not fail, but produces unexpected results.

  • The function is used correctly in server.go, but the naming and documentation is misleading.
  • The HandshakeInfo seems to be computed correctly.
  • The Message is wrong.

Example code with output:

package main

import (
	"fmt"
	"log"

	"github.com/google/glome/go/glome"
	"github.com/google/glome/go/login"
)

func main() {
	srv := login.Server{KeyFetcher: func(_ uint8) (*glome.PrivateKey, error) {
		var key glome.PrivateKey
		key[5] = 1
		return &key, nil
	}}
	resp, err := srv.ParseURLResponse("https://glome.example.com/v1/UYcvQ1u4uJ0OOtYqouURB07hleHDnvaogAFBi-ZW48N2/serial-number:123/reboot/")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("login.Message%+v\n", resp.Msg)
}
login.Message{HostIDType:https HostID: Action:/glome.example.com/v1/UYcvQ1u4uJ0OOtYqouURB07hleHDnvaogAFBi-ZW48N2/serial-number:123/reboot}
@vvidic vvidic added the go Go implementation of GLOME label Jul 5, 2022
@l9i
Copy link
Collaborator

l9i commented Mar 9, 2023

6648ac8 changed the ParseURLResponse implementation. Running the program listed above, results now the correct output:

login.Message{HostIDType:serial-number HostID:123 Action:reboot}

There are still ways to improvement that function but I believe we can do it as a part of #102.

@l9i l9i closed this as completed Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go Go implementation of GLOME
Projects
None yet
Development

No branches or pull requests

3 participants