index.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /**
  2. * TraCINg-Server - Gathering and visualizing cyber incidents on the world
  3. *
  4. * Copyright 2013 Matthias Gazzari, Annemarie Mattmann, André Wolski
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. // load node modules
  19. var fs = require("fs");
  20. // load config
  21. var config = require("./config.json");
  22. // load internal modules
  23. var server = require("./modules/server");
  24. var postHandler = require("./modules/postHandler");
  25. var ioListener = require("./modules/ioListener");
  26. // read keys from filesystem
  27. var ssl_options = {
  28. // server private key
  29. key: fs.readFileSync(config.ssl.keyPath),
  30. // server certificate (signed by CA)
  31. cert: fs.readFileSync(config.ssl.certPath),
  32. // CA certificate
  33. ca: fs.readFileSync(config.ssl.caPath),
  34. // require authentication by certificate
  35. requestCert: config.ssl.requestCert,
  36. // reject unauthenticated traffic
  37. rejectUnauthorized: config.ssl.rejectUnauthorized
  38. };
  39. // start the node.js server
  40. server.start(postHandler.process, ioListener, config.server, ssl_options);