Icecast Streaming Media Server Forum Index Icecast Streaming Media Server
Icecast is a Xiph Foundation Project
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Automating Admin Funtions and Commands - Remote DJ Dashboard

 
Post new topic   Reply to topic    Icecast Streaming Media Server Forum Index -> Icecast Server
View previous topic :: View next topic  
Author Message
square_eyes



Joined: 18 Oct 2011
Posts: 83

PostPosted: Fri Jun 14, 2013 10:01 am    Post subject: Automating Admin Funtions and Commands - Remote DJ Dashboard Reply with quote

Is there a way to securely automate admin commands?

For example, I'd like to develop a python script (or PHP webscript) to automate live show title updates. Or any of the other admin functions from a dashboard page I can share with my DJs.

e.g.

http://192.168.1.10:8000/admin/metadata?mount=/mystream&mode=updinfo&song=ACDC+Back+In+Black

Following the http command, I know I need to authenticate. So here are my questions.

1. Is it possible to automate authentication... perhaps by Get or Post? Is there more detailed documentation on this? (I'm looking here http://www.icecast.org/docs/icecast-2.3.2/icecast2_admin.html)
2. Assuming you can authenticate with a payload or similar, is it possible to secure (encrypt) the transmission of credentials? How might one do that?


Last edited by square_eyes on Wed Jun 19, 2013 1:46 pm; edited 1 time in total
Back to top
View user's profile Send private message
karlH
Code Warrior
Code Warrior


Joined: 13 Jun 2005
Posts: 5476
Location: UK

PostPosted: Fri Jun 14, 2013 2:24 pm    Post subject: Reply with quote

you can use the http://user:pass@host:port/.... syntax, if you need it more secure then define a https style socket

karl.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
square_eyes



Joined: 18 Oct 2011
Posts: 83

PostPosted: Sun Jun 16, 2013 10:41 am    Post subject: Reply with quote

OK I'll look into that. Do you know if work already exists out there? If not, and we get to a functioning stage I'll be happy to share ours.
Back to top
View user's profile Send private message
karlH
Code Warrior
Code Warrior


Joined: 13 Jun 2005
Posts: 5476
Location: UK

PostPosted: Sun Jun 16, 2013 12:02 pm    Post subject: Reply with quote

use [lib]curl or similar, any should allow basic auth

karl.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
square_eyes



Joined: 18 Oct 2011
Posts: 83

PostPosted: Sun Jun 16, 2013 3:46 pm    Post subject: Reply with quote

I'm still asked to authenticate after the below, when typing this into a browser.

http://myusername:mypassword@host:port/admin...

Also once passed, will the admin user remain logged in? Is there a command to log out?
Back to top
View user's profile Send private message
karlH
Code Warrior
Code Warrior


Joined: 13 Jun 2005
Posts: 5476
Location: UK

PostPosted: Sun Jun 16, 2013 6:41 pm    Post subject: Reply with quote

you will get asked again if the details are missing or incorrect (for most admn commands the admin user/pass is required), also known as a 401 response. There is no active session as such with logging in, websites usually use cookies for such but icecast does not use them.

karl.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
square_eyes



Joined: 18 Oct 2011
Posts: 83

PostPosted: Wed Jun 19, 2013 1:40 pm    Post subject: Reply with quote

Well, in the interest of anyone interested I thought I'd come back and share.

The below is what I have come up with so far. It's an updated version of the code here... http://forum.loudcity.net/viewtopic.php?id=4160 so thanks to Audioprobe. I tweaked it to suit a web based dashboard updater.

There's three things I still want it to do. 1. Send the data securely (your credentials transmit in plain text) and 2. handle the icecast response to show the DJ a definitive outcome for error handling. Currently the response just says the titles have been updated and gives you a back button. Lastly 3. field validation.

Note that you will need CURL and PHP on your web server.

In any case here it is. Use at your own risk...

Drop this HTML code in the page you want to have the update meta data feature...


Code:


<!--
Notes:
Replace: "response.php" with the relative reference of your php file
Replace: "DJ Name - Show Name" with whatever you want the default in the field/form to be
-->

<form action="response.php" method="GET" name="titles">
<p><input id="titles" onclick="this.select()" type="text" name="titles" value="DJ Name - Show Name" /> <input type="submit" value="Submit" /></p>
</form>


Create a file response.php with the following code and place it wherever you linked to above.

Code:


<html>
<head>
<script>
//Set up java for back button
function goBack()
  {
  window.history.back()
  }
</script>
</head>
<body>

<?php

//Update the 5 items below with your server info. You may need a static IP, or dyndns service, along with ports forwarded on your router.

$serv["host"] = "mysite.dyndns.org"; //ip or hostname the server is running on. Don't include http://
$serv["port"] = "8000"; //port the server is running on
$serv["mount"] = "/mymount"; //this format: /mount
$serv["user"] = "user"; //icecast server username
$serv["passwd"] = "pass"; //icecast server password

//encode the input to make sure spaces in titles are parsed correctly as +'s
$encoded = urlencode($_GET['titles']);
 
        $mysession = curl_init();
        curl_setopt($mysession, CURLOPT_URL, "http://".$serv["host"].":".$serv["port"]."/admin/metadata?mount=".$serv["mount"]."&mode=updinfo&song=".$encoded);
        curl_setopt($mysession, CURLOPT_HEADER, false);
        curl_setopt($mysession, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($mysession, CURLOPT_POST, false);
        curl_setopt($mysession, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
        curl_setopt($mysession, CURLOPT_USERPWD, $serv["user"].":".$serv["passwd"]);
        curl_setopt($mysession, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($mysession, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
        curl_setopt($mysession, CURLOPT_CONNECTTIMEOUT, 2);
        curl_exec($mysession);
        curl_close($mysession);

    echo "Titles updated: ";
    echo $_GET["titles"];

?>
<!--Implement back button-->
<p><input type="button" value="Back" onclick="goBack()"></p>
</form>

</body>
</html>
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Icecast Streaming Media Server Forum Index -> Icecast Server All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group
subRebel style by ktauber