-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Alexander V. Nikolaev <[email protected]>
- Loading branch information
Showing
6 changed files
with
51 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
pub mod auth; | ||
pub mod naming; | ||
pub mod tonic; | ||
pub mod vsock; | ||
pub mod x509; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use anyhow::bail; | ||
use tokio_vsock::{VsockAddr, VMADDR_CID_HOST, VMADDR_CID_LOCAL}; | ||
|
||
pub fn parse_vsock_addr(addr: &str) -> anyhow::Result<VsockAddr> { | ||
if let Some((cid, port)) = addr.split_once(":") { | ||
let cid = match cid { | ||
"local" => VMADDR_CID_LOCAL, | ||
"host" => VMADDR_CID_HOST, | ||
cid => cid.parse()?, | ||
}; | ||
return Ok(VsockAddr::new(cid, port.parse()?)); | ||
}; | ||
bail!("Address {addr} should be in CID:PORT format") | ||
} |