diff --git a/bumper/confserver.py b/bumper/confserver.py index 51db531..b6a4403 100644 --- a/bumper/confserver.py +++ b/bumper/confserver.py @@ -122,18 +122,22 @@ class ConfServer: async with aiohttp.ClientSession(headers=requestheaders, connector=aiohttp.TCPConnector(verify_ssl=False)) as session: if request.content.total_bytes > 0: proxymodelog.info(f"HTTP Proxy Request to EcoVacs (body=true) (host:{request.host}) - {ecorequest} - {request._read_bytes}") - jdata = request._read_bytes.decode('utf8') - jdata = json.loads(jdata) - async with session.request(request.method, ecorequest, json=jdata) as resp: - ecoresp = await resp.text() - #ecoresp = ecoresp.replace("portal-ww.ecouser.net", ecouser_net_ip) - proxymodelog.info(f"HTTP Proxy Response from EcoVacs (URL: {ecorequest}) - (Status: {resp.status}) - {ecoresp}") + if request.content_type == "application/x-www-form-urlencoded": # android apps use form + fdata = await request.post() + async with session.request(request.method, ecorequest, data=fdata) as resp: + ecoresp = await resp.text() + proxymodelog.info(f"HTTP Proxy Response from EcoVacs (URL: {ecorequest}) - (Status: {resp.status}) - {ecoresp}") + else: # handle json + jdata = request._read_bytes.decode('utf8') + jdata = json.loads(jdata) + async with session.request(request.method, ecorequest, json=jdata) as resp: + ecoresp = await resp.text() + proxymodelog.info(f"HTTP Proxy Response from EcoVacs (URL: {ecorequest}) - (Status: {resp.status}) - {ecoresp}") else: proxymodelog.info(f"HTTP Proxy Request to EcoVacs (body=false) (host:{request.host}) - {ecorequest}") async with session.request(request.method, ecorequest) as resp: - ecoresp = await asyncio.shield(resp.text()) - #ecoresp = ecoresp.replace("portal-ww.ecouser.net", ecouser_net_ip) + ecoresp = await resp.text() proxymodelog.info(f"HTTP Proxy Response from EcoVacs (URL: {ecorequest}) - (Status: {resp.status}) - {ecoresp}") if resp.status == 200: diff --git a/bumper/db.py b/bumper/db.py index 7488104..dfa001e 100644 --- a/bumper/db.py +++ b/bumper/db.py @@ -42,12 +42,12 @@ def config_proxyMode_deleteTable(): def config_proxyMode_defaults(): defaults = [ - {"type":"app","host":"gl-us-api.ecovacs.com","ip":"47.252.51.29","match":"gl-us-"}, + {"type":"app","host":"gl-us-api.ecovacs.com","ip":"47.252.51.29","match":"gl-"}, {"type":"app","host":"gl-us-openapi.ecovacs.com","ip":"47.252.51.29"}, {"type":"app","host":"portal-ww.ecouser.net","ip":"47.88.66.164","match":"portal-"}, {"type":"app","host":"bigdata-northamerica.ecovacs.com","ip":"47.88.66.111"}, - {"type":"app","host":"bigdata-international.ecovacs.com","ip":"47.88.132.151"}, - {"type":"app","host":"eco-us-api.ecovacs.com","ip":"47.89.135.130","match":"eco-us-"}, + {"type":"app","host":"bigdata-international.ecovacs.com","ip":"47.88.132.151","match":"bigdata-"}, + {"type":"app","host":"eco-us-api.ecovacs.com","ip":"47.89.135.130","match":"eco-"}, {"type":"app","host":"ecovacs.com","ip":"47.90.210.46"}, {"type":"app","host":"ecouser.net","ip":"116.62.93.217"}, {"type":"mqtt_server","host":"mq-ww.ecouser.net","ip":"47.254.52.46"},