Compare commits
18 Commits
Author | SHA1 | Date | |
---|---|---|---|
11eaaf7385 | |||
7485151f66 | |||
69d385e86f | |||
64318b0ec9 | |||
864748c98c | |||
0f09e75f0d | |||
89c96b0672 | |||
776c463c0c | |||
eda54928f2 | |||
0d1f57399a | |||
0db3fda0c6 | |||
e7957e7138 | |||
53cdd4da8e | |||
dc32e7c171 | |||
993f4fe135 | |||
ef94d8ec95 | |||
f46ca8615f | |||
53206dfc2d |
50
.gitea/workflows/build-docker-image.yml
Normal file
50
.gitea/workflows/build-docker-image.yml
Normal file
@@ -0,0 +1,50 @@
|
||||
name: Build and Push Server Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
build-server:
|
||||
runs-on: ubuntu-24.04
|
||||
container:
|
||||
image: docker:dind
|
||||
privileged: true
|
||||
|
||||
steps:
|
||||
|
||||
- name: Install required tools
|
||||
run: apk add --no-cache git nodejs npm
|
||||
# 1. Check out the repo
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
# 2. Set up Docker Buildx (recommended for advanced caching)
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
# 3. Log in to your container registry
|
||||
- name: Log in to registry
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: ${{ secrets.REGISTRY_URL }}
|
||||
username: ${{ secrets.REGISTRY_USERNAME }}
|
||||
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
|
||||
# 4. Lowercase the repository name
|
||||
- name: Set lowercase repo name
|
||||
run: echo "REPO_NAME_LOWER=$(echo '${{ github.event.repository.name }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
|
||||
|
||||
# 5. Build & push the server image, using remote cache
|
||||
- name: Build and push server image
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: VirtualDDNSRouter.Server
|
||||
file: VirtualDDNSRouter.Server/Dockerfile
|
||||
push: true
|
||||
tags: ${{ secrets.REGISTRY_URL }}/${{ github.repository_owner }}/${{ env.REPO_NAME_LOWER }}:latest-server
|
||||
cache-from: type=registry,ref=${{ secrets.REGISTRY_URL }}/${{ github.repository_owner }}/${{ env.REPO_NAME_LOWER }}:buildcache
|
||||
cache-to: type=registry,ref=${{ secrets.REGISTRY_URL }}/${{ github.repository_owner }}/${{ env.REPO_NAME_LOWER }}:buildcache,mode=max
|
||||
|
||||
|
||||
|
87
README.md
Normal file
87
README.md
Normal file
@@ -0,0 +1,87 @@
|
||||
# VirtualDDNSRouter (VDR)
|
||||
|
||||
VirtualDDNSRouter (VDR) is a lightweight dynamic DNS router solution that consists of two components:
|
||||
- **Client**: Updates the server with the current IP address of a service
|
||||
- **Server**: Acts as a reverse proxy that redirects requests to the correct IP address
|
||||
|
||||
This solution is particularly useful for accessing services running on dynamic IP addresses through consistent URLs.
|
||||
|
||||
## Quick Start (Recommended Method)
|
||||
|
||||
The easiest way to use VDR is by downloading the pre-built binaries:
|
||||
|
||||
1. Download the latest release for your platform from [https://git.mahdium.ir/mahdium/VDR/releases/latest](https://git.mahdium.ir/mahdium/VDR/releases/latest)
|
||||
2. Extract the archives for both client and server
|
||||
3. Configure each component using the provided examples
|
||||
4. Run the server and client applications
|
||||
|
||||
## Components
|
||||
|
||||
- [Client Documentation](VirtualDDNSRouter.Client/README.md) - For updating IP addresses
|
||||
- [Server Documentation](VirtualDDNSRouter.Server/README.md) - For routing requests
|
||||
|
||||
## Architecture
|
||||
|
||||
```
|
||||
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
|
||||
│ VDR Client │ │ VDR Server │ │ Service │
|
||||
│ │ │ │ │ │
|
||||
│ • Periodically │◄──────►│ • Maintains IP │◄──────►│ • Running on │
|
||||
│ updates IP │ │ mappings │ │ dynamic IP │
|
||||
│ with server │ │ • Redirects to │ │ • Exposes port │
|
||||
│ │ │ correct IP │ │ │
|
||||
└─────────────────┘ └─────────────────┘ └─────────────────┘
|
||||
|
||||
┌─────────────────┐
|
||||
│ User │
|
||||
│ │
|
||||
│ • Accesses │
|
||||
│ service via │
|
||||
│ consistent │
|
||||
│ URL │
|
||||
└─────────────────┘
|
||||
│
|
||||
▼
|
||||
┌─────────────────┐
|
||||
│ VDR Server │
|
||||
│ │
|
||||
│ • Redirects to │
|
||||
│ current IP │
|
||||
└─────────────────┘
|
||||
```
|
||||
|
||||
## Alternative Deployment Methods
|
||||
|
||||
### Using Docker
|
||||
|
||||
You can also run VDR using Docker:
|
||||
|
||||
```bash
|
||||
# Build the images
|
||||
docker-compose build
|
||||
|
||||
# Run the services
|
||||
docker-compose up
|
||||
```
|
||||
|
||||
See the [compose.yaml](compose.yaml) file for details.
|
||||
|
||||
### Building from Source
|
||||
|
||||
If you prefer to build from source:
|
||||
|
||||
```bash
|
||||
# For the server
|
||||
cd VirtualDDNSRouter.Server
|
||||
dotnet build
|
||||
dotnet run
|
||||
|
||||
# For the client
|
||||
cd VirtualDDNSRouter.Client
|
||||
dotnet build
|
||||
dotnet run
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
56
VirtualDDNSRouter.Client/README.md
Normal file
56
VirtualDDNSRouter.Client/README.md
Normal file
@@ -0,0 +1,56 @@
|
||||
# VirtualDDNSRouter Client
|
||||
|
||||
The VirtualDDNSRouter Client is a lightweight application that periodically updates the IP address of a service with the VirtualDDNSRouter Server.
|
||||
|
||||
## Configuration
|
||||
|
||||
The client uses a YAML configuration file named `settings.yaml`. You can create this file by copying and modifying the provided example:
|
||||
|
||||
```bash
|
||||
cp settings.example.yaml settings.yaml
|
||||
```
|
||||
|
||||
The configuration file has the following structure:
|
||||
|
||||
```yaml
|
||||
host: example.com # The hostname of the VDR server
|
||||
path: odoo # The path identifier for your service
|
||||
destination_port: 8081 # The port of your service
|
||||
api_key: abc123XYZ # The API key for authentication
|
||||
refresh_interval_minutes: 3 # How often to update the IP address (in minutes)
|
||||
```
|
||||
|
||||
## Running the Client
|
||||
|
||||
### Method 1: Downloading Pre-built Binaries (Recommended)
|
||||
|
||||
1. Download the latest client binary from [https://git.mahdium.ir/mahdium/VDR/releases/latest](https://git.mahdium.ir/mahdium/VDR/releases/latest)
|
||||
2. Extract the archive
|
||||
3. Create your `settings.yaml` file based on `settings.example.yaml`
|
||||
4. Run the client:
|
||||
|
||||
```bash
|
||||
./VirtualDDNSRouter.Client
|
||||
```
|
||||
|
||||
### Method 2: Using Docker
|
||||
|
||||
```bash
|
||||
docker run -v ./settings.yaml:/app/settings.yaml virtualddnsrouter.client
|
||||
```
|
||||
|
||||
### Method 3: Building from Source
|
||||
|
||||
```bash
|
||||
dotnet build
|
||||
dotnet run
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
After starting the client, it will:
|
||||
1. Read the configuration from `settings.yaml`
|
||||
2. Send an update to the server every `refresh_interval_minutes`
|
||||
3. Continue running until stopped with Ctrl+C
|
||||
|
||||
The client will output logs showing when updates are sent and whether they were successful.
|
@@ -1,23 +1,17 @@
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS base
|
||||
USER $APP_UID
|
||||
WORKDIR /app
|
||||
EXPOSE 8080
|
||||
EXPOSE 8081
|
||||
FROM mcr.microsoft.com/dotnet/sdk:10.0.100-preview.7-alpine3.22-aot AS build
|
||||
|
||||
# Install NativeAOT build prerequisites
|
||||
RUN apk update \
|
||||
&& apk add --no-cache \
|
||||
clang zlib-dev
|
||||
|
||||
WORKDIR /source
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
WORKDIR /src
|
||||
COPY ["VirtualDDNSRouter.Server/VirtualDDNSRouter.Server.csproj", "VirtualDDNSRouter.Server/"]
|
||||
RUN dotnet restore "VirtualDDNSRouter.Server/VirtualDDNSRouter.Server.csproj"
|
||||
COPY . .
|
||||
WORKDIR "/src/VirtualDDNSRouter.Server"
|
||||
RUN dotnet build "./VirtualDDNSRouter.Server.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
||||
RUN dotnet publish -r linux-musl-x64 -o /app 'VirtualDDNSRouter.Server.csproj'
|
||||
|
||||
FROM build AS publish
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
RUN dotnet publish "./VirtualDDNSRouter.Server.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
||||
FROM mcr.microsoft.com/dotnet/runtime-deps:10.0.0-preview.7-alpine3.22
|
||||
|
||||
FROM base AS final
|
||||
WORKDIR /app
|
||||
COPY --from=publish /app/publish .
|
||||
ENTRYPOINT ["dotnet", "VirtualDDNSRouter.Server.dll"]
|
||||
COPY --from=build /app .
|
||||
ENTRYPOINT ["/app/VirtualDDNSRouter.Server"]
|
89
VirtualDDNSRouter.Server/README.md
Normal file
89
VirtualDDNSRouter.Server/README.md
Normal file
@@ -0,0 +1,89 @@
|
||||
# VirtualDDNSRouter Server
|
||||
|
||||
The VirtualDDNSRouter Server is a lightweight reverse proxy that maintains dynamic mappings between paths and IP
|
||||
addresses. Clients can update their IP addresses, and users can access services through consistent URLs.
|
||||
|
||||
## Configuration
|
||||
|
||||
The server uses a YAML rules file named `rules.yaml`. You can create this file by copying and modifying the provided
|
||||
example:
|
||||
|
||||
```bash
|
||||
cp rules.example.yaml rules.yaml
|
||||
```
|
||||
|
||||
The rules file has the following structure:
|
||||
|
||||
```yaml
|
||||
- name: Odoo Server # A descriptive name for the service
|
||||
api_key: abc123XYZ # The API key for authentication
|
||||
path: odoo # The path identifier for the service
|
||||
|
||||
- name: Backup server
|
||||
api_key: def456ABC
|
||||
path: bk
|
||||
```
|
||||
|
||||
Each entry defines a service with:
|
||||
|
||||
- `name`: A descriptive label (for documentation purposes)
|
||||
- `api_key`: A secret key used by clients to authenticate updates
|
||||
- `path`: The URL path that users will use to access the service
|
||||
|
||||
## Running the Server
|
||||
|
||||
### Method 1: Downloading Pre-built Binaries (Recommended)
|
||||
|
||||
1. Download the latest server binary
|
||||
from [https://git.mahdium.ir/mahdium/VDR/releases/latest](https://git.mahdium.ir/mahdium/VDR/releases/latest)
|
||||
2. Extract the archive
|
||||
3. Create your `rules.yaml` file based on `rules.example.yaml`
|
||||
4. Run the server:
|
||||
|
||||
```bash
|
||||
./VirtualDDNSRouter.Server
|
||||
```
|
||||
|
||||
By default, the server listens on port 8080. You can change this by setting the `ASPNETCORE_HTTP_PORTS` environment
|
||||
variable:
|
||||
|
||||
```bash
|
||||
ASPNETCORE_HTTP_PORTS=8081 ./VirtualDDNSRouter.Server
|
||||
```
|
||||
|
||||
### Method 2: Using Docker
|
||||
|
||||
```bash
|
||||
docker run -p 8080:8080 -v ./rules.yaml:/app/rules.yaml virtualddnsrouter.server
|
||||
```
|
||||
|
||||
### Method 3: Building from Source
|
||||
|
||||
```bash
|
||||
dotnet build
|
||||
dotnet run
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
The server provides two main endpoints:
|
||||
|
||||
1. **IP Update Endpoint** (used by clients):
|
||||
```
|
||||
GET /setip/{path}/{port}/{api_key}
|
||||
```
|
||||
Clients call this endpoint to update their IP address.
|
||||
|
||||
2. **Service Access Endpoint** (used by users):
|
||||
```
|
||||
GET /goto/{path}
|
||||
```
|
||||
Users access this endpoint to reach the service associated with the path.
|
||||
|
||||
For example, if a client has configured a service with path "odoo", users can access it at:
|
||||
|
||||
```
|
||||
http://your-server:8080/goto/odoo
|
||||
```
|
||||
|
||||
The server will redirect users to the IP address and port that the client last reported.
|
@@ -1,11 +1,18 @@
|
||||
@VirtualDDNSRouter.Server_HostAddress = http://localhost:5277
|
||||
|
||||
GET {{VirtualDDNSRouter.Server_HostAddress}}/todos/
|
||||
Accept: application/json
|
||||
### Set IP for a path
|
||||
# This endpoint is used by clients to register/update their IP address for a specific path
|
||||
# Parameters:
|
||||
# - path: The path identifier (must match a rule in rules.yaml)
|
||||
# - port: The port number the client wants to expose
|
||||
# - apiKey: The API key for authentication (must match the rule for the path)
|
||||
POST {{VirtualDDNSRouter.Server_HostAddress}}/setip/{path}/{port}/{apiKey}
|
||||
Content-Type: application/json
|
||||
|
||||
###
|
||||
|
||||
GET {{VirtualDDNSRouter.Server_HostAddress}}/todos/1
|
||||
Accept: application/json
|
||||
### Redirect to registered service
|
||||
# This endpoint redirects to the IP and port registered for a specific path
|
||||
GET {{VirtualDDNSRouter.Server_HostAddress}}/goto/{path}
|
||||
|
||||
###
|
||||
|
Reference in New Issue
Block a user