matthuisman / kayo-for-channels

Kayo for Channels
MIT License
7 stars 0 forks source link

Login failing, looking up e2655.dsca.akamaiedge.net #4

Closed damoncoursey closed 1 year ago

damoncoursey commented 1 year ago

This has been working fine for me for quite sometime, but after a server reboot today it no longer works. I've uninstalled and reinstalled it, but no luck. I set up docker on a test computer, in the same network, and it's working fine.

On my main computer though I can see it only makes 1 dns query, for e2655.dsca.akamaiedge.net, and then it fails with "Make sure you're in Australia". On the test computer it only makes 1 dns query, for auth.streamotion.com.au.

Funny thing, I've just gone to check the test computer and it too is now failing, same issue. I can't even figure out from the source code what would make a request to e2655.dsca.akamaiedege.net.


2022-11-20 08:06:58   File "/usr/local/lib/python3.8/site-packages/requests/models.py", line 971, in json
2022-11-20 08:06:58     return complexjson.loads(self.text, **kwargs)
2022-11-20 08:06:58   File "/usr/local/lib/python3.8/json/__init__.py", line 357, in loads
2022-11-20 08:06:58     return _default_decoder.decode(s)
2022-11-20 08:06:58   File "/usr/local/lib/python3.8/json/decoder.py", line 337, in decode
2022-11-20 08:06:58     obj, end = self.raw_decode(s, idx=_w(s, 0).end())
2022-11-20 08:06:58   File "/usr/local/lib/python3.8/json/decoder.py", line 355, in raw_decode
2022-11-20 08:06:58     raise JSONDecodeError("Expecting value", s, err.value) from None
2022-11-20 08:06:58 json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
2022-11-20 08:06:58 
2022-11-20 08:06:58 During handling of the above exception, another exception occurred:
2022-11-20 08:06:58 
2022-11-20 08:06:58 Traceback (most recent call last):
2022-11-20 08:06:58   File "/usr/src/app/kayo.py", line 40, in _oauth_token
2022-11-20 08:06:58     token_data = requests.post('https://auth.streamotion.com.au/oauth/token', json=data, headers=HEADERS).json()
2022-11-20 08:06:58   File "/usr/local/lib/python3.8/site-packages/requests/models.py", line 975, in json
2022-11-20 08:06:58     raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
2022-11-20 08:06:58 requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
2022-11-20 08:06:58 
2022-11-20 08:06:58 During handling of the above exception, another exception occurred:
2022-11-20 08:06:58 
2022-11-20 08:06:58 Traceback (most recent call last):
2022-11-20 08:06:58   File "./app.py", line 116, in <module>
2022-11-20 08:06:58     kayo.login(USERNAME, PASSWORD)
2022-11-20 08:06:58   File "/usr/src/app/kayo.py", line 137, in login
2022-11-20 08:06:58     self._oauth_token(payload)
2022-11-20 08:06:58   File "/usr/src/app/kayo.py", line 42, in _oauth_token
2022-11-20 08:06:58     raise Exception('Unable to fetch token. Check your location is in Australia.')
2022-11-20 08:06:58 Exception: Unable to fetch token. Check your location is in Australia.```
matthuisman commented 1 year ago

Are you physically in Australia? Does the kayo website or app work for you?

damoncoursey commented 1 year ago

Yes the kayo app works, I've been watching things this morning.

I'm in NZ though.

On Sun, 20 Nov 2022, 8:53 am Matt Huisman, @.***> wrote:

Are you physically in Australia? Does the kayo website or app work for you?

— Reply to this email directly, view it on GitHub https://github.com/matthuisman/kayo-for-channels/issues/4#issuecomment-1320957199, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADGWWKXBY5H73VWA6TMMT6DWJEV4NANCNFSM6AAAAAASFOOQCU . You are receiving this because you authored the thread.Message ID: @.***>

damoncoursey commented 1 year ago

I've been doing some further testing and it must be some kind of docker dns issue. I modified the kayo.py script and added in:

print(socket.gethostbyname('auth.streamotion.com.au')), this outputs 23.222.69.160, which is different to what I get if I run nslookup auth.streamotion.com.au on my windows computer where docker is running.

I'm not sure why this is happening. I'm using wsl2 as the backend. During my initial troubleshooting I did a network capture, looking for all dns queries, and I never saw a query for auth.streamotion.com.au, only for e2655.dsca.akamaiedege.net, which as it turns out auth.streamotion.com.au is an alias of.

Odd! I'll close this issue though.

UPDATE:

I've just done another network capture, and I am indeed seeing a dns query for auth.streamotion.com.au, however the type is CNAME instead of A, this is getting around my smart dns proxy. I'm not sure why the behaviour has changed, will investigate further

UPDATE 2: As a workaround I got it working by setting the correct IP in the containers hosts file.

---
version: "2.1"
services:
  kayo-for-channels:
    image: matthuisman/kayo-for-channels
    container_name: kayo-for-channels
    environment:
      - USERNAME=myusername
      - PASSWORD=mypassword
    extra_hosts:
      - "auth.streamotion.com.au:${AUTH_IP}"
      - "vmndplay.kayosports.com.au:${VMNDPLAY_IP}"
    ports:
      - 8184:80
    restart: unless-stopped

And then running:

$env:AUTH_IP=(Resolve-DnsName -Name auth.streamotion.com.au).IPAddress
$env:VMNDPLAY_IP=(Resolve-DnsName -Name vmndplay.kayosports.com.au).IPAddress
docker compose up -d
damoncoursey commented 1 year ago

One final update, in case anyone else hits this issue. Instead of using extra_hosts, I've supplied the dns server instead. This configures the container to use my normal internal dns server, and seems to have fixed the problem.

---
version: "2.1"
services:
  kayo-for-channels:
    image: matthuisman/kayo-for-channels
    container_name: kayo-for-channels
    environment:
      - USERNAME=username
      - PASSWORD=password
    dns:
      - 192.168.0.1
    ports:
      - 8184:80
    restart: unless-stopped