move logging to journalctl + start trying to debug missing bytes
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
17e5b73aa4
commit
9070d87fba
|
@ -11,9 +11,8 @@ import "math/rand"
|
|||
import "net"
|
||||
import "strconv"
|
||||
import "strings"
|
||||
import "log"
|
||||
// import "fmt"
|
||||
// import "time"
|
||||
import log "github.com/sirupsen/logrus"
|
||||
import "github.com/wercker/journalhook"
|
||||
|
||||
import "git.wit.com/jcarr/shell"
|
||||
|
||||
|
@ -22,7 +21,7 @@ import "git.wit.com/jcarr/shell"
|
|||
|
||||
import "github.com/miekg/dns"
|
||||
|
||||
import "github.com/davecgh/go-spew/spew"
|
||||
// import "github.com/davecgh/go-spew/spew"
|
||||
|
||||
const MIN = 1
|
||||
const MAX = 100
|
||||
|
@ -44,7 +43,8 @@ func GetRemoteAddr(conn net.TCPConn) string {
|
|||
// Then each hostname is verified with DNSSEC
|
||||
//
|
||||
func HandleConnection(conn *net.TCPConn) {
|
||||
spew.Dump(conn)
|
||||
journalhook.Enable()
|
||||
// spew.Dump(conn)
|
||||
// ipv6client := GetRemoteAddr(c)
|
||||
ipv6client := conn.RemoteAddr()
|
||||
log.Println("Serving to %s as the IPv6 client", ipv6client)
|
||||
|
@ -80,7 +80,16 @@ func HandleConnection(conn *net.TCPConn) {
|
|||
}
|
||||
*/
|
||||
|
||||
f, _ := conn.File()
|
||||
// shell.SetStdout(f)
|
||||
// shell.SpewOn() // turn this on if you want to look at the process exit states
|
||||
|
||||
// send all log() output to systemd journalctl
|
||||
// shell.UseJournalctl()
|
||||
|
||||
for {
|
||||
defer shell.SetStdout(os.Stdout)
|
||||
defer conn.Close()
|
||||
netData, err := newreader.ReadString('\n')
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
|
@ -95,24 +104,19 @@ func HandleConnection(conn *net.TCPConn) {
|
|||
|
||||
if (temp == "list") {
|
||||
log.Println("Should run list here")
|
||||
f, _ := conn.File()
|
||||
shell.SetStdout(f)
|
||||
shell.Run("ls /tmp/")
|
||||
// close(f)
|
||||
shell.Run("/root/bin/list.testing.com")
|
||||
shell.SetStdout(os.Stdout)
|
||||
}
|
||||
|
||||
if (temp == "cpuinfo") {
|
||||
log.Println("Should cat /proc/cpuinfo")
|
||||
// f, _ := conn.File()
|
||||
// shell.SetStdout(f)
|
||||
shell.SetStdout(f)
|
||||
shell.Run("cat /proc/cpuinfo")
|
||||
// close(f)
|
||||
shell.SetStdout(os.Stdout)
|
||||
}
|
||||
|
||||
result := strconv.Itoa(random()) + "\n"
|
||||
conn.Write([]byte(string(result)))
|
||||
}
|
||||
conn.Close()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue