Skip to content

Commit

Permalink
remove nightly api usage
Browse files Browse the repository at this point in the history
  • Loading branch information
aschey committed Feb 13, 2025
1 parent 4866a0d commit 4782144
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 0 additions & 1 deletion .tokeignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
*_mock.go
*.pb.go
old
1 change: 0 additions & 1 deletion platuned/server/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![feature(ip)]
mod cert_gen;
mod ipc_stream;
mod rpc;
Expand Down
11 changes: 10 additions & 1 deletion platuned/server/src/services/management.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ async fn get_connection_type<T>(
})
.collect();

if remote_addr.is_global() {
if !is_local(remote_addr) {
if let Ok(mut global_addr) = env::var("PLATUNE_GLOBAL_FILE_URL") {
if !global_addr.ends_with('/') {
global_addr.push('/');
Expand Down Expand Up @@ -146,6 +146,15 @@ async fn get_connection_type<T>(
}
}

fn is_local(ip_addr: IpAddr) -> bool {
ip_addr.is_loopback()
|| ip_addr.is_unspecified()
|| match ip_addr {
IpAddr::V4(v4) => v4.is_link_local() || v4.is_private(),
IpAddr::V6(v6) => v6.is_unicast_link_local() || v6.is_unique_local(),
}
}

#[tonic::async_trait]
impl Management for ManagementImpl {
async fn start_sync(&self, _: Request<()>) -> Result<Response<()>, Status> {
Expand Down

0 comments on commit 4782144

Please sign in to comment.