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
4 changes: 0 additions & 4 deletions .coveragerc

This file was deleted.

66 changes: 66 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Python
__pycache__/
*.py[cod]
*.pyo
*.pyd
*.so

# Virtual environments
.venv/
venv/
env/
mac-venv/
mac-venv-py313/

# uv cache
.uv/

# Distribution / build
build/
dist/
*.egg-info/
*.egg

# Testing / coverage
.tox/
htmlcov/
.coverage
.coverage.*
.pytest_cache/
.ruff_cache/
.pyright/
coverage.xml

# Version control
.git/
.gitignore

# IDE / editor
.idea/
.vscode/
*.DS_Store

# Documentation build output
doc/build/

# Secrets / local config
etc/yabgp/yabgp.ini

# CI
.github/

# Cursor AI
.claude/
.cursor/

# Development-only directories (not needed in production image)
tools/
doc/
example/
bin/
yabgp/tests/

# Documentation files
*.rst
*.md
.mailmap
35 changes: 18 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This workflow will install Python dependencies, run tests with a variety of Python versions
# This workflow installs Python dependencies and runs tests on Python 3.13
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: CI
Expand All @@ -17,32 +17,33 @@ jobs:
strategy:
fail-fast: false
matrix:
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
os: [ ubuntu-20.04, macos-latest, windows-latest ]
python-version: [ "3.6", "3.x" ]
exclude:
- python-version: "3.x"
os: [ ubuntu-latest, macos-latest, windows-latest ]
python-version: [ "3.13" ]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Set up uv
uses: astral-sh/setup-uv@v5

- name: Display Python version
run: python -c "import sys; print(sys.version)"

- name: Install tox and other dependencies
- name: Sync dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install tox
python -m pip install -r requirements.txt
python -m pip install -r test-requirements.txt
uv --version
uv sync --locked --group test --group dev

- name: Run tests
run: uv run pytest yabgp/tests/unit/ --tb=short -q

- name: Run tox
run: tox -e pep8 -c tox.ini
- name: Lint
run: uv run ruff check yabgp/

- name: Run unittest
run: python run_test.py
- name: Type check
run: uv run pyright -p pyrightconfig.json
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,13 @@ pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.venv/
.ruff_cache/
.pyright/
.coverage
.coverage.*
.cache
.pytest_cache/
nosetests.xml
coverage.xml
*,cover
Expand Down Expand Up @@ -70,3 +74,5 @@ covhtml/
doc/build
*.DS_Store
.vscode/settings.json
mac-venv/
.claude/
4 changes: 0 additions & 4 deletions .testr.conf

This file was deleted.

14 changes: 10 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
FROM python:2.7.14-alpine
FROM python:3.13-alpine

LABEL maintainer="Peng Xiao <xiaoquwl@gmail.com>"

# Install uv binary from official image
COPY --from=ghcr.io/astral-sh/uv:0.9.15 /uv /bin/uv

RUN apk add --no-cache gcc musl-dev g++

ADD . /yabgp
COPY . /yabgp

WORKDIR /yabgp

RUN pip install -r requirements.txt && python setup.py install
ENV UV_LINK_MODE=copy

RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --locked --no-dev

EXPOSE 8801

VOLUME ["~/data"]

ENTRYPOINT ["/usr/local/bin/yabgpd"]
ENTRYPOINT ["/yabgp/.venv/bin/yabgpd"]

CMD []
24 changes: 17 additions & 7 deletions HACKING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,29 @@ Step 3: Read on
Running Tests
-------------

Run tox
Using uv + pytest (recommended):

.. code:: bash

$ cd yabgp
$ tox
$ uv sync --group test --group dev
$ uv run pytest yabgp/tests/unit/ -v

Running Lint / Type Check
-------------------------

.. code:: bash

$ cd yabgp
$ uv run ruff check yabgp/ --exclude yabgp/tests
$ uv run pyright


Building Docs
-------------

Run tox

.. code:: bash

$ cd yabgp
$ tox
$ uv sync --group docs
$ uv run sphinx-build -b html doc/source doc/build
36 changes: 16 additions & 20 deletions README-zh.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,22 @@ YABGP是另一种BGP协议的Python实现。它可以和各种路由器(包括

我们严格遵循RFCs文档的约定开发此项目。

此软件可应用于Linux/Unix,Mac OS和windows系统。
此软件可应用于Linux/Unix、Mac OS和Windows系统。需要 Python >= 3.13。
TCP MD5认证仅支持Linux。

功能
~~~~~~~~

- 它可以通过IPv4地址以主动模式(作为TCP客户端)建立BGP会话连接。

- 支持TCP的MD5认证(只有IPv4并且不支持windows系统
- 支持TCP的MD5认证(只有IPv4

- BGP capabilities支持:4字节的ASN,Route Refresh(Cisco Route Refresh),添加发送/接收路径;

- 地址族支持:

- IPv4/IPv6 Unicast

- IPv4/IPv6 Labeled Unicast

- IPv4 Flowspec(有限支持)
Expand All @@ -36,40 +37,37 @@ YABGP是另一种BGP协议的Python实现。它可以和各种路由器(包括
- IPv4/IPv6 MPLSVPN

- EVPN (部分支持)

- 解析所有BGP messages为json格式并写入本地文件(可配置);

- 支持通过基本的RESTFUL API获取对等体运行信息或者发送BGP messages。

快速开始
~~~~~~~~~~~

我们推荐在python的虚拟环境中运行``yabgp``,可以通过源码或者pip工具安装

源码安装:
**使用 uv(推荐):**

.. code:: bash

$ virtualenv yabgp-virl
$ source yabgp-virl/bin/activate
$ git clone https://github.com/smartbgp/yabgp
$ cd yabgp
$ pip install -r requirements.txt
$ cd bin
$ python yabgpd -h
$ uv sync
$ uv run yabgpd -h

pip安装:
**使用 pip:**

.. code:: bash

$ virtualenv yabgp-virl
$ source yabgp-virl/bin/activate
$ pip install yabgp
$ which yabgpd
/home/yabgp/yabgp-virl/bin/yabgpd
$ yabgpd -h

例如:
**使用 Docker:**

.. code:: bash

$ docker run -it smartbgp/yabgp:latest --bgp-afi_safi=ipv4 --bgp-local_as=65022 --bgp-remote_addr=10.75.44.219 --bgp-remote_as=65022

**例如:**

.. code:: bash

Expand All @@ -90,8 +88,6 @@ pip安装:
支持
~~~~~~~

加入Slack,欢迎问题与建议,我们一起讨论。http://smartbgp.slack.com/

可以发送email到xiaoquwl@gmail.com,或者在GitHub上提issue。

贡献
Expand Down
Loading
Loading