admin 7 лет назад
Родитель
Сommit
d271cec82c

+ 22 - 13
app/Http/Controllers/AuthController.php

@@ -733,23 +733,32 @@ class AuthController extends Controller
      */
     private function addUserLoginLog($userId, $ip)
     {
-        // 通过纯真IP库解析IP信息
-        $ipInfo = QQWry::ip($ip);
-        if (isset($ipInfo['error'])) {
-            Log::info('无法识别IP,可能是IPv6,尝试解析:' . $ip);
+        if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
+            Log::info('识别到IPv6,尝试解析:' . $ip);
             $ipInfo = getIPv6($ip);
+        } else {
+            $ipInfo = QQWry::ip($ip); // 通过纯真IP库解析IPv4信息
+            if (isset($ipInfo['error'])) {
+                Log::info('无法识别IPv4,尝试使用IPIP的IP库解析:' . $ip);
+                $ipip = IPIP::ip($ip);
+                $ipInfo = [
+                    'country'  => $ipip['country_name'],
+                    'province' => $ipip['region_name'],
+                    'city'     => $ipip['city_name']
+                ];
+            } else {
+                // 判断纯真IP库获取的国家信息是否与IPIP的IP库获取的信息一致,不一致则用IPIP的(因为纯真IP库的非大陆IP准确率较低)
+                $ipip = IPIP::ip($ip);
+                if ($ipInfo['country'] != $ipip['country_name']) {
+                    $ipInfo['country'] = $ipip['country_name'];
+                    $ipInfo['province'] = $ipip['region_name'];
+                    $ipInfo['city'] = $ipip['city_name'];
+                }
+            }
         }
 
         if (empty($ipInfo) || empty($ipInfo['country'])) {
-            Log::warning("获取IP地址信息异常:" . $ip);
-        }
-
-        // 判断是否与IPIP的IP库解析出来的信息一致,不一致则用IPIP的信息(因为纯真的非大陆IP正确率低)
-        $ipip = IPIP::ip($ip);
-        if ($ipInfo['country'] != $ipip['country_name']) {
-            $ipInfo['country'] = $ipip['country_name'];
-            $ipInfo['province'] = $ipip['region_name'];
-            $ipInfo['city'] = $ipip['city_name'];
+            Log::warning("获取IP信息异常:" . $ip);
         }
 
         $log = new UserLoginLog();

+ 23 - 4
app/Http/Middleware/isForbidden.php

@@ -3,6 +3,7 @@
 namespace App\Http\Middleware;
 
 use App\Components\Helpers;
+use App\Components\IPIP;
 use App\Components\QQWry;
 use Agent;
 use Log;
@@ -29,13 +30,31 @@ class isForbidden
             }
         }
 
-        $isIPv6 = false;
         $ip = getClientIP();
-        $ipInfo = QQWry::ip($ip);
-        if (isset($ipInfo['error'])) {
+        if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
+            Log::info('识别到IPv6,尝试解析:' . $ip);
             $isIPv6 = true;
-            Log::info('无法识别IP,可能是IPv6,尝试解析:' . $ip);
             $ipInfo = getIPv6($ip);
+        } else {
+            $isIPv6 = false;
+            $ipInfo = QQWry::ip($ip); // 通过纯真IP库解析IPv4信息
+            if (isset($ipInfo['error'])) {
+                Log::info('无法识别IPv4,尝试使用IPIP的IP库解析:' . $ip);
+                $ipip = IPIP::ip($ip);
+                $ipInfo = [
+                    'country'  => $ipip['country_name'],
+                    'province' => $ipip['region_name'],
+                    'city'     => $ipip['city_name']
+                ];
+            } else {
+                // 判断纯真IP库获取的国家信息是否与IPIP的IP库获取的信息一致,不一致则用IPIP的(因为纯真IP库的非大陆IP准确率较低)
+                $ipip = IPIP::ip($ip);
+                if ($ipInfo['country'] != $ipip['country_name']) {
+                    $ipInfo['country'] = $ipip['country_name'];
+                    $ipInfo['province'] = $ipip['region_name'];
+                    $ipInfo['city'] = $ipip['city_name'];
+                }
+            }
         }
 
         // 拒绝无IP请求

