Permalink
Browse files

add option to change AP name or password

  • Loading branch information...
1 parent b4fdfe1 commit d740b7f1b14b80eb39a04a7a61b6a58d66cabbe1 @rjyo rjyo committed Apr 12, 2011
Showing with 29 additions and 18 deletions.
  1. +4 −3 README
  2. +2 −0 org.mafipulation.shairport.plist
  3. +23 −15 shairport.pl
View
7 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
+* launchctl load org.mafipulation.shairport.plist
+* launchctl unload org.mafipulation.shairport.plist (to remove)
+
View
2 org.mafipulation.shairport.plist
@@ -9,6 +9,8 @@
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/shairport.pl</string>
+ <string>--apname</string>
+ <string>RJ</string>
</array>
</dict>
</plist>
View
38 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 @@
# 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 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 @@ sub POPE {
"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}),

0 comments on commit d740b7f

Please sign in to comment.