This commit is contained in:
jackdaw 2016-11-28 15:00:12 +09:00
parent 9763bc4568
commit fa5772c240
5 changed files with 16 additions and 9 deletions

View File

@ -17,6 +17,10 @@ func SetRootURL(url string) {
_c.RootURL = url _c.RootURL = url
} }
func GetRootURL() string {
return _c.RootURL
}
func Send(e *events.Event) { func Send(e *events.Event) {
_c.addEvent(e) _c.addEvent(e)
} }

View File

@ -65,7 +65,7 @@ func TestRealSendByGin(t *testing.T) {
var u events.URLMaker var u events.URLMaker
u = e.Data.(events.URLMaker) u = e.Data.(events.URLMaker)
t.Log(u.GetUrl()) t.Log(GetRootURL() + u.GetUrl())
req := httptest.NewRequest("POST", u.GetUrl(), bytes.NewReader(data)) req := httptest.NewRequest("POST", u.GetUrl(), bytes.NewReader(data))
w := httptest.NewRecorder() w := httptest.NewRecorder()

View File

@ -26,7 +26,7 @@ func (c *communicator) start() {
go func(event *events.Event) { go func(event *events.Event) {
m := event.Data.(events.URLMaker) m := event.Data.(events.URLMaker)
data, _ := json.Marshal(event) data, _ := json.Marshal(event)
r, _ := http.Post(c.RootURL+m.GetUrl(), "application/json", bytes.NewBuffer(data)) r, _ := http.Post(GetRootURL()+m.GetUrl(), "application/json", bytes.NewBuffer(data))
e.Result <- events.Result{Message: r.Status} e.Result <- events.Result{Message: r.Status}
}(e) }(e)
} }

View File

@ -6,7 +6,7 @@ const (
) )
const ( const (
COLLECTOR_INSTALL = "/_api/collector/discovery/event/status/install" COLLECTOR_INSTALL = "/_api/collector/event/status/install"
DISCOVERY_START = "/_api/collector/event/discovery/status/start" DISCOVERY_START = "/_api/collector/event/discovery/status/start"
DISCOVERY_END = "/_api/collector/event/discovery/status/end" DISCOVERY_END = "/_api/collector/event/discovery/status/end"

View File

@ -1,5 +1,7 @@
package events package events
import "loafle.com/overflow/collector/discovery/types"
//////////////////////////////////////////////////////////////////////// Port Event Start //////////////////////////////////////////////////////////////////////// Port Event Start
type PortStartEvent struct { type PortStartEvent struct {
Zone int64 Zone int64
@ -42,16 +44,17 @@ func NewPortFoundEvent(zone int64, host int64, port uint16, t string) *PortFound
type PortEndEvent struct { type PortEndEvent struct {
Zone int64 Zone int64
Host int64 Host int64
// history ??? Histories []*types.PortScanHistory
} }
func (i PortEndEvent) GetUrl() string { func (i PortEndEvent) GetUrl() string {
return PORT_START return PORT_START
} }
func NewPortEndEvent(zone int64, host int64) *PortEndEvent { func NewPortEndEvent(zone int64, host int64, history []*types.PortScanHistory) *PortEndEvent {
return &PortEndEvent{ return &PortEndEvent{
Zone: zone, Zone: zone,
Host: host, Host: host,
Histories: history,
} }
} }