Help us shape the future of Go! Take the 2026 Go Developer Survey

rustplus

module
v0.0.0-...-1fae330 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 3, 2026 License: MIT

README

rustplus

Go Reference Go Report Card

Idiomatic, unofficial Go library for interacting with Smart Switches, Smart Alarms, Storage Monitors, Team Chat, Maps, and CCTV / PTZ / Auto Turret cameras in the PC game Rust.

It connects directly to the Rust Game Server companion WebSocket (configured via app.port in server.cfg) or via the Facepunch proxy.

[!NOTE] This project is not affiliated with, endorsed by, or sponsored by Facepunch Studios. Rust™ is a trademark of Facepunch Studios Ltd. All game assets, names, and related marks are the property of their respective owners.

Installation

go get github.com/servusdei2018/rustplus

Features

  • Context-first: First-class context.Context support across all operations.
  • CCTV & PTZ Camera Ray Reconstruction: Decode server raycasts into standard library image.Image frames (pkg/camera).
  • Concurrency-Safe: Safe for concurrent requests across goroutines.
  • Server Push Notifications: Channel-based event subscriptions for team chat, entity updates, clan chat, and camera rays.

Quick Start

1. Connecting and Querying Server Info
package main

import (
	"context"
	"fmt"
	"log"
	"time"

	"github.com/servusdei2018/rustplus/pkg/rustplus"
)

func main() {
	client := rustplus.New(rustplus.Options{
		Server:      "127.0.0.1",
		Port:        28082,
		PlayerID:    76561198000000000,
		PlayerToken: 123456789,
	})

	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
	defer cancel()

	if err := client.Connect(ctx); err != nil {
		log.Fatalf("connect failed: %v", err)
	}
	defer client.Disconnect(context.Background())

	info, err := client.GetInfo(ctx)
	if err != nil {
		log.Fatalf("get info failed: %v", err)
	}

	fmt.Printf("Connected to %s (%d/%d players online)\n",
		info.GetName(), info.GetPlayers(), info.GetMaxPlayers())
}
2. Toggling a Smart Switch
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()

entityID := uint32(1234567)

// Turn switch ON
if err := client.TurnSmartSwitchOn(ctx, entityID); err != nil {
	log.Fatalf("failed to turn on switch: %v", err)
}

// Turn switch OFF
if err := client.TurnSmartSwitchOff(ctx, entityID); err != nil {
	log.Fatalf("failed to turn off switch: %v", err)
}
3. Listening for Entity State Changes (e.g. Storage Monitor)
events, cancel := client.Subscribe()
defer cancel()

// First query entity info to start receiving broadcasts from the server
_, _ = client.GetEntityInfo(ctx, entityID)

for event := range events {
	switch e := event.(type) {
	case rustplus.EntityChangedEvent:
		fmt.Printf("Entity %d changed value to %v\n",
			e.EntityID(), e.Payload().GetValue())
	}
}
4. Subscribing to a CCTV Camera and Rendering Frames
cam := client.GetCamera("OILRIG1")

ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()

if err := cam.Subscribe(ctx); err != nil {
	log.Fatalf("camera subscribe failed: %v", err)
}
defer cam.Unsubscribe(context.Background())

// Read rendered image.Image frames from the channel
for frame := range cam.Frames() {
	// frame is a standard library image.Image (*image.RGBA)
	bounds := frame.Bounds()
	fmt.Printf("Rendered camera frame: %dx%d\n", bounds.Dx(), bounds.Dy())
}

CLI Tool

A standalone CLI binary is provided under cmd/rustplus.

Install CLI
go install github.com/servusdei2018/rustplus/cmd/rustplus@latest
CLI Commands
# 1. Automatic Pairing & FCM Push Notification Listener
rustplus pair register            # Registers virtual FCM device & links Steam account
rustplus pair listen --auto-save  # Listens for in-game 'Pair' notifications & auto-saves profile

# Or manually import from pairing JSON payload
rustplus pair import pairing.json

# 2. Manage connection profiles
rustplus config add main --server 127.0.0.1 --port 28082 --player-id 76561198000000000 --token 123456
rustplus config list

# 3. Query server information
rustplus info       # Query active server info
rustplus info --all # Query all configured servers concurrently
rustplus time
rustplus map --out map.jpg
rustplus markers

# 4. Control smart switches & inspect entities
rustplus switch 1234567 on
rustplus switch 1234567 off
rustplus switch 1234567 toggle
rustplus entity 1234567

# 5. View team and chat
rustplus team
rustplus chat send "Hello from Go CLI!"
rustplus chat history

# 6. Inspect and render CCTV cameras
rustplus camera OILRIG1 --render frame.png
rustplus camera DOME1 --zoom

# 7. Stream live broadcasts in JSON
rustplus listen --json

License

The MIT License (MIT)

Copyright (c) 2026-present Nathanael Bracy

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Directories

Path Synopsis
cmd
rustplus command
gen
mcs
Package internal contains unexported transport, codec, and concurrency primitives for rustplus.
Package internal contains unexported transport, codec, and concurrency primitives for rustplus.
config
Package config manages persistent server connection profiles and CLI configuration files.
Package config manages persistent server connection profiles and CLI configuration files.
fcm
Package fcm provides a native client for Google Firebase Cloud Messaging (FCM) Mobile Connection Server (MCS) protocol.
Package fcm provides a native client for Google Firebase Cloud Messaging (FCM) Mobile Connection Server (MCS) protocol.
pending
Package pending provides in-flight request registration and response dispatching for sequence-based RPCs.
Package pending provides in-flight request registration and response dispatching for sequence-based RPCs.
proto
Package proto provides protobuf serialization and deserialization helpers for rustplus messages.
Package proto provides protobuf serialization and deserialization helpers for rustplus messages.
ws
Package ws provides a WebSocket transport wrapper for connecting to Rust companion servers.
Package ws provides a WebSocket transport wrapper for connecting to Rust companion servers.
pkg
Package pkg contains the public APIs for the Rust companion library.
Package pkg contains the public APIs for the Rust companion library.
camera
Package camera provides CCTV, PTZ, and Auto Turret camera subscription, movement control, and frame ray-tracing reconstruction.
Package camera provides CCTV, PTZ, and Auto Turret camera subscription, movement control, and frame ray-tracing reconstruction.
entity
Package entity provides domain types and helper functions for interacting with Smart Switches, Smart Alarms, and Storage Monitors.
Package entity provides domain types and helper functions for interacting with Smart Switches, Smart Alarms, and Storage Monitors.
rustplus
Package rustplus provides the primary client for interacting with Rust companion game servers.
Package rustplus provides the primary client for interacting with Rust companion game servers.
mcs

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL