Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions build-docker/alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ RUN apk add --no-cache \
musl-dev\
perl \
perl-utils \
perl-dev
perl-dev \
openssl-dev

COPY . .
RUN cargo build -p router-core --release
RUN cargo build -p router-api --release
RUN cargo build -p router-cli --release

# Runtime image stage
FROM alpine:latest
Expand All @@ -27,14 +29,12 @@ RUN apk add --no-cache \
# Copy binaries from builder
COPY --from=builder /app/target/release/router-core /usr/local/bin/router-core
COPY --from=builder /app/target/release/router-api /usr/local/bin/router-api
COPY --from=builder /app/target/release/router-cli /usr/local/bin/gwrs

COPY build-docker/alpine/entrypoint.sh /usr/local/bin/entrypoint.sh

# Make everything executable
RUN chmod +x /usr/local/bin/*

# Expose API port
EXPOSE 24042

# Set entrypoint
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
26 changes: 26 additions & 0 deletions build-docker/config.example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
proxy:
- name: "proxy1"
listen: "127.0.0.1:8080"
domains:
- domain: "example.com"
tls: false
tls_cert: |
-----BEGIN CERTIFICATE-----
cert
-----END CERTIFICATE-----
tls_key: |
-----BEGIN PRIVATE KEY-----
key
-----END PRIVATE KEY-----
highspeed:
enabled: true
target: "gateway1"
gateway:
- name: "gateway1"
domain: "example.com"
target: "127.0.0.1:8080"
path:
- priority: 1
pattern: "^(.*)$"
target: "/$1"

24 changes: 0 additions & 24 deletions common/memory_log_constants.rs

This file was deleted.

43 changes: 22 additions & 21 deletions router-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,26 @@ version = "0.0.1"
edition = "2021"

[dependencies]
thiserror = "1.0"
async-trait = "0.1"
actix-web = { workspace = true }
actix-cors = { workspace = true }
env_logger = { workspace = true }
log = { workspace = true }
tokio = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
mini-config = { workspace = true , features = [ "derive" ]}
rusqlite = { version = "0.32.0", features = ["bundled"] }
uuid = { version = "1.6.1", features = ["v4", "serde"] }
rand = "0.8.5"
jsonwebtoken = "9.3.1"
futures = "0.3.31"
futures-util = "0.3.31"
clap = { version = "4.5.35", features = ["derive"] }
chrono = { version = "0.4.40", features = ["serde"] }
tracing = { workspace = true }
actix-web = { workspace = true }
actix-cors = { workspace = true }
env_logger = { workspace = true }
log = { workspace = true }
tokio = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
tracing = { workspace = true }
mini-config = { workspace = true , features = [ "derive" ]}
rusqlite = { version = "0.35.0", features = ["bundled"] }
uuid = { version = "1.6.1", features = ["v4", "serde"] }
clap = { version = "4.5.35", features = ["derive"] }
chrono = { version = "0.4.40", features = ["serde"] }
thiserror = "2.0.12"
async-trait = "0.1"
serde_yaml = "0.9.29"
rand = "0.8.5"
jsonwebtoken = "9.3.1"
futures = "0.3.31"
futures-util = "0.3.31"
tracing-subscriber = "0.3.18"
tracing-appender = "0.2.3"
crossbeam-channel = "0.5.8"
Expand All @@ -31,8 +32,8 @@ parking_lot = "0.12.3"
tokio-stream = "0.1.17"
libc = "0.2.153"
lazy_static = "1.5.0"
bincode = "2.0.1"
lzma-rs = "0.3.0"
bincode = "2.0.1"
lzma-rs = "0.3.0"

[target.'cfg(target_os = "macos")'.dependencies]
dirs = "6.0.0"
Expand Down
91 changes: 90 additions & 1 deletion router-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1130,4 +1130,93 @@ Retrieves statistics about bytes transferred.
"low": 5124
}
]
```
```

## Auto-Configuration

The Auto-Configuration API provides endpoints for bulk importing and exporting gateway configurations using YAML files. This allows for easier setup, backup, and migration of configuration across environments.

### Upload Configuration

Uploads a YAML configuration file and applies it to the system by creating the corresponding proxy, domain, gateway node, and gateway configurations.

**Endpoint:** `POST /api/v1/auto-config`

**Request:** The request body should be a YAML document conforming to the following structure:

```yaml
proxy:
- name: "proxy1"
listen: "127.0.0.1:8080"
domains:
- domain: "example.com"
tls: false
tls_cert: |
-----BEGIN CERTIFICATE-----
cert
-----END CERTIFICATE-----
tls_key: |
-----BEGIN PRIVATE KEY-----
key
-----END PRIVATE KEY-----
highspeed:
enabled: true
target: "gateway1"
gateway:
- name: "gateway1"
domain: "example.com"
target: "127.0.0.1:8080"
path:
- priority: 1
pattern: "^(.*)$"
target: "/$1"
```

The configuration follows this structure:
- `proxy`: Array of proxy configurations
- `name`: Human-readable name for the proxy
- `listen`: Address where the proxy listens (format: "ip:port")
- `domains`: Array of domain configurations
- `domain`: Domain name (SNI value)
- `tls`: Whether TLS is enabled
- `tls_cert`: TLS certificate content (optional)
- `tls_key`: TLS private key content (optional)
- `highspeed`: High-speed mode configuration (optional)
- `enabled`: Whether high-speed mode is enabled
- `target`: Target gateway name for high-speed mode
- `gateway`: Array of gateway configurations
- `name`: Human-readable name for the gateway
- `domain`: Domain associated with this gateway
- `target`: Target address for the gateway node
- `path`: Array of path configurations
- `priority`: Priority level (lower numbers = higher priority)
- `pattern`: URL matching pattern
- `target`: Target URL where matching requests should be routed

**Response:**

| Field | Type | Description |
|----------|---------|---------------------------------------------|
| success | boolean | Whether the operation was successful |
| created | object | Summary of created resources |

**Example Response:**
```json
{
"success": true,
"created": {
"proxies": 1,
"domains": 1,
"gwnodes": 1,
"gateways": 1
}
}
```

### Download Configuration

Downloads the current configuration as a YAML file. This exports all proxy, domain, gateway node, and gateway configurations into a format that can be uploaded back through the upload endpoint.

**Endpoint:** `GET /api/v1/auto-config`

**Response:** Returns a YAML document containing the full configuration in the same format as described in the Upload Configuration section. The response includes a `Content-Disposition` header set to `attachment; filename="gateway-config.yaml"` to prompt the browser to download the file.
Loading