Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ivan Tyagov
slapos
Commits
409a6823
Commit
409a6823
authored
Jul 15, 2020
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
caddy-frontend: Correctly support backend urls with whitespaces
parent
c6fbeaeb
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
14 deletions
+21
-14
software/caddy-frontend/buildout.hash.cfg
software/caddy-frontend/buildout.hash.cfg
+2
-2
software/caddy-frontend/instance-apache-replicate.cfg.in
software/caddy-frontend/instance-apache-replicate.cfg.in
+10
-9
software/caddy-frontend/templates/apache-custom-slave-list.cfg.in
.../caddy-frontend/templates/apache-custom-slave-list.cfg.in
+1
-1
software/caddy-frontend/test/test.py
software/caddy-frontend/test/test.py
+8
-2
No files found.
software/caddy-frontend/buildout.hash.cfg
View file @
409a6823
...
@@ -26,11 +26,11 @@ md5sum = 23237969bbd9e974ac674b2052e8d67c
...
@@ -26,11 +26,11 @@ md5sum = 23237969bbd9e974ac674b2052e8d67c
[template-caddy-replicate]
[template-caddy-replicate]
filename = instance-apache-replicate.cfg.in
filename = instance-apache-replicate.cfg.in
md5sum =
dac4ed5b4c95b6905f48bab8769ca236
md5sum =
e2d9c782835ea9816539ce7b4f924ca9
[template-slave-list]
[template-slave-list]
_update_hash_filename_ = templates/apache-custom-slave-list.cfg.in
_update_hash_filename_ = templates/apache-custom-slave-list.cfg.in
md5sum =
6349bf609716ef77a1c0af0ad6cdc312
md5sum =
e142dad44db1a25d46a31661aa2f075f
[template-replicate-publish-slave-information]
[template-replicate-publish-slave-information]
_update_hash_filename_ = templates/replicate-publish-slave-information.cfg.in
_update_hash_filename_ = templates/replicate-publish-slave-information.cfg.in
...
...
software/caddy-frontend/instance-apache-replicate.cfg.in
View file @
409a6823
...
@@ -137,16 +137,17 @@ context =
...
@@ -137,16 +137,17 @@ context =
{% endfor %}
{% endfor %}
{% do slave.__setitem__('server-alias', ' '.join(slave_server_alias_unclashed)) %}
{% do slave.__setitem__('server-alias', ' '.join(slave_server_alias_unclashed)) %}
{% endif %}
{% endif %}
{% if slave.get('url') %}
{% for url_key in ['url', 'https-url'] %}
{% if subprocess_module.call([caddy_backend_url_validator, '' ~ slave['url']]) == 1 or not validators.url('' ~ slave['url']) %}
{% if slave.get(url_key) %}
{% do slave_error_list.append('slave url %r invalid' % (slave['url'],)) %}
{% set url = (slave[url_key] or '').strip() %}
{% if url != slave[url_key] %}
{% do slave_warning_list.append('slave %s %r has been converted to %r' % (url_key, slave[url_key], url)) %}
{% endif %}
{% endif %}
{% endif %}
{% if subprocess_module.call([caddy_backend_url_validator, url]) == 1 or not validators.url(url) %}
{% if slave.get('https-url') %}
{% do slave_error_list.append('slave %s %r invalid' % (url_key, url)) %}
{% if subprocess_module.call([caddy_backend_url_validator, '' ~ slave['https-url']]) == 1 or not validators.url('' ~ slave['https-url']) %}
{% do slave_error_list.append('slave https-url %r invalid' % (slave['https-url'],)) %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% endfor %}
{% if 'ssl_proxy_ca_crt' in slave %}
{% if 'ssl_proxy_ca_crt' in slave %}
{% set ssl_proxy_ca_crt = slave.get('ssl_proxy_ca_crt', '') %}
{% set ssl_proxy_ca_crt = slave.get('ssl_proxy_ca_crt', '') %}
{% set check_popen = popen([parameter_dict['openssl'], 'x509', '-noout']) %}
{% set check_popen = popen([parameter_dict['openssl'], 'x509', '-noout']) %}
...
...
software/caddy-frontend/templates/apache-custom-slave-list.cfg.in
View file @
409a6823
...
@@ -49,7 +49,7 @@ create = true
...
@@ -49,7 +49,7 @@ create = true
{%- for slave_instance in slave_instance_list %}
{%- for slave_instance in slave_instance_list %}
{#- prepare backend parameters #}
{#- prepare backend parameters #}
{%- for key, prefix in [('url', 'http_backend'), ('https-url', 'https_backend')] %}
{%- for key, prefix in [('url', 'http_backend'), ('https-url', 'https_backend')] %}
{%- set parsed = urlparse_module.urlparse(slave_instance.get(key, '')) %}
{%- set parsed = urlparse_module.urlparse(slave_instance.get(key, '')
.strip()
) %}
{%- set info_dict = {'scheme': parsed.scheme, 'hostname': parsed.hostname, 'port': parsed.port or DEFAULT_PORT[parsed.scheme], 'path': parsed.path, 'fragment': parsed.fragment} %}
{%- set info_dict = {'scheme': parsed.scheme, 'hostname': parsed.hostname, 'port': parsed.port or DEFAULT_PORT[parsed.scheme], 'path': parsed.path, 'fragment': parsed.fragment} %}
{%- do slave_instance.__setitem__(prefix, info_dict) %}
{%- do slave_instance.__setitem__(prefix, info_dict) %}
{%- endfor %}
{%- endfor %}
...
...
software/caddy-frontend/test/test.py
View file @
409a6823
...
@@ -1127,7 +1127,9 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
...
@@ -1127,7 +1127,9 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
'empty'
:
{
'empty'
:
{
},
},
'Url'
:
{
'Url'
:
{
'url'
:
cls
.
backend_url
,
# make URL "incorrect", with whitespace, nevertheless it shall be
# correctly handled
'url'
:
' '
+
cls
.
backend_url
+
' '
,
# authenticating to http backend shall be no-op
# authenticating to http backend shall be no-op
'authenticate-to-backend'
:
True
,
'authenticate-to-backend'
:
True
,
},
},
...
@@ -1562,7 +1564,11 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
...
@@ -1562,7 +1564,11 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
'rejected-slave-amount'
:
'0'
,
'rejected-slave-amount'
:
'0'
,
'slave-amount'
:
'56'
,
'slave-amount'
:
'56'
,
'rejected-slave-dict'
:
{
'rejected-slave-dict'
:
{
}
},
'warning-slave-dict'
:
{
'_Url'
:
[
"slave url ' %(backend)s ' has been converted to '%(backend)s'"
%
{
'backend'
:
self
.
backend_url
}]}
}
}
self
.
assertEqual
(
self
.
assertEqual
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment