move gotd fork into repo. (#111)

- update to latest telegram layer
- remove some references to fields in tg.Entities that don't exist in
the schema
- originally added here:
https://github.com/beeper/td/commit/820929062a2ba0104397bc01235ab58a9cff780e
  - referenced here
-
https://github.com/mautrix/telegramgo/commit/124f0967ed195b5a380c9bd02e170ada9710dde3
-
https://github.com/mautrix/telegramgo/commit/4205047aab2e0639217148b5d125bfaab668bd8e
This commit is contained in:
Adam Van Ymeren
2025-06-27 20:03:37 -07:00
committed by GitHub
parent 0952df0244
commit 7a04f298d2
19264 changed files with 1539697 additions and 84 deletions
+75
View File
@@ -0,0 +1,75 @@
package main
import (
"fmt"
"net/netip"
"os"
"gopkg.in/yaml.v3"
"go.mau.fi/mautrix-telegram/pkg/gotd/telegram/dcs"
)
type CIDRElement struct {
CIDR string `json:"cidr" yaml:"cidr"`
}
type Ports struct {
Ports []Port `json:"ports" yaml:"ports"`
}
type Port struct {
Port string `json:"port" yaml:"port"`
}
type Element struct {
ToCIDRSet []CIDRElement `json:"toCIDRSet" yaml:"toCIDRSet"`
ToPorts []Ports `json:"toPorts" yaml:"toPorts"`
}
/*
- toCIDRSet:
- cidr: 192.169.0.1/32
toPorts:
- ports:
- port: "443"
*/
func main() {
list := dcs.Prod()
var out []CIDRElement
met := make(map[string]struct{})
for _, v := range list.Options {
ip, err := netip.ParseAddr(v.IPAddress)
if err != nil {
panic(err)
}
if v.Port != 443 {
panic("port != 443")
}
prefix := netip.PrefixFrom(ip, ip.BitLen())
cidr := prefix.String()
if _, ok := met[cidr]; ok {
continue
}
met[cidr] = struct{}{}
out = append(out, CIDRElement{CIDR: cidr})
}
fmt.Println("# telegram datacenters list")
fmt.Println("# generated by cmd/dcsidr")
e := yaml.NewEncoder(os.Stdout)
e.SetIndent(2)
if err := e.Encode(Element{
ToCIDRSet: out,
ToPorts: []Ports{
{
Ports: []Port{
{Port: "443"},
},
},
},
}); err != nil {
panic(err)
}
}