summaryrefslogtreecommitdiff
path: root/internal/server
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2021-08-21 14:54:24 +0300
committerPaul Buetow <paul@buetow.org>2021-08-21 14:54:24 +0300
commitc2522ffb59514443816a96386c16bb7527cbe57c (patch)
tree6e6fb065e14b92e362f66103cfed2cbdc51ceccf /internal/server
parent70cc67e78278fcf103acc57dfe513bd6f5f258c9 (diff)
read files bytewise for more control of whats happening - change transport protocol for more control over newlines
Diffstat (limited to 'internal/server')
-rw-r--r--internal/server/handlers/serverhandler.go15
1 files changed, 9 insertions, 6 deletions
diff --git a/internal/server/handlers/serverhandler.go b/internal/server/handlers/serverhandler.go
index 185e7c2..23e3aeb 100644
--- a/internal/server/handlers/serverhandler.go
+++ b/internal/server/handlers/serverhandler.go
@@ -17,8 +17,8 @@ import (
"github.com/mimecast/dtail/internal/io/logger"
"github.com/mimecast/dtail/internal/mapr/server"
"github.com/mimecast/dtail/internal/omode"
+ "github.com/mimecast/dtail/internal/protocol"
user "github.com/mimecast/dtail/internal/user/server"
- "github.com/mimecast/dtail/internal/version"
)
const (
@@ -92,24 +92,27 @@ func (h *ServerHandler) Read(p []byte) (n int, err error) {
}
if message[0] == '.' {
// Handle hidden message (don't display to the user, interpreted by dtail client)
- wholePayload := []byte(fmt.Sprintf("%s\n", message))
+ wholePayload := []byte(fmt.Sprintf("%s%b", message, protocol.MessageDelimiter))
n = copy(p, wholePayload)
return
}
// Handle normal server message (display to the user)
- wholePayload := []byte(fmt.Sprintf("SERVER|%s|%s\n", h.hostname, message))
+ wholePayload := []byte(fmt.Sprintf("SERVER|%s|%s%b", h.hostname, message, protocol.MessageDelimiter))
n = copy(p, wholePayload)
return
case message := <-h.aggregatedMessages:
// Send mapreduce-aggregated data as a message.
- data := fmt.Sprintf("AGGREGATE➔%s➔%s\n", h.hostname, message)
+ data := fmt.Sprintf("AGGREGATE%s%s%s%s%b",
+ protocol.AggregateDelimiter, h.hostname,
+ protocol.AggregateDelimiter, message, protocol.MessageDelimiter)
wholePayload := []byte(data)
n = copy(p, wholePayload)
return
case line := <-h.lines:
+ //fmt.Printf("<<<%d,%s>>>\n", len(line.Content), line.Content)
// Send normal file content data as a message.
serverInfo := []byte(fmt.Sprintf("REMOTE|%s|%3d|%v|%s|",
h.hostname, line.TransmittedPerc, line.Count, line.SourceID))
@@ -182,8 +185,8 @@ func (h *ServerHandler) handleProtocolVersion(args []string) ([]string, int, err
return args, argc, errors.New("unable to determine protocol version")
}
- if args[1] != version.ProtocolCompat {
- err := fmt.Errorf("server with protocol version '%s' but client with '%s', please update DTail", version.ProtocolCompat, args[1])
+ if args[1] != protocol.ProtocolCompat {
+ err := fmt.Errorf("server with protocol version '%s' but client with '%s', please update DTail", protocol.ProtocolCompat, args[1])
return args, argc, err
}