Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
12cf54c
refactor: refactor all codes, add grpc and use interface
M03ED Dec 15, 2024
84e72d3
fix: test workflow
M03ED Dec 15, 2024
6da02cc
fix: move deps into make file
M03ED Dec 15, 2024
4f018d0
fix: add xray install to Makefile
M03ED Dec 15, 2024
cd01df0
fix: make file use sudo
M03ED Dec 15, 2024
706473c
fix: change xray config port
M03ED Dec 15, 2024
3bab4d4
fix: change config generated path
M03ED Dec 15, 2024
a639493
fix: change generated path in xray test
M03ED Dec 15, 2024
a3c2c09
chore: use xray sructs
M03ED Dec 16, 2024
2f431a1
feat: update generated config after alerting user
M03ED Dec 16, 2024
306ae03
fix: xray test case
M03ED Dec 16, 2024
ba8ec5e
fix: test case miss spell
M03ED Dec 16, 2024
5be898a
fix: fix update user method
M03ED Dec 17, 2024
e32e371
feat: add sync users method
M03ED Jan 5, 2025
4c82a80
fix: change 443 port in config
M03ED Jan 5, 2025
988b4dc
feat: use x-protobuf instead of json
M03ED Feb 5, 2025
9dfdc74
feat: add xray health check
M03ED Feb 6, 2025
c5bc7c2
feat: add README.md and some small fix
M03ED Feb 7, 2025
b74541a
fix: add CONTRIBUTING.md
M03ED Feb 7, 2025
af41649
feat: add table of content to README
M03ED Feb 8, 2025
8a6afc7
fix: url in readme
M03ED Feb 8, 2025
2412b8a
feat: add build docker image workflow
M03ED Feb 8, 2025
4c4e678
fix: docke file
M03ED Feb 8, 2025
dac5b98
fix: make file for alpine
M03ED Feb 8, 2025
6a9cd8d
fix: readme typo
M03ED Feb 8, 2025
a81118c
fix: rest content type
M03ED Feb 8, 2025
17ba8d7
fix: prevent panic in middleware
M03ED Feb 8, 2025
d1284a8
feat: leave reset statistics to client
M03ED Feb 10, 2025
0f2285e
feat: add docker compose file
M03ED Feb 10, 2025
adbb45c
refactore: replace long pulling with sse
M03ED Feb 14, 2025
99bae39
fix: kcp for flow
ImMohammad20000 Feb 16, 2025
ea2f6cf
Merge pull request #4 from ImMohammad20000/fix
M03ED Feb 16, 2025
4cbea33
feat: check inbound more carefuly
M03ED Feb 16, 2025
dfc97cc
feat: add python library to readme
M03ED Feb 16, 2025
abaa615
refactor: re-write workflows
M03ED Feb 17, 2025
4f8119d
chore: avoid generating binary for not popular os
M03ED Feb 18, 2025
254c14c
fix: module name in files
M03ED Feb 19, 2025
4140893
fix: name in make file
M03ED Feb 19, 2025
06930f1
bump to version v1.0.0
M03ED Feb 23, 2025
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
18 changes: 8 additions & 10 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
SERVICE_PORT = 62050
XRAY_API_PORT = 62051
NODE_HOST = "0.0.0.0"

# use absolute path

# XRAY_EXECUTABLE_PATH = /usr/local/bin/xray
# XRAY_ASSETS_PATH = /usr/local/share/xray

SSL_CERT_FILE = /var/lib/gozargah-node/certs/ssl_cert.pem
SSL_KEY_FILE = /var/lib/gozargah-node/certs/ssl_key.pem
SSL_CLIENT_CERT_FILE = /var/lib/gozargah-node/certs/ssl_client_cert.pem

SSL_CERT_FILE = /var/lib/marzban-node/ssl_cert.pem
SSL_KEY_FILE = /var/lib/marzban-node/ssl_key.pem
SSL_CLIENT_CERT_FILE = /var/lib/marzban-node/ssl_client_cert.pem

### can be rest or rpyc
# go version only support rest protocol
# SERVICE_PROTOCOL = rpyc
### can be rest or grpc
# SERVICE_PROTOCOL = grpc
# MAX_LOG_PER_REQUEST = 1000

### for developers
# DEBUG = false
# works only when debug is true
# GENERATED_CONFIG_PATH = /var/lib/marzban-node/generated_config-debug.json
# GENERATED_CONFIG_PATH = /var/lib/gozargah-node/generated
57 changes: 57 additions & 0 deletions .github/workflows/docker-build-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Build and Push Docker Image (All Branches)

on:
push:
branches:
- '*'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/m03ed/gozargah-node

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
m03ed/gozargah-node:${{ github.ref_name }}
ghcr.io/m03ed/gozargah-node:${{ github.ref_name }}

labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
64 changes: 64 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Build and Push Docker Image (On Release)

on:
release:
types: [created]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/m03ed/gozargah-node

- name: Set Docker tags
id: tags
run: |
if [ "${{ github.event.release.prerelease }}" = "true" ]; then
# Pre-release: only version tags
echo "DOCKER_TAGS=m03ed/gozargah-node:${{ github.ref_name }},ghcr.io/m03ed/gozargah-node:${{ github.ref_name }}" >> $GITHUB_ENV
else
# Regular release: version tags + latest tags
echo "DOCKER_TAGS=m03ed/gozargah-node:${{ github.ref_name }},m03ed/gozargah-node:latest,ghcr.io/m03ed/gozargah-node:${{ github.ref_name }},ghcr.io/m03ed/gozargah-node:latest" >> $GITHUB_ENV
fi

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ env.DOCKER_TAGS }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
143 changes: 143 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
name: Create Release

