# Configuration

## Command Line Options

```bash
kayakd [options]
```

### Core Options

| Option        | Description            | Default        |
| ------------- | ---------------------- | -------------- |
| `--listen`    | Address to listen on   | `0.0.0.0:4242` |
| `--bootstrap` | Bootstrap node address | Required       |
| `--name`      | Node display name      | `anonymous`    |
| `--data-dir`  | Data directory         | `./data`       |
| `--config`    | Config file path       | Auto-detect    |

### Proxy Options

| Option          | Description          | Default |
| --------------- | -------------------- | ------- |
| `--proxy`       | Enable browser proxy | `false` |
| `--http-proxy`  | HTTP proxy port      | `8118`  |
| `--socks-proxy` | SOCKS5 proxy port    | `8119`  |

### Network Options

| Option         | Description              | Default |
| -------------- | ------------------------ | ------- |
| `--public-api` | Expose API publicly      | `false` |
| `--api-port`   | Homepage/API port        | `8080`  |
| `--max-peers`  | Maximum peer connections | `50`    |

### Security Options

| Option             | Description                  | Default |
| ------------------ | ---------------------------- | ------- |
| `--onion-hops`     | Number of onion routing hops | `3`     |
| `--pow-difficulty` | Proof-of-work difficulty     | `20`    |

## Configuration File

Create `config.json` in your data directory:

```json
{
  "node": {
    "name": "my-node",
    "data_dir": "./data",
    "listen_address": "0.0.0.0:4242",
    "identity_file": "./data/identity.key"
  },
  "bootstrap": {
    "nodes": ["203.161.33.237:4242"]
  },
  "proxy": {
    "enabled": true,
    "http_port": 8118,
    "socks_port": 8119
  },
  "security": {
    "onion_hops": 3,
    "pow_difficulty": 20,
    "enable_traffic_analysis_resistance": true
  },
  "dht": {
    "k": 20,
    "alpha": 3,
    "record_ttl": "24h",
    "refresh_interval": "1h"
  },
  "crypto": {
    "monero": {
      "enabled": false,
      "rpc_host": "",
      "rpc_port": 18082
    },
    "zcash": {
      "enabled": false,
      "rpc_host": "",
      "rpc_port": 8232
    }
  },
  "logging": {
    "level": "info",
    "file": "./logs/kayaknet.log"
  }
}
```

## Environment Variables

| Variable             | Description                           |
| -------------------- | ------------------------------------- |
| `KAYAKNET_DATA_DIR`  | Override data directory               |
| `KAYAKNET_BOOTSTRAP` | Override bootstrap node               |
| `KAYAKNET_LOG_LEVEL` | Logging level (debug/info/warn/error) |

## Examples

### Basic Usage

```bash
./kayakd --bootstrap 203.161.33.237:4242 --proxy
```

### Custom Name and Ports

```bash
./kayakd \
  --bootstrap 203.161.33.237:4242 \
  --proxy \
  --name "my-private-node" \
  --listen 0.0.0.0:4243 \
  --http-proxy 8119 \
  --socks-proxy 8120
```

### Production Node

```bash
./kayakd \
  --config /etc/kayaknet/config.json \
  --data-dir /var/lib/kayaknet \
  --bootstrap 203.161.33.237:4242 \
  --public-api \
  --max-peers 100
```

### Bootstrap Node

```bash
./kayakd \
  --listen 0.0.0.0:4242 \
  --public-api \
  --name "bootstrap-node" \
  --data-dir /var/lib/kayaknet
```

## Data Directory Structure

```
data/
├── identity.key      # Node's cryptographic identity
├── peers.json        # Known peer addresses
├── dht/              # DHT records
├── chat/             # Chat history
├── market/           # Marketplace data
│   ├── listings.json
│   └── orders.json
├── escrow/           # Escrow records
└── names/            # .kyk domain registrations
```

## Identity Management

Your node's identity is stored in `identity.key`. This file contains:

* Ed25519 private key
* Node ID (derived from public key)

**Important:**

* Back up this file to maintain your identity
* If lost, you'll appear as a new node
* Never share this file with anyone
