summary refs log tree commit diff
path: root/host/Rory-ovh/services/containers/spacebar/services/spacebar.nix
blob: 7b8321ba09969f1994e7625efa29db291f1b670a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
{ spacebar, lib, ... }:

let
  sb = import "${spacebar}/nix/lib/mkEndpoint.nix";
in
{
  imports = [ spacebar.nixosModules.default ];
  services.spacebarchat-server = {
    enable = true;
    serverName = "spacebar.chat";

    apiEndpoint = sb.mkEndpoint "api.rory.server.spacebar.chat" 3001 true;
    gatewayEndpoint = sb.mkEndpoint "gateway.rory.server.spacebar.chat" 3002 true;
    extraGatewayPorts = lib.range 3100 3115;
    cdnEndpoint = sb.mkEndpoint "cdn.rory.server.spacebar.chat" 3003 true;
    adminApiEndpoint = sb.mkEndpoint "admin.rory.server.spacebar.chat" 3004 true;
    webrtcEndpoint = sb.mkEndpoint "voice.rory.server.spacebar.chat" 3005 true;

    cdnPath = "/storage";

    cdnSignaturePath = "/run/secrets/spacebar/cdnSignature";
    legacyJwtSecretPath = "/run/secrets/spacebar/legacyJwtSecret";
    mailjetApiKeyPath = "/run/secrets/spacebar/mailjetApiKey";
    mailjetApiSecretPath = "/run/secrets/spacebar/mailjetApiSecret";
    # smtpPasswordPath = "/run/secrets/spacebar/smtpPassword";
    gifApiKeyPath = "/run/secrets/spacebar/gifApiKey";
    # rabbitmqHostPath = "/run/secrets/spacebar/rabbitmqHost";
    abuseIpDbApiKeyPath = "/run/secrets/spacebar/abuseIpDbApiKey";
    captchaSecretKeyPath = "/run/secrets/spacebar/captchaSecretKey";
    captchaSiteKeyPath = "/run/secrets/spacebar/captchaSiteKey";
    ipdataApiKeyPath = "/run/secrets/spacebar/ipdataApiKey";
    requestSignaturePath = "/run/secrets/spacebar/requestSignature";

    adminApi = {
      enable = true;
      extraConfiguration.ConnectionStrings.Spacebar = "Host=192.168.100.1; Username=spacebar; Password=spacebar; Database=spacebar; Port=5432; Include Error Detail=true; Maximum Pool Size=1000; Command Timeout=6000; Timeout=600;";
    };

    pion-sfu = {
      enable = true;
      publicIp = "51.210.113.110";
    };

    settings = {
      security = {
        forwardedFor = "X-Forwarded-For";
        trustedProxies = "192.168.100.1, linklocal";
        cdnSignUrls = true;
        cdnSignatureIncludeIp = true;
        cdnSignatureIncludeUserAgent = false;
        cdnSignatureDuration = "15m";
      };
      general = {
        frontPage = "https://spacebar.chat";
        instanceDescription = "The official testing for Spacebar";
        instanceId = "1007550087590649856";
        instanceName = "Spacebar Staging Official";
        publicUrl = "https://rory.server.spacebar.chat";
        tosPage = "https://docs.spacebar.chat/contributing/conduct/";
        correspondenceUserID = "1006598230156341276";
        correspondenceEmail = "root@rory.gay";
      };
      guild = {
        autoJoin = {
          bots = false;
          canLeave = true;
          enabled = true;
          guilds = [ "1006649183970562092" ];
        };
      };
      limits = {
        guild = {
          maxMembers = 25000000;
          maxEmojis = 2000;
          maxChannelsInCategory = 65535;
          maxChannels = 250;
          maxRoles = 250;
          maxBulkBanUsers = 200;
          maxStickers = 500;
        };
        message = {
          maxCharacters = 1048576;
          maxTTSCharacters = 160;
          maxReactions = 2048;
          maxAttachmentSize = 1073741824;
          maxEmbedDownloadSize = 5242880;
          maxBulkDelete = 1000;
          maxPreloadCount = 100;
        };
        channel = {
          maxPins = 500;
          maxTopic = 1024;
          maxWebhooks = 100;
        };
        rate = {
          ip = {
            window = 5;
            count = 500;
          };
          global = {
            count = 250;
            window = 5;
          };
          error = {
            window = 5;
            count = 10;
          };
          routes = {
            guild = {
              window = 5;
              count = 5;
            };
            webhook = {
              count = 10;
              window = 5;
            };
            channel = {
              count = 10;
              window = 5;
            };
            auth = {
              login = {
                window = 60;
                count = 5;
              };
              register = {
                count = 2;
                window = 43200;
              };
            };
          };
          enabled = false;
        };
        user = {
          maxGuilds = 1000;
          maxUsername = 64;
          maxFriends = 2000;
          maxBio = 500;
        };
        absoluteRate = {
          register = {
            limit = 25;
            window = 3600000;
            enabled = false;
          };
          sendMessage = {
            limit = 120;
            window = 60000;
            enabled = false;
          };
        };
      };
      user = {
        blockedContains = [
          "discord"
          "clyde"
          "mail.ru"
          "penis"
          "child"
          "admin"
          "owner"
          "moderator"
          "Noruya"
          "𝖞𝖔𝖗𝖚𝖟𝖆"
          "spacebar"
          "1488"
          "hitler"
          "nigger"
          "nitro"
          "monero"
          "gmail.com"
          "outlook.com"
          "steam"
        ];
      };
      register = {
        blockIpDataCoThreatTypes = [];
        #checkIp = false;
        enableAbuseIpDb = true;
        enableIpData = false; # 1500req/d, needed by gateway
      };
      embeds = {
        youtube = {
          userAgent = "Mozilla/5.0 (compatible; Discordbot/2.0; +https://discordapp.com)";
        };
      };
    };
    extraEnvironment = {
      DATABASE = "postgres://spacebar:spacebar@192.168.100.1/spacebar";
      #LOG_REQUESTS = "-200,204,304";
      LOG_REQUESTS = "-";
      LOG_VALIDATION_ERRORS = true;
      LOG_API_ERRORS = true;
      #DB_LOGGING=true;
      #LOG_GATEWAY_TRACES=true;
      #LOG_PROTO_UPDATES=true;
      #LOG_PROTO_FRECENCY_UPDATES=true;
      #LOG_PROTO_SETTINGS_UPDATES=true;
    };
  };
}