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

Fix grpc failure to connect to some servers #242

Merged
merged 3 commits into from
Dec 31, 2023
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
1 change: 1 addition & 0 deletions clash_lib/src/proxy/converters/trojan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ impl TryFrom<&OutboundTrojan> for AnyOutboundHandler {
.as_ref()
.map(|x| {
Transport::Grpc(GrpcOption {
host: s.sni.as_ref().unwrap_or(&s.server).to_owned(),
service_name: x
.grpc_service_name
.as_ref()
Expand Down
1 change: 1 addition & 0 deletions clash_lib/src/proxy/converters/vmess.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ impl TryFrom<&OutboundVmess> for AnyOutboundHandler {
.as_ref()
.map(|x| {
VmessTransport::Grpc(GrpcOption {
host: s.server_name.as_ref().unwrap_or(&s.server).to_owned(),
service_name: x
.grpc_service_name
.as_ref()
Expand Down
2 changes: 1 addition & 1 deletion clash_lib/src/proxy/fallback/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl Handler {
let proxies = self.get_proxies(touch).await;
for proxy in proxies.iter() {
if self.proxy_manager.alive(proxy.name()).await {
debug!("{} fastest {} is alive", self.name(), proxy.name());
debug!("`{}` fallback to `{}`", self.name(), proxy.name());
return proxy.clone();
}
}
Expand Down
1 change: 1 addition & 0 deletions clash_lib/src/proxy/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub struct Http2Option {
}

pub struct GrpcOption {
pub host: String,
pub service_name: String,
}

Expand Down
2 changes: 1 addition & 1 deletion clash_lib/src/proxy/selector/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl Handler {
let proxies = get_proxies_from_providers(&self.providers, touch).await;
for proxy in proxies {
if proxy.name() == self.inner.read().await.current {
debug!("{} selected {}", self.name(), proxy.name());
debug!("`{}` selected `{}`", self.name(), proxy.name());
return proxy;
}
}
Expand Down
2 changes: 1 addition & 1 deletion clash_lib/src/proxy/trojan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl Handler {
}
Transport::Grpc(grpc_opts) => {
let grpc_builder = transport::GrpcStreamBuilder::new(
self.opts.server.clone(),
grpc_opts.host.clone(),
grpc_opts
.service_name
.to_owned()
Expand Down
2 changes: 1 addition & 1 deletion clash_lib/src/proxy/vmess/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl Handler {
};

let grpc_builder = transport::GrpcStreamBuilder::new(
self.opts.server.clone(),
opt.host.clone(),
opt.service_name
.to_owned()
.try_into()
Expand Down
Loading