Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing issues #45 #46 #47 #50

Closed
14 changes: 1 addition & 13 deletions api/ct.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (s *Server) StoreLogEntries(str api.CtApi_StoreLogEntriesServer) error {

// write a chunk
finishTime := time.Since(startTime)
if _, err := s.BenchmarkFile.Write([]byte(strconv.FormatInt(finishTime.Microseconds(), 10) + ",")); err != nil {
if _, err := s.MapEntryExecTime.Write([]byte(strconv.FormatInt(finishTime.Microseconds(), 10) + ",")); err != nil {
panic(err)
}
}
Expand All @@ -111,18 +111,6 @@ func (s *Server) StoreLogEntries(str api.CtApi_StoreLogEntriesServer) error {
}
}()
}
//todo change the response to the client
//errs := s.Store.MapBatchWithCacheAndDB()
//if len(errs) != 0 {
// fmt.Println(errs)
//}
//err = s.Store.StoreBatchPostHook()
//if err != nil {
// fmt.Println(err)
//}

log.Info().Msgf("%v", s.Store.Counter)
s.Store.ResetCounter()
}
wg.Wait()

Expand Down
7 changes: 0 additions & 7 deletions api/measurement.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ func (s *Server) StopMeasurement(ctx context.Context, muid *api.MeasurementId) (
return nil, status.Error(codes.Internal, err.Error())
}

if err := s.Store.RunPostHooks(); err != nil {
return nil, status.Error(codes.Internal, err.Error())
}

log.Debug().Str("muid", muid.Id).Msgf("stopped measurement")

return &api.Empty{}, nil
Expand Down Expand Up @@ -78,9 +74,6 @@ func (s *Server) StopStage(ctx context.Context, muid *api.MeasurementId) (*api.E
return nil, status.Error(codes.Internal, err.Error())
}

if err := s.Store.RunPostHooks(); err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
log.Debug().Str("muid", muid.Id).Msgf("stopped stage")

return &api.Empty{}, nil
Expand Down
8 changes: 4 additions & 4 deletions api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ func timeFromUnix(ts int64) time.Time {
}

type Server struct {
Conf Config
Store *store.Store
Log app.ErrLogger
BenchmarkFile *os.File
Conf Config
Store *store.Store
Log app.ErrLogger
MapEntryExecTime *os.File
}

func (s *Server) Run(lis net.Listener) error {
Expand Down
32 changes: 20 additions & 12 deletions app/cache/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ func main() {

opts := store.Opts{
AllowedInterval: 36 * time.Hour,
BatchSize: 50000,
BatchSize: 10000,
CacheOpts: store.CacheOpts{
LogSize: 1000,
TLDSize: 2000,
PSuffSize: 5000,
ApexSize: 20000,
FQDNSize: 20000,
CertSize: 20000,
PSuffSize: 10000,
ApexSize: 63000,
FQDNSize: 1474000,
CertSize: 673000,
},
}

Expand Down Expand Up @@ -82,25 +82,33 @@ func main() {
logger = app.NewZeroLogger(tags)
}

// open output file
fo, err := os.Create("output/output.txt")
fmp, err := os.Create("output/mapentry_exec_time.txt")
if err != nil {
panic(err)
}
// close fo on exit and check for its returned error
defer func() {
if err := fo.Close(); err != nil {
if err := fmp.Close(); err != nil {
panic(err)
}
}()

serv := api.Server{
Conf: conf.Api,
Store: s,
Log: logger,
BenchmarkFile: fo,
Conf: conf.Api,
Store: s,
Log: logger,
MapEntryExecTime: fmp,
}

defer func() {
if err := serv.Store.DBTime.Close(); err != nil {
panic(err)
}
if err := serv.Store.HitCount.Close(); err != nil {
panic(err)
}
}()

addr := fmt.Sprintf(":%d", conf.Api.Api.Port)
lis, err := net.Listen("tcp", addr)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion app/ct/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func main() {
StartIndex: 0,
//EndIndex: end,
//EndIndex: index.Start + 100,
EndIndex: 10000,
EndIndex: 50000000,
}

count, err = ct.Scan(ctx, &l, entryFn, opts)
Expand Down
3 changes: 2 additions & 1 deletion collectors/entrada/entrada.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package entrada
import (
"context"
"database/sql"
imp "github.com/bippio/go-impala"
"io"
"time"

imp "github.com/bippio/go-impala"
)

var (
Expand Down
12 changes: 12 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ services:
ports:
- "${GRPC_PORT}:${GRPC_PORT}"
- "8881:8881"
networks:
- gollector
# entrada:
# container_name: gollector-entrada
# build:
Expand Down Expand Up @@ -41,6 +43,8 @@ services:
command: [ "--config", "/config/ct.yml", "-logtostderr" ]
volumes:
- ./config:/config:ro # configuration files
networks:
- gollector
# splunk:
# container_name: gollector-splunk
# build:
Expand All @@ -61,3 +65,11 @@ services:
- ${DB_VOLUME?err}:/var/lib/postgresql/data # persistent storage of database
ports:
- "${POSTGRES_HOST?err}:${POSTGRES_PORT?err}:5432"
networks:
- gollector

# docker network create --subnet "10.13.20.0/24" gollector
networks:
gollector:
external:
name: gollector
Loading