geoBlock

  • builtin
  • by Takaro
  • Takaro >=0.0.1
  • all
Version

Built-in modules ship with Takaro — no import needed.

View export JSON

Block players from certain countries from joining the server.

Configuration 5

Settings you fill in when installing the module on a server.

SettingTypeDefaultDescription
mode Mode string "deny" If set to allow, only players from the specified countries will be allowed to join. If set to deny, players from the specified countries will be banned from the server.
countries required Countries array List of countries
ban Ban boolean true Ban players from the server when they are detected. When false, players will be kicked instead.
banDuration Ban duration number 86400000 Duration of the ban.
message Message string "Your IP address is banned." Message to send to the player when they are kicked or banned.
Raw config schema
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "mode": {
      "title": "Mode",
      "type": "string",
      "description": "If set to allow, only players from the specified countries will be allowed to join. If set to deny, players from the specified countries will be banned from the server.",
      "enum": [
        "allow",
        "deny"
      ],
      "default": "deny"
    },
    "countries": {
      "title": "Countries",
      "description": "List of countries",
      "type": "array",
      "uniqueItems": true,
      "x-component": "country",
      "items": {
        "type": "string",
        "anyOf": [
          {
            "const": "AF",
            "title": "Afghanistan"
          },
          {
            "const": "AX",
            "title": "Aland Islands"
          },
          {
            "const": "AL",
            "title": "Albania"
          },
          {
            "const": "DZ",
            "title": "Algeria"
          },
          {
            "const": "AS",
            "title": "American Samoa"
          },
          {
            "const": "AD",
            "title": "Andorra"
          },
          {
            "const": "AO",
            "title": "Angola"
          },
          {
            "const": "AI",
            "title": "Anguilla"
          },
          {
            "const": "AQ",
            "title": "Antarctica"
          },
          {
            "const": "AG",
            "title": "Antigua And Barbuda"
          },
          {
            "const": "AR",
            "title": "Argentina"
          },
          {
            "const": "AM",
            "title": "Armenia"
          },
          {
            "const": "AW",
            "title": "Aruba"
          },
          {
            "const": "AU",
            "title": "Australia"
          },
          {
            "const": "AT",
            "title": "Austria"
          },
          {
            "const": "AZ",
            "title": "Azerbaijan"
          },
          {
            "const": "BS",
            "title": "Bahamas"
          },
          {
            "const": "BH",
            "title": "Bahrain"
          },
          {
            "const": "BD",
            "title": "Bangladesh"
          },
          {
            "const": "BB",
            "title": "Barbados"
          },
          {
            "const": "BY",
            "title": "Belarus"
          },
          {
            "const": "BE",
            "title": "Belgium"
          },
          {
            "const": "BZ",
            "title": "Belize"
          },
          {
            "const": "BJ",
            "title": "Benin"
          },
          {
            "const": "BM",
            "title": "Bermuda"
          },
          {
            "const": "BT",
            "title": "Bhutan"
          },
          {
            "const": "BO",
            "title": "Bolivia"
          },
          {
            "const": "BA",
            "title": "Bosnia And Herzegovina"
          },
          {
            "const": "BW",
            "title": "Botswana"
          },
          {
            "const": "BV",
            "title": "Bouvet Island"
          },
          {
            "const": "BR",
            "title": "Brazil"
          },
          {
            "const": "IO",
            "title": "British Indian Ocean Territory"
          },
          {
            "const": "BN",
            "title": "Brunei Darussalam"
          },
          {
            "const": "BG",
            "title": "Bulgaria"
          },
          {
            "const": "BF",
            "title": "Burkina Faso"
          },
          {
            "const": "BI",
            "title": "Burundi"
          },
          {
            "const": "KH",
            "title": "Cambodia"
          },
          {
            "const": "CM",
            "title": "Cameroon"
          },
          {
            "const": "CA",
            "title": "Canada"
          },
          {
            "const": "CV",
            "title": "Cape Verde"
          },
          {
            "const": "KY",
            "title": "Cayman Islands"
          },
          {
            "const": "CF",
            "title": "Central African Republic"
          },
          {
            "const": "TD",
            "title": "Chad"
          },
          {
            "const": "CL",
            "title": "Chile"
          },
          {
            "const": "CN",
            "title": "China"
          },
          {
            "const": "CX",
            "title": "Christmas Island"
          },
          {
            "const": "CC",
            "title": "Cocos (Keeling) Islands"
          },
          {
            "const": "CO",
            "title": "Colombia"
          },
          {
            "const": "KM",
            "title": "Comoros"
          },
          {
            "const": "CG",
            "title": "Congo"
          },
          {
            "const": "CD",
            "title": "Congo, Democratic Republic"
          },
          {
            "const": "CK",
            "title": "Cook Islands"
          },
          {
            "const": "CR",
            "title": "Costa Rica"
          },
          {
            "const": "CI",
            "title": "Cote D'Ivoire"
          },
          {
            "const": "HR",
            "title": "Croatia"
          },
          {
            "const": "CU",
            "title": "Cuba"
          },
          {
            "const": "CY",
            "title": "Cyprus"
          },
          {
            "const": "CZ",
            "title": "Czech Republic"
          },
          {
            "const": "DK",
            "title": "Denmark"
          },
          {
            "const": "DJ",
            "title": "Djibouti"
          },
          {
            "const": "DM",
            "title": "Dominica"
          },
          {
            "const": "DO",
            "title": "Dominican Republic"
          },
          {
            "const": "EC",
            "title": "Ecuador"
          },
          {
            "const": "EG",
            "title": "Egypt"
          },
          {
            "const": "SV",
            "title": "El Salvador"
          },
          {
            "const": "GQ",
            "title": "Equatorial Guinea"
          },
          {
            "const": "ER",
            "title": "Eritrea"
          },
          {
            "const": "EE",
            "title": "Estonia"
          },
          {
            "const": "ET",
            "title": "Ethiopia"
          },
          {
            "const": "FK",
            "title": "Falkland Islands (Malvinas)"
          },
          {
            "const": "FO",
            "title": "Faroe Islands"
          },
          {
            "const": "FJ",
            "title": "Fiji"
          },
          {
            "const": "FI",
            "title": "Finland"
          },
          {
            "const": "FR",
            "title": "France"
          },
          {
            "const": "GF",
            "title": "French Guiana"
          },
          {
            "const": "PF",
            "title": "French Polynesia"
          },
          {
            "const": "TF",
            "title": "French Southern Territories"
          },
          {
            "const": "GA",
            "title": "Gabon"
          },
          {
            "const": "GM",
            "title": "Gambia"
          },
          {
            "const": "GE",
            "title": "Georgia"
          },
          {
            "const": "DE",
            "title": "Germany"
          },
          {
            "const": "GH",
            "title": "Ghana"
          },
          {
            "const": "GI",
            "title": "Gibraltar"
          },
          {
            "const": "GR",
            "title": "Greece"
          },
          {
            "const": "GL",
            "title": "Greenland"
          },
          {
            "const": "GD",
            "title": "Grenada"
          },
          {
            "const": "GP",
            "title": "Guadeloupe"
          },
          {
            "const": "GU",
            "title": "Guam"
          },
          {
            "const": "GT",
            "title": "Guatemala"
          },
          {
            "const": "GG",
            "title": "Guernsey"
          },
          {
            "const": "GN",
            "title": "Guinea"
          },
          {
            "const": "GW",
            "title": "Guinea-Bissau"
          },
          {
            "const": "GY",
            "title": "Guyana"
          },
          {
            "const": "HT",
            "title": "Haiti"
          },
          {
            "const": "VA",
            "title": "Holy See (Vatican City State)"
          },
          {
            "const": "HN",
            "title": "Honduras"
          },
          {
            "const": "HK",
            "title": "Hong Kong"
          },
          {
            "const": "HU",
            "title": "Hungary"
          },
          {
            "const": "IS",
            "title": "Iceland"
          },
          {
            "const": "IN",
            "title": "India"
          },
          {
            "const": "ID",
            "title": "Indonesia"
          },
          {
            "const": "IR",
            "title": "Iran, Islamic Republic Of"
          },
          {
            "const": "IQ",
            "title": "Iraq"
          },
          {
            "const": "IE",
            "title": "Ireland"
          },
          {
            "const": "IM",
            "title": "Isle Of Man"
          },
          {
            "const": "IL",
            "title": "Israel"
          },
          {
            "const": "IT",
            "title": "Italy"
          },
          {
            "const": "JM",
            "title": "Jamaica"
          },
          {
            "const": "JP",
            "title": "Japan"
          },
          {
            "const": "JE",
            "title": "Jersey"
          },
          {
            "const": "JO",
            "title": "Jordan"
          },
          {
            "const": "KZ",
            "title": "Kazakhstan"
          },
          {
            "const": "KE",
            "title": "Kenya"
          },
          {
            "const": "KI",
            "title": "Kiribati"
          },
          {
            "const": "KR",
            "title": "Korea"
          },
          {
            "const": "KW",
            "title": "Kuwait"
          },
          {
            "const": "KG",
            "title": "Kyrgyzstan"
          },
          {
            "const": "LA",
            "title": "Lao People's Democratic Republic"
          },
          {
            "const": "LV",
            "title": "Latvia"
          },
          {
            "const": "LB",
            "title": "Lebanon"
          },
          {
            "const": "LS",
            "title": "Lesotho"
          },
          {
            "const": "LR",
            "title": "Liberia"
          },
          {
            "const": "LY",
            "title": "Libyan Arab Jamahiriya"
          },
          {
            "const": "LI",
            "title": "Liechtenstein"
          },
          {
            "const": "LT",
            "title": "Lithuania"
          },
          {
            "const": "LU",
            "title": "Luxembourg"
          },
          {
            "const": "MO",
            "title": "Macao"
          },
          {
            "const": "MK",
            "title": "Macedonia"
          },
          {
            "const": "MG",
            "title": "Madagascar"
          },
          {
            "const": "MW",
            "title": "Malawi"
          },
          {
            "const": "MY",
            "title": "Malaysia"
          },
          {
            "const": "MV",
            "title": "Maldives"
          },
          {
            "const": "ML",
            "title": "Mali"
          },
          {
            "const": "MT",
            "title": "Malta"
          },
          {
            "const": "MH",
            "title": "Marshall Islands"
          },
          {
            "const": "MQ",
            "title": "Martinique"
          },
          {
            "const": "MR",
            "title": "Mauritania"
          },
          {
            "const": "MU",
            "title": "Mauritius"
          },
          {
            "const": "YT",
            "title": "Mayotte"
          },
          {
            "const": "MX",
            "title": "Mexico"
          },
          {
            "const": "FM",
            "title": "Micronesia, Federated States Of"
          },
          {
            "const": "MD",
            "title": "Moldova"
          },
          {
            "const": "MC",
            "title": "Monaco"
          },
          {
            "const": "MN",
            "title": "Mongolia"
          },
          {
            "const": "ME",
            "title": "Montenegro"
          },
          {
            "const": "MS",
            "title": "Montserrat"
          },
          {
            "const": "MA",
            "title": "Morocco"
          },
          {
            "const": "MZ",
            "title": "Mozambique"
          },
          {
            "const": "MM",
            "title": "Myanmar"
          },
          {
            "const": "NA",
            "title": "Namibia"
          },
          {
            "const": "NR",
            "title": "Nauru"
          },
          {
            "const": "NP",
            "title": "Nepal"
          },
          {
            "const": "NL",
            "title": "Netherlands"
          },
          {
            "const": "NC",
            "title": "New Caledonia"
          },
          {
            "const": "NZ",
            "title": "New Zealand"
          },
          {
            "const": "NI",
            "title": "Nicaragua"
          },
          {
            "const": "NE",
            "title": "Niger"
          },
          {
            "const": "NG",
            "title": "Nigeria"
          },
          {
            "const": "NU",
            "title": "Niue"
          },
          {
            "const": "NF",
            "title": "Norfolk Island"
          },
          {
            "const": "MP",
            "title": "Northern Mariana Islands"
          },
          {
            "const": "NO",
            "title": "Norway"
          },
          {
            "const": "OM",
            "title": "Oman"
          },
          {
            "const": "PK",
            "title": "Pakistan"
          },
          {
            "const": "PW",
            "title": "Palau"
          },
          {
            "const": "PS",
            "title": "Palestinian Territory, Occupied"
          },
          {
            "const": "PA",
            "title": "Panama"
          },
          {
            "const": "PG",
            "title": "Papua New Guinea"
          },
          {
            "const": "PY",
            "title": "Paraguay"
          },
          {
            "const": "PE",
            "title": "Peru"
          },
          {
            "const": "PH",
            "title": "Philippines"
          },
          {
            "const": "PN",
            "title": "Pitcairn"
          },
          {
            "const": "PL",
            "title": "Poland"
          },
          {
            "const": "PT",
            "title": "Portugal"
          },
          {
            "const": "PR",
            "title": "Puerto Rico"
          },
          {
            "const": "QA",
            "title": "Qatar"
          },
          {
            "const": "RE",
            "title": "Reunion"
          },
          {
            "const": "RO",
            "title": "Romania"
          },
          {
            "const": "RU",
            "title": "Russian Federation"
          },
          {
            "const": "RW",
            "title": "Rwanda"
          },
          {
            "const": "BL",
            "title": "Saint Barthelemy"
          },
          {
            "const": "SH",
            "title": "Saint Helena"
          },
          {
            "const": "KN",
            "title": "Saint Kitts And Nevis"
          },
          {
            "const": "LC",
            "title": "Saint Lucia"
          },
          {
            "const": "MF",
            "title": "Saint Martin"
          },
          {
            "const": "PM",
            "title": "Saint Pierre And Miquelon"
          },
          {
            "const": "VC",
            "title": "Saint Vincent And Grenadines"
          },
          {
            "const": "WS",
            "title": "Samoa"
          },
          {
            "const": "SM",
            "title": "San Marino"
          },
          {
            "const": "ST",
            "title": "Sao Tome And Principe"
          },
          {
            "const": "SA",
            "title": "Saudi Arabia"
          },
          {
            "const": "SN",
            "title": "Senegal"
          },
          {
            "const": "RS",
            "title": "Serbia"
          },
          {
            "const": "SC",
            "title": "Seychelles"
          },
          {
            "const": "SL",
            "title": "Sierra Leone"
          },
          {
            "const": "SG",
            "title": "Singapore"
          },
          {
            "const": "SK",
            "title": "Slovakia"
          },
          {
            "const": "SI",
            "title": "Slovenia"
          },
          {
            "const": "SB",
            "title": "Solomon Islands"
          },
          {
            "const": "SO",
            "title": "Somalia"
          },
          {
            "const": "ZA",
            "title": "South Africa"
          },
          {
            "const": "ES",
            "title": "Spain"
          },
          {
            "const": "LK",
            "title": "Sri Lanka"
          },
          {
            "const": "SD",
            "title": "Sudan"
          },
          {
            "const": "SR",
            "title": "Suriname"
          },
          {
            "const": "SZ",
            "title": "Swaziland"
          },
          {
            "const": "SE",
            "title": "Sweden"
          },
          {
            "const": "CH",
            "title": "Switzerland"
          },
          {
            "const": "SY",
            "title": "Syrian Arab Republic"
          },
          {
            "const": "TW",
            "title": "Taiwan"
          },
          {
            "const": "TJ",
            "title": "Tajikistan"
          },
          {
            "const": "TZ",
            "title": "Tanzania"
          },
          {
            "const": "TH",
            "title": "Thailand"
          },
          {
            "const": "TL",
            "title": "Timor-Leste"
          },
          {
            "const": "TG",
            "title": "Togo"
          },
          {
            "const": "TK",
            "title": "Tokelau"
          },
          {
            "const": "TO",
            "title": "Tonga"
          },
          {
            "const": "TT",
            "title": "Trinidad And Tobago"
          },
          {
            "const": "TN",
            "title": "Tunisia"
          },
          {
            "const": "TR",
            "title": "Turkey"
          },
          {
            "const": "TM",
            "title": "Turkmenistan"
          },
          {
            "const": "TV",
            "title": "Tuvalu"
          },
          {
            "const": "UG",
            "title": "Uganda"
          },
          {
            "const": "UA",
            "title": "Ukraine"
          },
          {
            "const": "AE",
            "title": "United Arab Emirates"
          },
          {
            "const": "GB",
            "title": "United Kingdom"
          },
          {
            "const": "US",
            "title": "United States"
          },
          {
            "const": "UY",
            "title": "Uruguay"
          },
          {
            "const": "UZ",
            "title": "Uzbekistan"
          },
          {
            "const": "VU",
            "title": "Vanuatu"
          },
          {
            "const": "VE",
            "title": "Venezuela"
          },
          {
            "const": "VN",
            "title": "Vietnam"
          },
          {
            "const": "EH",
            "title": "Western Sahara"
          },
          {
            "const": "YE",
            "title": "Yemen"
          },
          {
            "const": "ZM",
            "title": "Zambia"
          },
          {
            "const": "ZW",
            "title": "Zimbabwe"
          }
        ]
      }
    },
    "ban": {
      "title": "Ban",
      "description": "Ban players from the server when they are detected. When false, players will be kicked instead.",
      "type": "boolean",
      "default": true
    },
    "banDuration": {
      "title": "Ban duration",
      "description": "Duration of the ban.",
      "x-component": "duration",
      "type": "number",
      "minimum": 0,
      "default": 86400000
    },
    "message": {
      "title": "Message",
      "type": "string",
      "description": "Message to send to the player when they are kicked or banned.",
      "default": "Your IP address is banned."
    }
  },
  "required": [
    "countries"
  ],
  "additionalProperties": false
}
Raw UI schema
{
  "banDuration": {
    "ui:widget": "duration"
  }
}

