|
|
@@ -1,4 +1,5 @@
|
|
|
<?php
|
|
|
+
|
|
|
/**
|
|
|
* This file is part of workerman.
|
|
|
*
|
|
|
@@ -51,7 +52,7 @@ if ($ifssl) {
|
|
|
// gateway名称,status方便查看
|
|
|
$gateway->name = 'WhisperGateway';
|
|
|
// gateway进程数
|
|
|
-$gateway->count = 4;
|
|
|
+$gateway->count = 8;
|
|
|
// 本机ip,分布式部署时使用内网ip
|
|
|
$gateway->lanIp = '127.0.0.1';
|
|
|
// 内部通讯起始端口,假如$gateway->count=4,起始端口为4000
|
|
|
@@ -78,7 +79,7 @@ $gateway->onConnect = function ($connection) {
|
|
|
$apiToken = md5(strtolower('Customer-Service' . $_SERVER['HTTP_ORIGIN']));
|
|
|
//echo $apiToken."/".$_GET['apiToken'];
|
|
|
$_SESSION['userAgent'] = $_SERVER['HTTP_USER_AGENT'];
|
|
|
- $_SESSION['origin'] = $_SERVER['HTTP_ORIGIN'];//
|
|
|
+ $_SESSION['origin'] = $_SERVER['HTTP_ORIGIN']; //
|
|
|
$getToken = isset($_GET['apiToken']) ? $_GET['apiToken'] : '';
|
|
|
|
|
|
if ($getToken !== $apiToken) {
|
|
|
@@ -88,7 +89,14 @@ $gateway->onConnect = function ($connection) {
|
|
|
}
|
|
|
$_SESSION['remotip'] = isset($_SERVER['HTTP_X_REAL_IP']) ? $_SERVER['HTTP_X_REAL_IP'] : $connection->getRemoteIp();
|
|
|
$_SESSION['remotport'] = $connection->getRemotePort();
|
|
|
- $_SERVER['REMOTE_ADDR'] = $_SESSION['remotip'];
|
|
|
+ //cdn处理
|
|
|
+ $ips = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
|
|
|
+
|
|
|
+ if (isset($ips[0]) && $ips[0]) {
|
|
|
+ $_SESSION['remotip'] = $ips[0];
|
|
|
+ }
|
|
|
+ //cdn处理
|
|
|
+ $_SERVER['REMOTE_ADDR'] = $_SESSION['remotip'];
|
|
|
|
|
|
|
|
|
// 可以在这里判断连接来源是否合法,不合法就关掉连接
|
|
|
@@ -106,4 +114,3 @@ $gateway->onConnect = function ($connection) {
|
|
|
if (!defined('GLOBAL_START')) {
|
|
|
Worker::runAll();
|
|
|
}
|
|
|
-
|