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

示例中的 cf-srv.py 失效 #98

Open
liuran001 opened this issue Jun 16, 2024 · 12 comments
Open

示例中的 cf-srv.py 失效 #98

liuran001 opened this issue Jun 16, 2024 · 12 comments

Comments

@liuran001
Copy link

差不多从昨天开始,cf-srv.py 脚本就无法正常工作了

2024-06-16 18:34:54 [I] Calling script: ./cf-srv.py
Setting mc.example.com A record to 1.1.1.1...
Setting mc.example.com SRV record to tcp port 1145...
Traceback (most recent call last):
  File "/root/natter/cf-srv.py", line 186, in <module>
    main()
  File "/root/natter/cf-srv.py", line 22, in main
    cf.set_srv_record(cf_domain, public_port, service=cf_srv_service, protocol=f"_{protocol}")
  File "/root/natter/cf-srv.py", line 49, in set_srv_record
    rec_id = self._find_srv_record(zone_id, name)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/natter/cf-srv.py", line 133, in _find_srv_record
    if rec_data["type"] == "SRV" and rec_data["data"]["name"] == name:
                                     ~~~~~~~~~~~~~~~~^^^^^^^^
KeyError: 'name'

查了一下,应该是 Cloudflare 改了 api 导致的
Name-Related Data Fields on SRV (DNS) Records - API deprecations - Cloudflare Fundamentals docs

