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