support android app

handle form data sent by android apps
This commit is contained in:
Brian Martin 2020-01-20 12:01:01 -05:00
parent a4a77708e5
commit c2bcb13769
2 changed files with 15 additions and 11 deletions

View file

@ -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}")
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()
#ecoresp = ecoresp.replace("portal-ww.ecouser.net", ecouser_net_ip)
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:

View file

@ -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"},