     }
     
     func ensureRunning() -> (String?) {
+        if !registerVersion() {
+            return "Could not determine syncthing version"
+        }
         let result = portFinder.findPort()
         // mop: ITS GO :O ZOMG!!111
         if (result.err != nil) {

    var log : SyncthingLog
    var buf : NSString = NSString()
    var apiKey: NSString?

    init(log: SyncthingLog) {
        self.log = log

    
        notificationCenter.addObserver(self, selector: "taskStopped:", name: NSTaskDidTerminateNotification, object: task)
        notificationCenter.addObserver(self, selector: "receivedOut:", name: NSFileHandleDataAvailableNotification, object: nil)
    }
    
    func registerVersion() -> Bool {
        var pipe : NSPipe = NSPipe()
        var versionTask = NSTask()
        versionTask.launchPath = path as String
        versionTask.arguments = ["--version"]
        versionTask.standardOutput = pipe
        versionTask.launch()
        versionTask.waitUntilExit()
        
        let versionOut = pipe.fileHandleForReading.readDataToEndOfFile()
        let versionString = NSString(data: versionOut, encoding: NSUTF8StringEncoding)
        
        var regex = NSRegularExpression(pattern: "^syncthing v(\\d+)\\.(\\d+)\\.(\\d+)",
            options: nil, error: nil)
        var results = regex!.matchesInString(versionString! as String, options: nil, range: NSMakeRange(0, versionString!.length))
        if results.count == 1 {
            let major = versionString?.substringWithRange(results[0].rangeAtIndex(1)).toInt() as Int!
            let minor = versionString?.substringWithRange(results[0].rangeAtIndex(2)).toInt() as Int!
            let patch = versionString?.substringWithRange(results[0].rangeAtIndex(3)).toInt() as Int!
            
            version = [ major, minor, patch ]
            println("Syncthing version \(version![0]) \(version![1]) \(version![2])")
            return true
        } else {
            return false
        }
    }
    
    func run() -> (String?) {
