p2p/nat: improve STUN default server list

This commit is contained in:
Felix Lange 2025-01-21 17:18:31 +01:00
parent 0692059fce
commit 06ea9ee92e
3 changed files with 106 additions and 23 deletions

View file

@ -17,38 +17,20 @@
package nat package nat
import ( import (
_ "embed"
"errors" "errors"
"fmt" "fmt"
"math/rand" "math/rand"
"net" "net"
"strings"
"time" "time"
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
stunV2 "github.com/pion/stun/v2" stunV2 "github.com/pion/stun/v2"
) )
var stunDefaultServerList = []string{ //go:embed stun-list.txt
"159.223.0.83:3478", var stunDefaultServers string
"stun.l.google.com:19302",
"stun1.l.google.com:19302",
"stun2.l.google.com:19302",
"stun3.l.google.com:19302",
"stun4.l.google.com:19302",
"stun01.sipphone.com",
"stun.ekiga.net",
"stun.fwdnet.net",
"stun.ideasip.com",
"stun.iptel.org",
"stun.rixtelecom.se",
"stun.schlund.de",
"stunserver.org",
"stun.softjoys.com",
"stun.voiparound.com",
"stun.voipbuster.com",
"stun.voipstunt.com",
"stun.voxgratia.org",
"stun.xten.com",
}
const requestLimit = 3 const requestLimit = 3
@ -59,7 +41,7 @@ type stun struct {
func newSTUN(serverAddr string) (Interface, error) { func newSTUN(serverAddr string) (Interface, error) {
s := new(stun) s := new(stun)
if serverAddr == "default" || serverAddr == "" { if serverAddr == "default" || serverAddr == "" {
s.serverList = stunDefaultServerList s.serverList = strings.Split(stunDefaultServers, "\n")
} else { } else {
_, err := net.ResolveUDPAddr("udp4", serverAddr) _, err := net.ResolveUDPAddr("udp4", serverAddr)
if err != nil { if err != nil {

5
p2p/nat/stun-list-update.sh Executable file
View file

@ -0,0 +1,5 @@
#!/bin/sh
rm -f stun-list.txt
curl https://raw.githubusercontent.com/pradt2/always-online-stun/refs/heads/master/valid_ipv4s.txt >> stun-list.txt
curl https://raw.githubusercontent.com/pradt2/always-online-stun/refs/heads/master/valid_ipv6s.txt >> stun-list.txt

96
p2p/nat/stun-list.txt Normal file
View file

@ -0,0 +1,96 @@
3.132.228.249:3478
79.140.42.88:3478
52.47.70.236:3478
35.158.233.7:3478
212.103.68.7:3478
18.185.125.152:3478
194.149.74.157:3478
212.53.40.40:3478
81.82.206.117:3478
69.20.59.115:3478
157.161.10.32:3478
5.161.52.174:3478
188.40.18.246:3478
217.146.224.74:3478
51.83.201.84:3478
92.205.106.161:3478
188.40.203.74:3478
23.21.199.62:3478
213.239.206.5:3478
51.68.112.203:3478
91.213.98.54:3478
85.197.87.182:3478
212.18.0.14:3478
31.184.236.23:3478
51.83.15.212:3478
80.156.214.187:3478
52.26.251.34:3478
176.9.24.184:3478
212.53.40.43:3478
49.12.125.53:3478
62.72.83.10:3478
94.23.17.185:3478
51.255.31.35:3478
54.197.117.0:3478
159.69.191.124:3478
188.138.90.169:3478
209.251.63.76:3478
20.93.239.172:3478
212.144.246.197:3478
159.69.191.124:443
195.208.107.138:3478
3.78.237.53:3478
88.198.151.128:3478
198.100.144.121:3478
51.68.45.75:3478
129.153.212.128:3478
87.253.140.133:3478
52.24.174.49:3478
217.91.243.229:3478
185.125.180.70:3478
35.180.81.93:3478
5.161.57.75:3478
95.216.78.222:3478
66.228.54.23:3478
34.192.137.246:3478
44.230.252.214:3478
193.182.111.151:3478
195.145.93.141:3478
192.172.233.145:3478
24.204.48.11:3478
136.243.59.79:3478
90.145.158.66:3478
80.155.54.123:3478
94.140.180.141:3478
81.3.27.44:3478
213.251.48.147:3478
88.99.67.241:3478
34.206.168.53:3478
88.218.220.40:3478
52.52.70.85:3478
172.233.245.118:3478
34.74.124.204:3478
185.88.236.76:3478
143.198.60.79:3478
81.83.12.46:3478
193.22.17.97:3478
147.182.188.245:3478
95.216.145.84:3478
91.212.41.85:3478
34.195.177.19:3478
23.21.92.55:3478
137.74.112.113:3478
195.201.132.113:3478
192.76.120.66:3478
35.177.202.92:3478
[2a03:8600::89]:3478
[2a01:4f8:c17:8f74::1]:443
[2a00:1169:11b:a6b0::]:3478
[2600:1f16:8c5:101:80b:b58b:828:8df4]:3478
[2a01:4f8:242:56ca::2]:3478
[2001:1538:1::224:74]:3478
[2a01:4f8:c17:8f74::1]:3478
[2001:4060:1:1005::10:32]:3478
[2001:678:b28::118]:3478
[2001:4060:1:1005::10:32]:3478
[2001:41d0:2:12b9::1]:3478