@@ -12,6 +12,31 @@ package gateway;
1212message RegisterCvmRequest {
1313 // The public key of the WireGuard interface of the CVM.
1414 string client_public_key = 1 ;
15+ // Per-port policy the gateway should apply when proxying to this CVM.
16+ // Wrapped in a message so we can distinguish "not reported" (old CVM →
17+ // gateway falls back to fetching app-compose via Info()) from "reported
18+ // empty" (new CVM with no special port behaviour).
19+ optional PortPolicy port_policy = 2 ;
20+ }
21+
22+ // PortPolicy carries the gateway-relevant per-port configuration declared by
23+ // the app in its compose file. Keeping `ports` and `restrict_mode` together
24+ // lets a single Option distinguish "not reported" from "reported".
25+ message PortPolicy {
26+ // Per-port attributes (PROXY protocol opt-in, etc.).
27+ repeated PortAttrs ports = 1 ;
28+ // When true, the gateway only forwards traffic to ports listed in `ports`
29+ // and rejects connections to any other port at TCP-accept time.
30+ bool restrict_mode = 2 ;
31+ }
32+
33+ // PortAttrs declares per-port behaviour for the gateway.
34+ message PortAttrs {
35+ // The CVM port these attributes apply to.
36+ uint32 port = 1 ;
37+ // Whether the gateway should send a PROXY protocol header on outbound
38+ // connections to this port.
39+ bool pp = 2 ;
1540}
1641
1742// DebugRegisterCvmRequest is the request for DebugRegisterCvm (only works when debug_mode is enabled).
@@ -414,6 +439,18 @@ service Admin {
414439 rpc GetCertbotConfig (google.protobuf.Empty ) returns (CertbotConfigResponse ) {}
415440 // Set global certbot configuration (includes ACME URL)
416441 rpc SetCertbotConfig (SetCertbotConfigRequest ) returns (google.protobuf.Empty ) {}
442+
443+ // ==================== Per-Instance Port Policy Override ====================
444+ // Set an admin override for an instance's port policy. Takes precedence
445+ // over the policy reported by the instance itself, and survives app
446+ // upgrades. Errors if the instance is not registered.
447+ rpc SetInstancePortPolicy (SetInstancePortPolicyRequest ) returns (google.protobuf.Empty ) {}
448+ // Clear the admin override for an instance, reverting to the
449+ // instance-reported policy. Errors if the instance is not registered.
450+ rpc ClearInstancePortPolicy (ClearInstancePortPolicyRequest ) returns (google.protobuf.Empty ) {}
451+ // Inspect both the admin override and the instance-reported policy for an
452+ // instance, plus the effective policy the proxy will enforce.
453+ rpc GetInstancePortPolicy (GetInstancePortPolicyRequest ) returns (GetInstancePortPolicyResponse ) {}
417454}
418455
419456// ==================== DNS Credential Messages ====================
@@ -623,3 +660,36 @@ message SetCertbotConfigRequest {
623660 // ACME server URL (empty means use default Let's Encrypt production)
624661 optional string acme_url = 4 ;
625662}
663+
664+ // ==================== Per-Instance Port Policy Override Messages ====================
665+
666+ // Set an admin override for an instance.
667+ message SetInstancePortPolicyRequest {
668+ // The instance to override.
669+ string instance_id = 1 ;
670+ // The policy to apply. An empty `ports` list with `restrict_mode = true`
671+ // is a valid "deny everything" lockdown.
672+ PortPolicy policy = 2 ;
673+ }
674+
675+ // Clear the admin override for an instance.
676+ message ClearInstancePortPolicyRequest {
677+ string instance_id = 1 ;
678+ }
679+
680+ // Inspect an instance's port-policy state.
681+ message GetInstancePortPolicyRequest {
682+ string instance_id = 1 ;
683+ }
684+
685+ message GetInstancePortPolicyResponse {
686+ // The policy the proxy will actually enforce. Absent when neither admin
687+ // nor instance has set anything (fail-close until populated).
688+ optional PortPolicy effective = 1 ;
689+ // Where `effective` came from: "admin", "instance", or "none".
690+ string source = 2 ;
691+ // The policy reported by the instance itself, if any.
692+ optional PortPolicy instance_reported = 3 ;
693+ // The admin override, if any.
694+ optional PortPolicy admin_override = 4 ;
695+ }
0 commit comments