Skip to content
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

IP属地无法显示 #1002

Open
DeepChirp opened this issue Oct 15, 2024 · 4 comments
Open

IP属地无法显示 #1002

DeepChirp opened this issue Oct 15, 2024 · 4 comments

Comments

@DeepChirp
Copy link

我已经按照官方教程开启了IP属地选项,不过似乎仍未显示IP地址。

我是通过Docker部署的,将artalk的相关配置存储在了artalk-app-data卷中:

services:
  artalk:
    image: artalk/artalk-go
    volumes:
      - artalk-app-data:/data
volumes:
  artalk-app-data:

相关文件是从官方给出的链接中下载,且已经保存在了数据卷中,用户具有读取权限:

$ sudo stat /var/lib/docker/volumes/artalk_artalk-app-data/_data/ip2region.xdb
  File: /var/lib/docker/volumes/artalk_artalk-app-data/_data/ip2region.xdb
  Size: 11070083        Blocks: 21624      IO Block: 4096   regular file
Device: 254,2   Inode: 526771      Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2024-10-15 12:10:31.313748779 +0000
Modify: 2024-10-15 12:10:32.157748100 +0000
Change: 2024-10-15 12:10:32.157748100 +0000
 Birth: 2024-10-15 12:10:31.313748779 +0000

相关选项已经打开,这是artalk.yml中的配置:

# IP 属地
ip_region:
  # 启用 IP 属地展示
  enabled: true
  # 数据文件路径 (.xdb 格式)
  db_path: ./data/ip2region.xdb
  # 显示精度 ["province", "city", "country"]
  precision: province

我使用了postgres:17-alpine这一Docker镜像部署。我的评论数据是从twikoo中导入的。查询后发现数据库中存在IP数据,即comments表中存在ip字段。并且导出评论时,配置文件中亦存在IP数据,并且我确定这些IP是真实的IP,而不是Docker虚拟网卡或是私有地址的IP。其中一个IP地址为:2409:895a:65e:c05d:17fc:5234:a884:d650

查看artalk.log日志似乎未发现错误。

我还尝试了重启artalk服务,但是仍然没有效果。但我不清楚如何排查能否读取IP,或者是该IP的属地在数据库中并不存在。如果是后者,我认为加一个属地:未知可能更好。

请问一下是什么原因,或者是我应该如何进一步排查呢?不胜感激!

@penndu
Copy link

penndu commented Oct 16, 2024

db_path: ./data/ip2region.xdb
换成
db_path: ./_data/ip2region.xdb

@DeepChirp
Copy link
Author

DeepChirp commented Oct 16, 2024

db_path: ./data/ip2region.xdb 换成 db_path: ./_data/ip2region.xdb

感谢解答。不过应该不是这个问题。因为容器内的目录地址为./data/ip2region.xdb

$ sudo docker container ls
CONTAINER ID   IMAGE                                                    COMMAND                  CREATED             STATUS                       PORTS                                           NAMES
12cf134f6cb7   artalk/artalk-go                                         "/entrypoint.sh serv…"   About an hour ago   Up About an hour             0.0.0.0:8080->23366/tcp, [::]:8080->23366/tcp   artalk
$ sudo docker exec -it 12cf134f6cb7 bash
12cf134f6cb7:/# ls ./data
artalk.log     artalk.yml     ip2region.xdb

刚刚看到了此讨论,个人推测是否为数据库不支持IPv6导致的呢?

@acanyo
Copy link

acanyo commented Nov 20, 2024

我目前也有这个问题,路径是对的,相对的html就可以取到

@leapyear1969
Copy link

我也发现这个问题了,路径是对的,文件也是存在的。但是评论之后,不显示IP.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants