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

Use protobuf to serialize URL #22

Merged
merged 9 commits into from
Aug 12, 2023
Merged

Use protobuf to serialize URL #22

merged 9 commits into from
Aug 12, 2023

Conversation

krisukox
Copy link
Owner

@krisukox krisukox commented Aug 11, 2023

Google Flights uses protobuf to serialize the URL. Firstly, I did serialization manually, but I think adding protobuf, even for a really simple task, is the right approach. With this, it can be easily ported to any language with a protocol buffer compiler.

The downside of this method is that the final binary will be ~4 MB larger. (e.g. example3 binary 8 MB -> 12 MB).

Travelers:
When I tried to reverse engineer the URL, I found that it is serialized with protobuf:
Los Angeles -> Miami, 3 Adults
https://www.google.com/travel/flights/search?tfs=CBwQAholEgoyMDIzLTExLTA2ag4IAxIKL20vMDMwcWIzdHIHCAESA01JQRolEgoyMDIzLTExLTEzagcIARIDTUlBcg4IAxIKL20vMDMwcWIzdEABQAFAAUgBcAGCAQsI____________AZgBAQ

The tfs property is encoded with protobuf and with base64 encoding defined in RFC 4648.

Result of: protoc --decode_raw < proto.bin

1: 28
2: 2
3 {
  2: "2023-11-06"
  13 {
    1: 3
    2: "/m/030qb3t"
  }
  14 {
    1: 1
    2: "MIA"
  }
}
3 {
  2: "2023-11-13"
  13 {
    1: 1
    2: "MIA"
  }
  14 {
    1: 3
    2: "/m/030qb3t"
  }
}
8: 1
8: 1
8: 1
9: 1
14: 1
16 {
  1: 18446744073709551615
}
19: 1

Google Flights serializes travelers a bit differently than the implemented solution (3 adults):

  • Google Flights
8: 1
8: 1
8: 1
  • The client library:
8: "\001\001\001"

@krisukox krisukox changed the title Use protobuf to serialize url Use protobuf to serialize URL Aug 12, 2023
@krisukox krisukox merged commit 1ab0507 into main Aug 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant