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

Store emails in db #2

Merged
merged 2 commits into from
Jul 16, 2014
Merged

Store emails in db #2

merged 2 commits into from
Jul 16, 2014

Conversation

joedursun
Copy link
Collaborator

WARNING: There is currently no protection against sql injection. This is just a simple way to speed up repeated lookups and to circumvent being rate limited. Do not use if you don't trust the data coming in.

This branch adds the ability to store the whois data in a sql database. The raw whois data, along with the domain name and list of found emails, is stored in sqlite; swapping out sql databases should be as easy as changing adapters at the top of ./server.go. To keep the size of the database from growing too quickly we should consider only storing the domain and emails, but for now all data is being stored (for debugging purposes).

Some of the new functions can be refactored to be more DRY; I'll come back at a later date and fix that.

Another field I considered adding was "dateRetrieved" so we could request fresh data if it's "been a while." Again, I'll come back and add that feature later as well.

NOTE
I've been looking around at different ORMs for Go and it looks like this one is more established than Gorp: https://github.com/go-xorm/xorm

I'll come back and switch out the ORM for Xorm soon.

@zph
Copy link
Owner

zph commented Jul 16, 2014

Looks good 👍

And now I feel horrible for having a typo in your name in the README 👎.

I like the improvements and that you're getting into golang.

zph added a commit that referenced this pull request Jul 16, 2014
@zph zph merged commit 2ed781b into master Jul 16, 2014
@zph zph deleted the cache_emails branch July 16, 2014 13:13
@zph
Copy link
Owner

zph commented Jul 20, 2014

@joedursun,

Hmm, what other dependencies are involved for building this?

I tried on my dev machine and it spat out complaints about missing sqlite dev dependencies.

Do you remember what else you installed to be able to build it on OSX?

@joedursun
Copy link
Collaborator Author

Make sure you have sqlite3 installed: brew list sqlite3.
If not, make sure you install it before booting up the app. Apart from that, you should be able to just run go get . from the go-whois repo root and Go will install the necessary dependencies.

If you want to try it out with a different db (e.g. mysql), modify the following lines in server.go:

// _ "github.com/mattn/go-sqlite3"
_ "github.com/go-sql-driver/mysql"
...
// dbmap := &gorp.DbMap{Db: db, Dialect: gorp.SqliteDialect{}}
dbmap := &gorp.DbMap{Db: db, Dialect: gorp.MySQLDialect{}}

@zph
Copy link
Owner

zph commented Jul 21, 2014

Good news: working and deployed.

Bad news: brew install sqlite3 didn't allow me to build the linux_amd64 binary 👎. Seems like the osx one was building fine, but not linux. Shelled into linux box, and it built fine.

And I'm happy w/ sqlite3 😄, it was a great choice for a small project like this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants