public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: Re: [pbs-devel] [PATCH proxmox-backup] client/http_client: add necessary brackets
Date: Tue, 4 May 2021 12:54:22 +0200	[thread overview]
Message-ID: <bca49abe-506c-5274-39e1-259045042e28@proxmox.com> (raw)
In-Reply-To: <20210409081456.31189-1-d.csapak@proxmox.com>

ping

On 4/9/21 10:14, Dominik Csapak wrote:
> if we are given a 'naked' ipv6 without square brackets around it,
> we need to add them ourselves, since the address is ambigious otherwise
> when we add the port.
> 
> e.g. giving 'fe80::1' as address we arrive at the url (with the default port)
> 'https://fe80::1:8007/'
> 
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
> we could also only add it to the actual request if wanted, should not
> make much of a difference though
> 
>   src/client/http_client.rs | 16 ++++++++++++++--
>   1 file changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/src/client/http_client.rs b/src/client/http_client.rs
> index 76ab0391..07e8cd83 100644
> --- a/src/client/http_client.rs
> +++ b/src/client/http_client.rs
> @@ -273,6 +273,16 @@ fn load_ticket_info(prefix: &str, server: &str, userid: &Userid) -> Option<(Stri
>       }
>   }
>   
> +fn map_ipv6(server: &str) -> String {
> +    let bytes = server.as_bytes();
> +    let len = bytes.len();
> +    if len > 3 && bytes.contains(&b':') && bytes[0] != b'[' && bytes[len-1] != b']' {
> +        format!("[{}]", server)
> +    } else {
> +        server.to_string()
> +    }
> +}
> +
>   impl HttpClient {
>       pub fn new(
>           server: &str,
> @@ -285,11 +295,13 @@ impl HttpClient {
>   
>           let mut fingerprint = options.fingerprint.take();
>   
> +        let server = map_ipv6(server);
> +
>           if fingerprint.is_some() {
>               // do not store fingerprints passed via options in cache
>               options.fingerprint_cache = false;
>           } else if options.fingerprint_cache && options.prefix.is_some() {
> -            fingerprint = load_fingerprint(options.prefix.as_ref().unwrap(), server);
> +            fingerprint = load_fingerprint(options.prefix.as_ref().unwrap(), &server);
>           }
>   
>           let mut ssl_connector_builder = SslConnector::builder(SslMethod::tls()).unwrap();
> @@ -344,7 +356,7 @@ impl HttpClient {
>               };
>               let mut ticket_info = None;
>               if use_ticket_cache {
> -                ticket_info = load_ticket_info(options.prefix.as_ref().unwrap(), server, userid);
> +                ticket_info = load_ticket_info(options.prefix.as_ref().unwrap(), &server, userid);
>               }
>               if let Some((ticket, _token)) = ticket_info {
>                   ticket
> 




  reply	other threads:[~2021-05-04 10:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-09  8:14 Dominik Csapak
2021-05-04 10:54 ` Dominik Csapak [this message]
2021-05-04 11:17 ` Wolfgang Bumiller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bca49abe-506c-5274-39e1-259045042e28@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal