this repo has no description
1use std::collections::HashSet; 2use std::sync::LazyLock; 3 4const ATP_SPECIFIC: &[&str] = &[ 5 "at", 6 "atp", 7 "plc", 8 "pds", 9 "did", 10 "repo", 11 "tid", 12 "nsid", 13 "xrpc", 14 "lex", 15 "lexicon", 16 "bsky", 17 "bluesky", 18 "handle", 19]; 20 21const COMMONLY_RESERVED: &[&str] = &[ 22 "about", 23 "abuse", 24 "access", 25 "account", 26 "accounts", 27 "acme", 28 "activate", 29 "activities", 30 "activity", 31 "ad", 32 "add", 33 "address", 34 "adm", 35 "admanager", 36 "admin", 37 "administration", 38 "administrator", 39 "administrators", 40 "admins", 41 "ads", 42 "adsense", 43 "adult", 44 "advertising", 45 "adwords", 46 "affiliate", 47 "affiliatepage", 48 "affiliates", 49 "afp", 50 "ajax", 51 "all", 52 "alpha", 53 "analysis", 54 "analytics", 55 "android", 56 "anon", 57 "anonymous", 58 "answer", 59 "answers", 60 "ap", 61 "api", 62 "apis", 63 "app", 64 "appengine", 65 "appnews", 66 "apps", 67 "archive", 68 "archives", 69 "article", 70 "asdf", 71 "asset", 72 "assets", 73 "auth", 74 "authentication", 75 "avatar", 76 "backup", 77 "bank", 78 "banner", 79 "banners", 80 "base", 81 "beginners", 82 "beta", 83 "billing", 84 "bin", 85 "binaries", 86 "binary", 87 "blackberry", 88 "blog", 89 "blogs", 90 "blogsearch", 91 "board", 92 "book", 93 "bookmark", 94 "bookmarks", 95 "books", 96 "bot", 97 "bots", 98 "bug", 99 "bugs", 100 "business", 101 "buy", 102 "buzz", 103 "cache", 104 "calendar", 105 "call", 106 "campaign", 107 "cancel", 108 "captcha", 109 "career", 110 "careers", 111 "cart", 112 "catalog", 113 "catalogs", 114 "categories", 115 "category", 116 "cdn", 117 "cgi", 118 "cgi-bin", 119 "changelog", 120 "chart", 121 "charts", 122 "chat", 123 "check", 124 "checked", 125 "checking", 126 "checkout", 127 "client", 128 "cliente", 129 "clients", 130 "clients1", 131 "cnarne", 132 "code", 133 "comercial", 134 "comment", 135 "comments", 136 "communities", 137 "community", 138 "company", 139 "compare", 140 "compras", 141 "config", 142 "configuration", 143 "confirm", 144 "confirmation", 145 "connect", 146 "contact", 147 "contacts", 148 "contactus", 149 "contact-us", 150 "contact_us", 151 "content", 152 "contest", 153 "contribute", 154 "contributor", 155 "contributors", 156 "coppa", 157 "copyright", 158 "copyrights", 159 "core", 160 "corp", 161 "countries", 162 "country", 163 "cpanel", 164 "create", 165 "css", 166 "cssproxy", 167 "customise", 168 "customize", 169 "dashboard", 170 "data", 171 "db", 172 "default", 173 "delete", 174 "demo", 175 "design", 176 "designer", 177 "desktop", 178 "destroy", 179 "dev", 180 "devel", 181 "developer", 182 "developers", 183 "devs", 184 "diagram", 185 "diary", 186 "dict", 187 "dictionary", 188 "die", 189 "dir", 190 "directory", 191 "direct_messages", 192 "direct-messages", 193 "dist", 194 "diversity", 195 "dl", 196 "dmca", 197 "doc", 198 "docs", 199 "documentation", 200 "documentations", 201 "documents", 202 "domain", 203 "domains", 204 "donate", 205 "download", 206 "downloads", 207 "e", 208 "e-mail", 209 "earth", 210 "ecommerce", 211 "edit", 212 "edits", 213 "editor", 214 "edu", 215 "education", 216 "email", 217 "embed", 218 "embedded", 219 "employment", 220 "employments", 221 "empty", 222 "enable", 223 "encrypted", 224 "end", 225 "engine", 226 "enterprise", 227 "enterprises", 228 "entries", 229 "entry", 230 "error", 231 "errorlog", 232 "errors", 233 "eval", 234 "event", 235 "example", 236 "examplecommunity", 237 "exampleopenid", 238 "examplesyn", 239 "examplesyndicated", 240 "exampleusername", 241 "exchange", 242 "exit", 243 "explore", 244 "faq", 245 "faqs", 246 "favorite", 247 "favorites", 248 "favourite", 249 "favourites", 250 "feature", 251 "features", 252 "feed", 253 "feedback", 254 "feedburner", 255 "feedproxy", 256 "feeds", 257 "file", 258 "files", 259 "finance", 260 "folder", 261 "folders", 262 "first", 263 "following", 264 "forgot", 265 "form", 266 "forms", 267 "forum", 268 "forums", 269 "founder", 270 "free", 271 "friend", 272 "friends", 273 "ftp", 274 "fuck", 275 "fun", 276 "fusion", 277 "gadget", 278 "gadgets", 279 "game", 280 "games", 281 "gears", 282 "general", 283 "geographic", 284 "get", 285 "gettingstarted", 286 "gift", 287 "gifts", 288 "gist", 289 "git", 290 "github", 291 "gmail", 292 "go", 293 "golang", 294 "goto", 295 "gov", 296 "graph", 297 "graphs", 298 "group", 299 "groups", 300 "guest", 301 "guests", 302 "guide", 303 "guides", 304 "hack", 305 "hacks", 306 "head", 307 "help", 308 "home", 309 "homepage", 310 "host", 311 "hosting", 312 "hostmaster", 313 "hostname", 314 "howto", 315 "how-to", 316 "how_to", 317 "html", 318 "htrnl", 319 "http", 320 "httpd", 321 "https", 322 "i", 323 "iamges", 324 "icon", 325 "icons", 326 "id", 327 "idea", 328 "ideas", 329 "im", 330 "image", 331 "images", 332 "img", 333 "imap", 334 "inbox", 335 "inboxes", 336 "index", 337 "indexes", 338 "info", 339 "information", 340 "inquiry", 341 "intranet", 342 "investor", 343 "investors", 344 "invitation", 345 "invitations", 346 "invite", 347 "invoice", 348 "invoices", 349 "imac", 350 "ios", 351 "ipad", 352 "iphone", 353 "irc", 354 "irnages", 355 "irng", 356 "is", 357 "issue", 358 "issues", 359 "it", 360 "item", 361 "items", 362 "java", 363 "javascript", 364 "job", 365 "jobs", 366 "join", 367 "js", 368 "json", 369 "jump", 370 "kb", 371 "knowledge-base", 372 "knowledgebase", 373 "lab", 374 "labs", 375 "language", 376 "languages", 377 "last", 378 "ldap_status", 379 "ldap-status", 380 "ldapstatus", 381 "legal", 382 "license", 383 "licenses", 384 "link", 385 "links", 386 "linux", 387 "list", 388 "lists", 389 "livejournal", 390 "lj", 391 "local", 392 "locale", 393 "location", 394 "log", 395 "log-in", 396 "log-out", 397 "login", 398 "logout", 399 "logs", 400 "log_in", 401 "log_out", 402 "m", 403 "mac", 404 "macos", 405 "macosx", 406 "mac-os", 407 "mac-os-x", 408 "mac_os_x", 409 "mail", 410 "mailer", 411 "mailing", 412 "main", 413 "maintenance", 414 "manage", 415 "manager", 416 "manual", 417 "map", 418 "maps", 419 "marketing", 420 "master", 421 "me", 422 "media", 423 "member", 424 "members", 425 "memories", 426 "memory", 427 "merchandise", 428 "message", 429 "messages", 430 "messenger", 431 "mg", 432 "microblog", 433 "microblogs", 434 "mine", 435 "mis", 436 "misc", 437 "mms", 438 "mob", 439 "mobile", 440 "model", 441 "models", 442 "money", 443 "movie", 444 "movies", 445 "mp3", 446 "mp4", 447 "msg", 448 "msn", 449 "music", 450 "mx", 451 "my", 452 "mymme", 453 "mysql", 454 "name", 455 "named", 456 "nan", 457 "navi", 458 "navigation", 459 "net", 460 "network", 461 "networks", 462 "new", 463 "news", 464 "newsletter", 465 "nick", 466 "nickname", 467 "nil", 468 "none", 469 "notes", 470 "noticias", 471 "notification", 472 "notifications", 473 "notify", 474 "ns", 475 "ns1", 476 "ns2", 477 "ns3", 478 "ns4", 479 "ns5", 480 "null", 481 "oauth", 482 "oauth-clients", 483 "oauth_clients", 484 "ocsp", 485 "offer", 486 "offers", 487 "official", 488 "old", 489 "online", 490 "openid", 491 "operator", 492 "option", 493 "options", 494 "order", 495 "orders", 496 "org", 497 "organization", 498 "organizations", 499 "other", 500 "overview", 501 "owner", 502 "owners", 503 "p0rn", 504 "pack", 505 "page", 506 "pager", 507 "pages", 508 "paid", 509 "panel", 510 "partner", 511 "partnerpage", 512 "partners", 513 "password", 514 "patch", 515 "pay", 516 "payment", 517 "people", 518 "perl", 519 "person", 520 "phone", 521 "photo", 522 "photoalbum", 523 "photos", 524 "php", 525 "phpmyadmin", 526 "phppgadmin", 527 "phpredisadmin", 528 "pic", 529 "pics", 530 "picture", 531 "pictures", 532 "ping", 533 "pixel", 534 "places", 535 "plan", 536 "plans", 537 "plugin", 538 "plugins", 539 "podcasts", 540 "policies", 541 "policy", 542 "pop", 543 "pop3", 544 "popular", 545 "porn", 546 "portal", 547 "portals", 548 "post", 549 "postfix", 550 "postmaster", 551 "posts", 552 "pr", 553 "pr0n", 554 "premium", 555 "press", 556 "price", 557 "pricing", 558 "principles", 559 "print", 560 "privacy", 561 "privacy-policy", 562 "privacypolicy", 563 "privacy_policy", 564 "private", 565 "prod", 566 "product", 567 "production", 568 "products", 569 "profile", 570 "profiles", 571 "project", 572 "projects", 573 "promo", 574 "promotions", 575 "proxies", 576 "proxy", 577 "pub", 578 "public", 579 "purchase", 580 "purpose", 581 "put", 582 "python", 583 "queries", 584 "query", 585 "radio", 586 "random", 587 "ranking", 588 "read", 589 "reader", 590 "readme", 591 "recent", 592 "recruit", 593 "recruitment", 594 "redirect", 595 "register", 596 "registration", 597 "release", 598 "remove", 599 "replies", 600 "report", 601 "reports", 602 "repositories", 603 "repository", 604 "req", 605 "request", 606 "requests", 607 "research", 608 "reset", 609 "resolve", 610 "resolver", 611 "review", 612 "rnail", 613 "rnicrosoft", 614 "roc", 615 "root", 616 "rss", 617 "ruby", 618 "rule", 619 "sag", 620 "sale", 621 "sales", 622 "sample", 623 "samples", 624 "sandbox", 625 "save", 626 "scholar", 627 "school", 628 "schools", 629 "script", 630 "scripts", 631 "search", 632 "secure", 633 "security", 634 "self", 635 "seminars", 636 "send", 637 "server", 638 "server-info", 639 "server_info", 640 "server-status", 641 "server_status", 642 "servers", 643 "service", 644 "services", 645 "session", 646 "sessions", 647 "setting", 648 "settings", 649 "setup", 650 "share", 651 "shop", 652 "shopping", 653 "shortcut", 654 "shortcuts", 655 "show", 656 "sign-in", 657 "sign-up", 658 "signin", 659 "signout", 660 "signup", 661 "sign_in", 662 "sign_up", 663 "site", 664 "sitemap", 665 "sitemaps", 666 "sitenews", 667 "sites", 668 "sketchup", 669 "sky", 670 "slash", 671 "slashinvoice", 672 "slut", 673 "smartphone", 674 "sms", 675 "smtp", 676 "soap", 677 "software", 678 "sorry", 679 "source", 680 "spec", 681 "special", 682 "spreadsheet", 683 "spreadsheets", 684 "sql", 685 "src", 686 "srntp", 687 "ssh", 688 "ssl", 689 "ssladmin", 690 "ssladministrator", 691 "sslwebmaster", 692 "ssytem", 693 "staff", 694 "stage", 695 "staging", 696 "start", 697 "stat", 698 "state", 699 "static", 700 "statistics", 701 "stats", 702 "status", 703 "store", 704 "stores", 705 "stories", 706 "style", 707 "styleguide", 708 "styles", 709 "stylesheet", 710 "stylesheets", 711 "subdomain", 712 "subscribe", 713 "subscription", 714 "subscriptions", 715 "suggest", 716 "suggestqueries", 717 "support", 718 "survey", 719 "surveys", 720 "surveytool", 721 "svn", 722 "swf", 723 "syn", 724 "sync", 725 "syndicated", 726 "sys", 727 "sysadmin", 728 "sysadministrator", 729 "sysadmins", 730 "system", 731 "tablet", 732 "tablets", 733 "tag", 734 "tags", 735 "talk", 736 "talkgadget", 737 "task", 738 "tasks", 739 "team", 740 "teams", 741 "tech", 742 "telnet", 743 "term", 744 "terms", 745 "terms-of-service", 746 "termsofservice", 747 "terms_of_service", 748 "test", 749 "testing", 750 "tests", 751 "text", 752 "theme", 753 "themes", 754 "thread", 755 "threads", 756 "ticket", 757 "tickets", 758 "tmp", 759 "todo", 760 "to-do", 761 "to_do", 762 "toml", 763 "tool", 764 "toolbar", 765 "toolbars", 766 "tools", 767 "top", 768 "topic", 769 "topics", 770 "tos", 771 "tour", 772 "trac", 773 "translate", 774 "trace", 775 "translation", 776 "translations", 777 "translator", 778 "trends", 779 "tutorial", 780 "tux", 781 "tv", 782 "twitter", 783 "txt", 784 "ul", 785 "undef", 786 "unfollow", 787 "unsubscribe", 788 "update", 789 "updates", 790 "upgrade", 791 "upgrades", 792 "upi", 793 "upload", 794 "uploads", 795 "url", 796 "usage", 797 "user", 798 "username", 799 "usernames", 800 "users", 801 "uuid", 802 "validation", 803 "validations", 804 "ver", 805 "version", 806 "video", 807 "videos", 808 "video-stats", 809 "visitor", 810 "visitors", 811 "voice", 812 "volunteer", 813 "volunteers", 814 "w", 815 "watch", 816 "wave", 817 "weather", 818 "web", 819 "webdisk", 820 "webhook", 821 "webhooks", 822 "webmail", 823 "webmaster", 824 "webmasters", 825 "webrnail", 826 "website", 827 "websites", 828 "welcome", 829 "whm", 830 "whois", 831 "widget", 832 "widgets", 833 "wifi", 834 "wiki", 835 "wikis", 836 "win", 837 "windows", 838 "word", 839 "work", 840 "works", 841 "workshop", 842 "wpad", 843 "ww", 844 "wws", 845 "www", 846 "wwws", 847 "wwww", 848 "xfn", 849 "xhtml", 850 "xhtrnl", 851 "xml", 852 "xmpp", 853 "xpg", 854 "xxx", 855 "yaml", 856 "year", 857 "yml", 858 "you", 859 "yourdomain", 860 "yourname", 861 "yoursite", 862 "yourusername", 863]; 864 865const FAMOUS_ACCOUNTS: &[&str] = &[ 866 "10ronaldinho", 867 "3gerardpique", 868 "aclu", 869 "adele", 870 "akshaykumar", 871 "aliaa08", 872 "aliciakeys", 873 "amitshah", 874 "andresiniesta8", 875 "anushkasharma", 876 "arianagrande", 877 "arrahman", 878 "arvindkejriwal", 879 "avrillavigne", 880 "barackobama", 881 "bbcbreaking", 882 "bbcworld", 883 "beingsalmankhan", 884 "billgates", 885 "britneyspears", 886 "brunomars", 887 "bts_bighit", 888 "bts_twt", 889 "championsleague", 890 "chrisbrown", 891 "cnnbrk", 892 "coldplay", 893 "conanobrien", 894 "cristiano", 895 "danieltosh", 896 "davidguetta", 897 "ddlovato", 898 "deepikapadukone", 899 "drake", 900 "elisapie", 901 "ellendegeneres", 902 "elonmusk", 903 "eminem", 904 "emmawatson", 905 "fcbarcelona", 906 "foxnews", 907 "harry_styles", 908 "hillaryclinton", 909 "iamsrk", 910 "ihrithik", 911 "imvkohli", 912 "instagram", 913 "jimmyfallon", 914 "jlo", 915 "joebiden", 916 "jtimberlake", 917 "justinbieber", 918 "kaka", 919 "kanyewest", 920 "katyperry", 921 "kendalljenner", 922 "kevinhart4real", 923 "khloekardashian", 924 "kimkardashian", 925 "kingjames", 926 "kourtneykardash", 927 "kyliejenner", 928 "ladygaga", 929 "liampayne", 930 "liltunechi", 931 "manutd", 932 "mariahcarey", 933 "mileycyrus", 934 "mohamadalarefe", 935 "narendramodi", 936 "nasa", 937 "nba", 938 "neymarjr", 939 "nfl", 940 "niallofficial", 941 "nickiminaj", 942 "npr", 943 "nytimes", 944 "onedirection", 945 "oprah", 946 "pink", 947 "pitbull", 948 "playstation", 949 "pmoindia", 950 "premierleague", 951 "priyankachopra", 952 "realdonaldtrump", 953 "ricky_martin", 954 "rihanna", 955 "sachin_rt", 956 "selenagomez", 957 "shakira", 958 "shawnmendes", 959 "sportscenter", 960 "srbachchan", 961 "subhisharma100", 962 "taylorswift13", 963 "theeconomist", 964 "twitter", 965 "virendersehwag", 966 "whitehouse45", 967 "wizkhalifa", 968 "youtube", 969 "zaynmalik", 970 "beyonce", 971 "billieeilish", 972 "leomessi", 973 "natgeo", 974 "nike", 975 "snoopdogg", 976 "taylorswift", 977 "therock", 978 "10downingstreet", 979 "aoc", 980 "carterjwm", 981 "dril", 982 "gretathunberg", 983 "kamalaharris", 984 "kremlinrussia_e", 985 "potus", 986 "rondesantisfl", 987 "ukraine", 988 "washingtonpost", 989 "yousuck2020", 990 "zelenskyyua", 991 "akiko_lawson", 992 "ariyoshihiroiki", 993 "asahi", 994 "dozle_official", 995 "famima_now", 996 "ff_xiv_jp", 997 "fujitv", 998 "gigazine", 999 "hajimesyacho", 1000 "hikakin", 1001 "jocx", 1002 "jotx", 1003 "kiyo_saiore", 1004 "mainichi", 1005 "matsu_bouzu", 1006 "naomiosaka", 1007 "nhk", 1008 "nikkei", 1009 "nintendo", 1010 "ntv", 1011 "oowareware1945", 1012 "pamyurin", 1013 "poke_times", 1014 "rolaworld", 1015 "seikintv", 1016 "starbucksjapan", 1017 "tbs", 1018 "tbs_pr", 1019 "tvasahi", 1020 "tvtokyo", 1021 "yokoono", 1022 "yomiuri_online", 1023 "brasildefato", 1024 "claudialeitte", 1025 "correio", 1026 "em_com", 1027 "estadao", 1028 "folha", 1029 "gazetadopovo", 1030 "ivetesangalo", 1031 "jairbolsonaro", 1032 "jornaldobrasil", 1033 "jornaloglobo", 1034 "lucianohuck", 1035 "lulaoficial", 1036 "marcosmion", 1037 "paulocoelho", 1038 "portalr7", 1039 "rede_globo", 1040 "zerohora", 1041]; 1042 1043pub static RESERVED_SUBDOMAINS: LazyLock<HashSet<&'static str>> = LazyLock::new(|| { 1044 let mut set = HashSet::with_capacity( 1045 ATP_SPECIFIC.len() + COMMONLY_RESERVED.len() + FAMOUS_ACCOUNTS.len(), 1046 ); 1047 for s in ATP_SPECIFIC { 1048 set.insert(*s); 1049 } 1050 for s in COMMONLY_RESERVED { 1051 set.insert(*s); 1052 } 1053 for s in FAMOUS_ACCOUNTS { 1054 set.insert(*s); 1055 } 1056 set 1057}); 1058 1059pub fn is_reserved_subdomain(subdomain: &str) -> bool { 1060 RESERVED_SUBDOMAINS.contains(subdomain.to_lowercase().as_str()) 1061} 1062 1063#[cfg(test)] 1064mod tests { 1065 use super::*; 1066 1067 #[test] 1068 fn test_atp_specific_reserved() { 1069 assert!(is_reserved_subdomain("admin")); 1070 assert!(is_reserved_subdomain("api")); 1071 assert!(is_reserved_subdomain("bsky")); 1072 assert!(is_reserved_subdomain("plc")); 1073 assert!(is_reserved_subdomain("xrpc")); 1074 } 1075 1076 #[test] 1077 fn test_famous_accounts_reserved() { 1078 assert!(is_reserved_subdomain("barackobama")); 1079 assert!(is_reserved_subdomain("elonmusk")); 1080 assert!(is_reserved_subdomain("taylorswift")); 1081 assert!(is_reserved_subdomain("nintendo")); 1082 } 1083 1084 #[test] 1085 fn test_case_insensitive() { 1086 assert!(is_reserved_subdomain("ADMIN")); 1087 assert!(is_reserved_subdomain("Admin")); 1088 assert!(is_reserved_subdomain("BARACKOBAMA")); 1089 } 1090 1091 #[test] 1092 fn test_not_reserved() { 1093 assert!(!is_reserved_subdomain("alice")); 1094 assert!(!is_reserved_subdomain("bob123")); 1095 assert!(!is_reserved_subdomain("randomuser")); 1096 } 1097}