Skip to content

Commit 23eec43

Browse files
committed
feat: fix accessing nil backend and add exclude inbounds
1 parent 6e62bb9 commit 23eec43

40 files changed

Lines changed: 194 additions & 154 deletions

‎.env.example‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ NODE_HOST = "0.0.0.0"
66
# XRAY_EXECUTABLE_PATH = /usr/local/bin/xray
77
# XRAY_ASSETS_PATH = /usr/local/share/xray
88

9-
SSL_CERT_FILE = /var/lib/gozargah-node/certs/ssl_cert.pem
10-
SSL_KEY_FILE = /var/lib/gozargah-node/certs/ssl_key.pem
9+
SSL_CERT_FILE = /var/lib/pasarguard/certs/ssl_cert.pem
10+
SSL_KEY_FILE = /var/lib/pasarguard/certs/ssl_key.pem
1111

1212
# api key must be a valid uuid (you can use any version you want)
1313
API_KEY = xxxxxxxx-yyyy-zzzz-mmmm-aaaaaaaaaaa
@@ -17,5 +17,5 @@ API_KEY = xxxxxxxx-yyyy-zzzz-mmmm-aaaaaaaaaaa
1717

1818
### for developers
1919
# DEBUG = false
20-
# GENERATED_CONFIG_PATH = /var/lib/gozargah-node/generated
20+
# GENERATED_CONFIG_PATH = /var/lib/pasarguard/generated
2121
# CHANNELS_SIZE = 1000

‎.github/workflows/docker-build-dev.yml‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ on:
66

77
env:
88
REGISTRY: ghcr.io
9-
IMAGE_NAME: ${{ github.repository }}
9+
IMAGE: ${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ github.ref_name }}
10+
GHCR_IMAGE: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ github.ref_name }}
11+
BINARY_NAME: pasarguard-node-linux
1012

1113
jobs:
1214
build-and-push:
@@ -21,19 +23,19 @@ jobs:
2123
- name: Set up Go
2224
uses: actions/setup-go@v5
2325
with:
24-
go-version: '1.24.3'
26+
go-version: '1.25'
2527
check-latest: true
2628

2729
- name: Build binaries for all architectures
2830
run: |
2931
mkdir -p binaries
3032
# Build for amd64
3133
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 make build
32-
mv gozargah-node-linux-amd64 binaries/
34+
mv ${{env.BINARY_NAME}}-amd64 binaries/
3335
3436
# Build for arm64
3537
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 make build
36-
mv gozargah-node-linux-arm64 binaries/
38+
mv ${{env.BINARY_NAME}}-arm64 binaries/
3739
3840
ls -la binaries/
3941
@@ -64,7 +66,7 @@ jobs:
6466
platforms: linux/amd64,linux/arm64
6567
push: true
6668
tags: |
67-
m03ed/gozargah-node:${{ github.ref_name }}
68-
ghcr.io/m03ed/gozargah-node:${{ github.ref_name }}
69+
${{env.IMAGE}}
70+
${{env.GHCR_IMAGE}}
6971
cache-from: type=gha
70-
cache-to: type=gha,mode=max
72+
cache-to: type=gha,mode=max

‎.github/workflows/docker-build.yml‎

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ on:
66

77
env:
88
REGISTRY: ghcr.io
9-
IMAGE_NAME: ${{ github.repository }}
9+
IMAGE: ${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ github.ref_name }}
10+
GHCR_IMAGE: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ github.ref_name }}
11+
IMAGE_LATEST: ${{ github.repository_owner }}/${{ github.event.repository.name }}:latest
12+
GHCR_IMAGE_LATEST: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:latest
13+
BINARY_NAME: pasarguard-node-linux
1014

1115
jobs:
1216
build-and-push:
@@ -21,20 +25,20 @@ jobs:
2125
- name: Set up Go
2226
uses: actions/setup-go@v5
2327
with:
24-
go-version: '1.24.3'
28+
go-version: '1.25'
2529
check-latest: true
2630

2731
- name: Build binaries for all architectures
2832
run: |
2933
mkdir -p binaries
3034
# Build for amd64
3135
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 make build
32-
mv gozargah-node-linux-amd64 binaries/
33-
36+
mv ${{env.BINARY_NAME}}-amd64 binaries/
37+
3438
# Build for arm64
3539
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 make build
36-
mv gozargah-node-linux-arm64 binaries/
37-
40+
mv ${{env.BINARY_NAME}}-arm64 binaries/
41+
3842
ls -la binaries/
3943
4044
- name: Login to Docker Hub
@@ -60,17 +64,17 @@ jobs:
6064
id: meta
6165
uses: docker/metadata-action@v5
6266
with:
63-
images: ${{ env.REGISTRY }}/m03ed/gozargah-node
67+
images: ${{ env.REGISTRY }}/${{env.GHCR_IMAGE}}
6468

