Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fleshed out client command structure.

  • Loading branch information...
commit 6166bfbe98791e6ebce6c1bf8a314c9c72af4069 1 parent ea2ec24
@jwinnenb authored
View
5 src/kh/client/checksum.clj
@@ -0,0 +1,5 @@
+(ns kh.client.checksum
+ (:import commons.apache.codec.digest.DigestUtils))
+
+(defn checksum [cookie path]
+ (DigestUtils/md5hex (input-stream (file path))))
View
5 src/kh/client/command.clj
@@ -0,0 +1,5 @@
+(ns kh.client.command
+ (:use clojure.contrib.shell-out))
+
+(defn command [cookie cmd]
+ (sh cmd :return-map true))
View
18 src/kh/client/core.clj
@@ -1,16 +1,18 @@
(ns kh.client.core
(:use [compojure core route]
- [kh.client keyboard mouse screen]
- ring.adapter.jetty))
+ [kh.client checksum command download keyboard mouse screen upload]
+ ring.adapter.jetty
+ ring.middleware.multipart-params))
(defroutes client-core
(GET "/screen" [cookie scale] (screen-png cookie scale))
- (GET "/keyboard" [cookie cmd key] (keyboard-cmd cookie cmd key))
- (GET "/mouse" [cookie cmd x y b] (mouse-cmd cmd cookie x y b))
- (GET "/upload" [] nil)
- (GET "/download" [] nil)
- (GET "/checksum" [] nil)
- (GET "/command" [] nil))
+ (GET "/keyboard" [cookie cmd key] (keyboard cookie cmd key))
+ (GET "/mouse" [cookie cmd x y b] (mouse cmd cookie x y b))
+ (wrap-multipart-params
+ (POST "/upload" [cookie file dst name] (upload cookie file dst name)))
+ (GET "/download" [cookie file-path] (download cookie file-path))
+ (GET "/checksum" [cookie file-path] (checksum cookie file-path))
+ (GET "/command" [cookie cmd] (command cookie cmd))
(defn launch-client [client-port client-ssl-cert client-ssl-pass]
(.start
View
6 src/kh/client/download.clj
@@ -0,0 +1,6 @@
+(ns kh.client.download
+ (:use clojure.contrib.io))
+
+
+(defn download [cookie path]
+ (input-stream (file path)))
View
5 src/kh/client/upload.clj
@@ -0,0 +1,5 @@
+(ns kh.client.upload
+ (:use clojure.contrib.duck-streams))
+
+(defn upload [file dst name]
+ (copy (:tempfile file) (file-str dst name)))
Please sign in to comment.
Something went wrong with that request. Please try again.