vndroid / Access

Guest Access Plugin for Typecho
https://wave.red
Apache License 2.0
10 stars 0 forks source link

ipv6地址记录问题 #1

Closed xhlove closed 4 years ago

xhlove commented 5 years ago

首先很高兴有人继续更新着Access这个插件,不过ipv6访问记录的问题还是没有修复,不知道能不能修复一下这个问题? 以ipv6网络访问,后台记录到的ip是0.0.0.0 这好像是插件使用的数据库字段和ip转换函数有关。

vndroid commented 5 years ago

Hi xhlove,

First, thank you for your issues, but I don't have an IPv6 test environment, I will fix it when I have the requirement.

xhlove commented 5 years ago

我倒是有ipv6的环境,不知道能不能帮上忙,不行的话我就只有等等了。

vndroid commented 5 years ago

Hi xhlove,

Please visit my blog https://vvave.net use IPv6 address. Let me try to fix it. Then tell me your IPv6 address.

My blog' provider does not support IPv6 now, Does your blog environment support IPv6?

xhlove commented 5 years ago

支持,地址是 --> https://blog.weimo.info 要怎么帮助你呢?

vndroid commented 5 years ago

Ok, I will try to fix it later.

vndroid commented 4 years ago

支持,地址是 --> https://blog.weimo.info 要怎么帮助你呢?

Can you give me your blog some of MySQL table data include IPv6 address typecho_access_log?

I will try to support IPv6.

xhlove commented 4 years ago

typecho_access_log中的字段和数据是这样的,其中ip是被转为十进制存的,ipv6访问会记录成0,因为access插件用的函数好像是ip2long,不支持ipv6的转换。不过在typecho_comments里面有ipv6地址的记录。 这是typecho_access_log

"id","ua","browser_id","browser_version","os_id","os_version","url","path","query_string","ip","entrypoint","entrypoint_domain","referer","referer_domain","time","content_id","meta_id","robot","robot_id","robot_version"
"6832","Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1","Safari","601.1","iPhone OS","9.1","/","/",\N,"606077778",\N,\N,\N,\N,"1578139777",\N,"0","0","",""
"6831","Mozilla/4.074482891 Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0","Internet Explorer","8.0","Windows","7","/","/",\N,"606077940",\N,\N,\N,\N,"1578139745",\N,"0","0","",""

这是typecho_comments(部分位置使用星号隐藏个人信息)

"coid","cid","created","author","authorId","ownerId","mail","url","ip","agent","text","type","status","parent"
"30","290","1546222421","未末","1","1","****@qq.com","http://blog.weimo.info","2605:***:***:***:216:3eff:fec0:cdf0","Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36","comment contents","comment","waiting","28"
vndroid commented 4 years ago

Thx.

vndroid commented 4 years ago

很愉快得通知您,新的分支已经开发完毕,如果可以得话您可以尝试使用并提供测试。

地址:https://github.com/Vndroid/Access/tree/mainline

新特性如下

效果如图 https://i.loli.net/2020/01/14/VkxGWh2R1O8TFSN.jpg 此链接有效期 7 天。

使用注意

在使用过程中遇到的问题可以更新至此 issue 中。

xhlove commented 4 years ago

这是nginx的访问日志:

101.* [15/Jan/2020:17:09:24 +0000] "GET /admin/extending.php?panel=Access%2Fpage%2Fconsole.php HTTP/1.1" 200 5403 "https://blog.weimo.info/admin/plugins.php" Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36 172.68.211.94 0.006
2409:* [15/Jan/2020:17:09:33 +0000] "GET /archive.html HTTP/1.1" 200 6687 "https://blog.weimo.info/blog/" Mozilla/5.0 (Linux; Android 9; Redmi K20 Pro) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.93 Mobile Safari/537.36 162.158.178.243 0.039
2409:* [15/Jan/2020:17:09:35 +0000] "GET /usr/themes/G/IMG/archive.svg HTTP/1.1" 200 3600 "https://blog.weimo.info/usr/themes/G/CSS/G.css" Mozilla/5.0 (Linux; Android 9; Redmi K20 Pro) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.93 Mobile Safari/537.36 162.158.178.31 0.000
101.* [15/Jan/2020:17:09:37 +0000] "GET /admin/extending.php?panel=Access%2Fpage%2Fconsole.php HTTP/1.1" 200 5701 "https://blog.weimo.info/admin/plugins.php" Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36 172.68.211.94 0.005
2409:* [15/Jan/2020:17:09:58 +0000] "GET /archive.html HTTP/1.1" 200 6627 "https://blog.weimo.info/blog/" Mozilla/5.0 (Linux; Android 9; Redmi K20 Pro) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.93 Mobile Safari/537.36 162.158.178.111 0.029
101.* [15/Jan/2020:17:10:00 +0000] "GET /admin/extending.php?panel=Access%2Fpage%2Fconsole.php HTTP/1.1" 200 5812 "https://blog.weimo.info/admin/plugins.php" Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36 172.68.211.94 0.005
101.* [15/Jan/2020:17:10:06 +0000] "GET /admin/extending.php?panel=Access%2Fpage%2Fconsole.php HTTP/1.1" 200 5812 "https://blog.weimo.info/admin/plugins.php" Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36 172.68.211.94 0.005
101.* [15/Jan/2020:17:10:19 +0000] "GET / HTTP/1.1" 200 3419 "-" Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36 172.69.35.7 0.013
101.* [15/Jan/2020:17:10:22 +0000] "GET /admin/extending.php?panel=Access%2Fpage%2Fconsole.php HTTP/1.1" 200 5941 "https://blog.weimo.info/admin/plugins.php" Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36 172.68.211.94 0.008
101.* [15/Jan/2020:17:10:23 +0000] "GET /usr/plugins/ExSearch/cache/cache-213a9f1824a14c143f7acecc3938e478.json HTTP/1.1" 200 1088883 "https://blog.weimo.info/" Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36 172.69.35.7 0.003

