pub struct Config {Show 21 fields
pub version: u32,
pub opencode_web_port: u16,
pub bind: String,
pub auto_restart: bool,
pub boot_mode: String,
pub restart_retries: u32,
pub restart_delay: u32,
pub auth_username: Option<String>,
pub auth_password: Option<String>,
pub container_env: Vec<String>,
pub bind_address: String,
pub trust_proxy: bool,
pub allow_unauthenticated_network: bool,
pub rate_limit_attempts: u32,
pub rate_limit_window_seconds: u32,
pub users: Vec<String>,
pub cockpit_port: u16,
pub cockpit_enabled: bool,
pub image_source: String,
pub update_check: String,
pub mounts: Vec<String>,
}Expand description
Main configuration structure for opencode-cloud
Serialized to/from ~/.config/opencode-cloud/config.json
Fields§
§version: u32Config file version for migrations
opencode_web_port: u16Port for the opencode web UI (default: 3000)
bind: StringBind address (default: “localhost”) Use “localhost” for local-only access (secure default) Use “0.0.0.0” for network access (requires explicit opt-in)
auto_restart: boolAuto-restart service on crash (default: true)
boot_mode: StringBoot mode for service registration (default: “user”) “user” - Service starts on user login (no root required) “system” - Service starts on boot (requires root)
restart_retries: u32Number of restart attempts on crash (default: 3)
restart_delay: u32Seconds between restart attempts (default: 5)
auth_username: Option<String>Username for opencode basic auth (default: None, triggers wizard)
auth_password: Option<String>Password for opencode basic auth (default: None, triggers wizard)
container_env: Vec<String>Environment variables passed to container (default: empty) Format: [“KEY=value”, “KEY2=value2”]
bind_address: StringBind address for opencode web UI (default: “127.0.0.1”) Use “0.0.0.0” or “::” for network exposure (requires explicit opt-in)
trust_proxy: boolTrust proxy headers (X-Forwarded-For, etc.) for load balancer deployments
allow_unauthenticated_network: boolAllow unauthenticated access when network exposed Requires double confirmation on first start
rate_limit_attempts: u32Maximum auth attempts before rate limiting
rate_limit_window_seconds: u32Rate limit window in seconds
users: Vec<String>List of usernames configured in container (for persistence tracking) Passwords are NOT stored here - only in container’s /etc/shadow
cockpit_port: u16Cockpit web console port (default: 9090) Only used when cockpit_enabled is true
cockpit_enabled: boolEnable Cockpit web console (default: false)
When enabled:
- Container uses systemd as init (required for Cockpit)
- Requires Linux host with native Docker (does NOT work on macOS Docker Desktop)
- Cockpit web UI accessible at cockpit_port
When disabled (default):
- Container uses tini as init (lightweight, works everywhere)
- Works on macOS, Linux, and Windows
- No Cockpit web UI
image_source: StringSource of Docker image: ‘prebuilt’ (pull from registry) or ‘build’ (compile locally)
update_check: StringWhen to check for updates: ‘always’ (every start), ‘once’ (once per version), ‘never’
mounts: Vec<String>Bind mounts to apply when starting the container Format: [“/host/path:/container/path”, “/host:/mnt:ro”]
Implementations§
Source§impl Config
impl Config
Sourcepub fn has_required_auth(&self) -> bool
pub fn has_required_auth(&self) -> bool
Check if required auth credentials are configured
Returns true if:
- Both auth_username and auth_password are Some and non-empty (legacy), OR
- The users array is non-empty (PAM-based auth)
This is used to determine if the setup wizard needs to run.
Sourcepub fn is_network_exposed(&self) -> bool
pub fn is_network_exposed(&self) -> bool
Check if the bind address exposes the service to the network
Returns true if bind_address is “0.0.0.0” (IPv4 all interfaces) or “::” (IPv6 all interfaces).
Sourcepub fn is_localhost(&self) -> bool
pub fn is_localhost(&self) -> bool
Check if the bind address is localhost-only
Returns true if bind_address is “127.0.0.1”, “::1”, or “localhost”.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Config
impl<'de> Deserialize<'de> for Config
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl StructuralPartialEq for Config
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnwindSafe for Config
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request