mirror of
https://github.com/j93es/oauth-backend.git
synced 2026-06-05 00:01:28 +09:00
Merge pull request #21 from j93es/feat/ignore
일부 트래커와 cdn, 여러 파일 확장자를 제외했습니다.
This commit is contained in:
commit
4758d7a689
1 changed files with 34 additions and 2 deletions
|
|
@ -29,8 +29,40 @@ class AddonBase:
|
||||||
else:
|
else:
|
||||||
self.google_login_hint = None
|
self.google_login_hint = None
|
||||||
|
|
||||||
|
def should_ignore(self, flow: http.HTTPFlow) -> bool:
|
||||||
|
"""Check if the request should be ignored."""
|
||||||
|
ignore_domains = [
|
||||||
|
".googleapis.com",
|
||||||
|
"android.clients.google.com", # Added missing comma here
|
||||||
|
".adtrafficquality.google",
|
||||||
|
".googlesyndication.com",
|
||||||
|
"cdn.jsdelivr.net",
|
||||||
|
"update.googleapis.com",
|
||||||
|
]
|
||||||
|
# Ignore .googleapis.com domains
|
||||||
|
for domain in ignore_domains:
|
||||||
|
if domain in flow.request.pretty_host:
|
||||||
|
return True
|
||||||
|
|
||||||
|
# Ignore static files (JS, CSS, fonts, images, etc.)
|
||||||
|
# Split on '?' to remove query parameters before checking extension
|
||||||
|
path = flow.request.path.split('?')[0].lower()
|
||||||
|
static_extensions = [
|
||||||
|
'.js', '.css', '.woff2', '.woff', '.ttf', '.otf', '.svg',
|
||||||
|
'.png', '.jpg', '.jpeg', '.gif', '.webp', '.ico', '.bmp',
|
||||||
|
'.tiff', '.tif', '.webm', '.mp4', '.avi', '.mov', '.pdf', '.md',
|
||||||
|
'.txt', '.csv'
|
||||||
|
]
|
||||||
|
|
||||||
|
if any(path.endswith(ext) for ext in static_extensions):
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async def request(self, flow: http.HTTPFlow):
|
async def request(self, flow: http.HTTPFlow):
|
||||||
if false_true_varifing_task.is_verifing_false_true():
|
if false_true_varifing_task.is_verifing_false_true() or self.should_ignore(flow):
|
||||||
return
|
return
|
||||||
|
|
||||||
tasks = [
|
tasks = [
|
||||||
|
|
@ -40,7 +72,7 @@ class AddonBase:
|
||||||
await asyncio.gather(*tasks)
|
await asyncio.gather(*tasks)
|
||||||
|
|
||||||
async def response(self, flow: http.HTTPFlow):
|
async def response(self, flow: http.HTTPFlow):
|
||||||
if false_true_varifing_task.is_verifing_false_true():
|
if false_true_varifing_task.is_verifing_false_true() or self.should_ignore(flow):
|
||||||
return
|
return
|
||||||
|
|
||||||
tasks = [
|
tasks = [
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue