Skip to content
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
29 changes: 27 additions & 2 deletions ngrok/src/config/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ impl TunnelConfig for HttpOptions {
fn opts(&self) -> Option<BindOpts> {
let http_endpoint = HttpEndpoint {
proxy_proto: self.common_opts.proxy_proto,
hostname: self.domain.clone().unwrap_or_default(),
domain: self.domain.clone().unwrap_or_default(),
hostname: String::new(),
compression: self.compression.then_some(Compression {}),
circuit_breaker: (self.circuit_breaker != 0f64).then_some(CircuitBreaker {
error_threshold: self.circuit_breaker,
Expand Down Expand Up @@ -597,7 +598,7 @@ mod test {
let opts = tunnel_cfg.opts().unwrap();
assert!(matches!(opts, BindOpts::Http { .. }));
if let BindOpts::Http(endpoint) = opts {
assert_eq!(DOMAIN, endpoint.hostname);
assert_eq!(DOMAIN, endpoint.domain);
assert_eq!(String::default(), endpoint.subdomain);
assert!(matches!(endpoint.proxy_proto, ProxyProto::V2));

Expand Down Expand Up @@ -715,4 +716,28 @@ mod test {
builder.binding("public");
builder.binding("internal");
}

#[test]
fn test_binding_with_domain() {
let mut builder = HttpTunnelBuilder {
session: None,
options: Default::default(),
};
builder.binding("internal").domain("foo.internal");

// Check that both binding and domain are set
assert_eq!(vec!["internal"], builder.options.bindings);
assert_eq!(Some("foo.internal".to_string()), builder.options.domain);

// Check that they're properly included in extra() and opts()
let extra = builder.options.extra();
assert_eq!(vec!["internal"], extra.bindings);

let opts = builder.options.opts().unwrap();
if let BindOpts::Http(endpoint) = opts {
assert_eq!("foo.internal", endpoint.domain);
} else {
panic!("Expected Http endpoint");
}
}
}
5 changes: 2 additions & 3 deletions ngrok/src/config/tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ impl TunnelConfig for TlsOptions {
let mut tls_endpoint = proto::TlsEndpoint::default();

if let Some(domain) = self.domain.as_ref() {
// note: hostname and subdomain are going away in favor of just domain
tls_endpoint.hostname = domain.clone();
tls_endpoint.domain = domain.clone();
}
tls_endpoint.proxy_proto = self.common_opts.proxy_proto;

Expand Down Expand Up @@ -318,7 +317,7 @@ mod test {
let opts = tunnel_cfg.opts().unwrap();
assert!(matches!(opts, BindOpts::Tls { .. }));
if let BindOpts::Tls(endpoint) = opts {
assert_eq!(DOMAIN, endpoint.hostname);
assert_eq!(DOMAIN, endpoint.domain);
assert_eq!(String::default(), endpoint.subdomain);
assert!(matches!(endpoint.proxy_proto, ProxyProto::V2));
assert!(!endpoint.mutual_tls_at_agent);
Expand Down
4 changes: 4 additions & 0 deletions ngrok/src/internals/proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
pub const STOP_REQ: StreamType = StreamType::clamp(5);
pub const UPDATE_REQ: StreamType = StreamType::clamp(6);
pub const BIND_LABELED_REQ: StreamType = StreamType::clamp(7);
pub const SRV_INFO_REQ: StreamType = StreamType::clamp(8);

Check warning on line 40 in ngrok/src/internals/proto.rs

View workflow job for this annotation

GitHub Actions / Test Windows Stable

constant `SRV_INFO_REQ` is never used

Check warning on line 40 in ngrok/src/internals/proto.rs

View workflow job for this annotation

GitHub Actions / Test Stable

constant `SRV_INFO_REQ` is never used
pub const STOP_TUNNEL_REQ: StreamType = StreamType::clamp(9);

pub const VERSION: &[&str] = &["3", "2"]; // integers in priority order
Expand Down Expand Up @@ -550,11 +550,11 @@

#[derive(Serialize, Deserialize, Debug, Clone, Copy, Default)]
#[serde(rename_all = "PascalCase")]
pub struct SrvInfo {}

Check warning on line 553 in ngrok/src/internals/proto.rs

View workflow job for this annotation

GitHub Actions / Test Windows Stable

struct `SrvInfo` is never constructed

Check warning on line 553 in ngrok/src/internals/proto.rs

View workflow job for this annotation

GitHub Actions / Test Stable

struct `SrvInfo` is never constructed

#[derive(Serialize, Deserialize, Debug, Clone, Default)]
#[serde(rename_all = "PascalCase")]
pub struct SrvInfoResp {

Check warning on line 557 in ngrok/src/internals/proto.rs

View workflow job for this annotation

GitHub Actions / Test Windows Stable

struct `SrvInfoResp` is never constructed

Check warning on line 557 in ngrok/src/internals/proto.rs

View workflow job for this annotation

GitHub Actions / Test Stable

struct `SrvInfoResp` is never constructed
pub region: String,
}

Expand Down Expand Up @@ -672,6 +672,8 @@
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
#[serde(rename_all = "PascalCase")]
pub struct HttpEndpoint {
#[serde(default)]
pub domain: String,
pub hostname: String,
pub auth: String,
pub subdomain: String,
Expand Down Expand Up @@ -833,6 +835,8 @@
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
#[serde(rename_all = "PascalCase")]
pub struct TlsEndpoint {
#[serde(default)]
pub domain: String,
pub hostname: String,
pub subdomain: String,
pub proxy_proto: ProxyProto,
Expand Down Expand Up @@ -861,7 +865,7 @@

#[derive(Serialize, Deserialize, Debug, Clone, Default)]
#[serde(rename_all = "PascalCase")]
pub struct LabelEndpoint {

Check warning on line 868 in ngrok/src/internals/proto.rs

View workflow job for this annotation

GitHub Actions / Test Windows Stable

struct `LabelEndpoint` is never constructed

Check warning on line 868 in ngrok/src/internals/proto.rs

View workflow job for this annotation

GitHub Actions / Test Stable

struct `LabelEndpoint` is never constructed
pub labels: HashMap<String, String>,
}

Expand Down
Loading