Merge pull request #272508 from jacobgreenleaf/jg-teamspeak3-protos

This commit is contained in:
Maciej Krüger 2023-12-08 18:17:37 +01:00 committed by GitHub
commit a2595d975f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -50,7 +50,7 @@ in
};
defaultVoicePort = mkOption {
type = types.int;
type = types.port;
default = 9987;
description = lib.mdDoc ''
Default UDP port for clients to connect to virtual servers - used for first virtual server, subsequent ones will open on incrementing port numbers by default.
@ -67,7 +67,7 @@ in
};
fileTransferPort = mkOption {
type = types.int;
type = types.port;
default = 30033;
description = lib.mdDoc ''
TCP port opened for file transfers.
@ -84,10 +84,26 @@ in
};
queryPort = mkOption {
type = types.int;
type = types.port;
default = 10011;
description = lib.mdDoc ''
TCP port opened for ServerQuery connections.
TCP port opened for ServerQuery connections using the raw telnet protocol.
'';
};
querySshPort = mkOption {
type = types.port;
default = 10022;
description = lib.mdDoc ''
TCP port opened for ServerQuery connections using the SSH protocol.
'';
};
queryHttpPort = mkOption {
type = types.port;
default = 10080;
description = lib.mdDoc ''
TCP port opened for ServerQuery connections using the HTTP protocol.
'';
};
@ -128,7 +144,9 @@ in
];
networking.firewall = mkIf cfg.openFirewall {
allowedTCPPorts = [ cfg.fileTransferPort ] ++ optionals (cfg.openFirewallServerQuery) [ cfg.queryPort (cfg.queryPort + 11) ];
allowedTCPPorts = [ cfg.fileTransferPort ] ++ (map (port:
mkIf cfg.openFirewallServerQuery port
) [cfg.queryPort cfg.querySshPort cfg.queryHttpPort]);
# subsequent vServers will use the incremented voice port, let's just open the next 10
allowedUDPPortRanges = [ { from = cfg.defaultVoicePort; to = cfg.defaultVoicePort + 10; } ];
};
@ -141,13 +159,19 @@ in
serviceConfig = {
ExecStart = ''
${ts3}/bin/ts3server \
dbsqlpath=${ts3}/lib/teamspeak/sql/ logpath=${cfg.logPath} \
${optionalString (cfg.voiceIP != null) "voice_ip=${cfg.voiceIP}"} \
dbsqlpath=${ts3}/lib/teamspeak/sql/ \
logpath=${cfg.logPath} \
license_accepted=1 \
default_voice_port=${toString cfg.defaultVoicePort} \
${optionalString (cfg.fileTransferIP != null) "filetransfer_ip=${cfg.fileTransferIP}"} \
filetransfer_port=${toString cfg.fileTransferPort} \
query_port=${toString cfg.queryPort} \
query_ssh_port=${toString cfg.querySshPort} \
query_http_port=${toString cfg.queryHttpPort} \
${optionalString (cfg.voiceIP != null) "voice_ip=${cfg.voiceIP}"} \
${optionalString (cfg.fileTransferIP != null) "filetransfer_ip=${cfg.fileTransferIP}"} \
${optionalString (cfg.queryIP != null) "query_ip=${cfg.queryIP}"} \
query_port=${toString cfg.queryPort} license_accepted=1
${optionalString (cfg.queryIP != null) "query_ssh_ip=${cfg.queryIP}"} \
${optionalString (cfg.queryIP != null) "query_http_ip=${cfg.queryIP}"} \
'';
WorkingDirectory = cfg.dataDir;
User = user;