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 {