   `run-driver` and `connect-driver` may accept."
   ([type]
    (boot-driver type {}))
-  ([type {host :host :as opt}]
+  ([type {:keys [host] :as opt}]
    (cond-> type
      true       (create-driver opt)
      (not host) (run-driver opt)

  [driver]
  (util/connectable? (:host @driver)
                     (:port @driver)))

(defn discover-port
  "Finds a port for a driver type.

  Takes a default one from `defaults` map. If it's already taken,
  continues to take random ports until if finds non-busy one.

  Arguments:

  - `type`: a keyword, browser type (:chrome, :firefox, etc),

  - `host`: a string, hostname or IP.

  Returns a port as an integer."
  [type host]
  (loop [port (or (get-in defaults [type :port])
                  (util/get-free-port))]
    (if (util/connectable? host port)
      (recur (util/get-free-port))
      port)))

;;
;; predicates

                     path-browser
                     driver-log-level]}]]

  (let [{:keys [type port host]} @driver

        _ (when (util/connectable? host port)
            (throw (ex-info
                     (format "Port %d already in use" port)
                     {:port port})))

        log-level   (or log-level :all)
        path-driver (or path-driver (get-in defaults [type :path]))

        _ (swap! driver drv/set-browser-log-level log-level)
        _ (swap! driver drv/set-path path-driver)
