add get_ip_addr util function for servers behind proxies
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
from typing import Dict, Any
|
||||
from types import ModuleType
|
||||
from twisted.web.http import Request
|
||||
import logging
|
||||
import importlib
|
||||
from os import walk
|
||||
@ -21,3 +22,7 @@ class Utils:
|
||||
logging.getLogger("core").error(f"get_all_titles: {dir} - {e}")
|
||||
raise
|
||||
return ret
|
||||
|
||||
@classmethod
|
||||
def get_ip_addr(cls, req: Request) -> str:
|
||||
return req.getAllHeaders()[b"x-forwarded-for"].decode() if b"x-forwarded-for" in req.getAllHeaders() else req.getClientAddress().host
|
||||
|
Reference in New Issue
Block a user