Packet-Clearing-House / DNSAuth

Go-lang app to aggregate DNS queries to 1 minute buckets and write them to influxdb
MIT License
2 stars 2 forks source link

Mysql customer db #6

Closed mrjones-plip closed 6 years ago

mrjones-plip commented 6 years ago

@alexisfasquel - can you please review the commits I've made to the README.md on this branch? Specifically around adding the go get -u github.com/go-sql-driver/mysql line? I kept on getting this error otherwise:

root@dnsauth3:~/DNSAuth/DNSAuth# pwd
/root/DNSAuth/DNSAuth

root@dnsauth3:~/DNSAuth/DNSAuth# go build
customers.go:6:2: cannot find package "github.com/go-sql-driver/mysql" in any of:
        /usr/lib/go-1.10/src/github.com/go-sql-driver/mysql (from $GOROOT)
        /root/go/src/github.com/go-sql-driver/mysql (from $GOPATH)

As well, after finally reproducing the build process reliably, I get a an segmentation violation error:

root@dnsauth3:~# sudo ./go/bin/DNSAuth -c DNSAuth/DNSAuth/dnsauth.toml 
2018/05/14 20:20:34 Loading config file...
2018/05/14 20:20:34 OK!
2018/05/14 20:20:34 Initializing customer DB (will be refresh every 24 hours)...
2018/05/14 20:20:34 OK!
2018/05/14 20:20:34 BGP lookups will be ignored, no BGP config provided.
2018/05/14 20:20:34 Pushing metrics!!
2018/05/14 20:20:34 Refreshing customer list from mysql...
2018/05/14 20:20:34 Influx pusher inserted 1 points!
2018/05/14 20:20:34 Took 2.566457msseconds
2018/05/14 20:20:34 OK!
2018/05/14 20:21:22 Refreshing customer list from mysql...
2018/05/14 20:21:22 OK!
2018/05/14 20:21:34 Pushing metrics!!
2018/05/14 20:21:34 Influx pusher inserted 1 points!
2018/05/14 20:21:34 Took 1.137164msseconds
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xaf7916]

goroutine 521 [running]:
main.(*CustomerDB).Resolve(0x0, 0xc4202fe166, 0xb, 0x9, 0x9)
        /root/go/src/github.com/Packet-Clearing-House/DNSAuth/DNSAuth/customers.go:33 +0x26
main.handleQuery(0x0, 0xed1782ff0, 0x0, 0xc420579ad7, 0x3, 0xc4202fe120, 0x59)
        /root/go/src/github.com/Packet-Clearing-House/DNSAuth/DNSAuth/main.go:233 +0xa0
main.aggreagate(0xc420579ad0, 0x2d, 0xc4200b0d00)
        /root/go/src/github.com/Packet-Clearing-House/DNSAuth/DNSAuth/main.go:213 +0x785
created by main.main.func3
        /root/go/src/github.com/Packet-Clearing-House/DNSAuth/DNSAuth/main.go:114 +0x174
alexisfasquel commented 6 years ago

Alright, fixed the dumb mistake behind the seg fault. Also, I changed the go get -u github.com/go-sql-driver/mysql to reflect the fact you need to install all the dependencies (go get ./...) before running go install.

mrjones-plip commented 6 years ago

Looks good! Merging to master and we can file bugs to fix anything that comes up.