Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
philippe44 committed Jun 9, 2021
1 parent cb1cc4e commit 68b9cd3
Show file tree
Hide file tree
Showing 17 changed files with 76 additions and 69 deletions.
26 changes: 16 additions & 10 deletions SOCKS.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
SSH tunnel with port forwarding allows per port TCP/UDP traffic to be
"forwarded" from one end to the tunnel to the other and appear like it was
initiated from the remote end of tunnel. For example all traffic send to
port 5000 on the local machine can be forwared to a remote machine, on port
port 5000 on the local machine can be forwarded to a remote machine, on port
25000 and will appear to any client on the remote side as if it was locally
coming from port 25000

Expand All @@ -13,22 +13,31 @@ This tunneling is not a all-or-nothing tunnel an allow each TCP request to be
selectively forwarding or not

You must first either use a public SOCKS server or create your own SOCKS/SSH
pair in which ase you must have a local SOCKS server, a local SSH client and
a remote SSH server. On Linux openssh does everything, one local instance with
pair in which case you must have a local SOCKS server, a local SSH client and
a remote SSH server. On Linux, openssh does everything, one local instance with
dynamic port forwarding (-D) and a remote instance to a friend's network does
the job. On Windows, you can use Bitvise Client & Server. There is plenty of
internet litterature on SOCKS/SSH that explain the concept much better than
anything I could write :-)

HTTP request ------> SOCKS client ------||-----> SOCKS server ------> www.google.com
>www.google.com >some.socks.com || >www.google.com >5000
>5000 >1080 || >5000 (from some.socks.com)

HTTP request ------> SOCKS client ----> SOCKS relay (encrypted) SOCKS server -----> www.google.com
>www.google.com >192.168.0.1 >SSH client -----||----> >SSH server 5000
>5000 >1080 >some.ssh.com || >www.google.com
>23 || >5000 (from some.ssh.com)

One thing to notice with SOCKS5 is the lack of proper authentication mechanism
which means that if you have a username/password, they will be sent in clear
to the server. SOCKS4 does not require authentication. That's why I prefer
to have a local SOCKS server that creates a SSH tunnel to a remote end but this
means you must have a SSH remote end.

To use socks proxy to your HTTP requests, set the SOCKS parameter in LMS and
simply passed a hash named "socks" to SimpleAsyncHTTP::new or Async::HTP::new
with the following content (see IO::Socket::Socks)
To use socks proxy to your HTTP requests, simply passed a hash named "socks"
to SimpleAsyncHTTP::new or Async::HTTP::new with the following content. See
also IO::Socket::Socks)

