Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Possibility to avoid an extra DNS lookup? #943

Closed
@trungda

Description

@trungda

Hi, thanks for the crate! We are using this crate heavily in prod. Nice work! I have a question regarding establishing TLS connection to a Postgres database. We are using the following code snippet to create a new connection to the db server.

let builder = ...;let tls = postgres_openssl::MakeTlsConnector::new(builder.build());let (client, connection) = config.connect(tls).await?;

We provide thehost andport parameters in the config object. Thehost here could be either a raw ipaddress or the hostname of the db server. In order to use TLS, we have to provide the hostname (since it's what the server cert includes). However, our use case is a bit special, we have the hostname but we also have the ipaddress of the db server upfront.

I am wondering if we could use the ipaddress + hostname to create a TLS connection somehow without passing the hostname toconfig.connect() since I believe under the hood,tls.make_tls_connect` would make a DNS request to resolve the hostname but we already have the hostname resolved before trying to create the connection.

One possibility I can think of is to extend theConfig struct to have an optionalhostname field just so we don't have tobuild hostname fromhost(if provided). If we can do that, we can still pass the "already known" ipaddress tohost and pass the hostname to the new hostname field. What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp