> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/sammwyy/mikuMikuBeam/llms.txt
> Use this file to discover all available pages before exploring further.

# Configuration Endpoints

> Manage proxies and user agents for attacks

## Overview

The configuration endpoints allow you to retrieve and update the server's proxy list and user agent list. These configurations are used for all attacks to rotate proxies and randomize user agents.

<Info>
  Configuration data is transmitted as base64-encoded strings to safely handle newlines and special characters in proxy URLs and user agent strings.
</Info>

***

## GET /configuration

Retrieve the current proxy and user agent configuration.

### Request

No parameters required.

### Response

<ResponseField name="proxies" type="string" required>
  Base64-encoded string containing the proxies file content (one proxy per line)
</ResponseField>

<ResponseField name="uas" type="string" required>
  Base64-encoded string containing the user agents file content (one user agent per line)
</ResponseField>

### Example Request

```bash theme={null}
curl http://localhost:8080/configuration
```

### Example Response

```json theme={null}
{
  "proxies": "aHR0cDovL3Byb3h5MS5leGFtcGxlLmNvbTo4MDgwCmh0dHA6Ly9wcm94eTIuZXhhbXBsZS5jb206ODA4MA==",
  "uas": "TW96aWxsYS81LjAgKFdpbmRvd3MgTlQgMTAuMDsgV2luNjQ7IHg2NCkgQXBwbGVXZWJLaXQvNTM3LjM2"
}
```

### Decoding Configuration

To decode the base64 strings:

```javascript theme={null}
fetch('http://localhost:8080/configuration')
  .then(res => res.json())
  .then(data => {
    const proxies = atob(data.proxies);
    const userAgents = atob(data.uas);
    
    console.log('Proxies:', proxies.split('\n'));
    console.log('User Agents:', userAgents.split('\n'));
  });
```

Or using Node.js:

```javascript theme={null}
const proxies = Buffer.from(data.proxies, 'base64').toString('utf-8');
const userAgents = Buffer.from(data.uas, 'base64').toString('utf-8');
```

***

## POST /configuration

Update the server's proxy and user agent configuration.

### Request Body

<ParamField body="proxies" type="string">
  Base64-encoded string containing proxy list (one per line). If omitted, proxies are not updated.
</ParamField>

<ParamField body="uas" type="string">
  Base64-encoded string containing user agent list (one per line). If omitted, user agents are not updated.
</ParamField>

### Proxy Format

Proxies should be formatted as:

```
http://proxy1.example.com:8080
http://username:password@proxy2.example.com:8080
socks5://proxy3.example.com:1080
```

### User Agent Format

User agents should be one per line:

```
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36
```

### Response

Returns `200 OK` with body `"OK"` on success.

### Example Request

```bash theme={null}
curl -X POST http://localhost:8080/configuration \
  -H "Content-Type: application/json" \
  -d '{
    "proxies": "aHR0cDovL3Byb3h5MS5leGFtcGxlLmNvbTo4MDgw",
    "uas": "TW96aWxsYS81LjAgKFdpbmRvd3MgTlQgMTAuMDsgV2luNjQ7IHg2NCk="
  }'
```

### Example with JavaScript

```javascript theme={null}
const proxies = `http://proxy1.example.com:8080
http://proxy2.example.com:8080`;

const userAgents = `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36`;

fetch('http://localhost:8080/configuration', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    proxies: btoa(proxies),
    uas: btoa(userAgents)
  })
})
.then(res => res.text())
.then(data => console.log('Configuration updated:', data));
```

### Example with Node.js

```javascript theme={null}
const proxies = `http://proxy1.example.com:8080
http://proxy2.example.com:8080`;

const userAgents = `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36`;

const response = await fetch('http://localhost:8080/configuration', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    proxies: Buffer.from(proxies).toString('base64'),
    uas: Buffer.from(userAgents).toString('base64')
  })
});

const result = await response.text();
console.log('Result:', result); // "OK"
```

***

## Socket.IO Events

While configuration is managed via REST endpoints, the Socket.IO connection provides real-time feedback about proxy usage during attacks.

### startAttack Event

When starting an attack, the server automatically filters and applies the appropriate proxies based on the attack method.

<ParamField body="target" type="string" required>
  Target URL or address (e.g., `http://example.com` or `127.0.0.1:25565`)
</ParamField>

<ParamField body="attackMethod" type="string" required>
  Attack method identifier (from `/attacks` endpoint)
</ParamField>

<ParamField body="duration" type="integer" required>
  Attack duration in seconds
</ParamField>

<ParamField body="packetDelay" type="integer" required>
  Delay between packets in milliseconds
</ParamField>

<ParamField body="packetSize" type="integer" required>
  Size of each packet in bytes
</ParamField>

<ParamField body="threads" type="integer">
  Number of concurrent threads (defaults to CPU count if omitted or 0)
</ParamField>

#### Example

```javascript theme={null}
socket.emit('startAttack', {
  target: 'http://example.com',
  attackMethod: 'http_flood',
  duration: 60,
  packetDelay: 100,
  packetSize: 1024,
  threads: 4
});
```

### stats Event

The server emits statistics every second during an attack, including proxy count.

<ResponseField name="pps" type="integer">
  Packets per second in the last interval
</ResponseField>

<ResponseField name="totalPackets" type="integer">
  Total packets sent since attack start
</ResponseField>

<ResponseField name="proxies" type="integer">
  Number of proxies being used for this attack
</ResponseField>

<ResponseField name="log" type="string">
  Log message (if any)
</ResponseField>

#### Example

```javascript theme={null}
socket.on('stats', (data) => {
  console.log(`PPS: ${data.pps}`);
  console.log(`Total: ${data.totalPackets}`);
  console.log(`Proxies: ${data.proxies}`);
  if (data.log) {
    console.log(`Log: ${data.log}`);
  }
});
```

### attackAccepted Event

Confirms attack started successfully and reports how many proxies are being used.

<ResponseField name="ok" type="boolean">
  Always `true` when attack is accepted
</ResponseField>

<ResponseField name="proxies" type="integer">
  Number of proxies being used
</ResponseField>

#### Example

```javascript theme={null}
socket.on('attackAccepted', (data) => {
  console.log(`Attack started with ${data.proxies} proxies`);
});
```

### attackError Event

Sent when attack cannot start (e.g., no proxies available).

<ResponseField name="message" type="string">
  Error message describing why the attack failed
</ResponseField>

#### Example

```javascript theme={null}
socket.on('attackError', (error) => {
  console.error('Attack failed:', error.message);
});
```

### stopAttack Event

Manually stop the current attack.

```javascript theme={null}
socket.emit('stopAttack');

socket.on('attackEnd', () => {
  console.log('Attack stopped');
});
```

***

## Implementation Details

The configuration endpoints are implemented in `/cmd/mmb-server/main.go:188-217`:

```go theme={null}
// GET endpoint
e.GET("/configuration", func(c echo.Context) error {
    pb, _ := osReadFileSafe(cfg.ProxiesFile)
    ub, _ := osReadFileSafe(cfg.UserAgentsFile)
    return c.JSON(http.StatusOK, api.ConfigurationResponse{
        Proxies: base64.StdEncoding.EncodeToString(pb),
        UAs:     base64.StdEncoding.EncodeToString(ub),
    })
})

// POST endpoint
e.POST("/configuration", func(c echo.Context) error {
    type body struct {
        Proxies string `json:"proxies"`
        UAs     string `json:"uas"`
    }
    var b body
    if err := c.Bind(&b); err != nil {
        return err
    }
    if b.Proxies != "" {
        if data, err := base64.StdEncoding.DecodeString(b.Proxies); err == nil {
            _ = osWriteFileSafe(cfg.ProxiesFile, data)
        }
    }
    if b.UAs != "" {
        if data, err := base64.StdEncoding.DecodeString(b.UAs); err == nil {
            _ = osWriteFileSafe(cfg.UserAgentsFile, data)
        }
    }
    return c.String(http.StatusOK, "OK")
})
```

<Warning>
  Configuration changes take effect for new attacks only. Running attacks continue using the proxies and user agents that were active when they started.
</Warning>

<Note>
  If you provide an empty string for `proxies` or `uas` in the POST request, that configuration will not be updated. Only non-empty values trigger updates.
</Note>