my $http = Slim::Networking::SimpleAsyncHTTP->new(
sub { # succes CB },
Expand Down Expand Up @@ -69,7 +78,4 @@ are set and to 4 otherwise. ProxyPort can be omitted and will be set to 1080.

If 'socks' hash is set but ProxyAddr is missing, a regular SimpleAsync or Async
call will be made





28 changes: 14 additions & 14 deletions Slim/Buttons/Playlist.pm
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ sub init {
} else {

Slim::Buttons::Common::pushModeLeft($client, 'trackinfo', {
'track' => Slim::Player::Playlist::song($client, browseplaylistindex($client)),
'track' => Slim::Player::Playlist::track($client, browseplaylistindex($client)),
'current' => browseplaylistindex($client) == Slim::Player::Source::playingSongIndex($client)
});
}
Expand Down Expand Up @@ -200,7 +200,7 @@ sub init {

# rec button deletes an entry if you are browsing the playlist...
my $songtitle = Slim::Music::Info::standardTitle($client,
Slim::Player::Playlist::song($client, browseplaylistindex($client))
Slim::Player::Playlist::track($client, browseplaylistindex($client))
);

$client->execute(["playlist", "delete", browseplaylistindex($client)]);
Expand Down Expand Up @@ -424,26 +424,26 @@ sub lines {
Slim::Player::Playlist::count($client);
}

my $song = Slim::Player::Playlist::song($client, browseplaylistindex($client) );
my $track = Slim::Player::Playlist::track($client, browseplaylistindex($client) );

my $title;
my $meta;

# Get remote metadata for other tracks in the playlist if available
if ( $song->isRemoteURL ) {
my $handler = Slim::Player::ProtocolHandlers->handlerForURL($song->url);
if ( $track->isRemoteURL ) {
my $handler = Slim::Player::ProtocolHandlers->handlerForURL($track->url);

if ( $handler && $handler->can('getMetadataFor') ) {
$meta = $handler->getMetadataFor( $client, $song->url );
$meta = $handler->getMetadataFor( $client, $track->url );

if ( $meta->{title} ) {
$title = Slim::Music::Info::getCurrentTitle( $client, $song->url, 0, $meta );
$title = Slim::Music::Info::getCurrentTitle( $client, $track->url, 0, $meta );
}
}
}

if ( !$title ) {
$title = Slim::Music::Info::standardTitle($client, $song);
$title = Slim::Music::Info::standardTitle($client, $track);
}

$parts = {
Expand All @@ -453,21 +453,21 @@ sub lines {

if ($client->display->showExtendedText()) {

if ($song && !($song->isRemoteURL)) {
if ($track && !($track->isRemoteURL)) {

$parts->{'screen2'} = {
'line' => [
Slim::Music::Info::displayText($client, $song, 'ALBUM'),
Slim::Music::Info::displayText($client, $song, 'ARTIST'),
Slim::Music::Info::displayText($client, $track, 'ALBUM'),
Slim::Music::Info::displayText($client, $track, 'ARTIST'),
]
};

} elsif ($song && $meta) {
} elsif ($track && $meta) {

$parts->{'screen2'} = {
'line' => [
Slim::Music::Info::displayText($client, $song, 'ALBUM', $meta),
Slim::Music::Info::displayText($client, $song, 'ARTIST', $meta),
Slim::Music::Info::displayText($client, $track, 'ALBUM', $meta),
Slim::Music::Info::displayText($client, $track, 'ARTIST', $meta),
]
};

Expand Down
6 changes: 3 additions & 3 deletions Slim/Control/Commands.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1174,7 +1174,7 @@ sub playlistSaveCommand {
if ($prefs->get('saveShuffled')) {

for my $shuffleitem (@{Slim::Player::Playlist::shuffleList($client)}) {
push @$annotatedList, Slim::Player::Playlist::song($client, $shuffleitem, 0, 0);
push @$annotatedList, Slim::Player::Playlist::track($client, $shuffleitem, 0, 0);
}

} else {
Expand Down Expand Up @@ -1842,7 +1842,7 @@ sub playlistZapCommand {

my $zapped = $client->string('ZAPPED_SONGS');
my $zapindex = defined $index ? $index : Slim::Player::Source::playingSongIndex($client);
my $zapsong = Slim::Player::Playlist::song($client, $zapindex);
my $zaptrack = Slim::Player::Playlist::track($client, $zapindex);

# Remove from current playlist
if (Slim::Player::Playlist::count($client) > 0) {
Expand All @@ -1863,7 +1863,7 @@ sub playlistZapCommand {
},
});

$playlistObj->appendTracks([ $zapsong ]);
$playlistObj->appendTracks([ $zaptrack ]);
$playlistObj->update;

Slim::Player::Playlist::scheduleWriteOfPlaylist($client, $playlistObj);
Expand Down
12 changes: 6 additions & 6 deletions Slim/Control/Jive.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2504,10 +2504,10 @@ sub jivePresetsMenu {
# if playlist_index is sent, that's for the current NP track, derive everything you need from it
my $playlist_index = $request->getParam('playlist_index');
if ( defined($playlist_index) ) {
my $song = Slim::Player::Playlist::song( $client, $playlist_index );
$url = $song->url;
my $track = Slim::Player::Playlist::track( $client, $playlist_index );
$url = $track->url;
$type = 'audio';
$title = $song->title;
$title = $track->title;
}

# preset needs to be saved as either a playlist or default to audio
Expand Down Expand Up @@ -2624,10 +2624,10 @@ sub jiveFavoritesCommand {
# if playlist_index is sent, that's for the current NP track, derive everything you need from it
my $playlist_index = $request->getParam('playlist_index');
if ( defined($playlist_index) ) {
my $song = Slim::Player::Playlist::song( $client, $playlist_index );
$url = $song->url;
my $track = Slim::Player::Playlist::track( $client, $playlist_index );
$url = $track->url;
$type = 'audio';
$title = $song->title;
$title = $track->title;
}

# favorite needs to be saved as either a playlist or default to audio
Expand Down
6 changes: 3 additions & 3 deletions Slim/Control/Queries.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2508,7 +2508,7 @@ sub playlistXQuery {

my $songData = _songData(
$request,
Slim::Player::Playlist::song($client, $index),
Slim::Player::Playlist::track($client, $index),
'dalgN', # tags needed for our entities
);

Expand Down Expand Up @@ -3883,7 +3883,7 @@ sub statusQuery {
my $track;

if (!$totalOnly) {
$track = Slim::Player::Playlist::song($client, $playlist_cur_index, $refreshTrack);
$track = Slim::Player::Playlist::track($client, $playlist_cur_index, $refreshTrack);

if ($track->remote) {
$tags .= "B" unless $totalOnly; # include button remapping
Expand Down Expand Up @@ -4007,7 +4007,7 @@ sub statusQuery {
for ($idx = $start; $idx <= $end; $idx++){

_addSong($request, $loop, $count,
Slim::Player::Playlist::song($client, $idx, $refreshTrack), $tags,
Slim::Player::Playlist::track($client, $idx, $refreshTrack), $tags,
'playlist index', $idx
);

Expand Down
2 changes: 1 addition & 1 deletion Slim/Display/Transporter.pm
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ sub showVisualizer {
my $display = shift;

# turn off visualizer if we're playing a digital input
if ( Slim::Music::Info::isDigitalInput(Slim::Player::Playlist::song($display->client)) ) {
if ( Slim::Music::Info::isDigitalInput(Slim::Player::Playlist::track($display->client)) ) {
return 0;
}

Expand Down
8 changes: 4 additions & 4 deletions Slim/Menu/TrackInfo.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1345,9 +1345,9 @@ sub cliQuery {

# special case-- playlist_index given but no trackId
if (defined($playlist_index) && ! $trackId ) {
if (my $song = Slim::Player::Playlist::song( $client, $playlist_index )) {
$trackId = $song->id;
$url = $song->url;
if (my $track = Slim::Player::Playlist::track( $client, $playlist_index )) {
$trackId = $track->id;
$url = $track->url;
$request->addParam('track_id', $trackId);
$request->addParam('url', $url);
}
Expand Down Expand Up @@ -1376,7 +1376,7 @@ sub cliQuery {

# sometimes we get a $trackId which wouldn't return a valid track object
# try the song based on the playlist_index instead
if ( !$feed && $playlist_index && (my $song = Slim::Player::Playlist::song( $client, $playlist_index )) ) {
if ( !$feed && $playlist_index && (my $song = Slim::Player::Playlist::track( $client, $playlist_index )) ) {
$feed = Slim::Menu::TrackInfo->menu( $client, $song->url, $song, $tags, \%filter );
}

Expand Down
2 changes: 1 addition & 1 deletion Slim/Networking/SliMP3/Stream.pm
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ sub gotAck {

main::INFOLOG && $log->info($client->id, " Buffer full, starting playback");

$client->currentplayingsong(Slim::Player::Playlist::song($client));
$client->currentplayingsong(Slim::Player::Playlist::track($client));
$client->remoteStreamStartTime(time());

$client->bufferReady(1);
Expand Down
34 changes: 17 additions & 17 deletions Slim/Player/Player.pm
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ sub power {
$client->execute(["playlist","jump", 0, 1, 1]);
}

if ($resumeOn =~ /Play/ && Slim::Player::Playlist::song($client)
if ($resumeOn =~ /Play/ && Slim::Player::Playlist::track($client)
&& $prefs->client($client)->get('playingAtPowerOff')) {
# play even if current playlist item is a remote url (bug 7426)
# but only if we were playing at power-off (bug 7061)
Expand Down Expand Up @@ -567,19 +567,19 @@ sub currentSongLines {
}
}

my $song = Slim::Player::Playlist::song($client);
my $track = Slim::Player::Playlist::track($client);

my $currentTitle;
my $imgKey;
my $artwork;
my $remoteMeta;

if ( $song->isRemoteURL ) {
my $handler = Slim::Player::ProtocolHandlers->handlerForURL($song->url);
if ( $track->isRemoteURL ) {
my $handler = Slim::Player::ProtocolHandlers->handlerForURL($track->url);

if ( $handler && $handler->can('getMetadataFor') ) {

$remoteMeta = $handler->getMetadataFor( $client, $song->url );
$remoteMeta = $handler->getMetadataFor( $client, $track->url );

if ( $remoteMeta->{cover} ) {
$imgKey = 'icon';
Expand All @@ -591,12 +591,12 @@ sub currentSongLines {
}

# Format remote metadata according to title format
$currentTitle = Slim::Music::Info::getCurrentTitle( $client, $song->url, 0, $remoteMeta );
$currentTitle = Slim::Music::Info::getCurrentTitle( $client, $track->url, 0, $remoteMeta );
}

# If that didn't return anything, use default title
if ( !$currentTitle ) {
$currentTitle = Slim::Music::Info::getCurrentTitle( $client, $song->url );
$currentTitle = Slim::Music::Info::getCurrentTitle( $client, $track->url );
}

if ( !$artwork ) {
Expand All @@ -605,9 +605,9 @@ sub currentSongLines {
}
}
else {
$currentTitle = Slim::Music::Info::getCurrentTitle( $client, $song->url );
$currentTitle = Slim::Music::Info::getCurrentTitle( $client, $track->url );

if ( my $album = $song->album ) {
if ( my $album = $track->album ) {
$imgKey = 'icon-id';
$artwork = $album->artwork || 0;
}
Expand All @@ -622,24 +622,24 @@ sub currentSongLines {

my ($s2line1, $s2line2);

if ($song && $song->isRemoteURL) {
if ($track && $track->isRemoteURL) {

my $title = Slim::Music::Info::displayText($client, $song, 'TITLE');
my $title = Slim::Music::Info::displayText($client, $track, 'TITLE');

if ( ($currentTitle || '') ne ($title || '') && !Slim::Music::Info::isURL($title) ) {

$s2line2 = $title;

} elsif ($remoteMeta) {

$s2line1 = Slim::Music::Info::displayText($client, $song, 'ALBUM', $remoteMeta);
$s2line2 = Slim::Music::Info::displayText($client, $song, 'ARTIST', $remoteMeta);
$s2line1 = Slim::Music::Info::displayText($client, $track, 'ALBUM', $remoteMeta);
$s2line2 = Slim::Music::Info::displayText($client, $track, 'ARTIST', $remoteMeta);
}

} else {

$s2line1 = Slim::Music::Info::displayText($client, $song, 'ALBUM');
$s2line2 = Slim::Music::Info::displayText($client, $song, 'ARTIST');
$s2line1 = Slim::Music::Info::displayText($client, $track, 'ALBUM');
$s2line2 = Slim::Music::Info::displayText($client, $track, 'ARTIST');
}

$screen2 = {
Expand All @@ -649,10 +649,10 @@ sub currentSongLines {

$jive = {
'type' => 'icon',
'text' => [ $status, $song ? $song->title : undef ],
'text' => [ $status, $track ? $track->title : undef ],
'style' => $jiveIconStyle,
'play-mode' => $playmode,
'is-remote' => $song->isRemoteURL,
'is-remote' => $track->isRemoteURL,
};

if ( $imgKey ) {
Expand Down
1 change: 1 addition & 0 deletions Slim/Player/Playlist.pm
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ sub song {
}

sub track {

my ($client, $index, $refresh, $useShuffled) = @_;
$refresh ||= 0;
$useShuffled = 1 unless defined $useShuffled;
Expand Down
4 changes: 2 additions & 2 deletions Slim/Player/ReplayGain.pm
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ sub findTracksByIndex {
}

# Get the track objects
my $current_url = Slim::Player::Playlist::song($client, $current_index);
my $current_url = Slim::Player::Playlist::track($client, $current_index);
my $current_track = Slim::Schema->objectForUrl({ 'url' => $current_url, 'create' => 1, 'readTags' => 1 });

my $compare_url = Slim::Player::Playlist::song($client, $compare_index);
my $compare_url = Slim::Player::Playlist::track($client, $compare_index);
my $compare_track = Slim::Schema->objectForUrl({ 'url' => $compare_url, 'create' => 1, 'readTags' => 1 });

return ($current_track, $compare_track);
Expand Down
2 changes: 1 addition & 1 deletion Slim/Player/Song.pm
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ sub new {

my $client = $owner->master();

my $objOrUrl = Slim::Player::Playlist::song($client, $index) || return undef;
my $objOrUrl = Slim::Player::Playlist::track($client, $index) || return undef;

# Bug: 3390 - reload the track if it's changed.
my $url = blessed($objOrUrl) && $objOrUrl->can('url') ? $objOrUrl->url : $objOrUrl;
Expand Down
Loading

0 comments on commit 68b9cd3

Please sign in to comment.