MikeWang000000 / Natter

Expose your TCP/UDP port behind full-cone NAT to the Internet.
GNU General Public License v3.0
1.63k stars 137 forks source link

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

Open liuran001 opened 5 months ago

liuran001 commented 5 months ago

差不多从昨天开始,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 commented 5 months ago

我测试了一下还能用啊

liuran001 commented 5 months ago

我测试了一下还能用啊

我这边测试不行( 贴一下完整日志,-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 commented 5 months ago

我测试了一下还能用啊

刚刚又去看了一下 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 commented 5 months ago

我测试了一下还能用啊

刚刚又去看了一下 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 commented 5 months ago

我测试了一下还能用啊

刚刚又去看了一下 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 commented 5 months ago

我测试了一下还能用啊

刚刚又去看了一下 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 commented 5 months ago

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

liuran001 commented 5 months ago

修了下再试试?

@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
},
Droid-MAX commented 4 months ago

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

Droid-MAX commented 4 months ago

https://github.com/Droid-MAX/natter-deb/commit/e80ee33f4c154230dde54521847000314ef1fa69

liuran001 commented 4 months ago

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

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

Droid-MAX commented 4 months ago

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