Skip to content
Merged
52 changes: 32 additions & 20 deletions linkup-cli/src/commands/deploy/resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,23 @@ impl TargetCfResources {
}
}

let worker_token = final_metadata
.bindings
.iter()
.find(|b| matches!(b, cloudflare::endpoints::workers::WorkersBinding::PlainText { name, .. } if name == "WORKER_TOKEN"));

if let Some(cloudflare::endpoints::workers::WorkersBinding::PlainText {
text, ..
}) = worker_token
{
println!("@@@@@@@");
println!(
"The worker_token to add to your linkup config is: {:?}",
text
);
println!("@@@@@@@");
}

notifier.notify("Uploading worker script...");
api.create_worker_script(script_name.clone(), final_metadata, parts.clone())
.await?;
Expand Down Expand Up @@ -985,19 +1002,22 @@ impl TargetCfResources {
let dns_records_to_delete: Vec<String> =
dns_records.iter().map(|record| record.id.clone()).collect();

let batch_delete_dns_req = cloudflare::endpoints::dns::BatchDnsRecords {
zone_identifier: &self.tunnel_zone_id,
params: cloudflare::endpoints::dns::BatchDnsRecordsParams {
deletes: Some(dns_records_to_delete),
},
};
for record in dns_records_to_delete {
let delete_req = cloudflare::endpoints::dns::DeleteDnsRecord {
zone_identifier: &self.tunnel_zone_id,
identifier: &record,
};

match cloudflare_client.request(&batch_delete_dns_req).await {
Ok(_) => {
notifier.notify("DNS records deleted");
}
Err(error) => {
notifier.notify(&format!("Failed to delete DNS records: {}", error));
match cloudflare_client.request(&delete_req).await {
Ok(_) => {
notifier.notify(&format!("DNS record '{}' deleted", record));
}
Err(error) => {
notifier.notify(&format!(
"Failed to delete DNS record '{}': {}",
record, error
));
}
}
}
}
Expand Down Expand Up @@ -1104,10 +1124,6 @@ pub fn cf_resources(
name: "CLOUDLFLARE_ALL_ZONE_IDS".to_string(),
text: all_zone_ids.join(","),
},
cloudflare::endpoints::workers::WorkersBinding::DurableObjectNamespace {
name: "CERTIFICATE_LOCKS".to_string(),
class_name: "CertificateStoreLock".to_string(),
},
],
worker_script_schedules: vec![cloudflare::endpoints::workers::WorkersSchedule {
cron: Some("0 12 * * 2-6".to_string()),
Expand All @@ -1122,10 +1138,6 @@ pub fn cf_resources(
name: format!("linkup-tunnels-kv-{joined_zone_names}"),
binding: "LINKUP_TUNNELS".to_string(),
},
KvNamespace {
name: format!("linkup-certificate-cache-kv-{joined_zone_names}"),
binding: "LINKUP_CERTIFICATE_CACHE".to_string(),
},
],
tunnel_zone_cache_rules: TargetCacheRules {
name: "default".to_string(),
Expand Down
7 changes: 0 additions & 7 deletions worker/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ use ws::handle_ws_resp;

mod http_error;
mod kv_store;
mod libdns;
mod routes;
mod tunnel;
mod ws;

Expand All @@ -46,7 +44,6 @@ pub struct LinkupState {
pub min_supported_client_version: Version,
pub sessions_kv: KvStore,
pub tunnels_kv: KvStore,
pub certs_kv: KvStore,
pub cloudflare: CloudflareEnvironemnt,
pub env: Env,
}
Expand All @@ -60,7 +57,6 @@ impl TryFrom<Env> for LinkupState {

let sessions_kv = value.kv("LINKUP_SESSIONS")?;
let tunnels_kv = value.kv("LINKUP_TUNNELS")?;
let certs_kv = value.kv("LINKUP_CERTIFICATE_CACHE")?;
let cf_account_id = value.var("CLOUDFLARE_ACCOUNT_ID")?;
let cf_tunnel_zone_id = value.var("CLOUDFLARE_TUNNEL_ZONE_ID")?;
let cf_all_zone_ids: Vec<String> = value
Expand All @@ -76,7 +72,6 @@ impl TryFrom<Env> for LinkupState {
min_supported_client_version,
sessions_kv,
tunnels_kv,
certs_kv,
cloudflare: CloudflareEnvironemnt {
account_id: cf_account_id.to_string(),
tunnel_zone_id: cf_tunnel_zone_id.to_string(),
Expand All @@ -99,8 +94,6 @@ pub fn linkup_router(state: LinkupState) -> Router {
.route("/linkup/check", get(always_ok))
.route("/linkup/no-tunnel", get(no_tunnel))
.route("/linkup", any(deprecated_linkup_session_handler))
.merge(routes::certificate_dns::router())
.merge(routes::certificate_cache::router())
.route_layer(from_fn_with_state(state.clone(), authenticate))
// Fallback for all other requests
.fallback(any(linkup_request_handler))
Expand Down
125 changes: 0 additions & 125 deletions worker/src/libdns.rs

This file was deleted.

Loading
Loading