VLC needs a password

Fixed and closed topics
Locked
Fe-X
User
Posts: 4
Joined: Thu Aug 28, 2014 11:49 pm

VLC needs a password

Post by Fe-X »

VLC > 2.1.0 needs a password.

I changed some code to get this fixed:

netjukebox version 6.03.2 and VLC 2.1.5

config.php

Code: Select all

function initialize() {
	configform.name.focus();
<?php
	if ($cfg['player_type'] == NJB_MPD) {
		echo "\tconfigform.player_pass.className = 'short readonly';\n";
		echo "\tconfigform.media_share.className = 'short readonly';\n";
		echo "\tconfigform.player_pass.disabled = true;\n";
		echo "\tconfigform.media_share.disabled = true;\n";
	}
	//if ($cfg['player_type'] == NJB_VLC){            -----------> VLC > 2.1.0 needs a password for the http interface
	//	echo "\tconfigform.player_pass.className = 'short readonly';\n";
	//	echo "\tconfigform.player_pass.disabled = true;\n";
	//}
?>
}
Edit: There are a few more lines to change:

Code: Select all

function vlcDefault() {
	configform.name.value = 'VideoLAN';
	configform.player_port.value = '8080';
	configform.player_pass.value = '';
	configform.player_pass.className = 'short readonly';
	configform.media_share.className = 'short';
	configform.player_pass.disabled = false;
	configform.media_share.disabled = false;
	serverDefault();
}

Code: Select all