+ 15 - 2
app/helpers.php

@@ -157,7 +157,20 @@ if (!function_exists('getIPv6')) {
      *     "country_code3": "CHN",
      *     "continent_code": "AS",
      *     "country_code": "CN"
-     *  }
+     * }
+     *
+     * {
+     *     "longitude": 105,
+     *     "latitude": 35,
+     *     "area_code": "0",
+     *     "dma_code": "0",
+     *     "organization": "AS9808 Guangdong Mobile Communication Co.Ltd.",
+     *     "country": "China",
+     *     "ip": "2409:8a74:487:1f30:5178:e5a5:1f36:3525",
+     *     "country_code3": "CHN",
+     *     "continent_code": "AS",
+     *     "country_code": "CN"
+     * }
      */
     function getIPv6($ip)
     {
@@ -177,7 +190,7 @@ if (!function_exists('getIPv6')) {
 
             $result = json_decode($result, true);
             if (!is_array($result) || isset($result['code'])) {
-                throw new Exception('解析IPv6信息异常:' . $ip);
+                throw new Exception('解析IPv6异常:' . $ip);
             }
 
             return $result;

+ 1 - 1
public/clients/ipa.plist

@@ -10,7 +10,7 @@
                         <key>kind</key>
                         <string>software-package</string>
                         <key>url</key>
-                        <string>https://demo.ssrpanel.com/clients/Shadowrocket_2.1.23.ipa</string>
+                        <string>https://demo.ssrpanel.com/clients/Shadowrocket-2.1.23.ipa</string>
                     </dict>
                 </array>
                 <key>metadata</key>

+ 16 - 17
readme.md

@@ -1,45 +1,44 @@
 # SSRPanel
-Support ShadowsocksR、ShadowsocksRR、V2Ray
+Support but not limited to: Shadowsocks,ShadowsocksR,ShadowsocksRR,V2Ray
 
-[Demo](https://demo.ssrpanel.com)
-
-[Telegram](https://t.me/ssrpanel)
-
-[Issues](https://github.com/ssrpanel/SSRPanel/issues)
-
-[WIKI](https://github.com/ssrpanel/SSRPanel/wiki)
+- [Demo](https://demo.ssrpanel.com)
+- [Telegram](https://t.me/ssrpanel)
+- [Issues](https://github.com/ssrpanel/SSRPanel/issues)
+- [WIKI](https://github.com/ssrpanel/SSRPanel/wiki)
 
 ## Donate
 **ETH** : 0x968f797f194fcec05ea571723199748b58de38ba
 
-![Chat in Telegram](https://github.com/ssrpanel/ssrpanel/blob/master/public/assets/images/donate.jpg?raw=true)
+![Chat in Telegram](https://i.loli.net/2019/01/10/5c37189a75edd.png)
 
 [VPS Recommend](https://github.com/ssrpanel/SSRPanel/wiki/VPS%E6%8E%A8%E8%8D%90&%E8%B4%AD%E4%B9%B0%E7%BB%8F%E9%AA%8C)
 
 ## Requirements
 - PHP 7.1.3 +
 - Mysql 5.5 +
-- Memory 1G + 
+- Memory 1G +
 - Disk 10G +
-- PHP Extensions: ZIP、XML、CURL、GD2、FileInfo、OpenSSL、Mbstring、PDO、Tokenizer、Ctype、JSON、BCMath 
+- PHP Extensions: ZIP、XML、CURL、GD2、FileInfo、OpenSSL、Mbstring、PDO、Tokenizer、Ctype、JSON、BCMath
+- Laravel 5.6
 
 ## Thanks
 - [@shadowsocks](https://github.com/shadowsocks)
+- [@V2Ray](https://www.v2ray.com)
 - [@breakwa11](https://github.com/breakwa11)
 - [@glzjin](https://github.com/esdeathlove)
 - [@orvice](https://github.com/orvice)
-- [@ToyoDAdoubi](https://github.com/ToyoDAdoubi)
-- [@V2Ray](https://www.v2ray.com)
-- [@91yun](https://github.com/91yun)
 - [@Akkariiin](https://github.com/shadowsocksrr)
-- [@tonychanczm](https://github.com/tonychanczm)
 - [@aiyahacke](https://github.com/aiyahacke)
 - [@ColetteContreras](https://github.com/ColetteContreras)
+- [@rc452860](https://github.com/rc452860)
+- [@pch18](https://github.com/pch18)
+- [@tonychanczm](https://github.com/tonychanczm)
+- [@91yun](https://github.com/91yun)
+- [@ToyoDAdoubi](https://github.com/ToyoDAdoubi)
 - [@ipcheck](https://ipcheck.need.sh)
 - [@cz88](http://www.cz88.net/index.shtml)
 - [@ip.sb](https://www.ip.sb)
-- [@aiyahacke](https://github.com/aiyahacke)
-- [@pch18](https://github.com/pch18/shadowsocksr)
+- [@ipip](https://www.ipip.net)
 
 ## License
 

+ 4 - 4
resources/views/vendor/laravel-log-viewer/log.blade.php

@@ -148,14 +148,14 @@
             @endif
             <div class="p-3">
                 @if($current_file)
-                    <a href="?dl={{ \Illuminate\Support\Facades\Crypt::encrypt($current_file) }}{{ ($current_folder) ? '&f=' . \Illuminate\Support\Facades\Crypt::encrypt($current_folder) : '' }}"><span class="fa fa-download"></span> Download file </a>
+                    <a href="?dl={{ \Illuminate\Support\Facades\Crypt::encrypt($current_file) }}{{ ($current_folder) ? '&f=' . \Illuminate\Support\Facades\Crypt::encrypt($current_folder) : '' }}"><span class="fa fa-download"></span> 下载 </a>
                     -
-                    <a id="clean-log" href="?clean={{ \Illuminate\Support\Facades\Crypt::encrypt($current_file) }}{{ ($current_folder) ? '&f=' . \Illuminate\Support\Facades\Crypt::encrypt($current_folder) : '' }}"><span class="fa fa-sync"></span> Clean file </a>
+                    <a id="clean-log" href="?clean={{ \Illuminate\Support\Facades\Crypt::encrypt($current_file) }}{{ ($current_folder) ? '&f=' . \Illuminate\Support\Facades\Crypt::encrypt($current_folder) : '' }}"><span class="fa fa-sync"></span> 清空 </a>
                     -
-                    <a id="delete-log" href="?del={{ \Illuminate\Support\Facades\Crypt::encrypt($current_file) }}{{ ($current_folder) ? '&f=' . \Illuminate\Support\Facades\Crypt::encrypt($current_folder) : '' }}"><span class="fa fa-trash"></span> Delete file </a>
+                    <a id="delete-log" href="?del={{ \Illuminate\Support\Facades\Crypt::encrypt($current_file) }}{{ ($current_folder) ? '&f=' . \Illuminate\Support\Facades\Crypt::encrypt($current_folder) : '' }}"><span class="fa fa-trash"></span> 删除 </a>
                     @if(count($files) > 1)
                         -
-                        <a id="delete-all-log" href="?delall=true{{ ($current_folder) ? '&f=' . \Illuminate\Support\Facades\Crypt::encrypt($current_folder) : '' }}"><span class="fa fa-trash-alt"></span> Delete all files </a>
+                        <a id="delete-all-log" href="?delall=true{{ ($current_folder) ? '&f=' . \Illuminate\Support\Facades\Crypt::encrypt($current_folder) : '' }}"><span class="fa fa-trash-alt"></span> 删除全部 </a>
                     @endif
                 @endif
             </div>