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

Replace host str to use https if encrypted #193

Merged
merged 2 commits into from
Dec 6, 2019
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
2 changes: 1 addition & 1 deletion examples/volumes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fn main() {
println!("volume -> {:#?}", v)
}
})
.map_err(|e| eprintln!("Error: {}", e));;
.map_err(|e| eprintln!("Error: {}", e));

tokio::run(fut);
}
6 changes: 4 additions & 2 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1662,7 +1662,7 @@ mod tests {
assert_eq!(
r#"{"HostConfig":{"RestartPolicy":{"MaximumRetryCount":10,"Name":"on-failure"}},"Image":"test_image"}"#,
options.serialize().unwrap()
);
);

options = ContainerOptionsBuilder::new("test_image")
.restart_policy("always", 0)
Expand Down Expand Up @@ -1707,7 +1707,9 @@ mod tests {
.server_address("https://example.org")
.build();
assert_eq!(
base64::encode(r#"{"username":"user_abc","password":"password_abc","email":"email_abc","serveraddress":"https://example.org"}"#),
base64::encode(
r#"{"username":"user_abc","password":"password_abc","email":"email_abc","serveraddress":"https://example.org"}"#
),
options.serialize()
);
}
Expand Down
10 changes: 10 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,16 @@ fn get_docker_for_tcp(tcp_host_str: String) -> Docker {
connector.set_ca_file(&Path::new(ca)).unwrap();
}

// If we are attempting to connec to the docker daemon via tcp
// we need to convert the scheme to `https` to let hyper connect.
// Otherwise, hyper will reject the connection since it does not
// recongnize `tcp` as a valid `http` scheme.
let tcp_host_str = if tcp_host_str.contains("tcp://") {
tcp_host_str.replace("tcp://", "https://")
} else {
tcp_host_str
};

Docker {
transport: Transport::EncryptedTcp {
client: Client::builder()
Expand Down