Merge pull request #9 from danielhoherd/master
Code cleanup and shrinking.
This commit is contained in:
commit
a1e7054ccb
2 changed files with 89 additions and 45 deletions
19
README.md
19
README.md
|
@ -1,3 +1,20 @@
|
|||
This is a forked version of relaymyhome:
|
||||
========================================
|
||||
|
||||
* Some variables have been added in place of static numbers.
|
||||
* shebang line is put on #1 so it can function correctly
|
||||
* general code clean up
|
||||
* Audibly speaks to you when it's done relaying
|
||||
|
||||
Future improvements:
|
||||
====================
|
||||
|
||||
* Better handling of switches
|
||||
* Support shirt colors
|
||||
* Perhaps make a sqlite3 db of mac addresses to pull from in order to support grabbing least-recently used, and other limiting factors like gender, shirt color, etc..
|
||||
* If we're doing db stuff, make it more modular to support different sources. eg: fallback on default generated list if db is absent
|
||||
|
||||
|
||||
relaymyhome
|
||||
===========
|
||||
OSX Bash Script for automating the process of getting Nintendo 3DS StreetPass hits via Internet Connection Sharing. Gathers the maximum of ten (10) StreetPass hits within about 3-5 minutes.
|
||||
|
@ -12,7 +29,7 @@ Script has been updated for the new "six at a time" feature of StreetPass Relay.
|
|||
* Each address in the cycle will now connect for 90 seconds in order to provide more time for the additional data to be sent for all six potential streetpasses. This additional time is more than offset by checking far fewer addresses (see next three points below).
|
||||
* Running the script in standard mode ( **./relaymyhome** ) will now only hit the five main Nintendo World addresses. You should be able to run this mode 2-3 times before you run out of streetpasses. This mode also provides the opportunity to get any "special" Miis that are generally only available via these addresses.
|
||||
* Running the script in full mode ( **./relaymyhome full** ) will now connect to five random addresses (down from 20), taking a total of 7.5 minutes. This provides 30 potential streetpasses, and should fill your 10 slots reliably.
|
||||
* **New mode**: Running the script in quick mode ( **./relaymyhome quick** ) will connect to two random addresses, taking a total of three (3) minutes. This should quickyl fill your 10 streetpasses (out of the 12 potential ones), but will sometimes return fewer than 10.
|
||||
* **New mode**: Running the script in quick mode ( **./relaymyhome quick** ) will connect to two random addresses, taking a total of three (3) minutes. This should quickly fill your 10 streetpasses, but will sometimes return fewer than 10.
|
||||
|
||||
What It Does
|
||||
============
|
||||
|
|
115
relaymyhome
115
relaymyhome
|
@ -1,3 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
# The MIT License (MIT)
|
||||
#
|
||||
# Copyright (c) 2013 Rob Zimmerman
|
||||
|
@ -25,36 +27,72 @@
|
|||
# See other generous contributors, plus view the source, readme, and license at https://github.com/taintedzodiac/relaymyhome
|
||||
# Tested in OS X 10.8 (Mountain Lion) and Mavericks
|
||||
|
||||
#! /bin/bash
|
||||
|
||||
wservice=`/usr/sbin/networksetup -listallnetworkservices | grep -Ei '(wi-fi|airport)'`
|
||||
wifi=$(networksetup -listallhardwareports | awk "/$wservice/,/Ethernet/"' getline { print $2 }')
|
||||
### The time we will pause on each MAC address
|
||||
relay_time="90"
|
||||
sleep_time="10"
|
||||
|
||||
WirelessMAC=$(networksetup -getmacaddress $wifi | awk '{print $3}')
|
||||
wservice="$(/usr/sbin/networksetup -listallnetworkservices | grep -Ei '(wi-fi|airport)')"
|
||||
wifi="$(networksetup -listallhardwareports | awk "/${wservice}/,/Ethernet/"' getline { print $2 }')"
|
||||
|
||||
WirelessMAC=$(networksetup -getmacaddress "${wifi}" | awk '{print $3}')
|
||||
echo "Original MAC address is: $WirelessMAC"
|
||||
|
||||
cleanup()
|
||||
{
|
||||
sudo ifconfig $wifi lladdr $WirelessMAC
|
||||
networksetup -setairportpower $wifi off
|
||||
networksetup -setairportpower $wifi on
|
||||
|
||||
echo "Cycling of Relays has completed, MAC address reverted."
|
||||
function notify {
|
||||
if [ -z ${speak} ] ; then
|
||||
echo "${@}" ;
|
||||
else
|
||||
say --interactive=green "${@}" ;
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
ctrl_c()
|
||||
{
|
||||
# user quit midway through, so we should revert
|
||||
# the MAC address by calling our cleanup function
|
||||
echo "*** Interrupted ***"
|
||||
cleanup
|
||||
exit $?
|
||||
function cleanup {
|
||||
sudo ifconfig ${wifi} lladdr ${WirelessMAC}
|
||||
networksetup -setairportpower ${wifi} off
|
||||
networksetup -setairportpower ${wifi} on
|
||||
|
||||
echo "Cycling of Relays has completed, MAC address reverted."
|
||||
notify "Time to check your street passes!"
|
||||
return 0
|
||||
}
|
||||
|
||||
function ctrl_c {
|
||||
# user quit midway through, so we should revert
|
||||
# the MAC address by calling our cleanup function
|
||||
echo "*** Interrupted ***"
|
||||
cleanup
|
||||
exit $?
|
||||
}
|
||||
|
||||
function usage {
|
||||
echo "$0 [-c count] [-s]"
|
||||
echo "c: the number of MAC addresses to cycle through."
|
||||
echo "s: audibly speak when the script is done"
|
||||
}
|
||||
|
||||
# trap keyboard interrupt (control-c) or unexpected quit
|
||||
trap ctrl_c SIGINT SIGTERM
|
||||
|
||||
if [[ $1 == "full" || $1 == "quick" ]]
|
||||
while getopts hsc: option
|
||||
do
|
||||
case "${option}" in
|
||||
h) usage ; exit ;;
|
||||
s) speak=1 ;;
|
||||
c) count=${OPTARG} ;;
|
||||
*) usage ; exit 1 ;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $((OPTIND - 1))
|
||||
|
||||
### TODO:
|
||||
### * change this to a case statement
|
||||
### * Make most of this into functions
|
||||
### * Parse other cli options for verbosity and say vs silent
|
||||
### * Put the list of MACs into a sqlite3 db and query only oldest visited ones?
|
||||
|
||||
if [[ $1 == "full" || $1 == "fuller" || $1 == "quick" ]]
|
||||
then
|
||||
# Generate a full list of 160 MACs when "full" mode is specified
|
||||
# To use full mode: ./relaymyhome full
|
||||
|
@ -63,28 +101,17 @@ then
|
|||
# Set the base MAC address
|
||||
baseAddr="4E:53:50:4F:4F:"
|
||||
|
||||
# Legal characters for MAC (Limited range for first digit)
|
||||
CharsA=("0" "1" "2" "3" "4" "5" "6" "7" "8" "9")
|
||||
CharsB=("0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "A" "B" "C" "D" "E" "F")
|
||||
# Create an array for the last octet of the mac address, limited range.
|
||||
Addr=($(for X in {0..159} ; do echo ${X} | awk '{printf "%02X ", $1}'; done ;))
|
||||
|
||||
# Create the addresses programmatically
|
||||
count=0
|
||||
for i in "${CharsA[@]}"
|
||||
do
|
||||
for j in "${CharsB[@]}"
|
||||
do
|
||||
mac=$baseAddr$i$j
|
||||
Addr+=($mac)
|
||||
done
|
||||
done
|
||||
|
||||
if [[ $1 == "full" ]]
|
||||
then
|
||||
num=5
|
||||
echo "Full Mode enabled. Randomly seeding five addresses from full list."
|
||||
if [[ $1 == "full" ]] ; then
|
||||
num=7
|
||||
echo "Full Mode enabled. Randomly seeding ${num} addresses from full list."
|
||||
elif [[ $1 == "fuller" ]] ; then
|
||||
num=99
|
||||
else
|
||||
num=2
|
||||
echo "Quick Mode enabled. Randomly seeding two addresses from full list."
|
||||
echo "Quick Mode enabled. Randomly seeding ${num} addresses from full list."
|
||||
fi
|
||||
|
||||
for ((a=1; a<=$num; a++));
|
||||
|
@ -93,9 +120,10 @@ then
|
|||
echo "Cycling WiFi..."
|
||||
sudo ifconfig $wifi lladdr $selectedAddr
|
||||
networksetup -setairportpower $wifi off
|
||||
sleep ${sleep_time}
|
||||
networksetup -setairportpower $wifi on
|
||||
echo "Spoofing $wifi to $selectedAddr for 90 seconds ($a of $num)"
|
||||
sleep 90
|
||||
echo "Spoofing $wifi to $selectedAddr for ${relay_time} seconds ($a of $num)"
|
||||
sleep ${relay_time}
|
||||
done
|
||||
|
||||
|
||||
|
@ -116,15 +144,14 @@ else
|
|||
echo "Cycling WiFi..."
|
||||
sudo ifconfig $wifi lladdr $a
|
||||
networksetup -setairportpower $wifi off
|
||||
sleep ${sleep_time}
|
||||
networksetup -setairportpower $wifi on
|
||||
echo "Spoofing $wifi to $a for 90 seconds ($n of 5)"
|
||||
echo "Spoofing $wifi to ${a} for ${relay_time} seconds (${n} of 5)"
|
||||
n=$((n+1))
|
||||
sleep 90
|
||||
sleep ${relay_time}
|
||||
done
|
||||
fi
|
||||
|
||||
# ... and we are done
|
||||
|
||||
cleanup
|
||||
|
||||
echo "Time to check your StreetPasses!"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue