This commit is contained in:
jackdaw 2016-11-30 16:26:53 +09:00
parent 2d5cff9c0f
commit 8dfa6f9c0c
2 changed files with 11 additions and 12 deletions

View File

@ -2,6 +2,7 @@ package communicate
import ( import (
"bytes" "bytes"
"compress/gzip"
"encoding/json" "encoding/json"
"loafle.com/commons/communicate/events" "loafle.com/commons/communicate/events"
"net/http" "net/http"
@ -20,14 +21,13 @@ func (c *communicator) addEvent(e *events.Event) {
c.Queue <- e c.Queue <- e
} }
// func CompressDataGzip(data []byte) []byte {
//func CompressDataGzip(data []byte) []byte { var b bytes.Buffer
// var b bytes.Buffer w := gzip.NewWriter(&b)
// w := gzip.NewWriter(&b) w.Write(data)
// w.Write(data) w.Close()
// w.Close() return b.Bytes()
// return b.Bytes() }
//}
func (c *communicator) start() { func (c *communicator) start() {
go func() { go func() {
@ -37,9 +37,8 @@ func (c *communicator) start() {
data, _ := json.Marshal(event) data, _ := json.Marshal(event)
// compress , accept-encoding : gzip // 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(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(data))
// todo timeout,error // todo timeout,error
if err != nil { if err != nil {

View File

@ -53,7 +53,7 @@ type PortEndEvent struct {
} }
func (i PortEndEvent) GetUrl() string { func (i PortEndEvent) GetUrl() string {
return PORT_START return PORT_END
} }
func NewPortEndEvent(zone int64, host int64, history []*types.PortScanHistory, t string) *PortEndEvent { func NewPortEndEvent(zone int64, host int64, history []*types.PortScanHistory, t string) *PortEndEvent {