summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/ISSUE_TEMPLATE/bug_report.md38
-rw-r--r--.github/ISSUE_TEMPLATE/feature_request.md20
-rw-r--r--.github/workflows/ci-build.yml6
-rw-r--r--CHANGELOG.md6
-rw-r--r--README.md3
-rw-r--r--bors.toml2
-rwxr-xr-xbuild.sh2
-rw-r--r--composer.json4
-rw-r--r--service/http/handler.go16
-rw-r--r--src/HttpClient.php2
-rw-r--r--src/PSR7Client.php14
-rw-r--r--src/Worker.php30
12 files changed, 121 insertions, 22 deletions
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
new file mode 100644
index 00000000..448a1aa4
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -0,0 +1,38 @@
+---
+name: Bug report
+about: Create a report to help us improve
+title: "[BUG]"
+labels: B-bug, F-need-verification
+assignees: 48d90782
+
+---
+
+---
+name: Bug Report
+about: Issue in HTTP module <replace>
+labels: A-network <replace>
+---
+<!--
+Thank you for filing a bug report! 🐛 Please provide a short summary of the bug,
+along with any information you feel relevant to replicating the bug.
+-->
+
+I tried this code:
+
+```go
+<code>
+```
+
+I expected to see this happen: *explanation*
+
+Instead, this happened: *explanation*
+
+The version of RR used: *explanation*
+
+Errortrace, Backtrace or Panictrace
+```
+<backtrace>
+```
+
+</p>
+</details>
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
new file mode 100644
index 00000000..65ac962a
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/feature_request.md
@@ -0,0 +1,20 @@
+---
+name: Feature request
+about: Suggest an idea for this project
+title: "[FEATURE REQUEST]"
+labels: C-feature-request
+assignees: 48d90782, vvval, wolfy-j
+
+---
+
+**Is your feature request related to a problem? Please describe.**
+A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
+
+**Describe the solution you'd like**
+A clear and concise description of what you want to happen.
+
+**Describe alternatives you've considered**
+A clear and concise description of any alternative solutions or features you've considered.
+
+**Additional context**
+Add any other context or screenshots about the feature request here.
diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml
index 6045fd57..57edc624 100644
--- a/.github/workflows/ci-build.yml
+++ b/.github/workflows/ci-build.yml
@@ -9,7 +9,7 @@ jobs:
strategy:
fail-fast: false
matrix:
- php: [7.3, 7.4]
+ php: [7.2, 7.3, 7.4]
go: [1.13, 1.14]
os: [ubuntu-latest]
env:
@@ -57,8 +57,8 @@ jobs:
- name: Install Composer dependencies
run: composer install --prefer-dist --no-interaction --no-suggest # --prefer-source
- - name: Analyze PHP sources
- run: composer analyze
+# - name: Analyze PHP sources
+# run: composer analyze
- name: Install Go dependencies
run: go mod download
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 229609fd..b17ad8da 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,12 @@
CHANGELOG
=========
+v1.8.0 (05.05.2020)
+-------------------
+- Update goridge version to 2.4.0
+- Update PHP version to the 7.2 (currently minimum supported)
+- See the full milestone here: [link](https://github.com/spiral/roadrunner/issues?q=is%3Aclosed+milestone%3A1.8.0)
+
v1.7.1 (22.04.2020)
-------------------
- Syscall usage optimized. Now the data is packing and sending via 1 (or 2 in some cases) send_socket calls, instead of 2-3 (by @vvval)
diff --git a/README.md b/README.md
index 30eb2ab3..1c3439f0 100644
--- a/README.md
+++ b/README.md
@@ -44,7 +44,8 @@ Features:
- Payload context and body
- Protocol, worker and job level error management (including PHP errors)
- Very fast (~250k rpc calls per second on Ryzen 1700X using 16 threads)
-- Integrations with Symfony, Laravel, Slim, CakePHP, Zend Expressive, Spiral
+- Integrations with Symfony, Laravel, Slim, CakePHP, Zend Expressive
+- Application server for [Spiral](https://github.com/spiral/framework)
- Automatic reloading on file changes
- Works on Windows (Unix sockets (AF_UNIX) supported on Windows 10)
diff --git a/bors.toml b/bors.toml
index 51ac6357..cedaffb2 100644
--- a/bors.toml
+++ b/bors.toml
@@ -1,4 +1,6 @@
status = [
+'Build (PHP 7.2, Go 1.13, OS ubuntu-latest)',
+'Build (PHP 7.2, Go 1.14, OS ubuntu-latest)',
'Build (PHP 7.3, Go 1.13, OS ubuntu-latest)',
'Build (PHP 7.3, Go 1.14, OS ubuntu-latest)',
'Build (PHP 7.4, Go 1.13, OS ubuntu-latest)',
diff --git a/build.sh b/build.sh
index da6826f9..b14bcb88 100755
--- a/build.sh
+++ b/build.sh
@@ -3,7 +3,7 @@ cd $(dirname "${BASH_SOURCE[0]}")
OD="$(pwd)"
# Pushes application version into the build information.
-RR_VERSION=1.7.1
+RR_VERSION=1.8.0
# Hardcode some values to the core package
LDFLAGS="$LDFLAGS -X github.com/spiral/roadrunner/cmd/rr/cmd.Version=${RR_VERSION}"
diff --git a/composer.json b/composer.json
index fde54fa8..c4fa8609 100644
--- a/composer.json
+++ b/composer.json
@@ -14,10 +14,10 @@
}
],
"require": {
- "php": "^7.1",
+ "php": "^7.2",
"ext-json": "*",
"ext-curl": "*",
- "spiral/goridge": "^2.3",
+ "spiral/goridge": "^2.4",
"psr/http-factory": "^1.0",
"psr/http-message": "^1.0",
"symfony/console": "^2.5.0 || ^3.0.0 || ^4.0.0 || ^5.0.0",
diff --git a/service/http/handler.go b/service/http/handler.go
index 3c667035..ab7c382b 100644
--- a/service/http/handler.go
+++ b/service/http/handler.go
@@ -175,7 +175,23 @@ func (h *Handler) resolveIP(r *Request) {
return
}
+ // The logic here is the following:
+ // In general case, we only expect X-Real-Ip header. If it exist, we get the IP addres from header and set request Remote address
+ // But, if there is no X-Real-Ip header, we also trying to check CloudFlare headers
+ // True-Client-IP is a general CF header in which copied information from X-Real-Ip in CF.
+ // CF-Connecting-IP is an Enterprise feature and we check it last in order.
+ // This operations are near O(1) because Headers struct are the map type -> type MIMEHeader map[string][]string
if r.Header.Get("X-Real-Ip") != "" {
r.RemoteAddr = fetchIP(r.Header.Get("X-Real-Ip"))
+ return
+ }
+
+ if r.Header.Get("True-Client-IP") != "" {
+ r.RemoteAddr = fetchIP(r.Header.Get("True-Client-IP"))
+ return
+ }
+
+ if r.Header.Get("CF-Connecting-IP") != "" {
+ r.RemoteAddr = fetchIP(r.Header.Get("CF-Connecting-IP"))
}
}
diff --git a/src/HttpClient.php b/src/HttpClient.php
index 42c434a8..4ca152c8 100644
--- a/src/HttpClient.php
+++ b/src/HttpClient.php
@@ -34,7 +34,7 @@ final class HttpClient
* @return mixed[]|null Request information as ['ctx'=>[], 'body'=>string]
* or null if termination request or invalid context.
*/
- public function acceptRequest()
+ public function acceptRequest(): ?array
{
$body = $this->getWorker()->receive($ctx);
if (empty($body) && empty($ctx)) {
diff --git a/src/PSR7Client.php b/src/PSR7Client.php
index 98897890..777dd891 100644
--- a/src/PSR7Client.php
+++ b/src/PSR7Client.php
@@ -10,11 +10,11 @@ declare(strict_types=1);
namespace Spiral\RoadRunner;
use Psr\Http\Message\ResponseInterface;
-use Psr\Http\Message\UploadedFileInterface;
use Psr\Http\Message\ServerRequestFactoryInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\StreamFactoryInterface;
use Psr\Http\Message\UploadedFileFactoryInterface;
+use Psr\Http\Message\UploadedFileInterface;
/**
* Manages PSR-7 request and response.
@@ -69,7 +69,7 @@ class PSR7Client
/**
* @return ServerRequestInterface|null
*/
- public function acceptRequest()
+ public function acceptRequest(): ?ServerRequestInterface
{
$rawRequest = $this->httpClient->acceptRequest();
if ($rawRequest === null) {
@@ -101,11 +101,11 @@ class PSR7Client
}
if ($rawRequest['ctx']['parsed']) {
- $request = $request->withParsedBody(json_decode($rawRequest['body'], true));
- } else {
- if ($rawRequest['body'] !== null) {
- $request = $request->withBody($this->streamFactory->createStream($rawRequest['body']));
- }
+ return $request->withParsedBody(json_decode($rawRequest['body'], true));
+ }
+
+ if ($rawRequest['body'] !== null) {
+ return $request->withBody($this->streamFactory->createStream($rawRequest['body']));
}
return $request;
diff --git a/src/Worker.php b/src/Worker.php
index d9de0fa9..2da16e86 100644
--- a/src/Worker.php
+++ b/src/Worker.php
@@ -11,6 +11,8 @@ namespace Spiral\RoadRunner;
use Spiral\Goridge\Exceptions\GoridgeException;
use Spiral\Goridge\RelayInterface as Relay;
+use Spiral\Goridge\SocketRelay;
+use Spiral\Goridge\StreamRelay;
use Spiral\RoadRunner\Exception\RoadRunnerException;
/**
@@ -28,15 +30,19 @@ class Worker
// Send as response context to request worker termination
public const STOP = '{"stop":true}';
- /** @var Relay */
+ /** @var Relay|StreamRelay|SocketRelay */
private $relay;
+ /** @var bool */
+ private $optimizedRelay;
+
/**
* @param Relay $relay
*/
public function __construct(Relay $relay)
{
$this->relay = $relay;
+ $this->optimizedRelay = method_exists($relay, 'sendPackage');
}
/**
@@ -83,12 +89,22 @@ class Worker
*/
public function send(string $payload = null, string $header = null): void
{
- $this->relay->sendPackage(
- (string)$header,
- Relay::PAYLOAD_CONTROL | ($header === null ? Relay::PAYLOAD_NONE : Relay::PAYLOAD_RAW),
- (string)$payload,
- Relay::PAYLOAD_RAW
- );
+ if (!$this->optimizedRelay) {
+ if ($header === null) {
+ $this->relay->send('', Relay::PAYLOAD_CONTROL | Relay::PAYLOAD_NONE);
+ } else {
+ $this->relay->send($header, Relay::PAYLOAD_CONTROL | Relay::PAYLOAD_RAW);
+ }
+
+ $this->relay->send((string)$payload, Relay::PAYLOAD_RAW);
+ } else {
+ $this->relay->sendPackage(
+ (string)$header,
+ Relay::PAYLOAD_CONTROL | ($header === null ? Relay::PAYLOAD_NONE : Relay::PAYLOAD_RAW),
+ (string)$payload,
+ Relay::PAYLOAD_RAW
+ );
+ }
}
/**