Art-of-WiFi / UniFi-API-client

A PHP API client class to interact with Ubiquiti's UniFi Controller API
MIT License
1.13k stars 223 forks source link

Allowing to create RADIUS accounts without Tunnel Type and Medium #122

Closed mreho closed 2 years ago

mreho commented 3 years ago

Unifi controllers allow us to create RADIUS accounts without a tunnel_type or a tunnel_medium_type defined.

With these changes, tunnel_type and tunnel_medium_type are now optional.

With the XOR operator, if tunnel_type is set, tunnel_medium_type must be too, and vice versa.

Tested and approved on PHP 8.0.9.

malle-pietje commented 3 years ago

Manually merged in with 1.1.71

malle-pietje commented 3 years ago

After considering the use of CURLOPT_TIMEOUT to fix the login with recent UDM PROs under specific conditions (still not clear which conditions these are exactly), I get the feeling it’s more a bandaid than a real fix of the root cause. The option can be useful anyway for general use, but I’d prefer we figure out why these failures occur and exactly under which conditions.

malle-pietje commented 2 years ago

@mreho I stumbled across something that may be related: apparently, as of cURL version 7.62.0 the value for cURL option CURLOPT_HTTP_VERSION is CURL_HTTP_VERSION_2TLS: https://curl.se/libcurl/c/CURLOPT_HTTP_VERSION.html

I believe setting this option to CURL_HTTP_VERSION_1_1 could fix your issues. Can you please confirm?

curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
malle-pietje commented 2 years ago

From the feedback we've received, it looks as if the timeout issue is resolved by changing the default HTTP version option for cURL back to 1.1. The other changes have already been merged. Thanks for contributing!

mreho commented 2 years ago

Hi @malle-pietje, Sorry for this late reply, very busy at this time.. Happy that this bug has been fixed, thank you !

malle-pietje commented 2 years ago

@mreho With the latest release (1.1.76) I've removed several unnecessary cURL options including some per your suggestions. Thanks