diff options
Diffstat (limited to 'src/app')
-rw-r--r-- | src/app/portmaster.clj | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/app/portmaster.clj b/src/app/portmaster.clj new file mode 100644 index 0000000..0d88270 --- /dev/null +++ b/src/app/portmaster.clj @@ -0,0 +1,23 @@ +(ns app.portmaster + (:import (java.io File) + (java.util.concurrent TimeUnit) + (net.sf.expectit ExpectBuilder))) + +(def pm (agent nil)) + +(defn init + [port-name] + (let [socat (.. (new ProcessBuilder + (into-array ["socat" + "-v" + (str "OPEN:" port-name ",b9600,raw") + "-"])) + (redirectError (new File "/tmp/portmaster.log")) + (start)) + expect (.. (new ExpectBuilder) + (withInputs (into-array [(.getInputStream socat)])) + (withOutput (.getOutputStream socat)) + (withTimeout 1 TimeUnit/SECONDS) + (withExceptionOnFailure) + (build))] + (send pm assoc :socat socat :expect expect))) |