now almost a week of me trying to make URL authentication in the IceCast2. Nothing works.
I tried standard Windows 2.4.4 build, I tried it on different linuxes (eg. Ubuntu, SUSE), I even compiled it myself from sources (to ensure curl library is there), I tried even 2.3.0 build.
Nothing works. By that I mean – it always brings same answer: 400 – Wrong Request
I tried it doing by (obviously) sending POST request, by sending GET request, by sending PUT request. Nah.
I tried it from the php page, i tried it directly from the curl. It is allways same answer – 400.
I even tried doing it from IceCast KH build – it brings 501 – feature not implemented.
So I assume something is wrong either with icecast.xml, either with POST-request.
So, here is part of icecast.xml
<mount type="normal">
<mount-name>/1</mount-name>
<username>source</username>
<password>somepass</password>
<burst-size>65536</burst-size>
<authentication type="url">
<option name="listener_add" value="http://rb.xyz/i/icecast_auth.php"/>
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// It is just virtual server running under MAMP
<option name="auth_header" value="icecast-auth-user: 1"/>
</authentication>
<http-headers>
<header name="Access-Control-Allow-Origin" value="http://localhost/1" />
</http-headers>
</mount>
Now, curl request I send. Almost like in the icecast docs:
C:Program Files (x86)Icecast>curl -v --data-urlencode "action=listener_add&server=rb.xyz&port=8000&client=1&mount=/1&user=someuser&pass=somepass&ip=127.0.0.1&agent=My%20player" http://localhost:8000
* Trying [::1]:8000...
* Trying 127.0.0.1:8000...
* Connected to localhost (127.0.0.1) port 8000
> POST / HTTP/1.1
> Host: localhost:8000
> User-Agent: curl/8.4.0
> Accept: */*
> Content-Length: 156
> Content-Type: application/x-www-form-urlencoded
>
* HTTP 1.0, assume close after body
< HTTP/1.0 400 Bad Request
< Server: Icecast 2.4.4
< Connection: Close
< Date: Sun, 28 Apr 2024 18:12:27 GMT
< Content-Type: text/html; charset=utf-8
< Cache-Control: no-cache, no-store
< Expires: Mon, 26 Jul 1997 05:00:00 GMT
< Pragma: no-cache
< Access-Control-Allow-Origin: *
<
<html><head><title>Error 400</title></head><body><b>400 - unknown request</b></body></html>
* Closing connection
Also php code:
<?php
$post_arr = array(
'action' => 'listener_add',
'server' => 'localhost',
'port' => 8000,
'client' => 1,
'mount' => '/1',
'user' => 'someuser',
'pass' => 'somepass',
'ip' => '127.0.0.1',
'agent' => 'My Player'
);
$query = http_build_query($post_arr);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://127.0.0.1:8000/");
curl_setopt($ch, CURLOPT_POST, True);
curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
// receive server response ...
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
echo 'Server output: '.$server_output;
curl_close ($ch);
?>
If someone was lucky enough to make it work – I will be greatly appreciated if you can provide a clue – what is wrong.
Dream Walker is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.