6569
- name: Set Docker tags
6670
id: tags
6771
run: |
6872
if [ "${{ github.event.release.prerelease }}" = "true" ]; then
6973
# Pre-release: only version tags
70-
echo "DOCKER_TAGS=m03ed/gozargah-node:${{ github.ref_name }},ghcr.io/m03ed/gozargah-node:${{ github.ref_name }}" >> $GITHUB_ENV
74+
echo "DOCKER_TAGS=${{env.IMAGE}},${{env.GHCR_IMAGE}}" >> $GITHUB_ENV
7175
else
7276
# Regular release: version tags + latest tags
73-
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
77+
echo "DOCKER_TAGS=${{env.IMAGE}},${{env.IMAGE_LATEST}},${{env.GHCR_IMAGE}},${{env.GHCR_IMAGE_LATEST}}" >> $GITHUB_ENV
7478
fi
7579
7680
- name: Build and push Docker image

‎.github/workflows/release.yml‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,12 @@ jobs:
113113
_NAME="${GOOS}-${GOARCH}"
114114
fi
115115
echo "ASSET_NAME=$_NAME" >> $GITHUB_ENV
116-
echo "BINARY_NAME=gozargah-node-${_NAME}" >> $GITHUB_ENV
116+
echo "BINARY_NAME=pasarguard-node-${_NAME}" >> $GITHUB_ENV
117117
118118
- name: Set up Go
119119
uses: actions/setup-go@v5
120120
with:
121-
go-version: ${{ matrix.gotoolchain || '1.24.3' }}
121+
go-version: ${{ matrix.gotoolchain || '1.25' }}
122122
check-latest: true
123123

124124
- name: Get project dependencies
@@ -127,9 +127,9 @@ jobs:
127127
- name: Build binary and zip
128128
run: |
129129
make
130-
find . -type f -name "gozargah-node*" -exec mv {} "./gozargah-node-${{ env.ASSET_NAME }}" \;
130+
find . -type f -name "pasarguard-node*" -exec mv {} "./pasarguard-node-${{ env.ASSET_NAME }}" \;
131131
# Create zip file with max compression and include README & LICENSE
132-
zip -9 "./gozargah-node-${{ env.ASSET_NAME }}.zip" "./gozargah-node-${{ env.ASSET_NAME }}" README.md LICENSE
132+
zip -9 "./pasarguard-node-${{ env.ASSET_NAME }}.zip" "./pasarguard-node-${{ env.ASSET_NAME }}" README.md LICENSE
133133
134134
- name: Upload Release Asset
135135
id: upload-release-asset
@@ -138,6 +138,6 @@ jobs:
138138
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
139139
with:
140140
upload_url: ${{ github.event.release.upload_url }}
141-
asset_path: ./gozargah-node-${{ env.ASSET_NAME }}.zip
142-
asset_name: gozargah-node-${{ env.ASSET_NAME }}.zip
141+
asset_path: ./pasarguard-node-${{ env.ASSET_NAME }}.zip
142+
asset_name: pasarguard-node-${{ env.ASSET_NAME }}.zip
143143
asset_content_type: application/zip

‎.github/workflows/run-tests.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Set up Go
2020
uses: actions/setup-go@v5
2121
with:
22-
go-version: ${{ matrix.gotoolchain || '1.24.3' }}
22+
go-version: ${{ matrix.gotoolchain || '1.25' }}
2323
check-latest: true
2424

2525
- name: Get project dependencies

‎Dockerfile‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.24.3 as base
1+
FROM golang:1.25 as base
22

33
WORKDIR /app
44
COPY go.mod .
@@ -22,4 +22,4 @@ COPY Makefile .
2222

2323
RUN make install_xray
2424

25-
ENTRYPOINT ["./main", "serve"]
25+
ENTRYPOINT ["./main"]

‎Dockerfile.multi‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ WORKDIR /app
88
COPY Makefile .
99

1010
ARG TARGETARCH
11-
COPY binaries/gozargah-node-linux-${TARGETARCH} ./main
11+
COPY binaries/pasarguard-node-linux-${TARGETARCH} ./main
1212
RUN chmod +x ./main
1313

1414
RUN make install_xray
1515

16-
ENTRYPOINT ["./main", "serve"]
16+
ENTRYPOINT ["./main"]

‎Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
NAME = gozargah-node-$(GOOS)-$(GOARCH)
1+
NAME = pasarguard-node-$(GOOS)-$(GOARCH)
22

33
LDFLAGS = -s -w -buildid=
44
PARAMS = -trimpath -ldflags "$(LDFLAGS)" -v

