项目作者: relaypro-open

项目描述 :
Distributed firewall manager
高级语言: Erlang
项目地址: git://github.com/relaypro-open/dog_trainer.git
创建时间: 2021-05-17T22:03:04Z
项目社区:https://github.com/relaypro-open/dog_trainer

开源协议:GNU Affero General Public License v3.0

下载




dog_trainer

dog_trainer is the central server component of dog,
a centralized firewall management system.

Runtime Dependencies

  • linux 4.x+ (Ubuntu 22.04 tested)
  • diffutils
  • coreutils
  • rabbitmq-server 3.7+
  • rethinkdb 2.3.6+
  • git

Build Dependencies

  • erlang 24

Certificate Creation

If you already have a CA and per-server certs, you can reuse them, or buy new ones
(costly).
You can create your own self-signed certs with your own Certificate Authority.

One option to get you started is: https://github.com/relaypro-open/csc

RethinkDB setup

Install RethinkDB

  1. sudo apt install rethinkdb=2.3.6~0xenial

Setup clustering

For high availability, setup replication: sharding-and-replication

RethinkDB security

RethinkDB’s web console doesn’t require authentication,
but you can use oauth2_proxy oauth2-proxy
for that purpose.

Create database tables and indexes

Automatically created on dog_trainer start.

Import default Services

Definitions for some well known services can be imported.

  1. rethinkdb import -f /opt/dog_trainer/scripts/default_services.json --table dog.service

RabbitMQ setup

install RabbitMQ

  1. sudo apt install rabbitmq-server=3.7.17-1

Copy and edit config

  1. cp config/rabbitmq/rabbitmq.conf /etc/rabbitmq/
  2. #edit rabbitmq to reflect location of certs and
  3. #you should replace PRIVATE_IP with an IP that is not accessible via the
  4. #pubilc internet.
  5. cp config/rabbitmq/enabled_plugins /etc/rabbitmq/
  6. restart rabbitmq-server

Create virtual host and admin users

  1. #edit setup_rabbitmq.sh, define variables.
  2. script/setup_rabbitmq.sh

Networking

Create DNS service names

It’s useful to create service names for the dog_trainer clients to connect to.
You may want to create one for each type of connection:

  • rabbitmq clients: To force rabbitmq connections over private networks in EC2,
    create this service name as a A Record with the private IP of your server as its
    value.
  • dog_park (gui) clients

Federate multiple brokers to connect to multiple regions

You can deploy multiple rabbitmq servers across regions, using the federation
plugin to replcate client queues
and exchanges. You can then connect your agents to these distributed rabbitmqs
via their local private IPs,
avoiding having to have agents connect to a rabbitmq in another region across
the public internet.
RabbitMQ federation

Install

Create directories:

  1. ./install.sh

Use github Release archive

github.com builds releases for Ubuntu x86

Download latest release archive:
https://github.com/relaypro-open/dog_trainer/releases

Extract archive to /opt/dog_trainer/

Create configuration file /etc/dog_trainer/dog_trainer.config, based on this template:

{% raw %}

  1. [
  2. {dog_trainer, [
  3. {keepalive_alert_seconds, 60}
  4. ]},
  5. {sync, [
  6. {growl, none},
  7. {log, [warnings, errors]},
  8. {non_descendants, fix},
  9. {executable, auto},
  10. {whitelisted_modules, []},
  11. {excluded_modules, []}
  12. ]},
  13. {lager, [
  14. {handlers, [
  15. {lager_console_backend,
  16. [none,
  17. {lager_default_formatter, [time,
  18. " [", severity, "] ", pid, " (", {turbine_id, "non-turbine"}, ") ==> ", message, "\n"]}]},
  19. {{lager_file_backend, "error_log"}, [{file, "/var/log/dog_trainer/error.log"}, {level, error}]},
  20. {{lager_file_backend, "console_log"}, [{file, "/var/log/dog_trainer/console.log"}, {level, info }]}
  21. ]},
  22. {crash_log, "/var/log/dog_trainer/crash.log"},
  23. {tracefiles, [
  24. ]},
  25. {async_threshold, 10000},
  26. {sieve_threshold, 5000},
  27. {sieve_window, 100}
  28. ]},
  29. {thumper, [
  30. {substitution_rules, []},
  31. {thumper_svrs, [default, publish]},
  32. {brokers, [
  33. {default, [
  34. {rabbitmq_config,
  35. [
  36. {host, "DOG_RABBITMQ_HOST"},
  37. {port, 5673},
  38. {api_port, 15672},
  39. {virtual_host, <<"dog">>},
  40. {user, <<"dog_trainer">>},
  41. {password, <<"PASSWORD">>},
  42. {ssl_options, [{cacertfile, "/opt/dog_trainer/priv/certs/rabbitmq/ca/cacert.pem"},
  43. {certfile, "/opt/dog_trainer/priv/certs/rabbitmq/client/cert.pem"},
  44. {keyfile, "/opt/dog_trainer/priv/certs/rabbitmq/client/key.pem"},
  45. {verify, verify_none},
  46. {fail_if_no_peer_cert, true}
  47. ]},
  48. {broker_config,
  49. {thumper_tx,
  50. ["/opt/dog_trainer/priv/broker.tx"]}}
  51. ]}]},
  52. {publish, [{rabbitmq_config, default}]}
  53. ]},
  54. {queuejournal,
  55. [
  56. {enabled, true},
  57. {dir, "/var/db/dog_trainer/queuejournal"},
  58. {memqueue_max, 10000},
  59. {check_journal, true}
  60. ]
  61. }
  62. ]},
  63. {erlcloud, [
  64. {aws_config, [
  65. {ec2_host, "ec2.us-east-1.amazonaws.com"}
  66. ]}
  67. ]}
  68. ].

{% endraw %}

Build Release Deploy

  1. $ rebar as $ENV tar
  2. #copy tar to system, extract to /opt/dog_trainer

Run

Setup systemd service

  1. cp config/dog_trainer.service /lib/systemd/system/dog_trainer.service
  2. systemctl enable dog_trainer
  3. systemctl start dog_trainer

Logs

  1. /var/log/dog_trainer/

Deploy Agents

Agents