on:
release:
types: [created]

jobs:
build:
permissions:
contents: write
strategy:
matrix:
# Include amd64 on all platforms.
goos:
# - windows
- freebsd
- openbsd
- linux
# - darwin

goarch: [ amd64, 386 ]
gotoolchain: [ "" ]
patch-assetname: [ "" ]

# exclude:

include:
# BEGIN MacOS ARM64
# - goos: darwin
# goarch: arm64
# END MacOS ARM64
# BEGIN Linux ARM 5 6 7
- goos: linux
goarch: arm
goarm: 7
- goos: linux
goarch: arm
goarm: 6
- goos: linux
goarch: arm
goarm: 5
# END Linux ARM 5 6 7
# Windows ARM
# - goos: windows
# goarch: arm64
# - goos: windows
# goarch: arm
# goarm: 7
# BEGIN Other architectures
# BEGIN ARM64
- goos: linux
goarch: arm64
# END ARM64
#BEGIN riscv64 & LOONG64
# - goos: linux
# goarch: riscv64
# - goos: linux
# goarch: loong64
# END riscv64 & LOONG64
# BEGIN MIPS
# - goos: linux
# goarch: mips64
# - goos: linux
# goarch: mips64le
# - goos: linux
# goarch: mipsle
# - goos: linux
# goarch: mips
# END MIPS
# BEGIN PPC
# - goos: linux
# goarch: ppc64
# - goos: linux
# goarch: ppc64le
# END PPC
# BEGIN FreeBSD ARM
- goos: freebsd
goarch: arm64
- goos: freebsd
goarch: arm
goarm: 7
# END FreeBSD ARM
# BEGIN S390X
- goos: linux
goarch: s390x
# END S390X
# END Other architectures
# BEGIN OPENBSD ARM
- goos: openbsd
goarch: arm64
- goos: openbsd
goarch: arm
goarm: 7
# END OPENBSD ARM
fail-fast: false

runs-on: ubuntu-latest
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
GOARM: ${{ matrix.goarm }}
CGO_ENABLED: 0
steps:
- name: Checkout codebase
uses: actions/checkout@v4

- name: Show workflow information
run: |
_GOARM="${GOARM:-""}"
if [ -n "$_GOARM" ]; then
_NAME="${GOOS}-${GOARCH}-${_GOARM}"
else
_NAME="${GOOS}-${GOARCH}"
fi
echo "ASSET_NAME=$_NAME" >> $GITHUB_ENV
echo "BINARY_NAME=gozargah-node-${_NAME}" >> $GITHUB_ENV

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.gotoolchain || '1.24.0' }}
check-latest: true

- name: Get project dependencies
run: make deps

- name: Build binary and zip
run: |
make
find . -type f -name "gozargah-node*" -exec mv {} "./gozargah-node-${{ env.ASSET_NAME }}" \;
# Create zip file with max compression and include README & LICENSE
zip -9 "./gozargah-node-${{ env.ASSET_NAME }}.zip" "./gozargah-node-${{ env.ASSET_NAME }}" README.md LICENSE

- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./gozargah-node-${{ env.ASSET_NAME }}.zip
asset_name: gozargah-node-${{ env.ASSET_NAME }}.zip
asset_content_type: application/zip
38 changes: 38 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Test Modules

on:
push:
branches:
- '*'
pull_request:
branches:
- '*'

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout codebase
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.gotoolchain || '1.24.0' }}
check-latest: true

- name: Get project dependencies
run: make deps

- name: Install xray-core
run: make install_xray

- name: Create certificate
run: |
mkdir certs
make generate_server_cert
make generate_client_cert

- name: Run tests
run: make test
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
*.dll
*.so
*.dylib
*xray.json
# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out
*.idea
./certs
./generated

# Dependency directories (remove the comment below to include it)
# vendor/
Expand Down
39 changes: 39 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Contribute to Gozargah-Node-Go
Thanks for considering contributing to Gozargah!

## Questions

Please don't ask your questions in issues. Instead, use one of the following ways to ask:
- Ask on our telegram group: [@Gozargah_Marzban](https://t.me/gozargah_marzban)
- Ask on our [Node GitHub Discussions](https://github.com/m03ed/gozargah_node_go/discussions) for long term discussion or larger questions.
- Ask on our [Marzban GitHub Discussions](https://github.com/gozargah/marzban/discussions) for long term discussion or larger questions.

## Reporting issues

Include the following information in your post:
- Describe what you expected to happen.
- Describe what actually happened. Include server logs or any error that browser shows.
- If possible, post your core config file and what you have set in env (by censoring critical information).
- Also tell the version of Marzban, Core and docker (if you use docker) you are using.

# Submitting a Pull Request
If there is not an open issue for what you want to submit, prefer opening one for discussion before working on a PR. You can work on any issue that doesn't have an open PR linked to it or a maintainer assigned to it. These show up in the sidebar. No need to ask if you can work on an issue that interests you.
<br/>
Before you create a PR, make sure to run tests using the `make test` command to prevent any bugs.

## Branches
When starting development on this project, please make sure to create a new branch off the `dev` branch. This helps to keep the `main` branch stable and free of any development work that may not be complete or fully tested.

## Project Structure
```
├───backend # Backend handler and interfaces
│ └───xray # Xray methods and jobs
│ └───api # Xray API handler
├───common # Proto files and common object structures
├───config # Reads .env configuration
├───controller # Service controllers for managing API interactions
│ ├───rest # REST API protocol methods
│ └───rpc # gRPC protocol methods
├───logger # primary logger for backend logs
└───tools # Standalone utilities with no project dependencies
```
Loading
Loading