实际上并没有成功记录,在后台显示的是255.255.255.255。 查看数据库显示的是(4294967295): "3" "Mozilla/5.0 (Linux; Android 9; Redmi K20 Pro) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.93 Mobile Safari/537.36" "Chrome" "79.0.3945.93" "Android" "9" "/archive.html" "/archive.html" \N "4294967295" \N \N "https://blog.weimo.info/blog/" "blog.weimo.info" "1579136998" "5" \N "0" "" ""

另外遇到一个问题,在这里记录下来,供他人参考。 新版插件引入了gmp_strval函数,这个函数需要安装php7.0-gmp(我的环境是php7.0-fpm),不过由于个人操作原因导致了无法安装这个包(遇到诸多问题),最后将sources.list改为如下配置后成功安装,仅供参考:

deb http://deb.debian.org/debian/ oldstable main contrib non-free
deb-src http://deb.debian.org/debian/ oldstable main contrib non-free

deb http://deb.debian.org/debian/ oldstable-updates main contrib non-free
deb-src http://deb.debian.org/debian/ oldstable-updates main contrib non-free

deb http://deb.debian.org/debian-security oldstable/updates main
deb-src http://deb.debian.org/debian-security oldstable/updates main

deb http://ftp.debian.org/debian stretch-backports main
deb-src http://ftp.debian.org/debian stretch-backports main
xhlove commented 4 years ago

补充一点,操作过程是:

xhlove commented 4 years ago

找到问题所在了,数据表中ip字段用的int(32),显然对于ipv6是不够的,改为varchar(38)即可,其他的不用改。 不过查询ip好像有些问题,提示: 很抱歉,ipip.net 查询无结果,同时服务器无法连接 fallback 接口(tools.keycdn.com)

xhlove commented 4 years ago

查询问题是我自己前面操作导致的(php7.0-curl没了)。 安装php7.0-curl后正常了。 另外希望能将这个异常直接反馈到页面提示(因为我挨着挨着看代码才找到这里) https://github.com/Vndroid/Access/blob/f236c5e016985cadad39fe0f16542d85644720d2/Access_Ip.php#L57

vndroid commented 4 years ago

找到问题所在了,数据表中ip字段用的int(32),显然对于ipv6是不够的,改为varchar(38)即可,其他的不用改。 不过查询ip好像有些问题,提示: 很抱歉,ipip.net 查询无结果,同时服务器无法连接 fallback 接口(tools.keycdn.com)

感谢提醒,这个在测试数据库修改了,忘了同步到代码中,已经修正。 至于 GMP 的话,这个不同的发行版略有不同,因此不提及,并且你环境的 php 版本过旧,导致仓库中没有包,建议尝试升级 PHP 版本到 7.2 或以上版本,性能会有一定提升(不仅是对于本插件)。

已经更新至全新的中文说明,感谢支持。

vndroid commented 4 years ago

查询问题是我自己前面操作导致的(php7.0-curl没了)。 安装php7.0-curl后正常了。 另外希望能将这个异常直接反馈到页面提示(因为我挨着挨着看代码才找到这里) https://github.com/Vndroid/Access/blob/f236c5e016985cadad39fe0f16542d85644720d2/Access_Ip.php#L57

这个问题后续有空修复一下,最近年末,公司事务较多,响应速度较慢,希望理解。

另外此分支你可测试一段时间,有问题请反馈,没有问题的话,找机会合并到主分支,此分支是用于测试新功能的(虽然可能不会有什么新功能了)。