Zomboided / service.vpn.manager

VPN plugin for Kodi
GNU General Public License v2.0
305 stars 81 forks source link

Shellfire VPN won't authenticate. VPN Mgr : (alternativeShellfire.py) Response was <class 'TypeError'> POST data should be bytes, an iterable of bytes, or a file object. It cannot be of type str. #402

Closed wildcat2020 closed 4 months ago

wildcat2020 commented 1 year ago

Setup Shellfire VPN, getting error VPN Mgr : (alternativeShellfire.py) Response was <class 'TypeError'> POST data should be bytes, an iterable of bytes, or a file object. It cannot be of type str.

Username and passwords are correct and correctly passed to the openVPN as debug log shows (which I have altered in the log below for obvious reason).

Below Debug Log from Kodi:

2023-05-19 21:53:58.826 T:4668 info : VPN Mgr : (service.py) Starting VPN monitor service, platform is 1, version is 7.0.3 2023-05-19 21:53:58.826 T:4668 info : VPN Mgr : (service.py) Kodi build is 20.1 (20.1.0) Git:20230312-289ec664e3 2023-05-19 21:53:58.827 T:4668 info : VPN Mgr : (service.py) Addon path is C:\Users\argyr\AppData\Roaming\Kodi\addons\service.vpn.manager\ 2023-05-19 21:53:59.875 T:5308 info : [service.upnext] UpNextMonitor -> Service started 2023-05-19 21:54:00.225 T:10456 info : Loading skin file: DialogConfirm.xml, load type: KEEP_IN_MEMORY 2023-05-19 21:54:00.597 T:1032 info : [plugin.video.netflix (0)] [NF_SERVER] Picked Port: 51951 2023-05-19 21:54:00.676 T:1032 info : [plugin.video.netflix (0)] Initialized new session 2023-05-19 21:54:03.096 T:1032 info : [plugin.video.netflix (0)] Loaded MSL data from disk 2023-05-19 21:54:03.337 T:1032 info : [plugin.video.netflix (0)] [NF_SERVER] Thread started 2023-05-19 21:54:03.488 T:10456 info : Loading skin file: DialogAddonSettings.xml, load type: KEEP_IN_MEMORY 2023-05-19 21:54:06.155 T:224 warning : CPythonInvoker(8): Script invoked without an addon. Adding all addon modules installed to python path as fallback. This behaviour will be removed in future version. 2023-05-19 21:54:06.911 T:10456 info : Loading skin file: DialogConfirm.xml, load type: KEEP_IN_MEMORY 2023-05-19 21:54:17.572 T:224 error : VPN Mgr : (alternativeShellfire.py) Authenticating with VPN failed 2023-05-19 21:54:17.572 T:224 error : VPN Mgr : (alternativeShellfire.py) API call was https://www.shellfire.de/webservice/json.php?action=login 2023-05-19 21:54:17.573 T:224 error : VPN Mgr : (alternativeShellfire.py) Data returned was "{\"email\":\"\", \"password\":\"\"}" 2023-05-19 21:54:17.573 T:224 error : VPN Mgr : (alternativeShellfire.py) Response was <class 'TypeError'> POST data should be bytes, an iterable of bytes, or a file object. It cannot be of type str. 2023-05-19 21:54:20.055 T:224 error : VPN Mgr : (common.py) Could not authenticate with VPN provider. Please check user name and password and try again.

Zomboided commented 1 year ago

Need a proper log, with HTTP tracing enabled as well https://github.com/Zomboided/service.vpn.manager/wiki/13.-Trouble-Shooting#gathering-logs

wildcat2020 commented 1 year ago

kodi.log Many thanks for your reply. kodi.log with specific addon and http tracing enabled, uploaded.

wildcat2020 commented 1 year ago

Traced it a bit further, within the below function of alternativeShellfire.py:

def sendAPI(command, command_text, api_data, check_response):

failing on the below line:

response = urlopen(req)

with error:

<class 'TypeError'> not a valid non-string sequence or mapping object

Zomboided commented 1 year ago

