Skip to content

Commit

Permalink
NewsServer Add UI - Default encryption and ports (#225)
Browse files Browse the repository at this point in the history
- moved `Server.Encryption` between `Server.Host` and `Server.Port`;
- made `Server.Encryption` to `ON` by default;
- made port depend on `Server.Encryption value unless user has put something up:
  - 563/443 for secure;
  - 119/80 for unsecure.
  • Loading branch information
dnzbk authored Apr 16, 2024
1 parent 26de6ed commit cd1cab4
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 8 deletions.
16 changes: 8 additions & 8 deletions nzbget.conf
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,14 @@ Server1.Group=0
# Host name of news server.
Server1.Host=my.newsserver.com

# Port to connect to (1-65535).
Server1.Port=119
# Encrypted server connection (TLS/SSL) (yes, no).
#
# NOTE: By changing this option you should also change the option <ServerX.Port>
# accordingly because unsecure and encrypted connections use different ports.
Server1.Encryption=yes

# News Server port, usually 563 for secure connections, 119 for unsecure connections, rare - 80 or 443 (1-65535).
Server1.Port=563

# User name to use for authentication.
Server1.Username=user
Expand All @@ -211,12 +217,6 @@ Server1.Password=pass
# Server requires "Join Group"-command (yes, no).
Server1.JoinGroup=no

# Encrypted server connection (TLS/SSL) (yes, no).
#
# NOTE: By changing this option you should also change the option <ServerX.Port>
# accordingly because unsecure and encrypted connections use different ports.
Server1.Encryption=no

# Cipher to use for encrypted server connection.
#
# By default (when the option is empty) the underlying encryption library
Expand Down
57 changes: 57 additions & 0 deletions webui/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* This file is part of nzbget. See <https://nzbget.com>.
*
* Copyright (C) 2012-2019 Andrey Prygunkov <hugbug@users.sourceforge.net>
* Copyright (C) 2024 Denis <denis@nzbget.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -1323,10 +1324,66 @@ var Config = (new function($)
{
var optFormId = $(control).parent().attr('id');
var option = findOptionById(optFormId);

if (option.onchange)
{
option.onchange(option);
}

tlsSwitchHelper(option)
}
}

function tlsSwitchHelper(option)
{
var defaultPort = '119';
var defaultTlsPort = '563';

var defaultPort2 = '80';
var defaultTlsPort2 = '443';

var suffixStartIdx = option.formId.indexOf('_Encryption');
if (suffixStartIdx < 0)
{
return;
}

var portOptionId = option.formId.substring(0, suffixStartIdx) + '_Port';
var portOption = findOptionById(portOptionId);
var useTls = getOptionValue(option) === 'yes';
var currentPort = getOptionValue(portOption);
var inputField = $('#' + portOptionId)[0];

if (useTls)
{
if (currentPort === defaultPort)
{
inputField.value = defaultTlsPort;
return;
}

if (currentPort === defaultPort2)
{
inputField.value = defaultTlsPort2;
}

return;
}

if (!useTls)
{
if (currentPort === defaultTlsPort)
{
inputField.value = defaultPort;
return;
}

if (currentPort === defaultTlsPort2)
{
inputField.value = defaultPort2;
}

return;
}
}

Expand Down

0 comments on commit cd1cab4

Please sign in to comment.