From fdbce861de13b9eaf9dbc32c428eabec742a1af8 Mon Sep 17 00:00:00 2001 From: Rakuraku Jyo Date: Tue, 12 Apr 2011 08:28:43 +0900 Subject: [PATCH 1/4] udpate README with instruction on Mac --- README | 1 + 1 file changed, 1 insertion(+) diff --git a/README b/README index cc59b3e3..fd6a7f64 100644 --- a/README +++ b/README @@ -60,6 +60,7 @@ How to compile and install on Mac OSX 10.6 * brew install pkg-config libao * make * perl -MCPAN -e 'install Crypt::OpenSSL::RSA' +* perl -MCPAN -e 'install IO::Socket::INET6' * perl shairport.pl OSX 10.5 only bundles perl 5.8, which won't work with shairport. After getting a update From ece70481a750b44fdff793390ecc8caa4dbeceba Mon Sep 17 00:00:00 2001 From: Rakuraku Jyo Date: Tue, 12 Apr 2011 10:52:01 +0900 Subject: [PATCH 2/4] add a config for mac's LaunchAgents with instructions in README --- README | 10 +++++++++- org.mafipulation.shairport.plist | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 org.mafipulation.shairport.plist diff --git a/README b/README index fd6a7f64..33d3a3e8 100644 --- a/README +++ b/README @@ -64,4 +64,12 @@ How to compile and install on Mac OSX 10.6 * perl shairport.pl OSX 10.5 only bundles perl 5.8, which won't work with shairport. After getting a update -here (http://www.perl.org/get.html), it worked. \ No newline at end of file +here (http://www.perl.org/get.html), it worked. + +How to run as a daemon on Mac +------ +* cp hairtunes shairport.pl /usr/local/bin +* vi /usr/loca/bin/shairport.pl, change the path of hairtunes from ./hairtunes to /usr/loca/bin/hairtunes +* cp org.mafipulation.shairport.plist ~/Library/LaunchAgents/ +* launchctl load org.mafipulation.shairport +* launchctl start org.mafipulation.shairport \ No newline at end of file diff --git a/org.mafipulation.shairport.plist b/org.mafipulation.shairport.plist new file mode 100644 index 00000000..26b5fbe3 --- /dev/null +++ b/org.mafipulation.shairport.plist @@ -0,0 +1,14 @@ + + + + + Label + org.mafipulation.shairport + RunAtLoad + + ProgramArguments + + /usr/local/bin/shairport.pl + + + From b4fdfe1882e0c33c3b88a8d0f6c4a93fa1a2d520 Mon Sep 17 00:00:00 2001 From: Rakuraku Jyo Date: Tue, 12 Apr 2011 10:53:57 +0900 Subject: [PATCH 3/4] fix typo --- README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README b/README index 33d3a3e8..3b3cba7c 100644 --- a/README +++ b/README @@ -69,7 +69,7 @@ here (http://www.perl.org/get.html), it worked. How to run as a daemon on Mac ------ * cp hairtunes shairport.pl /usr/local/bin -* vi /usr/loca/bin/shairport.pl, change the path of hairtunes from ./hairtunes to /usr/loca/bin/hairtunes +* vi /usr/local/bin/shairport.pl, change the path of hairtunes from ./hairtunes to /usr/local/bin/hairtunes * cp org.mafipulation.shairport.plist ~/Library/LaunchAgents/ * launchctl load org.mafipulation.shairport * launchctl start org.mafipulation.shairport \ No newline at end of file From d740b7f1b14b80eb39a04a7a61b6a58d66cabbe1 Mon Sep 17 00:00:00 2001 From: Rakuraku Jyo Date: Tue, 12 Apr 2011 18:42:12 +0900 Subject: [PATCH 4/4] add option to change AP name or password --- README | 7 +++--- org.mafipulation.shairport.plist | 2 ++ shairport.pl | 38 +++++++++++++++++++------------- 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/README b/README index 3b3cba7c..98d5ebb2 100644 --- a/README +++ b/README @@ -66,10 +66,11 @@ How to compile and install on Mac OSX 10.6 OSX 10.5 only bundles perl 5.8, which won't work with shairport. After getting a update here (http://www.perl.org/get.html), it worked. -How to run as a daemon on Mac +How to run as a daemon on Mac 10.6 ------ * cp hairtunes shairport.pl /usr/local/bin * vi /usr/local/bin/shairport.pl, change the path of hairtunes from ./hairtunes to /usr/local/bin/hairtunes * cp org.mafipulation.shairport.plist ~/Library/LaunchAgents/ -* launchctl load org.mafipulation.shairport -* launchctl start org.mafipulation.shairport \ No newline at end of file +* launchctl load org.mafipulation.shairport.plist +* launchctl unload org.mafipulation.shairport.plist (to remove) + diff --git a/org.mafipulation.shairport.plist b/org.mafipulation.shairport.plist index 26b5fbe3..9c6530a1 100644 --- a/org.mafipulation.shairport.plist +++ b/org.mafipulation.shairport.plist @@ -9,6 +9,8 @@ ProgramArguments /usr/local/bin/shairport.pl + --apname + RJ diff --git a/shairport.pl b/shairport.pl index 23ad2393..20421133 100755 --- a/shairport.pl +++ b/shairport.pl @@ -1,18 +1,5 @@ #!/usr/bin/perl -# Configure the following two options: -# AP name - as will be shown in iTunes' menu -# example: -# my $apname = "SteePort"; -my $apname = "ShairPort $$ on " . `hostname`; - -# password - required to connect -# for no password, set: -# my $password = ''; -my $password = ''; - -# that's all! - # ShairPort - Airtunes compatible server # Copyright (c) 2011 James Laird # All rights reserved. @@ -36,6 +23,9 @@ my $password = ''; # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR # OTHER DEALINGS IN THE SOFTWARE. +use Getopt::Long; +use FindBin; + use IO::Select; use IO::Socket; use MIME::Base64; @@ -47,6 +37,24 @@ use Digest::MD5 qw/md5_hex/; use POSIX ":sys_wait_h"; eval "use IO::Socket::INET6;"; + +# Configure the following two options: +# AP name - as will be shown in iTunes' menu +# example: +# my $apname = "SteePort"; + +my $apname = "ShairPort $$ on " . `hostname`; +# password - required to connect +# for no password, set: +my $password = ''; +# suppose hairtunes is under same directory +my $hairtunes_cli = $FindBin::Bin . '/hairtunes'; + +GetOptions("apname=s" => \$apname, + "password=s" => \$password); + +# use --apname MyName --password secret as arguments + chomp $apname; my @hw_addr = (0, map { int rand 256 } 1..5); @@ -72,7 +80,7 @@ if ($avahi_publish==0) { "5000", "tp=UDP","sm=false","sv=false","ek=1","et=0,1","cn=0,1","ch=2","ss=16","sr=44100","pw=false","vn=3","txtvers=1"; die "could not run avahi-publish-service nor dns-sd"; -} +} sub REAP { if ($avahi_publish == waitpid(-1, WNOHANG)) { @@ -281,7 +289,7 @@ sub conn_handle_request { $resp->header('Session', 'DEADBEEF'); - my $dec = sprintf("./hairtunes iv %s key %s fmtp %s cport %s tport %s dport %s host %s", + my $dec = sprintf("$hairtunes_cli iv %s key %s fmtp %s cport %s tport %s dport %s host %s", map { "'$_'" } ( unpack('H*', $conn->{aesiv}), unpack('H*', $conn->{aeskey}),