自己试着修复了下没改好,就先开个 issue 在这里吧(

@Droid-MAX
Copy link

我测试了一下还能用啊

@liuran001
Copy link
Author

我测试了一下还能用啊

我这边测试不行(
贴一下完整日志,-v 看了下没什么差别就不贴上来了

[root@frp natter]# git pull
Already up to date.
[root@frp natter]# python natter.py -U -t 10.0.0.55 -p 25565 -m socat -r -e ./cf-srv.py
2024-06-17 07:06:49 [I] Natter v2.1.1
2024-06-17 07:06:54 [I]
2024-06-17 07:06:54 [I] Scanning UPnP Devices...
2024-06-17 07:06:57 [I] [UPnP] Found router 10.0.0.1
2024-06-17 07:06:57 [I]
2024-06-17 07:06:57 [I] tcp://10.0.0.55:25565 <--socat--> tcp://10.0.0.151:42525 <--Natter--> tcp://114.51.4.1:7075
2024-06-17 07:06:57 [I]
2024-06-17 07:06:57 [I] Calling script: ./cf-srv.py
Setting mc.example.com A record to 114.51.4.1...
Setting mc.example.com SRV record to tcp port 7075...
Traceback (most recent call last):
  File "/root/natter/cf-srv.py", line 185, in <module>
    main()
  File "/root/natter/cf-srv.py", line 21, in main
    cf.set_srv_record(cf_domain, public_port, service=cf_srv_service, protocol=f"_{protocol}")
  File "/root/natter/cf-srv.py", line 48, in set_srv_record
    rec_id = self._find_srv_record(zone_id, name)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/natter/cf-srv.py", line 132, in _find_srv_record
    if rec_data["type"] == "SRV" and rec_data["data"]["name"] == name:
                                     ~~~~~~~~~~~~~~~~^^^^^^^^
KeyError: 'name'
2024-06-17 07:07:01 [I] LAN > 10.0.0.55:25565       [ OPEN ]
2024-06-17 07:07:01 [I] LAN > 10.0.0.151:42525      [ OPEN ]
2024-06-17 07:07:01 [I] LAN > 114.51.4.1:7075    [ OPEN ]
2024-06-17 07:07:02 [I] WAN > 114.51.4.1:7075    [ OPEN ]
2024-06-17 07:07:02 [I]
^C[root@frp natter]# python
Python 3.12.3 (main, Apr 23 2024, 09:16:07) [GCC 13.2.1 20240417] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
[root@frp natter]# neofetch --stdout
root@frp
--------
OS: Arch Linux x86_64
Kernel: 6.5.13-5-pve
Uptime: 14 hours, 21 mins
Packages: 150 (pacman)
Shell: fish 3.7.1
Terminal: /dev/pts/0

因为我前一段时间也是这么用的,自己机子上环境应该是没有什么变化,然后去 Cloudflare 那边看了一下就是 15 号左右禁用的旧 api

@liuran001
Copy link
Author

我测试了一下还能用啊

刚刚又去看了一下
You may be seeing differences in behavior across zones because this change is being rolled out on a per-zone basis until June 17, 08:00 UTC
https://community.cloudflare.com/t/eol-of-name-related-data-fields-on-srv-dns-records-is-not-applying

@Droid-MAX 所以你过会再试估计就不行了(

@MasterOfStar
Copy link

我测试了一下还能用啊

刚刚又去看了一下 You may be seeing differences in behavior across zones because this change is being rolled out on a per-zone basis until June 17, 08:00 UTC https://community.cloudflare.com/t/eol-of-name-related-data-fields-on-srv-dns-records-is-not-applying

@Droid-MAX 所以你过会再试估计就不行了(

https://github.com/MasterOfStar/Natter/blob/patch-1/natter-docker/minecraft/cf-srv.py
试下这个?等饭的时候改的 不保证能用

@liuran001
Copy link
Author

我测试了一下还能用啊

刚刚又去看了一下 You may be seeing differences in behavior across zones because this change is being rolled out on a per-zone basis until June 17, 08:00 UTC https://community.cloudflare.com/t/eol-of-name-related-data-fields-on-srv-dns-records-is-not-applying
@Droid-MAX 所以你过会再试估计就不行了(

https://github.com/MasterOfStar/Natter/blob/patch-1/natter-docker/minecraft/cf-srv.py 试下这个?等饭的时候改的 不保证能用

@MasterOfStar 看起来确实不太能用(

2024-06-17 10:48:33 [I] Calling script: ./111.py
Setting mc.example.com A record to 1.1.1.1...
Setting mc.example.com SRV record to tcp port 7120...
Traceback (most recent call last):
  File "/root/natter/111.py", line 188, in <module>
    main()
  File "/root/natter/111.py", line 22, in main
    cf.set_srv_record(cf_domain, public_port, service=cf_srv_service, protocol=f"_{protocol}")
  File "/root/natter/111.py", line 51, in set_srv_record
    rec_id = self._create_srv_record(zone_id, name, service,
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/natter/111.py", line 141, in _create_srv_record
    data = self._url_req(
           ^^^^^^^^^^^^^^
  File "/root/natter/111.py", line 71, in _url_req
    raise RuntimeError(ret["errors"])
RuntimeError: [{'code': 1004, 'message': 'DNS Validation Error', 'error_chain': [{'code': 9000, 'message': "SRV data fields 'service', 'proto' and 'name' are no longer supported. Please see <https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#name-related-data-fields-on-srv-dns-records> for more information."}]}]

@MasterOfStar
Copy link

我测试了一下还能用啊

刚刚又去看了一下 You may be seeing differences in behavior across zones because this change is being rolled out on a per-zone basis until June 17, 08:00 UTC https://community.cloudflare.com/t/eol-of-name-related-data-fields-on-srv-dns-records-is-not-applying
@Droid-MAX 所以你过会再试估计就不行了(

https://github.com/MasterOfStar/Natter/blob/patch-1/natter-docker/minecraft/cf-srv.py 试下这个?等饭的时候改的 不保证能用

@MasterOfStar 看起来确实不太能用(

2024-06-17 10:48:33 [I] Calling script: ./111.py
Setting mc.example.com A record to 1.1.1.1...
Setting mc.example.com SRV record to tcp port 7120...
Traceback (most recent call last):
  File "/root/natter/111.py", line 188, in <module>
    main()
  File "/root/natter/111.py", line 22, in main
    cf.set_srv_record(cf_domain, public_port, service=cf_srv_service, protocol=f"_{protocol}")
  File "/root/natter/111.py", line 51, in set_srv_record
    rec_id = self._create_srv_record(zone_id, name, service,
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/natter/111.py", line 141, in _create_srv_record
    data = self._url_req(
           ^^^^^^^^^^^^^^
  File "/root/natter/111.py", line 71, in _url_req
    raise RuntimeError(ret["errors"])
RuntimeError: [{'code': 1004, 'message': 'DNS Validation Error', 'error_chain': [{'code': 9000, 'message': "SRV data fields 'service', 'proto' and 'name' are no longer supported. Please see <https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#name-related-data-fields-on-srv-dns-records> for more information."}]}]

修了下再试试?

@Droid-MAX
Copy link

可能是分地区逐步应用更新的,我这边现在还是可以用的,6.17/19:27

@liuran001
Copy link
Author

liuran001 commented Jun 17, 2024

修了下再试试?

@MasterOfStar 现在不会报错了,但是看了下传的还是不太对
srv 记录之前是把 name proto service 三个参数分开传的,实际的记录应该类似 _minecraft._tcp.mc.example.com
现在只传一个 name 的话应该把那三个参数拼接起来

这样改完就没问题了,测试一切正常

data={
    "data": {
        "port":     port,
        "priority": priority,
        "target":   target,
        "weight":   weight
    },
    "name":     f"{service}{protocol}.{name}",
    "proxied":  False,
    "type":     "SRV",
    "ttl":      ttl
},

MasterOfStar added a commit to MasterOfStar/Natter that referenced this issue Jun 17, 2024
@Droid-MAX
Copy link

Droid-MAX commented Jul 19, 2024

{service}跟{protocol}中间不用加.么?
还是要加.号的

@Droid-MAX
Copy link

MasterOfStar added a commit to MasterOfStar/Natter that referenced this issue Jul 19, 2024
@liuran001
Copy link
Author

{service}跟{protocol}中间不用加.么? 还是要加.号的

应该是我漏了来着,但是我没记错的话之前我没加.也是没问题的

@Droid-MAX
Copy link

没加.能正常更新srv记录?不能吧,我试过

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

3 participants