Permalink
Browse files

Merge branch 'macapp'

A cute little GUI for sshuttle on MacOS, written using pyobjc.

* macapp:
  ui-macos: call the main binary MacOS/Sshuttle.
  ui-macos/git-export.do: write the generated app to a branch.
  ui-macos/default.app.do: get rid of some duplicated files.
  ui-macos: Actually prompt for passwords instead of assuming a default.
  ui-macos: Don't enable connecting for hosts with Custom but zero subnets.
  ui-macos: Smoother log messages in the log window.
  ui-macos: Notice when we've connected; make debug logs optional.
  ui-macos: Much better connection status reporting.
  ui-macos/run.do: a shortcut for running debug.app.
  ui-macos/*: "a series of unfortunate events."
  • Loading branch information...
2 parents 415be93 + d4ccd30 commit 668441adb68d015e6ad452651756b3bee7d44383 @apenwarr apenwarr committed Jan 23, 2011
View
@@ -226,6 +226,8 @@ def _main(listener, fw, ssh_cmd, remotename, python, seed_hosts, auto_nets,
raise Fatal('expected server init string %r; got %r'
% (expected, initstring))
debug1('connected.\n')
+ print 'Connected.'
+ sys.stdout.flush()
if daemon:
daemonize()
log('daemonizing (%s).\n' % _pidname)
View
@@ -0,0 +1,8 @@
+*.pyc
+*~
+/*.nib
+/debug.app
+/sources.list
+/Sshuttle VPN.app
+/*.tar.gz
+/*.zip
View
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleDisplayName</key>
+ <string>Sshuttle VPN</string>
+ <key>CFBundleExecutable</key>
+ <string>Sshuttle</string>
+ <key>CFBundleIconFile</key>
+ <string>app.icns</string>
+ <key>CFBundleIdentifier</key>
+ <string>ca.apenwarr.Sshuttle</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>Sshuttle VPN</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>0.0.0</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>0.0.0</string>
+ <key>LSUIElement</key>
+ <string>1</string>
+ <key>LSHasLocalizedDisplayName</key>
+ <false/>
+ <key>NSAppleScriptEnabled</key>
+ <false/>
+ <key>NSHumanReadableCopyright</key>
+ <string>GNU LGPL Version 2</string>
+ <key>NSMainNibFile</key>
+ <string>MainMenu</string>
+ <key>NSPrincipalClass</key>
+ <string>NSApplication</string>
+</dict>
+</plist>
View

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>startAtLogin</key>
+ <false/>
+ <key>autoReconnect</key>
+ <true/>
+</dict>
+</plist>
View
@@ -0,0 +1 @@
+redo-ifchange debug.app dist
View
Binary file not shown.
View
@@ -0,0 +1,28 @@
+import sys, os, re, subprocess
+
+def askpass(prompt):
+ prompt = prompt.replace('"', "'")
+
+ if 'yes/no' in prompt:
+ return "yes"
+
+ script="""
+ tell application "Finder"
+ activate
+ display dialog "%s" \
+ with title "Sshuttle SSH Connection" \
+ default answer "" \
+ with icon caution \
+ with hidden answer
+ end tell
+ """ % prompt
+
+ p = subprocess.Popen(['osascript', '-e', script], stdout=subprocess.PIPE)
+ out = p.stdout.read()
+ rv = p.wait()
+ if rv:
+ return None
+ g = re.match("text returned:(.*), button returned:.*", out)
+ if not g:
+ return None
+ return g.group(1)
View
@@ -0,0 +1 @@
+/runpython
View
@@ -0,0 +1 @@
+APPL????
View
@@ -0,0 +1,23 @@
+/*
+ * This rather pointless program acts like the python interpreter, except
+ * it's intended to sit inside a MacOS .app package, so that its argv[0]
+ * will point inside the package.
+ *
+ * NSApplicationMain() looks for Info.plist using the path in argv[0], which
+ * goes wrong if your interpreter is /usr/bin/python.
+ */
+#include <Python.h>
+#include <string.h>
+#include <unistd.h>
+
+int main(int argc, char **argv)
+{
+ char *path = strdup(argv[0]), *cptr;
+ char *args[] = {argv[0], "../Resources/main.py", NULL};
+ cptr = strrchr(path, '/');
+ if (cptr)
+ *cptr = 0;
+ chdir(path);
+ free(path);
+ return Py_Main(2, args);
+}
@@ -0,0 +1,5 @@
+exec >&2
+redo-ifchange runpython.c
+gcc -Wall -o $3 runpython.c \
+ -I/usr/include/python2.5 \
+ -lpython2.5
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -0,0 +1,4 @@
+exec >&2
+find -name '*~' | xargs rm -f
+rm -rf *.app *.zip *.tar.gz
+rm -f bits/runpython *.nib sources.list
View
@@ -0,0 +1,15 @@
+redo-ifchange bits/runpython MainMenu.nib
+rm -rf debug.app
+mkdir debug.app debug.app/Contents
+cd debug.app/Contents
+ln -s ../.. Resources
+ln -s ../.. English.lproj
+ln -s ../../Info.plist .
+ln -s ../../app.icns .
+
+mkdir MacOS
+cd MacOS
+ln -s ../../../bits/runpython Sshuttle
+
+cd ../../..
+redo-ifchange $(find debug.app -type f)
View
@@ -0,0 +1,28 @@
+TOP=$PWD
+redo-ifchange sources.list
+redo-ifchange Info.plist bits/runpython \
+ $(while read name newname; do echo "$name"; done <sources.list)
+
+rm -rf "$1.app"
+mkdir "$1.app" "$1.app/Contents"
+cd "$1.app/Contents"
+
+cp "$TOP/Info.plist" .
+
+mkdir MacOS
+cp "$TOP/bits/runpython" MacOS/Sshuttle
+
+mkdir Resources
+
+cd "$TOP"
+while read name newname; do
+ [ -z "$name" ] && continue
+ : "${newname:=$name}"
+ outname=$1.app/Contents/Resources/$newname
+ outdir=$(dirname "$outname")
+ [ -d "$outdir" ] || mkdir "$outdir"
+ cp "${name-$newname}" "$outname"
+done <sources.list
+
+cd "$1.app"
+redo-ifchange $(find . -type f)
@@ -0,0 +1,5 @@
+exec >&2
+IFS="
+"
+redo-ifchange $1.app
+tar -czf $3 $1.app/
@@ -0,0 +1,5 @@
+exec >&2
+IFS="
+"
+redo-ifchange $1.app
+zip -q -r $3 $1.app/
View
@@ -0,0 +1,2 @@
+redo-ifchange $1.xib
+ibtool --compile $3 $1.xib
View
@@ -0,0 +1 @@
+redo-ifchange "Sshuttle VPN.app.zip" "Sshuttle VPN.app.tar.gz"
View
@@ -0,0 +1,19 @@
+# update a local branch with pregenerated output files, so people can download
+# the completed tarballs from github. Since we don't have any real binaries,
+# our final distribution package contains mostly blobs from the source code,
+# so this doesn't cost us much extra space in the repo.
+BRANCH=dist/macos
+redo-ifchange 'Sshuttle VPN.app'
+git update-ref refs/heads/$BRANCH origin/$BRANCH '' 2>/dev/null || true
+
+export GIT_INDEX_FILE=$PWD/gitindex.tmp
+rm -f "$GIT_INDEX_FILE"
+git add -f 'Sshuttle VPN.app'
+
+MSG="MacOS precompiled app package for $(git describe)"
+TREE=$(git write-tree --prefix=ui-macos)
+git show-ref refs/heads/$BRANCH >/dev/null && PARENT="-p refs/heads/$BRANCH"
+COMMITID=$(echo "$MSG" | git commit-tree $TREE $PARENT)
+
+git update-ref refs/heads/$BRANCH $COMMITID
+rm -f "$GIT_INDEX_FILE"
Oops, something went wrong.

0 comments on commit 668441a

Please sign in to comment.