stephen304 / bitcannon

A torrent index archiving, browsing, and backup tool
http://bitcannon.io/
MIT License
408 stars 40 forks source link

Enable MongoDB port/login/password/etc. to be configured in config.json #74

Open tubededentifrice opened 9 years ago

tubededentifrice commented 9 years ago

Enable MongoDB port/login/password/etc. to be configured in config.json so it's possible to use an external service like https://www.compose.io or host the MongoDB database on another server (auth is a must have, people can't rely on source IP for security), possibly with sharding enabled for example.

stephen304 commented 9 years ago

This is definitely necessary. I'm not sure when I'll be able to implement this, but I'll keep this issue updated.

alexandre-p commented 9 years ago

I haven't taken the time to test, but I believe it is already possible.

The mongo parameter in Bitcannon's config file is directly used in the Mongo connector (mgo). The connector accepts any mongo connection string. So 127.0.0.1 works (for a local database, on the default port, with no authentification), but a connection string like mongodb://my_username:my_password@127.0.0.1:7777 should work if you want to use authentication and 7777 as the port.

If you want to work with a mongo replica set, you can give multiple hosts in a connection string like this : mongodb://host1:port1,host2:port2

The full documentation can be found here.

For the authentication part, note that by default, even if you have users, the default MongoDB setting is to allow anonymous connections, you have to force it in the config file (with auth=true I believe).