Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http: T5762: rename "virtual-host listen-port" -> "virtual-host port" #2519

Merged
merged 1 commit into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions interface-definitions/https.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,9 @@
</constraint>
</properties>
</leafNode>
<leafNode name='listen-port'>
<properties>
<help>Port to listen for HTTPS requests; default 443</help>
<valueHelp>
<format>u32:1-65535</format>
<description>Numeric IP port</description>
</valueHelp>
<constraint>
<validator name="numeric" argument="--range 1-65535"/>
</constraint>
</properties>
#include <include/port-number.xml.i>
<leafNode name='port'>
<defaultValue>443</defaultValue>
</leafNode>
<leafNode name="server-name">
<properties>
Expand Down
3 changes: 0 additions & 3 deletions python/vyos/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@
}

api_data = {
'listen_address' : '127.0.0.1',
'port' : '8080',
'socket' : False,
'strict' : False,
'debug' : False,
'api_keys' : [ {'id' : 'testapp', 'key' : 'qwerty'} ]
Expand Down
8 changes: 8 additions & 0 deletions smoketest/config-tests/basic-api-service
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ set service ntp server time1.vyos.net
set service ntp server time2.vyos.net
set service ntp server time3.vyos.net
set service https api keys id 1 key 'S3cur3'
set service https virtual-host bar allow-client address '172.16.0.0/12'
set service https virtual-host bar port '5555'
set service https virtual-host foo allow-client address '10.0.0.0/8'
set service https virtual-host foo allow-client address '2001:db8::/32'
set service https virtual-host foo port '7777'
set service https virtual-host baz allow-client address '192.168.0.0/16'
set service https virtual-host baz port '6666'
set service https virtual-host baz server-name 'baz'
set system config-management commit-revisions '100'
set system host-name 'vyos'
set system login user vyos authentication encrypted-password '$6$2Ta6TWHd/U$NmrX0x9kexCimeOcYK1MfhMpITF9ELxHcaBU/znBq.X2ukQOj61fVI2UYP/xBzP4QtiTcdkgs7WOQMHWsRymO/'
Expand Down
24 changes: 22 additions & 2 deletions smoketest/configs/basic-api-service
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,28 @@ service {
}
socket
}
}
ssh {
virtual-host bar {
allow-client {
address 172.16.0.0/12
}
listen-port 5555
server-name bar
}
virtual-host baz {
allow-client {
address 192.168.0.0/16
}
listen-port 6666
server-name baz
}
virtual-host foo {
allow-client {
address 10.0.0.0/8
address 2001:db8::/32
}
listen-port 7777
server-name foo
}
}
}
system {
Expand Down
5 changes: 2 additions & 3 deletions smoketest/scripts/cli/test_service_https.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def test_server_block(self):
test_path = base_path + ['virtual-host', vhost_id]

self.cli_set(test_path + ['listen-address', address])
self.cli_set(test_path + ['listen-port', port])
self.cli_set(test_path + ['port', port])
self.cli_set(test_path + ['server-name', name])

self.cli_commit()
Expand All @@ -102,15 +102,14 @@ def test_certificate(self):
def test_api_auth(self):
vhost_id = 'example'
address = '127.0.0.1'
port = '443'
port = '443' # default value
name = 'localhost'

key = 'MySuperSecretVyOS'
self.cli_set(base_path + ['api', 'keys', 'id', 'key-01', 'key', key])

test_path = base_path + ['virtual-host', vhost_id]
self.cli_set(test_path + ['listen-address', address])
self.cli_set(test_path + ['listen-port', port])
self.cli_set(test_path + ['server-name', name])

self.cli_commit()
Expand Down
4 changes: 2 additions & 2 deletions src/conf_mode/https.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def verify(https):
server_block = deepcopy(default_server_block)
data = vhost_dict.get(vhost, {})
server_block['address'] = data.get('listen-address', '*')
server_block['port'] = data.get('listen-port', '443')
server_block['port'] = data.get('port', '443')
server_block_list.append(server_block)

for entry in server_block_list:
Expand Down Expand Up @@ -156,7 +156,7 @@ def generate(https):
server_block['id'] = vhost
data = vhost_dict.get(vhost, {})
server_block['address'] = data.get('listen-address', '*')
server_block['port'] = data.get('listen-port', '443')
server_block['port'] = data.get('port', '443')
name = data.get('server-name', ['_'])
server_block['name'] = name
allow_client = data.get('allow-client', {})
Expand Down
6 changes: 6 additions & 0 deletions src/migration-scripts/https/4-to-5
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ if config.exists(base + ['api', 'socket']):
if config.exists(base + ['api', 'port']):
config.delete(base + ['api', 'port'])

# rename listen-port -> port ver virtual-host
if config.exists(base + ['virtual-host']):
for vhost in config.list_nodes(base + ['virtual-host']):
if config.exists(base + ['virtual-host', vhost, 'listen-port']):
config.rename(base + ['virtual-host', vhost, 'listen-port'], 'port')

try:
with open(file_name, 'w') as f:
f.write(config.to_string())
Expand Down
Loading