bogdanfinn / tls-client

net/http.Client like HTTP Client with options to select specific client TLS Fingerprints to use for requests.
BSD 4-Clause "Original" or "Old" License
670 stars 134 forks source link

Priority frames problem #17

Closed Harusakii closed 1 year ago

Harusakii commented 1 year ago

Theres two things, first of all

{
        "frame_type": "WINDOW_UPDATE",
        "length": 4,
        "increment": 12517377
      }

this right here for firefox, on the normal browser its the second sent frame when using the firefox client and doing the same thing, then its the 8th frame sent

the second thing is, in the HEADERS frame sent, the priority on browser is this:

"priority": {
        "weigth": 42,
        "depends_on": 13,
        "exclusive": 0
      }

on the client it is this:

"priority": {
          "weight": 256,
          "depends_on": 0,
          "exclusive": 1
        }

and idk where I could change that

bogdanfinn commented 1 year ago

long time no see @Harusakii

For the First thing: You are right. See here: https://github.com/bogdanfinn/fhttp/blob/master/http2/transport.go#L810 I'm writing the Priority Header Frames before the WriteWindowUpdate

I will change that in 1.0.2 i guess as i just released 1.0.1.

Second Thing: Yes you are again right. This was a hardcoded value for Chrome see: https://github.com/bogdanfinn/fhttp/blob/master/http2/transport.go#L1379

I think we can change that to supply this priority object by the profile (and if none supplied we are using chrome default)

bogdanfinn commented 1 year ago

@Harusakii

I released https://github.com/bogdanfinn/tls-client/releases/tag/v1.1.0

It is now possible to optional set the header priority as you can see here for firefox: https://github.com/bogdanfinn/tls-client/blob/master/profiles.go#L340

If nothing is provided, then the default header priority is taken as before.

Also i changed the order the Header Frames are sent that WindowUpdate is sent before the priority headers. See this example for verification:

https://github.com/bogdanfinn/tls-client/blob/master/example/main.go#L540

Harusakii commented 1 year ago

Haha, also great to see you still going strong @bogdanfinn ^^

I will look into the updates provided, but already thank you! Pretty fast haha ^^

Always good to bring customizability when stuff like that changes ;)

Harusakii commented 1 year ago

Hey @bogdanfinn!

It works haha ^^, one thing I am seeing though is that the stream ID on the headers frame is 1 even though it should be 15 (Firefox obv).

Then its perfect :)

Harusakii commented 1 year ago

I just did this and now it tracks the stream ID with the priorities to be sent, idk if its the best solution but it works haha:

for _, priority := range t.Priorities {
        cc.fr.WritePriority(priority.StreamID, priority.PriorityParam)
        cc.nextStreamID = priority.StreamID + 2
    }

here

bogdanfinn commented 1 year ago

@Harusakii added your suggestion in https://github.com/bogdanfinn/tls-client/releases/tag/v1.1.1

Harusakii commented 1 year ago

Very nice ^^