Maasea / sgmodule

surge module
Apache License 2.0
842 stars 105 forks source link

What does these two rules mean? #53

Closed FrontMage closed 4 months ago

FrontMage commented 4 months ago

Hi, I'm trying to build my own surge alternative, so I would like to support as much surge rules as I can, but when I'm trying to use these rules, I don't know how to implement them

[Rule]
AND,((DOMAIN-SUFFIX,googlevideo.com), (PROTOCOL,UDP)),REJECT
AND,((DOMAIN,youtubei.googleapis.com), (PROTOCOL,UDP)),REJECT

Other rules and functions are implemented, but without these two I still get some ads when playing video

Can you plz help me understand what these rules do? Thx!

Maasea commented 4 months ago

These two rules are used to block quic requests from YouTube app and make it fallbacks to HTTP requests.

This is because surge supports mitm over http but not mitm over quic.

Maasea commented 4 months ago

Specifically, without the rules above, Youtube would be transmitting the data using the quic protocol.

FrontMage commented 4 months ago

Oh, I see, so these are blocking UDP connections that have remote addresses of googlevideo.com and youtubei.googleapis.com? So can I just block these two domains' DNS requests or do I have to maintain an IP to domain hashmap to block the UDP connections only?

Maasea commented 4 months ago

Blocking dns requests can't be done because http has the same domain name.

You can only go to block udp requests, or you subject to implement mitm over quic

FrontMage commented 4 months ago

Crystal clear! Thx for the help!