forked from Hay1tsme/artemis
add get_ip_addr util function for servers behind proxies
This commit is contained in:
@ -11,7 +11,7 @@ from Crypto.Util.Padding import pad
|
||||
from os import path
|
||||
from typing import Tuple
|
||||
|
||||
from core import CoreConfig
|
||||
from core import CoreConfig, Utils
|
||||
from titles.chuni.config import ChuniConfig
|
||||
from titles.chuni.const import ChuniConstants
|
||||
from titles.chuni.base import ChuniBase
|
||||
@ -111,6 +111,7 @@ class ChuniServlet:
|
||||
encrtped = False
|
||||
internal_ver = 0
|
||||
endpoint = url_split[len(url_split) - 1]
|
||||
client_ip = Utils.get_ip_addr(request)
|
||||
|
||||
if version < 105: # 1.0
|
||||
internal_ver = ChuniConstants.VER_CHUNITHM
|
||||
@ -179,7 +180,7 @@ class ChuniServlet:
|
||||
req_data = json.loads(unzip)
|
||||
|
||||
self.logger.info(
|
||||
f"v{version} {endpoint} request from {request.getClientAddress().host}"
|
||||
f"v{version} {endpoint} request from {client_ip}"
|
||||
)
|
||||
self.logger.debug(req_data)
|
||||
|
||||
|
@ -10,7 +10,7 @@ import inflection
|
||||
from os import path
|
||||
from google.protobuf.message import DecodeError
|
||||
|
||||
from core.config import CoreConfig
|
||||
from core import CoreConfig, Utils
|
||||
from titles.pokken.config import PokkenConfig
|
||||
from titles.pokken.base import PokkenBase
|
||||
from titles.pokken.const import PokkenConstants
|
||||
@ -128,7 +128,7 @@ class PokkenServlet(resource.Resource):
|
||||
|
||||
def handle_matching(self, request: Request) -> bytes:
|
||||
content = request.content.getvalue()
|
||||
client_ip = request.getClientAddress().host
|
||||
client_ip = Utils.get_ip_addr(request)
|
||||
|
||||
if content is None or content == b"":
|
||||
self.logger.info("Empty matching request")
|
||||
|
@ -8,7 +8,7 @@ from twisted.web.http import Request
|
||||
from typing import Dict, Tuple
|
||||
from os import path
|
||||
|
||||
from core.config import CoreConfig
|
||||
from core import CoreConfig, Utils
|
||||
from titles.wacca.config import WaccaConfig
|
||||
from titles.wacca.config import WaccaConfig
|
||||
from titles.wacca.const import WaccaConstants
|
||||
@ -89,6 +89,7 @@ class WaccaServlet:
|
||||
request.responseHeaders.addRawHeader(b"X-Wacca-Hash", hash.hex().encode())
|
||||
return json.dumps(resp).encode()
|
||||
|
||||
client_ip = Utils.get_ip_addr(request)
|
||||
try:
|
||||
req_json = json.loads(request.content.getvalue())
|
||||
version_full = Version(req_json["appVersion"])
|
||||
@ -140,7 +141,7 @@ class WaccaServlet:
|
||||
return end(resp.make())
|
||||
|
||||
self.logger.info(
|
||||
f"v{req_json['appVersion']} {url_path} request from {request.getClientAddress().host} with chipId {req_json['chipId']}"
|
||||
f"v{req_json['appVersion']} {url_path} request from {client_ip} with chipId {req_json['chipId']}"
|
||||
)
|
||||
self.logger.debug(req_json)
|
||||
|
||||
|
Reference in New Issue
Block a user