From 671436e8e085e5d3d1651fd692765d2859c7b06a Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Tue, 27 Jan 2015 08:19:38 -0800 Subject: [PATCH] add structure to handle SockCmd --- cmd/warrend/.main.go.swo | Bin 0 -> 12288 bytes cmd/warrend/main.go | 11 +++++++++++ 2 files changed, 11 insertions(+) create mode 100644 cmd/warrend/.main.go.swo diff --git a/cmd/warrend/.main.go.swo b/cmd/warrend/.main.go.swo new file mode 100644 index 0000000000000000000000000000000000000000..813b89133a31fa971b294d9d79b4678f67ca06ca GIT binary patch literal 12288 zcmeI2O^g&p6vs>OgB4K0i$R5AOiZsXJ)kC<)zz%a!jcHP?gwbd#`Jdg4DHTz58XWq zk`*P<#3-l-4OgS6k&7|G1Yx7v5=+vaY{C)B1kPw#PD(ixus^i-J6UKu5p2lG@ z@Xcb`iyuz7r#_>bUbSe=7?q0QTg4|0-?!bOS#1=pV%2b5z3eUMKJSn#kSowlfqGcl zaL-C{=N+3isxG$_*30WxPj%~^+j9kS1#$&)1#$&)1#$&)1#$&)1^$N$gtg1WLDsb- zS=%GY^RkX-Qq3Q^0=WXY0=WXY0=WXY0=WXY0=WXY0=WXY0=WYJK?Mv;h-a4x@mCMQ z^Z);izyE)`R)}BW9Q+6;;R84h$KWU&hC}cS90VJt;AXfH*1&~pg!mrLz-f2`o`)(t z4wF!X4bTV6;o?dm&cerV9FD@v@Dl8Top3j-hE=cxPOlK+6r6zPU>|r;fnnGT1(2`~ zR>Aq@Li_^9;0VmY1dPEb+y`r61zfyZh@aqV_zXUU58z#R9bSc3;02h42^fU6um+Zb zfWOgMY5gZ$gx}#ToPm?@4!jI|;c;-lf^isud*L3q6|M&X=h?qA@Ch7;_uw6vg9=Q+ zN>~Bsu0kvL7QTTG;RGCk7vT`pVHoa&b@0cPjDw%yb9f8h1Q%vu21en2SOWqsTp`3) z@Fjc!Z^J8a7(#dy*1=l136{gz%Z2y>zJp`%8XSP9U>{Ur2Bu&XMqm(bfK{*zu7Zn8 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,7 @@ import ( "net" "os" "os/signal" + "strings" "syscall" ) @@ -37,8 +38,18 @@ func sockCmdHandle(c net.Conn) { } fmt.Println("cmdHandle got command:", string(data)) + // BAD: TODO: handle quotes " + var args = strings.Split(" ", data) + // parse args + var icmd = warren.GetCommand(args[0]) // get and run cmd + if icmd == nil { + c.Write([]byte("Unknown command " + args[0])) + // usage ? + return + } + icmd.(*SockCommand).Exec(c, args[1:]) c.Write([]byte("echo: " + data)) }