Skip to content

Commit

Permalink
Fix grpc failure to connect to some servers (#242)
Browse files Browse the repository at this point in the history
* default port 80

* Update clash_lib/src/app/remote_content_manager/mod.rs

Signed-off-by: Yuwei Ba <contact@yba.dev>

* fix grpc not connecting

---------

Signed-off-by: Yuwei Ba <contact@yba.dev>
  • Loading branch information
ibigbug authored Dec 31, 2023
1 parent 3d28efa commit e5364e8
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 4 deletions.
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

0 comments on commit e5364e8

Please sign in to comment.