From 8dfa6f9c0c7130b9c039e2e5040f96226ebb6ab6 Mon Sep 17 00:00:00 2001 From: jackdaw Date: Wed, 30 Nov 2016 16:26:53 +0900 Subject: [PATCH] . --- communicator.go | 21 ++++++++++----------- events/event_port.go | 2 +- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/communicator.go b/communicator.go index 04b29ec..9d2a557 100644 --- a/communicator.go +++ b/communicator.go @@ -2,6 +2,7 @@ package communicate import ( "bytes" + "compress/gzip" "encoding/json" "loafle.com/commons/communicate/events" "net/http" @@ -20,14 +21,13 @@ func (c *communicator) addEvent(e *events.Event) { c.Queue <- e } -// -//func CompressDataGzip(data []byte) []byte { -// var b bytes.Buffer -// w := gzip.NewWriter(&b) -// w.Write(data) -// w.Close() -// return b.Bytes() -//} +func CompressDataGzip(data []byte) []byte { + var b bytes.Buffer + w := gzip.NewWriter(&b) + w.Write(data) + w.Close() + return b.Bytes() +} func (c *communicator) start() { go func() { @@ -37,9 +37,8 @@ func (c *communicator) start() { data, _ := json.Marshal(event) // compress , accept-encoding : gzip - - //res, err := http.Post(GetRootURL()+m.GetUrl(), "application/json", bytes.NewBuffer(CompressDataGzip(data))) - res, err := http.Post(GetRootURL()+m.GetUrl(), "application/json", bytes.NewBuffer(data)) + res, err := http.Post(GetRootURL()+m.GetUrl(), "application/json", bytes.NewBuffer(CompressDataGzip(data))) + //res, err := http.Post(GetRootURL()+m.GetUrl(), "application/json", bytes.NewBuffer(data)) // todo timeout,error if err != nil { diff --git a/events/event_port.go b/events/event_port.go index af3e466..935834c 100644 --- a/events/event_port.go +++ b/events/event_port.go @@ -53,7 +53,7 @@ type PortEndEvent struct { } func (i PortEndEvent) GetUrl() string { - return PORT_START + return PORT_END } func NewPortEndEvent(zone int64, host int64, history []*types.PortScanHistory, t string) *PortEndEvent {