-
Notifications
You must be signed in to change notification settings - Fork 0
Multi protocol proxy #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
abnegate
wants to merge
51
commits into
main
Choose a base branch
from
dev
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
92a5b9f
Add adapter base
abnegate a5005ac
Performance tweaks
abnegate 722c4c7
Add coroutine server + benchmarks
abnegate aaa8df0
Add CI workflows and update config
abnegate 19a370c
Replace Service classes with Resolver pattern
abnegate 86ca764
Update adapters and servers to use Resolver
abnegate d883ab7
Update proxies, examples, and benchmarks for Resolver
abnegate b52f618
Update tests and add MockResolver
abnegate 2856ece
Update docs
abnegate 36e9663
Fix composer
abnegate caa4cd9
Remove platform
abnegate eebb9c9
Remove redundant dep
abnegate 334ad72
Fix trailing comma in composer.json
abnegate 06a084b
Merge pull request #1 from utopia-php/fix/composer-json-syntax
abnegate 9176c3d
Merge remote-tracking branch 'origin/main' into dev
abnegate e9ba926
perf: optimize TCP proxy for lower latency and higher throughput
abnegate 2abc68d
feat: add Linux performance tuning script for benchmarks
abnegate c1f6893
feat: add production-safe Linux tuning script
abnegate 324274c
feat: add one-shot droplet benchmark bootstrap script
abnegate 47aa0db
feat: add bootstrap test script for debugging
abnegate 90dd36e
fix: bootstrap script PHP/Swoole installation
abnegate bf6553b
docs: add Docker quick-test option to bootstrap script
abnegate e5104c6
feat: add sustained load test benchmark
abnegate 4d91d7d
feat: increase benchmark targets to 1M burst, 100k sustained
abnegate e202f99
Fix bench bootstraps
abnegate 8611a94
Update bench scripts
abnegate dcd9e15
Update docs
abnegate f7257b8
Update docs
abnegate 0723e59
Fix composer
abnegate d0e5d8e
Merge remote-tracking branch 'origin/main' into dev
abnegate e20ebae
(refactor): Use PHP 8.4 property hooks, readonly class, and optimise …
abnegate 2ff9a33
(refactor): Add PHPStan type annotations to HTTP and SMTP servers
abnegate 2eb0137
(refactor): Replace config array with named parameters in TCP server
abnegate 953f5fc
(chore): Update PHPStan memory limit and remove unused import
abnegate ed5a9be
Abstract config
abnegate 3c66bb6
Remove dep
abnegate 2d46040
(feat): Add TLS and TlsContext classes for TCP proxy TLS termination
abnegate 771243b
(feat): Add QueryParser and ReadWriteResolver for read/write split ro…
abnegate 2fac054
(feat): Integrate TLS termination, read/write split, MongoDB support,…
abnegate fe7b9fc
(test): Add tests for QueryParser, read/write split, integration, and…
abnegate 40150e1
(refactor): Collapse adapter hierarchy, add Protocol enum, rename Res…
abnegate 6bad65c
(refactor): Extract query parser to utopia-php/query dependency
abnegate 1d91e37
(test): Update tests for adapter refactor and query parser extraction
abnegate 4b81d8d
(style): Convert test method names from snake_case to camelCase
abnegate e2c66a7
(chore): Update Dockerfile and remove unused files
abnegate 27d1e9e
(docs): Update README to match current codebase
abnegate 5d9b048
fix: resolve CI failures for composer, lint, and unit test workflows
abnegate c13ca9e
fix: use correct query package branch and resolve PHPStan errors
abnegate 48c8f49
fix: relax parse performance threshold for CI runners
abnegate 18d464f
(chore): Remove orphaned docblock, profanity in comments, and section…
abnegate 3305edd
(test): Add 217 unit tests for TLS, Config, byte tracking, endpoint v…
abnegate File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| .git | ||
| .gitignore | ||
| .idea | ||
| vendor | ||
| *.md | ||
| .dockerignore | ||
| Dockerfile | ||
| docker-compose.yml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # Database Configuration | ||
| DB_HOST=mariadb | ||
| DB_PORT=3306 | ||
| DB_USER=appwrite | ||
| DB_PASS=password | ||
| DB_NAME=appwrite | ||
|
|
||
| # Redis Configuration | ||
| REDIS_HOST=redis | ||
| REDIS_PORT=6379 | ||
|
|
||
| # Compute API Configuration | ||
| COMPUTE_API_URL=http://appwrite-api/v1/compute | ||
| COMPUTE_API_KEY= | ||
|
|
||
| # MySQL Root Password (for docker-compose) | ||
| MYSQL_ROOT_PASSWORD=rootpassword | ||
|
|
||
| # TLS Configuration (for TCP proxy) | ||
| PROXY_TLS_ENABLED=false | ||
| PROXY_TLS_CERT= | ||
| PROXY_TLS_KEY= | ||
| PROXY_TLS_CA= | ||
| PROXY_TLS_REQUIRE_CLIENT_CERT=false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| name: Integration Tests | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| branches: [main] | ||
|
|
||
| jobs: | ||
| integration: | ||
| name: Integration Tests | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup PHP | ||
| uses: shivammathur/setup-php@v2 | ||
| with: | ||
| php-version: '8.4' | ||
| extensions: swoole, redis, sockets | ||
| tools: composer:v2 | ||
|
|
||
| - name: Install dependencies | ||
| run: composer install --prefer-dist --no-progress | ||
|
|
||
| - name: Run integration tests | ||
| run: composer test:integration |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| name: Lint | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| branches: [main] | ||
|
|
||
| jobs: | ||
| pint: | ||
| name: Laravel Pint | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup PHP | ||
| uses: shivammathur/setup-php@v2 | ||
| with: | ||
| php-version: '8.4' | ||
| extensions: swoole, redis | ||
| tools: composer:v2 | ||
|
|
||
| - name: Install dependencies | ||
| run: composer install --no-interaction --prefer-dist | ||
|
|
||
| - name: Run Pint | ||
| run: composer lint |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| name: Static Analysis | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| branches: [main] | ||
|
|
||
| jobs: | ||
| phpstan: | ||
| name: PHPStan | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup PHP | ||
| uses: shivammathur/setup-php@v2 | ||
| with: | ||
| php-version: '8.4' | ||
| extensions: swoole, redis | ||
| tools: composer:v2 | ||
|
|
||
| - name: Install dependencies | ||
| run: composer install --no-interaction --prefer-dist | ||
|
|
||
| - name: Run PHPStan | ||
| run: composer check |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| name: Tests | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| branches: [main] | ||
|
|
||
| jobs: | ||
| unit: | ||
| name: Unit Tests | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Build test image | ||
| run: | | ||
| docker build -t protocol-proxy-test --target test -f Dockerfile.test . | ||
|
|
||
| - name: Run tests | ||
| run: | | ||
| docker run --rm protocol-proxy-test composer test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,16 @@ | ||
| /vendor/ | ||
| /composer.lock | ||
| /.phpunit.cache | ||
| /.phpunit.result.cache | ||
| /.php-cs-fixer.cache | ||
| /phpstan.neon | ||
| /.idea/ | ||
| .DS_Store | ||
| *.log | ||
| /coverage/ | ||
|
|
||
| # Environment files | ||
| .env | ||
|
|
||
| # Docker volumes | ||
| /docker-volumes/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| FROM php:8.4.18-cli-alpine3.23 | ||
|
|
||
| RUN apk update && apk upgrade && apk add --no-cache \ | ||
| autoconf \ | ||
| g++ \ | ||
| make \ | ||
| linux-headers \ | ||
| libstdc++ \ | ||
| brotli-dev \ | ||
| libzip-dev \ | ||
| openssl-dev \ | ||
| && rm -rf /var/cache/apk/* | ||
|
|
||
| RUN docker-php-ext-install \ | ||
| pcntl \ | ||
| sockets \ | ||
| zip | ||
|
|
||
| RUN pecl channel-update pecl.php.net | ||
|
|
||
| RUN pecl install swoole && \ | ||
| docker-php-ext-enable swoole | ||
|
|
||
| RUN pecl install redis && \ | ||
| docker-php-ext-enable redis | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| COPY composer.json ./ | ||
| COPY --from=composer:latest /usr/bin/composer /usr/bin/composer | ||
| RUN composer install \ | ||
| --no-dev \ | ||
| --optimize-autoloader \ | ||
| --ignore-platform-reqs | ||
|
|
||
| COPY . . | ||
|
|
||
| EXPOSE 8080 8081 8025 | ||
|
|
||
| CMD ["php", "proxies/http.php"] | ||
|
Comment on lines
+36
to
+40
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Drop root before starting the proxy. This container still runs as root at runtime. The proxy only binds to unprivileged ports, so it should run as a dedicated user instead of keeping full container privileges. Proposed change+RUN addgroup -S app && adduser -S -G app app
+
-COPY . .
+COPY --chown=app:app . .
+RUN chown -R app:app /app
EXPOSE 8080 8081 8025
+USER app
CMD ["php", "proxies/http.php"]🤖 Prompt for AI Agents |
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| FROM php:8.4-cli-alpine AS test | ||
|
|
||
| RUN apk add --no-cache \ | ||
| autoconf \ | ||
| g++ \ | ||
| make \ | ||
| linux-headers \ | ||
| libstdc++ \ | ||
| brotli-dev \ | ||
| libzip-dev \ | ||
| openssl-dev | ||
|
|
||
| RUN docker-php-ext-install \ | ||
| pcntl \ | ||
| sockets \ | ||
| zip | ||
|
|
||
| RUN pecl channel-update pecl.php.net && \ | ||
| pecl install swoole && \ | ||
| docker-php-ext-enable swoole | ||
|
|
||
| RUN pecl install redis && \ | ||
| docker-php-ext-enable redis | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| COPY composer.json ./ | ||
| COPY --from=composer:latest /usr/bin/composer /usr/bin/composer | ||
| RUN composer install \ | ||
| --optimize-autoloader \ | ||
| --ignore-platform-reqs | ||
|
|
||
| COPY . . |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: utopia-php/protocol-proxy
Length of output: 79
🏁 Script executed:
cat -n Dockerfile | head -50Repository: utopia-php/protocol-proxy
Length of output: 1089
🏁 Script executed:
Repository: utopia-php/protocol-proxy
Length of output: 1895
Remove
--ignore-platform-reqsto validate required extensions.The Dockerfile installs
ext-swooleandext-redisbefore running Composer, andcomposer.jsonexplicitly requires both extensions. Using--ignore-platform-reqssuppresses Composer's platform validation, masking installation failures and deferring errors to runtime. Remove the flag to ensure Composer verifies that the required extensions are actually available.Proposed change
RUN composer install \ --no-dev \ - --optimize-autoloader \ - --ignore-platform-reqs + --optimize-autoloader📝 Committable suggestion
🤖 Prompt for AI Agents