{"_id":"@callowayisweird/source-rcon","name":"@callowayisweird/source-rcon","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@callowayisweird/source-rcon","version":"0.1.0","description":"Production-grade Source Engine RCON client for Node.js/Bun. Zero runtime dependencies.","license":"MIT","author":{"name":"CallowayIsWeird"},"homepage":"https://github.com/CallowayIsWeird/source-rcon#readme","bugs":{"url":"https://github.com/CallowayIsWeird/source-rcon/issues"},"repository":{"type":"git","url":"git+https://github.com/CallowayIsWeird/source-rcon.git"},"keywords":["rcon","source","valve","gmod","csgo","server","remote","console","typescript"],"type":"module","main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}}},"scripts":{"build":"tsup","lint":"tsc --noEmit","test":"vitest run","prepublishOnly":"npm run build"},"peerDependencies":{"@callowayisweird/source-query":">=0.1.0"},"peerDependenciesMeta":{"@callowayisweird/source-query":{"optional":true}},"devDependencies":{"@types/node":"^25.5.0","tsup":"^8.4.0","typescript":"~5.9.3","vitest":"^3.0.0"},"gitHead":"288f20b066d0c112b6c1e72ce19a9a7271028fbc","_id":"@callowayisweird/source-rcon@0.1.0","_nodeVersion":"22.19.0","_npmVersion":"9.6.7","dist":{"integrity":"sha512-ih01i/qNXQD/UQxDiwCr81AOfvVNJQsfF1nmqf7CtxlfujSesI/5bQL5j8vN7hx0aTNGfITu9YTy/6BtgtzomQ==","shasum":"351880dabe64616a71b2445ad4b6b351bfe56817","tarball":"https://registry.npmjs.org/@callowayisweird/source-rcon/-/source-rcon-0.1.0.tgz","fileCount":9,"unpackedSize":120142,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIBm9OeMj7QCuGrL0Wvd03zYnvAypnnSErBnLFYFZ9xNdAiEAsxqa9Fzmzobk+0ZYZkegpIs+Fqa/UQ3mXl7lKqgLRFA="}]},"_npmUser":{"name":"callowayisweird","email":"henrythegamerguy62@gmail.com"},"directories":{},"maintainers":[{"name":"callowayisweird","email":"henrythegamerguy62@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/source-rcon_0.1.0_1774690007753_0.7410588720501052"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-28T09:26:47.391Z","0.1.0":"2026-03-28T09:26:47.897Z","modified":"2026-03-28T09:26:48.130Z"},"maintainers":[{"name":"callowayisweird","email":"henrythegamerguy62@gmail.com"}],"description":"Production-grade Source Engine RCON client for Node.js/Bun. Zero runtime dependencies.","homepage":"https://github.com/CallowayIsWeird/source-rcon#readme","keywords":["rcon","source","valve","gmod","csgo","server","remote","console","typescript"],"repository":{"type":"git","url":"git+https://github.com/CallowayIsWeird/source-rcon.git"},"author":{"name":"CallowayIsWeird"},"bugs":{"url":"https://github.com/CallowayIsWeird/source-rcon/issues"},"license":"MIT","readme":"# @callowayisweird/source-rcon\n\nProduction-grade Source Engine RCON client for Node.js and Bun. Zero runtime dependencies, full TypeScript support.\n\n## Install\n\n```bash\nnpm install @callowayisweird/source-rcon\n```\n\n## Usage\n\n### Basic Connection\n\n```typescript\nimport { Rcon } from '@callowayisweird/source-rcon'\n\nconst rcon = new Rcon({\n  host: '127.0.0.1',\n  port: 27015,\n  password: 'your_rcon_password',\n})\n\nawait rcon.connect()\n\nconst status = await rcon.execute('status')\nconsole.log(status)\n\nawait rcon.disconnect()\n```\n\n### Events\n\n```typescript\nconst rcon = new Rcon({\n  host: '127.0.0.1',\n  port: 27015,\n  password: 'secret',\n})\n\nrcon.on('connect', () => console.log('Connected'))\nrcon.on('disconnect', () => console.log('Disconnected'))\nrcon.on('error', (err) => console.error('Error:', err))\n\nawait rcon.connect()\n```\n\n### Auto-Reconnection\n\n```typescript\nconst rcon = new Rcon({\n  host: '127.0.0.1',\n  port: 27015,\n  password: 'secret',\n  autoReconnect: true,\n  maxReconnectAttempts: 5,\n  reconnectDelay: 3000,\n})\n\nrcon.on('reconnecting', (attempt) => {\n  console.log(`Reconnecting... attempt ${attempt}`)\n})\n\nawait rcon.connect()\n```\n\n### Multi-Server Pool\n\n```typescript\nimport { RconPool } from '@callowayisweird/source-rcon'\n\nconst pool = new RconPool([\n  { host: '10.0.0.1', port: 27015, password: 'pass1' },\n  { host: '10.0.0.2', port: 27015, password: 'pass2' },\n  { host: '10.0.0.3', port: 27015, password: 'pass3' },\n])\n\nawait pool.connectAll()\n\n// Execute on a specific server\nconst status = await pool.execute('10.0.0.1:27015', 'status')\n\n// Execute on all servers\nconst results = await pool.executeAll('status')\nfor (const [server, response] of results) {\n  console.log(`${server}: ${response}`)\n}\n\nawait pool.disconnectAll()\n```\n\n### Permission-Gated RCON\n\n```typescript\nimport { Rcon, GatedRcon } from '@callowayisweird/source-rcon'\n\nconst rcon = new Rcon({\n  host: '127.0.0.1',\n  port: 27015,\n  password: 'secret',\n})\n\nawait rcon.connect()\n\nconst gated = new GatedRcon(rcon, {\n  allowedUsers: ['STEAM_0:1:12345678', 'STEAM_0:1:87654321'],\n  permissions: {\n    'STEAM_0:1:12345678': ['say *', 'status', 'changelevel *'], // admin\n    'STEAM_0:1:87654321': ['say *', 'status'],                   // moderator\n  },\n  rateLimit: {\n    windowMs: 60000,  // 1 minute\n    maxCommands: 10,   // max 10 commands per minute\n  },\n  onExecute: (steamId, command, response) => {\n    console.log(`[RCON] ${steamId} executed: ${command}`)\n  },\n  onBlocked: (steamId, command, reason) => {\n    console.warn(`[RCON] Blocked ${steamId}: ${command} (${reason})`)\n  },\n})\n\n// Will succeed for allowed users with matching permissions\nawait gated.execute('STEAM_0:1:12345678', 'say Hello everyone!')\n\n// Will throw PermissionDeniedError\nawait gated.execute('STEAM_0:1:87654321', 'changelevel gm_flatgrass')\n```\n\n### Error Handling\n\n```typescript\nimport {\n  Rcon,\n  AuthFailedError,\n  ConnectionRefusedError,\n  TimeoutError,\n  DisconnectedError,\n} from '@callowayisweird/source-rcon'\n\nconst rcon = new Rcon({\n  host: '127.0.0.1',\n  port: 27015,\n  password: 'secret',\n  timeout: 5000,\n})\n\ntry {\n  await rcon.connect()\n} catch (err) {\n  if (err instanceof AuthFailedError) {\n    console.error('Wrong RCON password')\n  } else if (err instanceof ConnectionRefusedError) {\n    console.error('Server refused connection')\n  } else if (err instanceof TimeoutError) {\n    console.error('Connection timed out')\n  }\n}\n\ntry {\n  await rcon.execute('status')\n} catch (err) {\n  if (err instanceof DisconnectedError) {\n    console.error('Not connected to server')\n  } else if (err instanceof TimeoutError) {\n    console.error('Command timed out')\n  }\n}\n```\n\n## API Reference\n\n### `Rcon`\n\n| Method | Description |\n|---|---|\n| `new Rcon(options)` | Create a new RCON client |\n| `connect()` | Connect and authenticate |\n| `execute(command)` | Execute a command (queued, sequential) |\n| `disconnect()` | Disconnect from the server |\n| `isConnected` | Whether the client is authenticated |\n\n#### `RconOptions`\n\n| Option | Type | Default | Description |\n|---|---|---|---|\n| `host` | `string` | **required** | Server hostname or IP |\n| `port` | `number` | **required** | Server RCON port |\n| `password` | `string` | **required** | RCON password |\n| `timeout` | `number` | `5000` | Timeout in milliseconds |\n| `autoReconnect` | `boolean` | `false` | Auto-reconnect on disconnect |\n| `maxReconnectAttempts` | `number` | `5` | Max reconnection attempts |\n| `reconnectDelay` | `number` | `3000` | Delay between reconnect attempts (ms) |\n\n#### Events\n\n| Event | Arguments | Description |\n|---|---|---|\n| `connect` | none | Successfully connected and authenticated |\n| `disconnect` | none | Disconnected from server |\n| `error` | `Error` | An error occurred |\n| `reconnecting` | `number` | Attempting to reconnect (attempt number) |\n\n### `RconPool`\n\n| Method | Description |\n|---|---|\n| `new RconPool(servers)` | Create pool from array of server options |\n| `connectAll()` | Connect to all servers |\n| `execute(key, command)` | Execute on a specific server (`host:port`) |\n| `executeAll(command)` | Execute on all servers |\n| `disconnectAll()` | Disconnect all servers |\n| `get(key)` | Get the `Rcon` instance for a server |\n| `size` | Number of servers in the pool |\n\n### `GatedRcon`\n\n| Method | Description |\n|---|---|\n| `new GatedRcon(rcon, options)` | Create gated wrapper around an `Rcon` instance |\n| `execute(steamId, command)` | Execute if permitted, throws `PermissionDeniedError` if not |\n\n### Errors\n\n| Error | Code | Description |\n|---|---|---|\n| `RconError` | varies | Base error class |\n| `AuthFailedError` | `AUTH_FAILED` | Wrong RCON password |\n| `ConnectionError` | `CONNECTION_FAILED` | Cannot connect to server |\n| `ConnectionRefusedError` | `CONNECTION_REFUSED` | Connection actively refused |\n| `TimeoutError` | `TIMEOUT` | Operation timed out |\n| `DisconnectedError` | `DISCONNECTED` | Not connected to server |\n| `BannedError` | `BANNED` | IP banned after failed auth attempts |\n| `PermissionDeniedError` | `PERMISSION_DENIED` | GatedRcon blocked the command |\n\n## License\n\nMIT\n","readmeFilename":"README.md","_rev":"1-1e89b3867b6c42897672f33d75258bfc"}