Skip to content

Commit 3c96fcf

Browse files
committed
Add CloudExitNode implementation and
Into<ExitNode> conversion
1 parent 05a64b2 commit 3c96fcf

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/cloud/mod.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
use async_trait::async_trait;
22
use digitalocean_rs::DigitalOceanApi;
33
use digitalocean_rs::DigitalOceanError;
4+
use kube::core::ObjectMeta;
45
use names::Generator;
56
use schemars::JsonSchema;
67
use serde::{Deserialize, Serialize};
78
use std::env;
89

10+
use crate::ops::ExitNode;
11+
912
/// Simple wrapper for names crate
1013
pub fn generate_name() -> String {
1114
let mut generator = Generator::default();
@@ -30,6 +33,27 @@ pub struct CloudExitNode {
3033
pub ip: String,
3134
}
3235

36+
const CHISEL_PORT: u16 = 9090;
37+
38+
impl Into<ExitNode> for CloudExitNode {
39+
fn into(self) -> ExitNode {
40+
ExitNode {
41+
spec: crate::ops::ExitNodeSpec {
42+
host: self.ip.clone(),
43+
external_host: Some(self.ip.clone()),
44+
port: CHISEL_PORT,
45+
fingerprint: None,
46+
auth: Some(self.password),
47+
default_route: false,
48+
},
49+
metadata: ObjectMeta {
50+
name: Some(self.name),
51+
..ObjectMeta::default()
52+
},
53+
}
54+
}
55+
}
56+
3357
#[async_trait]
3458
pub trait Provisioner {
3559
async fn create_exit_node(&self) -> color_eyre::Result<CloudExitNode>;

0 commit comments

Comments
 (0)