As you appear to not be an average user, go ahead and edit line 634 to be: req = Request(rest_url, api_data.encode('utf-8'), REQUEST_HEADERS) (ie adding the encode piece to what's already there) With this fix, i can get a fully formed response back telling me I'm not authorised (as I have no Shellfire account). It should work for other requests, but I can't test this so you'll need to. I can make the fix permanently if you can confirm it's good.

On Tue, May 23, 2023 at 8:26 AM Argyrios Derlopas @.***> wrote:

Traced it a bit further, within the below function of alternativeShellfire.py:

def sendAPI(command, command_text, api_data, check_response):

failing on the below line:

response = urlopen(req)

with error:

<class 'TypeError'> not a valid non-string sequence or mapping object

— Reply to this email directly, view it on GitHub https://github.com/Zomboided/service.vpn.manager/issues/402#issuecomment-1558689414, or unsubscribe https://github.com/notifications/unsubscribe-auth/AECJZZMEGDFB42PNTSPA2HLXHRREDANCNFSM6AAAAAAYIEIMP4 . You are receiving this because you commented.Message ID: @.***>

wildcat2020 commented 1 year ago

Many thanks for the quick reply.

Now it authenticated, however it got another error, while retrieving locations. Uploading kodi.log kodi.log

It seems it is failing now within:

def getShellfirePreFetch(vpn_provider):

At the below line:

req = Request(rest_url, "", REQUEST_HEADERS)

With the below error:

<class 'TypeError'> POST data should be bytes, an iterable of bytes, or a file object. It cannot be of type str.

wildcat2020 commented 1 year ago

Changed this:

req = Request(rest_url, "", REQUEST_HEADERS)

to this:

req = Request(rest_url, headers=REQUEST_HEADERS)

and it now works.

wildcat2020 commented 1 year ago

But unfortunately now under normal operation, the below function errors out:

getShellfireMessages

With error:

if getAccountType() > 0 and not last_time == 0: return "", "" TypeError: '>' not supported between instances of 'str' and 'int' -->End of Python script error report<--

wildcat2020 commented 1 year ago

So I changed the 549 line from:

if getAccountType() >0 and not last_time == 0: return "", ""

To:

if getAccountType() != "Free" and not last_time == 0: return "", ""

and it showed the window with the offer, but...

wildcat2020 commented 1 year ago

Now it errors out in service.py line 1002:

2023-05-24 17:17:02.464 T:5636 error : EXCEPTION: argument "value" for method "setSetting" must be unicode or str 2023-05-24 17:17:02.477 T:5636 error : EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--

wildcat2020 commented 1 year ago

So I changed the two lines in service.py

from:

                                    addon.setSetting("alternative_message_time", str(now()))
                                    addon.setSetting("alternative_message_token", new_id)

to:

                                    addon.setSetting("alternative_message_time", str(now()).encode("utf-8"))
                                    addon.setSetting("alternative_message_token", str(new_id).encode("utf-8"))

and it now works completely.

Zomboided commented 1 year ago

Can you attach your version of alterniveShellfire.py please so I can do a diff?

On Wed, May 24, 2023 at 3:28 PM Argyrios Derlopas @.***> wrote:

So I changed the two lines in service.py

from:

                                addon.setSetting("alternative_message_time", str(now()))
                                addon.setSetting("alternative_message_token", new_id)

to:

                                addon.setSetting("alternative_message_time", str(now()).encode("utf-8"))
                                addon.setSetting("alternative_message_token", str(new_id).encode("utf-8"))

and it now works completely.

— Reply to this email directly, view it on GitHub https://github.com/Zomboided/service.vpn.manager/issues/402#issuecomment-1561267987, or unsubscribe https://github.com/notifications/unsubscribe-auth/AECJZZNQLE3QCI5DKEGMP2DXHYLIHANCNFSM6AAAAAAYIEIMP4 . You are receiving this because you commented.Message ID: @.***>

wildcat2020 commented 1 year ago

Sure, let me reinstall first the original one so that it does not have the additional tracing I put, re-do the changes and upload. I will also upload service.py as I changed that one too...

wildcat2020 commented 1 year ago

and thank God I did that because when setting up for the first time, it also failed at line 198 so I corrected that one as well.... Here are the two files in .zip format alternativeShellfire.zip

Zomboided commented 1 year ago

This is great, thank you for your help

On Sun, May 28, 2023 at 9:26 AM Argyrios Derlopas @.***> wrote:

and thank God I did that because when setting up for the first time, it also failed at line 198 so I corrected that one as well.... Here are the two files in .zip format alternativeShellfire.zip https://github.com/Zomboided/service.vpn.manager/files/11584051/alternativeShellfire.zip

— Reply to this email directly, view it on GitHub https://github.com/Zomboided/service.vpn.manager/issues/402#issuecomment-1565994253, or unsubscribe https://github.com/notifications/unsubscribe-auth/AECJZZLLZIRYMJAUZPAOBUDXIMD2FANCNFSM6AAAAAAYIEIMP4 . You are receiving this because you commented.Message ID: @.***>

wildcat2020 commented 1 year ago

You are welcome, glad I was able to help. Let me know once new version is ready :-)

Zomboided commented 1 year ago

Release is here if you can grab and install @wildcat2020 https://github.com/Zomboided/service.vpn.manager/releases/tag/7.0.4

@peno64 This makes a small change which is part of the Nord flow. Would you mind giving this a run before I push this up please? Just needs a cycle through connecting/disconnecting/reconnecting.

When this is confirmed good, I'll push it onto the repo

wildcat2020 commented 1 year ago

Hi, tested the latest release and it works fine. Many thanks.