Skip to content

Commit 72562b7

Browse files
authored
Cloudflare changes (#66)
1 parent b4da7dd commit 72562b7

28 files changed

Lines changed: 510 additions & 716 deletions

.env.development

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
PUBLIC_RELAY_URL="http://localhost:4443"
22
PUBLIC_RELAY_TOKEN=""
3+
PUBLIC_CLOUDFLARE_URL="https://relay.cloudflare.mediaoverquic.com"

.env.production

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
PUBLIC_RELAY_URL="https://relay.moq.dev"
22
# Generate with: cargo run --bin moq-token -- --key root.jwk sign --root "demo" --subscribe ""
33
PUBLIC_RELAY_TOKEN="eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyb290IjoiZGVtbyIsImdldCI6WyIiXSwiZXhwIjpudWxsLCJpYXQiOm51bGx9.6EoN-Y1Ouj35_qV5FokcdcdderrE2navNbYQjJyR2Ac"
4+
PUBLIC_CLOUDFLARE_URL="https://relay.cloudflare.mediaoverquic.com"

astro.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,8 @@ export default defineConfig({
3636
"@": "/src",
3737
},
3838
},
39+
optimizeDeps: {
40+
exclude: ["@kixelated/hang"],
41+
},
3942
},
4043
});

env.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
interface ImportMetaEnv {
44
readonly PUBLIC_RELAY_URL: string;
55
readonly PUBLIC_RELAY_TOKEN: string;
6+
readonly PUBLIC_CLOUDFLARE_URL: string;
67
}
78

89
interface ImportMeta {

infra/input.tf

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,12 @@ variable "domain" {
2525

2626
variable "docker_relay" {
2727
description = "Docker image for moq-relay"
28-
default = "docker.io/kixelated/moq-relay:0.8.8"
28+
default = "docker.io/kixelated/moq-relay:0.9.2"
2929
}
3030

3131
variable "docker_hang" {
3232
description = "Docker image for hang"
33-
default = "docker.io/kixelated/hang:0.2.5"
34-
}
35-
36-
variable "cloudflare_dns_token" {
37-
description = "Cloudflare DNS API token - edit permissions for moq.dev"
38-
sensitive = true
39-
}
40-
41-
variable "cloudflare_zone_token" {
42-
description = "Cloudflare Zone API token - read permissions for all zones"
43-
sensitive = true
33+
default = "docker.io/kixelated/hang:0.2.9"
4434
}
4535

4636
# Too complicated to specify via flags, so do it here.

infra/relay-lb.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,13 @@ resource "google_compute_backend_service" "relay_lb" {
7070
google_compute_http_health_check.relay.self_link
7171
]
7272
}
73+
74+
75+
# We must use a legacy health check for the UDP load balancer
76+
resource "google_compute_http_health_check" "relay" {
77+
name = "relay"
78+
request_path = "/health"
79+
check_interval_sec = 5
80+
timeout_sec = 5
81+
}
7382
*/

infra/relay.tf

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ resource "google_dns_record_set" "relay" {
8989
rrdatas = [google_compute_address.relay[each.key].address]
9090
}
9191

92-
# Allow UDP 443
92+
# Allow port 443
9393
resource "google_compute_firewall" "relay" {
9494
name = "relay"
9595
network = "default"
@@ -99,18 +99,15 @@ resource "google_compute_firewall" "relay" {
9999
ports = ["443"]
100100
}
101101

102+
allow {
103+
protocol = "tcp"
104+
ports = ["443"]
105+
}
106+
102107
source_ranges = ["0.0.0.0/0"]
103108
target_tags = ["relay"]
104109
}
105110

106-
# We must use a legacy health check for the UDP load balancer
107-
resource "google_compute_http_health_check" "relay" {
108-
name = "relay"
109-
request_path = "/health"
110-
check_interval_sec = 5
111-
timeout_sec = 5
112-
}
113-
114111
# Create an internal TLS certificate for the relay
115112
resource "tls_private_key" "relay_internal" {
116113
for_each = local.relays

infra/relay.yml.tpl

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,17 @@ write_files:
5656
[server]
5757
listen = "0.0.0.0:443"
5858

59-
[[server.tls.cert]]
60-
chain = "/etc/cert/${cluster_node}.crt"
61-
key = "/etc/cert/${cluster_node}.key"
62-
63-
[[server.tls.cert]]
64-
chain = "/etc/cert/${public_host}.crt"
65-
key = "/etc/cert/${public_host}.key"
59+
tls.cert = [ "/etc/cert/${cluster_node}.crt", "/etc/cert/${public_host}.crt" ]
60+
tls.key = [ "/etc/cert/${cluster_node}.key", "/etc/cert/${public_host}.key" ]
6661

6762
[client]
6863
tls.root = [ "/etc/cert/internal.ca" ]
6964

65+
[web.https]
66+
listen = "0.0.0.0:443"
67+
cert = "/etc/cert/${public_host}.crt"
68+
key = "/etc/cert/${public_host}.key"
69+
7070
[cluster]
7171
connect = "${cluster_root}"
7272
advertise = "${cluster_node}"
@@ -115,6 +115,7 @@ write_files:
115115
Type=oneshot
116116
RemainAfterExit=true
117117
ExecStart=iptables -A INPUT -p udp --dport 443 -j ACCEPT
118+
ExecStart=iptables -A INPUT -p tcp --dport 443 -j ACCEPT
118119

119120
# There's a mismatch between the GCP network MTU and the docker MTU
120121
- path: /etc/docker/daemon.json

justfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,14 @@ build:
5454
pnpm astro build
5555

5656
# Deploy the site to Cloudflare Pages
57-
deploy: build
58-
pnpm wrangler deploy
57+
deploy env="staging": build
58+
pnpm wrangler deploy --env {{env}}
5959

6060
dev:
6161
pnpm i
6262

6363
# Run the web development server
6464
pnpm astro dev --open
65+
66+
preview: build
67+
pnpm astro preview --open

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"fix": "biome check --write && pnpm audit fix"
1414
},
1515
"dependencies": {
16-
"@kixelated/hang": "^0.3.9",
16+
"@kixelated/hang": "link:../moq/js/hang",
1717
"astro": "^5.8.2",
1818
"solid-js": "^1.9.7",
1919
"unique-names-generator": "^4.7.1"

0 commit comments

Comments
 (0)