Skip to main content

Config

Struct Config 

Source
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: u32

Config file version for migrations

§opencode_web_port: u16

Port for the opencode web UI (default: 3000)

§bind: String

Bind 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: bool

Auto-restart service on crash (default: true)

§boot_mode: String

Boot mode for service registration (default: “user”) “user” - Service starts on user login (no root required) “system” - Service starts on boot (requires root)

§restart_retries: u32

Number of restart attempts on crash (default: 3)

§restart_delay: u32

Seconds between restart attempts (default: 5)

§auth_username: Option<String>

Username for opencode basic auth (DEPRECATED - use PAM users via occ user add instead)

This field is kept for backward compatibility but is ignored. New deployments should create users via occ user add which uses PAM authentication. Legacy deployments can migrate by running occ user add <username>.

§auth_password: Option<String>

Password for opencode basic auth (DEPRECATED - use PAM users via occ user add instead)

This field is kept for backward compatibility but is ignored. Passwords are stored in the container’s /etc/shadow via PAM, not in config files.

§container_env: Vec<String>

Environment variables passed to container (default: empty) Format: [“KEY=value”, “KEY2=value2”]

§bind_address: String

Bind 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: bool

Trust proxy headers (X-Forwarded-For, etc.) for load balancer deployments

§allow_unauthenticated_network: bool

Allow unauthenticated access when network exposed Requires double confirmation on first start

§rate_limit_attempts: u32

Maximum auth attempts before rate limiting

§rate_limit_window_seconds: u32

Rate 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: u16

Cockpit web console port (default: 9090) Only used when cockpit_enabled is true

§cockpit_enabled: bool

Enable 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: String

Source of Docker image: ‘prebuilt’ (pull from registry) or ‘build’ (compile locally)

§update_check: String

When 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

Source

pub fn new() -> Self

Create a new Config with default values

Source

pub fn has_required_auth(&self) -> bool

Check if required auth credentials are configured

Returns true if:

  • The users array is non-empty (PAM-based auth - preferred), OR
  • Both auth_username and auth_password are Some and non-empty (legacy - deprecated)

Note: Legacy auth_username/auth_password fields are deprecated and ignored in favor of PAM users. This method still checks them for backward compatibility, but new deployments should use occ user add.

This is used to determine if the setup wizard needs to run.

Source

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).

Source

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 Clone for Config

Source§

fn clone(&self) -> Config

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Config

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Config

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Config

Source§

fn eq(&self, other: &Config) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Config

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,