function savePlayerProfile() {
	global $cfg, $db;
	authenticate('access_admin', false, true, true);
	
	$player_id 		= @$_POST['player_id'];
	$player_name	= @$_POST['name'];
	$player_type	= @$_POST['player_type'];
	$player_host	= @$_POST['player_host'];
	$player_port	= @$_POST['player_port'];
	$player_pass	= @$_POST['player_pass'];
	$media_share	= @$_POST['media_share'];
	$media_share	= urlSyntaxFix($media_share);
	
	//if ($player_type == NJB_VLC) {
	//	$player_pass = '';
	//}
		
	if ($player_type == NJB_MPD) {
		$player_pass = '';
		$media_share = '';
	}
EndEdit

config.inc.php

Code: Select all

//  +------------------------------------------------------------------------+
//  | videoLAN                                                               |
//  +------------------------------------------------------------------------+
function vlc($command) {   // -----------> VLC > 2.1.0 needs a password for the http interface
	global $cfg;
	
	$request  = 'GET /requests/status.xml?command=' . $command . ' HTTP/1.1' . "\r\n";
	$request .= 'Host: ' . $cfg['player_host'] . ':' . $cfg['player_port'] . "\r\n";
	$request .= 'Connection: Close' . "\r\n";
	$request .= 'Authorization: Basic ' . base64_encode(':' . $cfg['player_pass']) . "\r\n\r\n";
	
	$soket = @fsockopen($cfg['player_host'], $cfg['player_port'], $error_no, $error_string, 1) or message(__FILE__, __LINE__, 'error', '[b]videoLAN error[/b][br]Failed to connect to: ' . $cfg['player_host'] . ':' . $cfg['player_port'] . '[br]' . $error_string . '[br][url=config.php?action=playerProfile][img]small_vlc.png[/img]Player profile[/url]');
	@fwrite($soket, $request) or message(__FILE__, __LINE__, 'error', '[b]videoLAN error[/b][br]Failed to write to: ' . $cfg['player_host'] . ':' . $cfg['player_port']);
	$content = stream_get_contents($soket);
	fclose($soket);
	
	$temp = explode("\r\n\r\n", $content, 2);
	if (isset($temp[1])) {
		$header = $temp[0];
		$content = $temp[1];
	}
	
	return $content;
}
Thanks for your great work!

Fe-X

User avatar
wbartels
netjukebox developer
Posts: 823
Joined: Thu Nov 04, 2004 3:12 pm
Location: Netherlands
Contact:

Re: VLC needs a password

Post by wbartels »

Thanks very much for your contribution!
I will definitely implement password support for VLC in the next netjukebox release.

I see that the http request uses: Authorization: Basic
Do you know how to use a password for telnet?
Than I can also implement password support for MPD (Music Player Daemon)

User avatar
wbartels
netjukebox developer
Posts: 823
Joined: Thu Nov 04, 2004 3:12 pm
Location: Netherlands
Contact:

Re: VLC needs a password

Post by wbartels »

I have made a minor change to the code for backwards compatibility.
Now it will only send the Authorization: Basic header if a password is set.

Code: Select all

//  +------------------------------------------------------------------------+
//  | videoLAN                                                               |
//  +------------------------------------------------------------------------+
function vlc($command) {
	global $cfg;
	
	$request  = 'GET /requests/status.xml?command=' . $command . ' HTTP/1.1' . "\r\n";
	$request .= 'Host: ' . $cfg['player_host'] . ':' . $cfg['player_port'] . "\r\n";
	$request .= ($cfg['player_pass'] != '') ? 'Authorization: Basic ' . base64_encode(':' . $cfg['player_pass']) . "\r\n" : '';
	$request .= 'Connection: Close' . "\r\n\r\n";
	
	$soket = @fsockopen($cfg['player_host'], $cfg['player_port'], $error_no, $error_string, 1) or message(__FILE__, __LINE__, 'error', '[b]videoLAN error[/b][br]Failed to connect to: ' . $cfg['player_host'] . ':' . $cfg['player_port'] . '[br]' . $error_string . '[br][url=config.php?action=playerProfile][img]small_vlc.png[/img]Player profile[/url]');
	@fwrite($soket, $request) or message(__FILE__, __LINE__, 'error', '[b]videoLAN error[/b][br]Failed to write to: ' . $cfg['player_host'] . ':' . $cfg['player_port']);
	$content = stream_get_contents($soket);
	fclose($soket);
	
	$temp = explode("\r\n\r\n", $content, 2);
	if (isset($temp[1])) {
		$header = $temp[0];
		$content = $temp[1];
	}
	return $content;
}

Fe-X
User
Posts: 4
Joined: Thu Aug 28, 2014 11:49 pm

Re: VLC needs a password

Post by Fe-X »

wbartels wrote:Do you know how to use a password for telnet?
Than I can also implement password support for MPD (Music Player Daemon)
Do you mean MPD access over port 6600? (this is not a telnet-connection).

If mpd has configured a password, access over port 6600 is always open and the password has to be transmitted within the mpd commands simply as "password secretpassword" as described in http://www.musicpd.org/doc/protocol/ch03s08.html. I don't use mpd with a password, so I can't say anymore about.

Fe-X

User avatar
wbartels
netjukebox developer
Posts: 823
Joined: Thu Nov 04, 2004 3:12 pm
Location: Netherlands
Contact:

Re: VLC needs a password

Post by wbartels »

Fe-X wrote:
wbartels wrote:Do you know how to use a password for telnet?
Than I can also implement password support for MPD (Music Player Daemon)
Do you mean MPD access over port 6600? (this is not a telnet-connection).

If mpd has configured a password, access over port 6600 is always open and the password has to be transmitted within the mpd commands simply as "password secretpassword" as described in http://www.musicpd.org/doc/protocol/ch03s08.html. I don't use mpd with a password, so I can't say anymore about.

Fe-X
I don't use a password with mpd, but I will implement it for who want's to use it.
With the mpd password command you described above I can implement it as an option (only if a password is set with mpd).

Thanks again!

Fe-X
User
Posts: 4
Joined: Thu Aug 28, 2014 11:49 pm

Re: VLC needs a password

Post by Fe-X »

By the way: Are you working on the playlist implementation for vlc?
While there is an vlc-own http-playlist I think about an iframe for it (somewhat quick n' dirty). But yet I did not found time for checking the netjukebox code for a good inserting point. Any suggestion?

Thank you!

Fe-X

User avatar
wbartels
netjukebox developer
Posts: 823
Joined: Thu Nov 04, 2004 3:12 pm
Location: Netherlands
Contact:

Re: VLC needs a password

Post by wbartels »

Fe-X wrote:By the way: Are you working on the playlist implementation for vlc?
While there is an vlc-own http-playlist I think about an iframe for it (somewhat quick n' dirty). But yet I did not found time for checking the netjukebox code for a good inserting point. Any suggestion?

Thank you!

Fe-X
I have no plans to implement VLC playlist at the moment.
However I have implemented the VLC password option in netjukebox 6.0.5.

Locked