Hooks 1

Code that runs in reaction to a game or Takaro event.

  • IPDetected

    Hook for player-new-ip-detected events

    Hook source
    import { takaro, data, checkPermission } from '@takaro/helpers';
    async function main() {
        const { gameServerId, player, pog } = data;
        const { country } = data.eventData;
        const { ban, banDuration, countries, message, mode } = data.module.userConfig;
        async function handleAction() {
            if (ban) {
                const now = new Date();
                const expiresAt = new Date(now.getTime() + banDuration);
                await takaro.player.banControllerCreate({
                    gameServerId,
                    playerId: player.id,
                    until: expiresAt,
                    reason: message,
                });
            }
            else {
                await takaro.gameserver.gameServerControllerKickPlayer(gameServerId, player.id, {
                    reason: message,
                });
            }
        }
        const isImmune = checkPermission(pog, 'GEOBLOCK_IMMUNITY');
        if (isImmune) {
            console.log('Player has immunity, no action');
            return;
        }
        if (mode === 'allow') {
            if (countries.includes(country)) {
                console.log('Allowed country detected, no action');
                return;
            }
            console.log('Blocked country detected, performing actions');
            await handleAction();
            return;
        }
        if (mode === 'deny') {
            if (countries.includes(country)) {
                console.log('Blocked country detected, performing actions');
                await handleAction();
                return;
            }
            else {
                console.log('Allowed country detected, no action');
                return;
            }
        }
    }
    await main();
    //# sourceMappingURL=IPDetected.js.map

Permissions 1

Roles you can grant to decide who may use what.

  • GeoBlock immunity

    Players with this permission will not be kicked or banned by GeoBlock.