diff --git a/.gitignore b/.gitignore index 68ecccc..2379f09 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ dontprobe_list.txt config.yml license_key_geoip.txt + diff --git a/Dockerfile b/Dockerfile index 122e8b6..0c591ff 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,30 +1,51 @@ # Start from the latest golang base image FROM golang:latest -ENV GOOS=linux\ - GOARCH=amd64 +ENV GO111MODULE=on \ + CGO_ENABLED=0 \ + GOOS=linux \ + GOARCH=amd64 -WORKDIR /github.com/niclabs/Observatorio +#WORKDIR /github.com/niclabs/Observatorio/ -COPY . . +#ADD . /github.com/niclabs/Observatorio/ + +# Postgres +#EXPOSE 5432 +# Download all the dependencies +#RUN go get github.com/miekg/dns +#RUN go get github.com/oschwald/geoip2-golang +#RUN go get github.com/lib/pq +#RUN go get gopkg.in/yaml.v2 + +# Build the dns package +#RUN go build github.com/miekg/dns -# Get dependencies -RUN apt update +#CMD ["go", "run", "main/main.go"] -RUN apt install -y libgeoip-dev -#libgeoip1 geoip-bin -# Create database -RUN apt-get install -y postgresql -USER postgres -RUN /etc/init.d/postgresql start &&\ - psql --command "CREATE USER obslac WITH SUPERUSER PASSWORD 'password';" &&\ - createdb -O obslac observatorio +WORKDIR $GOPATH/src/github.com/niclabs/Observatorio + +# Copy and download dependency using go mod +COPY go.mod . +COPY go.sum . +RUN go mod download + +# Copy the code into the container +COPY . . -USER root +# Build the application +#RUN go build -o main . -RUN go build -o main ./src/main +# Move to /dist directory as the place for resulting binary folder +#WORKDIR /dist -CMD ["./main"] +# Copy binary from build to main folder +#RUN cp $GOPATH/src/github.com/niclabs/Observatorio/main . +# Export necessary port +EXPOSE 5432 +# Command to run when starting the container +##CMD ["/dist/main"] +CMD ["go", "run", "main/main.go"] \ No newline at end of file diff --git a/dataAnalyzer/dataAnalyzer.go b/dataAnalyzer/dataAnalyzer.go index 5dbe758..57a3819 100644 --- a/dataAnalyzer/dataAnalyzer.go +++ b/dataAnalyzer/dataAnalyzer.go @@ -3,18 +3,14 @@ package main import ( "database/sql" _ "github.com/lib/pq" - "github.com/niclabs/Observatorio/src/dbController" - //"github.com/miekg/dns" + "github.com/niclabs/Observatorio/dbController" "fmt" "log" "sync" "time" - // "github.com/maitegm/dnsUtils" "encoding/csv" "os" "strconv" - //"flag" - //"github.com/howeyc/gopass" "gopkg.in/yaml.v2" ) diff --git a/dataCollector/dataCollector.go b/dataCollector/dataCollector.go index d36991a..be1c828 100644 --- a/dataCollector/dataCollector.go +++ b/dataCollector/dataCollector.go @@ -5,10 +5,10 @@ import ( "fmt" _ "github.com/lib/pq" "github.com/miekg/dns" - "github.com/niclabs/Observatorio/src/dbController" - "github.com/niclabs/Observatorio/src/dnsUtils" - "github.com/niclabs/Observatorio/src/geoIPUtils" - "github.com/niclabs/Observatorio/src/utils" + "github.com/niclabs/Observatorio/dbController" + "github.com/niclabs/Observatorio/dnsUtils" + "github.com/niclabs/Observatorio/geoIPUtils" + "github.com/niclabs/Observatorio/utils" "github.com/oschwald/geoip2-golang" "net" "runtime" diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..671fe11 --- /dev/null +++ b/go.mod @@ -0,0 +1,12 @@ +module Observatorio + +go 1.15 + +require ( + github.com/howeyc/gopass v0.0.0-20190910152052-7cb4b85ec19c + github.com/korylprince/ipnetgen v0.0.0-20160712025547-34a2abb431f4 + github.com/lib/pq v1.8.0 + github.com/miekg/dns v1.1.31 + github.com/oschwald/geoip2-golang v1.4.0 + gopkg.in/yaml.v2 v2.3.0 +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..f1b33a6 --- /dev/null +++ b/go.sum @@ -0,0 +1,42 @@ +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/howeyc/gopass v0.0.0-20190910152052-7cb4b85ec19c h1:aY2hhxLhjEAbfXOx2nRJxCXezC6CO2V/yN+OCr1srtk= +github.com/howeyc/gopass v0.0.0-20190910152052-7cb4b85ec19c/go.mod h1:lADxMC39cJJqL93Duh1xhAs4I2Zs8mKS89XWXFGp9cs= +github.com/korylprince/ipnetgen v0.0.0-20160712025547-34a2abb431f4 h1:yMBxUzMGyS40obSiIkcj6d8HllfujIcwftQDPDK64Hg= +github.com/korylprince/ipnetgen v0.0.0-20160712025547-34a2abb431f4/go.mod h1:WUy1jS5kZzPfL2gWyJq3LAV5XzK71v9G/NMcT0TAYVo= +github.com/lib/pq v1.8.0 h1:9xohqzkUwzR4Ga4ivdTcawVS89YSDVxXMa3xJX3cGzg= +github.com/lib/pq v1.8.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/miekg/dns v1.1.31 h1:sJFOl9BgwbYAWOGEwr61FU28pqsBNdpRBnhGXtO06Oo= +github.com/miekg/dns v1.1.31/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM= +github.com/oschwald/geoip2-golang v1.4.0 h1:5RlrjCgRyIGDz/mBmPfnAF4h8k0IAcRv9PvrpOfz+Ug= +github.com/oschwald/geoip2-golang v1.4.0/go.mod h1:8QwxJvRImBH+Zl6Aa6MaIcs5YdlZSTKtzmPGzQqi9ng= +github.com/oschwald/maxminddb-golang v1.6.0 h1:KAJSjdHQ8Kv45nFIbtoLGrGWqHFajOIm7skTyz/+Dls= +github.com/oschwald/maxminddb-golang v1.6.0/go.mod h1:DUJFucBg2cvqx42YmDa/+xHvb0elJtOm3o4aFQ/nb/w= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 h1:ObdrDkeb4kJdCP557AjRjq69pTHfNouLtWZG7j9rPN8= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190923162816-aa69164e4478 h1:l5EDrHhldLYb3ZRHDUhXF7Om7MvYXnkV9/iQNo1lX6g= +golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191224085550-c709ea063b76 h1:Dho5nD6R3PcW2SH1or8vS0dszDaXRxIw55lBX7XiE5g= +golang.org/x/sys v0.0.0-20191224085550-c709ea063b76/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/tools v0.0.0-20191216052735-49a3e744a425/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/main/main.go b/main/main.go index 62f756b..d65be58 100644 --- a/main/main.go +++ b/main/main.go @@ -2,8 +2,8 @@ package main import ( "fmt" - "github.com/niclabs/Observatorio/src/dataCollector" - "github.com/niclabs/Observatorio/src/geoIPUtils" + "github.com/niclabs/Observatorio/dataCollector" + "github.com/niclabs/Observatorio/geoIPUtils" "gopkg.in/yaml.v2" "os" )