‎README.md‎

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
# Gozargah-Node-Go
1+
# PasarGuard-Node
22
<p align="center">
33
<a href="#">
4-
<img src="https://img.shields.io/github/actions/workflow/status/m03ed/gozargah-node/docker-build.yml?style=flat-square" />
4+
<img src="https://img.shields.io/github/actions/workflow/status/PasarGuard/node/docker-build.yml?style=flat-square" />
55
</a>
6-
<a href="https://hub.docker.com/r/gozargah/marzban" target="_blank">
7-
<img src="https://img.shields.io/docker/pulls/m03ed/gozargah-node?style=flat-square&logo=docker" />
6+
<a href="https://hub.docker.com/r/pasarguard/node" target="_blank">
7+
<img src="https://img.shields.io/docker/pulls/PasarGuard/node?style=flat-square&logo=docker" />
88
</a>
99
<a href="#">
10-
<img src="https://img.shields.io/github/license/m03ed/gozargah-node?style=flat-square" />
10+
<img src="https://img.shields.io/github/license/PasarGuard/node?style=flat-square" />
1111
</a>
1212
<a href="#">
13-
<img src="https://img.shields.io/github/stars/m03ed/gozargah-node?style=social" />
13+
<img src="https://img.shields.io/github/stars/PasarGuard/node?style=social" />
1414
</a>
1515
</p>
1616

@@ -20,7 +20,7 @@ This project is in the testing and development stage. The code may undergo major
2020
## Table of Contents
2121

