Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions bin/casimir.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ var Storage = require(path.join(__dirname, '/../app/modules/storage.js'))
var storage = new Storage(properties)

var verifyCallback = function (jwtToken, req, res, next) {
if (!properties.JWT.jwtTokenSecret) {
if (!properties.JWT.user || !properties.JWT.jwtTokenSecret) {
return next()
}
try {
var decoded = jwt.decode(jwtToken, properties.JWT.jwtTokenSecret)
var expiration = Date.parse(decoded.exp)
if (expiration > Date.now()) {
if (expiration > Date.now() && properties.JWT.user === decoded.iss) {
req.user = decoded.iss
}
} catch (e) {
Expand All @@ -48,7 +48,7 @@ var verifyCallback = function (jwtToken, req, res, next) {
}

var accessCallback = function (req, res, next) {
if (!properties.JWT.jwtTokenSecret) {
if (!properties.JWT.user || !properties.JWT.jwtTokenSecret) {
return next() // if no JWT secret is provided, consider this a public end-point
}
next(['Unauthorized', 401])
Expand Down
5 changes: 5 additions & 0 deletions config/properties_QA.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#The most basic HTTP server settings, must at least contain the port value
[server]
hostname=localhost
https_port=8181
http_port=8180
#cookies_secret=
Expand All @@ -21,6 +22,7 @@ type=QA

#JWT runs the authentication for the private API. Decomment the next lines to use it
[JWT]
#user=
#jwtTokenSecret=

[AWS]
Expand All @@ -29,6 +31,9 @@ type=QA
#S3bucket=

[torrent]
torrentPort=13231
dhtPort=20000
#seed=false
seedBulkSize=20
seedBulkIntervalInMs=60000

Expand Down
5 changes: 5 additions & 0 deletions config/properties_development.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#The most basic HTTP server settings, must at least contain the port value
[server]
hostname=localhost
https_port=8181
http_port=8180
#cookies_secret=
Expand All @@ -21,6 +22,7 @@ type=development

#JWT runs the authentication for the private API. Decomment the next lines to use it
[JWT]
#user=
#jwtTokenSecret=

[AWS]
Expand All @@ -29,6 +31,9 @@ type=development
#S3bucket=

[torrent]
torrentPort=13231
dhtPort=20000
#seed=false
#fromTorrentHash=
seedBulkSize=20
seedBulkIntervalInMs=60000
Expand Down
5 changes: 5 additions & 0 deletions config/properties_production.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#The most basic HTTP server settings, must at least contain the port value
[server]
hostname=localhost
https_port=8181
http_port=8180
#cookies_secret=
Expand All @@ -21,6 +22,7 @@ type=production

#JWT runs the authentication for the private API. Decomment the next lines to use it
[JWT]
#user=
#jwtTokenSecret=

[AWS]
Expand All @@ -29,6 +31,9 @@ type=production
#S3bucket=

[torrent]
torrentPort=13231
dhtPort=20000
#seed=false
seedBulkSize=100
seedBulkIntervalInMs=60000

Expand Down
6 changes: 3 additions & 3 deletions startup.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ var fs = require('graceful-fs')

var torrentProperties = {
client: {
// torrentPort: 13231,
// dhtPort: 20000,
torrentPort: properties.torrent.torrentPort,
dhtPort: properties.torrent.dhtPort,
// Enable DHT (default=true), or options object for DHT
dht: true,
// Max number of peers to connect to per torrent (default=100)
Expand Down Expand Up @@ -53,7 +53,7 @@ folders.forEach(function (dir) {
}
})

server.http_server.listen(server.port, function (err) {
server.http_server.listen(server.port, properties.server.hostname, function (err) {
if (err) {
logger.info('Critical Error so killing server - ' + err)
casimir.running = false
Expand Down