2222
- [Overview](#overview)
23-
- [Why Use Gozargah Node?](#why-use-gozargah-node)
23+
- [Why Use PasarGuard Node?](#why-use-the-PasarGuard-node)
2424
- [Supported Cores](#supported-cores)
2525
- [Documentation](#documentation)
2626
- [Installation](#installation)
@@ -37,11 +37,11 @@ This project is in the testing and development stage. The code may undergo major
3737

3838
# Overview
3939

40-
Gozargah Node is developed by the Gozargah team to replace [Marzban-node](https://github.com/Gozargah/Marzban-node). It aims to be more stable, scalable, and efficient.
40+
The PasarGuard Node is developed by the PasarGuard team. It aims to be stable, scalable, and efficient.
4141

42-
## Why Use Gozargah Node?
42+
## Why use the PasarGuard Node?
4343

44-
We designed this project to be usable in any project, even without Marzban. You can run nodes with a simple script and the help of official libraries.
44+
We designed this project to be usable in any project, even without PasarGuard panel. You can run nodes with a simple script and the help of official libraries.
4545
We plan to expand supported cores after the testing stage, allowing you to use any core you want.
4646

4747
## Supported Cores
@@ -57,21 +57,21 @@ We plan to expand supported cores after the testing stage, allowing you to use a
5757
## Installation
5858

5959
### One Click
60-
run following command in you shell and use node
60+
run the following command in your shell and use node
6161
```shell
62-
sudo bash -c "$(curl -sL https://github.com/ImMohammad20000/Marzban-scripts/raw/master/gozargah-node.sh)" @ install
62+
sudo bash -c "$(curl -sL https://github.com/PasarGuard/scripts/raw/main/node-cli.sh)" @ install
6363
```
6464

6565
### Docker
6666
Install docker on your machine
6767
```shell
6868
curl -fsSL https://get.docker.com | sh
6969
```
70-
Download docker compose file
70+
Download a docker compose file
7171
```shell
72-
wget https://raw.githubusercontent.com/M03ED/gozargah-node/refs/heads/main/docker-compose.yml
72+
wget https://raw.githubusercontent.com/PasarGuard/node/refs/heads/main/docker-compose.yml
7373
```
74-
Configure your .env file and run node with following command
74+
Configure your .env file and run node with the following command
7575
```shell
7676
docker compose up -d
7777
```
@@ -80,9 +80,9 @@ docker compose up -d
8080
Install go on your system (https://go.dev/dl/)
8181
Clone the project
8282
```shell
83-
git clone https://github.com/M03ED/gozargah-node.git
83+
git clone https://github.com/PasarGuard/node.git
8484
```
85-
Generate binary file for your system
85+
Generate a binary file for your system
8686
```shell
8787
make deps
8888
make
@@ -95,7 +95,7 @@ Generate certificate based on your system network ip or domain
9595
```shell
9696
make generate_server_cert CN=example.com SAN="DNS:example.com,IP:your server ip"
9797
```
98-
Configure you .env file and run the binary
98+
Configure your `.env` file and run the binary
9999

100100

101101
## Configuration
@@ -114,7 +114,7 @@ Configure you .env file and run the binary
114114
| `SERVICE_PROTOCOL` | Protocol to use: `grpc` or `rest` (recommended: `grpc`). |
115115
| `MAX_LOG_PER_REQUEST` | Maximum number of logs per request (only for long polling in REST connections). |
116116
| `DEBUG` | Debug mode for development; prints core logs in the node server (default: `False`). |
117-
| `GENERATED_CONFIG_PATH` | Path to the generated config by the node (default: `/var/lib/gozargah-node/generated`). |
117+
| `GENERATED_CONFIG_PATH` | Path to the generated config by the node (default: `/var/lib/pasarguard/generated`). |
118118

119119
## SSL Configuration
120120

@@ -128,15 +128,15 @@ If you don't have access to a real domain or tools like `ACME`, you can use `sel
128128
Just replace the `CN` and `subjectAltName` values with your server information:
129129

130130
```shell
131-
openssl req -x509 -newkey rsa:4096 -keyout /var/lib/gozargah-node/certs/ssl_key.pem \
132-
-out /var/lib/gozargah-node/certs/ssl_cert.pem -days 36500 -nodes \
131+
openssl req -x509 -newkey rsa:4096 -keyout /var/lib/pasarguard/certs/ssl_key.pem \
132+
-out /var/lib/pasarguard/certs/ssl_cert.pem -days 36500 -nodes \
133133
-subj "/CN={replace with your server IP or domain}" \
134134
-addext "subjectAltName = {replace with alternative names you need}"
135135
```
136136

137137
## API
138138

139-
Gozargah Node supports two types of connection protocols: **gRPC** and **REST API**.
139+
PasarGuard Node supports two types of connection protocols: **gRPC** and **REST API**.
140140
We recommend using **gRPC**, with REST always available as a fallback option (in case there is a problem with gRPC).
141141

142142
### Data Structure
@@ -189,39 +189,39 @@ The node uses the `common/service.proto` file messages for both protocols.
189189
| `SyncUsers()` | `PUT`,`/users/sync` | `Users` | `Empty` | Removes all old users and replaces them with the provided users. |
190190

191191
# Official library
192-
We create some library's for you so make your job easier
192+
We create some library for you so make your job easier
193193

194194
## Go
195-
[gozargah-node-bridge](https://github.com/m03ed/gozargah_node_bridge)
195+
[node-bridge](https://github.com/PasarGuard/node_bridge)
196196

197-
To add bridge to your project use:
197+
To add `bridge` to your project use:
198198
```shell
199-
go get github.com/m03ed/gozargah_node_bridge
199+
go get github.com/PasarGuard/node_bridge
200200
```
201201
## Python
202-
[gozargah-node-bridge-py](https://github.com/m03ed/gozargah_node_bridge_py)
202+
[node-bridge-py](https://github.com/PasarGuard/node_bridge_py)
203203
```shell
204-
pip install gozargah-node-bridge
204+
pip install pasarguard-node-bridge
205205
```
206206

207207
# Donation
208-
You can help gozargah team with your donations, [Click Here](https://donate.gozargah.pro)
208+
You can help PasarGuard team with your donations, [Click Here](https://donate.pasarguard.org/)
209209

210210
# Contributors
211211

212-
We ❤️‍🔥 contributors! If you'd like to contribute, please check out our [Contributing Guidelines](CONTRIBUTING.md) and feel free to submit a pull request or open an issue. We also welcome you to join our [Telegram](https://t.me/gozargah_marzban) group for either support or contributing guidance.
212+
We ❤️‍🔥 contributors! If you'd like to contribute, please check out our [Contributing Guidelines](CONTRIBUTING.md) and feel free to submit a pull request or open an issue. We also welcome you to join our [Telegram](https://t.me/Pasar_Guard) group for either support or contributing guidance.
213213

214-
Check [open issues](https://github.com/m03ed/gozargah-node/issues) to help the progress of this project.
214+
Check [open issues](https://github.com/PasarGuard/node/issues) to help the progress of this project.
215215

216216
## Stargazers over time
217-
[![Stargazers over time](https://starchart.cc/M03ED/gozargah-node.svg?variant=adaptive)](https://starchart.cc/M03ED/gozargah-node)
217+
[![Stargazers over time](https://starchart.cc/PasarGuard/node.svg?variant=adaptive)](https://starchart.cc/PasarGuard/node)
218218

219219
<p align="center">
220-
Thanks to the all contributors who have helped improve Gozargah Node:
220+
Thanks to the all contributors who have helped improve PasarGuard Node:
221221
</p>
222222
<p align="center">
223-
<a href="https://github.com/m03ed/gozargah-node/graphs/contributors">
224-
<img src="https://contrib.rocks/image?repo=m03ed/gozargah-node" />
223+
<a href="https://github.com/PasarGuard/node/graphs/contributors">
224+
<img src="https://contrib.rocks/image?repo=PasarGuard/node" />
225225
</a>
226226
</p>
227227
<p align="center">

‎backend/backend.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package backend
33
import (
44
"context"
55

6-
"github.com/m03ed/gozargah-node/common"
6+
"github.com/pasarguard/node/common"
77
)
88

99
type Backend interface {

0 commit comments

Comments
 (0)