diff --git a/SQL/bluemoon_schema.sql b/SQL/bluemoon_schema.sql index a00aac276bd5..4eb4ac4f68d1 100644 --- a/SQL/bluemoon_schema.sql +++ b/SQL/bluemoon_schema.sql @@ -80,48 +80,3 @@ DELIMITER ; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; - --- --- Table structure for table `ipintel` --- -DROP TABLE IF EXISTS `ipintel`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `ipintel` ( - `ip` int UNSIGNED NOT NULL, - `date` timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL, - `intel` real NOT NULL DEFAULT '0', - PRIMARY KEY (`ip`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `vpn_whitelist` --- -DROP TABLE IF EXISTS `vpn_whitelist`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `vpn_whitelist` ( - `ckey` varchar(32) NOT NULL, - `reason` text, - PRIMARY KEY (`ckey`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `connection_ipintel_log` --- -DROP TABLE IF EXISTS `connection_ipintel_log`; -CREATE TABLE `connection_ipintel_log` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `datetime` datetime NOT NULL, - `ckey` varchar(32) NOT NULL, - `ip` INT UNSIGNED NOT NULL, - `computerid` varchar(32) NOT NULL, - `server_id` VARCHAR(50) NULL DEFAULT NULL, - `result` ENUM('ESTABLISHED','DROPPED - IPINTEL','DROPPED - BANNED','DROPPED - INVALID') NOT NULL DEFAULT 'ESTABLISHED' COLLATE 'utf8mb4_general_ci', - PRIMARY KEY (`id`), - KEY `ckey` (`ckey`), - KEY `ip` (`ip`), - KEY `computerid` (`computerid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; diff --git a/code/_BLUEMOONCODE/_HELPERS/time.dm b/code/_BLUEMOONCODE/_HELPERS/time.dm deleted file mode 100644 index a32763d3681f..000000000000 --- a/code/_BLUEMOONCODE/_HELPERS/time.dm +++ /dev/null @@ -1,3 +0,0 @@ -//returns timestamp in a sql and a not-quite-compliant ISO 8601 friendly format -/proc/ISOtime(timevar) - return time2text(timevar || world.timeofday, "YYYY-MM-DD hh:mm:ss") diff --git a/code/_BLUEMOONCODE/_HELPERS/unsorted.dm b/code/_BLUEMOONCODE/_HELPERS/unsorted.dm deleted file mode 100644 index 438c32a968bb..000000000000 --- a/code/_BLUEMOONCODE/_HELPERS/unsorted.dm +++ /dev/null @@ -1,45 +0,0 @@ -/** - * HTTP Get (Powered by RUSTG) - * - * This proc should be used as a replacement for [/world/proc/Export] due to an underlying issue with it. - * See: https://www.byond.com/forum/post/2772166 - * The one thing you will need to be aware of is that this no longer wraps the response inside a "file", so anything that relies on a file2text() unwrap will need tweaking. - * RUST HTTP also has better support for HTTPS as well as weird quirks with modern webservers. - * Returns an assoc list that follows the standard [/world/proc/Export] format (https://secure.byond.com/docs/ref/index.html#/world/proc/Export), with the above exception - * - * Arguments: - * * url - URL to GET - */ -/proc/HTTPGet(url) - var/datum/http_request/req = new - req.prepare(RUSTG_HTTP_METHOD_GET, url) - req.begin_async() - - // Check if we are complete - UNTIL(req.is_complete()) - var/datum/http_response/res = req.into_response() - - if(res.errored) - . = list() // Return an empty list - CRASH("Internal error during HTTP get: [res.error]") - - var/list/output = list() - output["STATUS"] = res.status_code - - // Handle changes of line format. ASCII 13 = CR - var/content = replacetext(res.body, "[ascii2text(13)]\n", "\n") - output["CONTENT"] = content - - return output - -/proc/log_connection(ckey, ip, cid, connection_type) - ASSERT(connection_type in list(CONNECTION_TYPE_ESTABLISHED, CONNECTION_TYPE_DROPPED_IPINTEL, CONNECTION_TYPE_DROPPED_BANNED, CONNECTION_TYPE_DROPPED_INVALID)) - var/datum/db_query/query_accesslog = SSdbcore.NewQuery("INSERT INTO connection_ipintel_log (`datetime`, `ckey`, `ip`, `computerid`, `result`, `server_id`) VALUES(Now(), :ckey, INET_ATON(:ip), :cid, :result, :server_id)", list( - "ckey" = ckey, - "ip" = "[ip ? ip : "127.0.0.1"]", - "cid" = cid, - "result" = connection_type, - "server_id" = CONFIG_GET(string/servername) - )) - query_accesslog.warn_execute() - qdel(query_accesslog) diff --git a/code/__BLUEMOONCODE/_DEFINES/ipintel.dm b/code/__BLUEMOONCODE/_DEFINES/ipintel.dm deleted file mode 100644 index 781fd4bb277e..000000000000 --- a/code/__BLUEMOONCODE/_DEFINES/ipintel.dm +++ /dev/null @@ -1,9 +0,0 @@ -// Connection types. These match enums in the SQL DB. Dont change them -/// Client was let into the server -#define CONNECTION_TYPE_ESTABLISHED "ESTABLISHED" -/// Client was disallowed due to IPIntel -#define CONNECTION_TYPE_DROPPED_IPINTEL "DROPPED - IPINTEL" -/// Client was disallowed due to being banned -#define CONNECTION_TYPE_DROPPED_BANNED "DROPPED - BANNED" -/// Client was disallowed due to invalid data -#define CONNECTION_TYPE_DROPPED_INVALID "DROPPED - INVALID" diff --git a/code/controllers/configuration/bluemoon_entries/general.dm b/code/controllers/configuration/bluemoon_entries/general.dm deleted file mode 100644 index cf8b8566a57a..000000000000 --- a/code/controllers/configuration/bluemoon_entries/general.dm +++ /dev/null @@ -1,41 +0,0 @@ -/// Defines whether or not mentors can see ckeys alongside mobnames. -/datum/config_entry/flag/mentors_mobname_only - -/// Defines whether the server uses the legacy mentor system with mentors.txt or the SQL system. -/datum/config_entry/flag/mentor_legacy_system - protection = CONFIG_ENTRY_LOCKED - -/datum/config_entry/flag/ipintel_enabled - default = FALSE - -/datum/config_entry/string/ipintel_domain - default = "check.getipintel.net" - -/datum/config_entry/string/details_url - default = "https://iphub.info/?ip=" - -/datum/config_entry/string/contact_email - -/datum/config_entry/string/contact_email/ValidateAndSet(str_val) - return str_val != "ch@nge.me" && (!length(str_val) || findtext(str_val, "@")) && ..() - -/datum/config_entry/number/bad_rating - default = 0.9 - integer = FALSE - min_val = 0 - max_val = 1 - -/datum/config_entry/flag/whitelist_mode - default = TRUE - -/datum/config_entry/number/hours_save_good - default = 72 - min_val = 0 - -/datum/config_entry/number/hours_save_bad - default = 24 - min_val = 0 - -/datum/config_entry/number/playtime_ignore_threshold - default = 10 - min_val = 0 diff --git a/code/controllers/configuration/entries/connections.dm b/code/controllers/configuration/entries/connections.dm index 91d1a6fc97f1..afbe94840ade 100644 --- a/code/controllers/configuration/entries/connections.dm +++ b/code/controllers/configuration/entries/connections.dm @@ -37,7 +37,6 @@ /datum/config_entry/flag/check_randomizer -/* BLUEMOON EDIT:START IPINTEL FROM TG /datum/config_entry/string/ipintel_email /datum/config_entry/string/ipintel_email/ValidateAndSet(str_val) @@ -59,7 +58,6 @@ /datum/config_entry/string/ipintel_domain default = "check.getipintel.net" -*/ // BLUEMOON EDIT:END IPINTEL FROM TG /datum/config_entry/flag/aggressive_changelog diff --git a/code/controllers/subsystem/ipintel.dm b/code/controllers/subsystem/ipintel.dm index a7f5da72de84..fb0ddead09a5 100644 --- a/code/controllers/subsystem/ipintel.dm +++ b/code/controllers/subsystem/ipintel.dm @@ -11,3 +11,4 @@ SUBSYSTEM_DEF(ipintel) /datum/controller/subsystem/ipintel/Initialize(timeofday, zlevel) enabled = TRUE . = ..() + diff --git a/code/modules/admin/IsBanned.dm b/code/modules/admin/IsBanned.dm index 32883d77500a..825e2d83c787 100644 --- a/code/modules/admin/IsBanned.dm +++ b/code/modules/admin/IsBanned.dm @@ -6,7 +6,7 @@ #define STICKYBAN_MAX_EXISTING_USER_MATCHES 5 //ie, users who were connected before the ban triggered #define STICKYBAN_MAX_ADMIN_MATCHES 2 -/world/IsBanned(key,address,computer_id,type,real_bans_only=FALSE, check_ipintel = TRUE, log_info = TRUE) // BLUEMOON EDIT:START IPINTEL FROM TG +/world/IsBanned(key,address,computer_id,type,real_bans_only=FALSE) var/static/key_cache = list() if(!real_bans_only) if(key_cache[key] >= REALTIMEOFDAY) @@ -17,17 +17,13 @@ if(real_bans_only) key_cache[key] = 0 return FALSE - log_access("Login (invalid data): [key] [address]-[computer_id]") + log_access("Failed Login (invalid data): [key] [address]-[computer_id]") key_cache[key] = 0 - if(log_info) // BLUEMOON EDIT:START IPINTEL FROM TG - INVOKE_ASYNC(GLOBAL_PROC, GLOBAL_PROC_REF(log_connection), (ckey(key) || ""), (address || ""), (computer_id || ""), CONNECTION_TYPE_DROPPED_INVALID) return list("reason"="invalid login data", "desc"="Error: Could not check ban status, Please try again. Error message: Your computer provided invalid or blank information to the server on connection (byond username, IP, and Computer ID.) Provided information for reference: Username:'[key]' IP:'[address]' Computer ID:'[computer_id]'. (If you continue to get this error, please restart byond or contact byond support.)") if (text2num(computer_id) == 2147483647) //this cid causes stickybans to go haywire - log_access("Login (invalid cid): [key] [address]-[computer_id]") + log_access("Failed Login (invalid cid): [key] [address]-[computer_id]") key_cache[key] = 0 - if(log_info) // BLUEMOON EDIT:START IPINTEL FROM TG - INVOKE_ASYNC(GLOBAL_PROC, GLOBAL_PROC_REF(log_connection), ckey(key), address, computer_id, CONNECTION_TYPE_DROPPED_INVALID) return list("reason"="invalid login data", "desc"="Error: Could not check ban status, Please try again. Error message: Your computer provided an invalid Computer ID.)") if (type == "world") @@ -52,10 +48,8 @@ message_admins("The admin [key] has been allowed to bypass the whitelist") addclientmessage(ckey,"You have been allowed to bypass the whitelist") else - log_access("Login: [key] - Not on whitelist") + log_access("Failed Login: [key] - Not on whitelist") key_cache[key] = 0 - if(log_info) // BLUEMOON EDIT:START IPINTEL FROM TG - INVOKE_ASYNC(GLOBAL_PROC, GLOBAL_PROC_REF(log_connection), ckey(key), address, computer_id, CONNECTION_TYPE_DROPPED_IPINTEL) return list("reason"="whitelist", "desc" = "\nReason: You are not on the white list for this server") //Guest Checking @@ -63,14 +57,10 @@ if (CONFIG_GET(flag/guest_ban)) log_access("Failed Login: [key] - Guests not allowed") key_cache[key] = 0 - if(log_info) // BLUEMOON EDIT:START IPINTEL FROM TG - INVOKE_ASYNC(GLOBAL_PROC, GLOBAL_PROC_REF(log_connection), ckey(key), address, computer_id, CONNECTION_TYPE_DROPPED_BANNED) return list("reason"="guest", "desc"="\nReason: Guests not allowed. Please sign in with a byond account.") if (CONFIG_GET(flag/panic_bunker) && SSdbcore.Connect()) log_access("Failed Login: [key] - Guests not allowed during panic bunker") key_cache[key] = 0 - if(log_info) // BLUEMOON EDIT:START IPINTEL FROM TG - INVOKE_ASYNC(GLOBAL_PROC, GLOBAL_PROC_REF(log_connection), ckey(key), address, computer_id, CONNECTION_TYPE_DROPPED_BANNED) return list("reason"="guest", "desc"="\nReason: Sorry but the server is currently not accepting connections from never before seen players or guests. If you have played on this server with a byond account before, please log in to the byond account you have played from.") //Population Cap Checking @@ -80,16 +70,6 @@ key_cache[key] = 0 return list("reason"="popcap", "desc"= "\nReason: [CONFIG_GET(string/extreme_popcap_message)]") - // BLUEMOON EDIT:START IPINTEL FROM TG - //check if the IP address is a known proxy/vpn, and the user is not whitelisted - if(check_ipintel && CONFIG_GET(string/contact_email) && CONFIG_GET(flag/whitelist_mode) && GLOB.ipintel_manager.ipintel_is_banned(key, address)) - log_admin("Failed Login: [key] [computer_id] [address] - Proxy/VPN") - var/mistakemessage = "" - if(CONFIG_GET(string/banappeals)) - mistakemessage = "\nIf you have to use one, request whitelisting at: [CONFIG_GET(string/banappeals)]" - return list("reason"="using proxy or vpn", "desc"="\nReason: Proxies/VPNs are not allowed here. [mistakemessage]") - // BLUEMOON EDIT:END IPINTEL FROM TG - if(CONFIG_GET(flag/ban_legacy_system)) //Ban Checking @@ -102,8 +82,6 @@ else log_access("Failed Login: [key] [computer_id] [address] - Banned [.["reason"]]") key_cache[key] = 0 - if(log_info) // BLUEMOON EDIT: IPINTEL FROM TG - INVOKE_ASYNC(GLOBAL_PROC, GLOBAL_PROC_REF(log_connection), ckey(key), address, computer_id, CONNECTION_TYPE_DROPPED_BANNED) return . else @@ -176,8 +154,6 @@ log_access("Failed Login: [key] [computer_id] [address] - Banned (#[banid]) [.["reason"]]") qdel(query_ban_check) key_cache[key] = 0 - if(log_info) // BLUEMOON EDIT IPINTEL FROM TG - INVOKE_ASYNC(GLOBAL_PROC, GLOBAL_PROC_REF(log_connection), ckey(key), address, computer_id, CONNECTION_TYPE_DROPPED_BANNED) return . qdel(query_ban_check) @@ -256,7 +232,7 @@ var/desc = "\nReason:(StickyBan) You, or another user of this computer or connection ([bannedckey]) is banned from playing here. The ban reason is:\n[ban["message"]]\nThis ban was applied by [ban["admin"]]\nThis is a BanEvasion Detection System ban, if you think this ban is a mistake, please wait EXACTLY 6 seconds, then try again before filing an appeal.\n" . = list("reason" = "Stickyban", "desc" = desc) - log_access("Login: [key] [computer_id] [address] - StickyBanned [ban["message"]] Target Username: [bannedckey] Placed by [ban["admin"]]") + log_access("Failed Login: [key] [computer_id] [address] - StickyBanned [ban["message"]] Target Username: [bannedckey] Placed by [ban["admin"]]") key_cache[key] = 0 return . diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm index b9cee19d54d3..4254acce8536 100644 --- a/code/modules/admin/admin_verbs.dm +++ b/code/modules/admin/admin_verbs.dm @@ -58,7 +58,6 @@ GLOBAL_PROTECT(admin_verbs_admin) /client/proc/Getkey, /*teleports a mob with a certain ckey to our location*/ /client/proc/game_panel, /*game panel, allows to change game-mode etc*/ /client/proc/mail_panel, /*BLUEMOON ADD - панель управления почтой*/ - /datum/admins/proc/vpn_whitelist, /*BLUEMOON ADD - Допуск */ /client/proc/fax_panel, /*send a paper to fax*/ // /client/proc/sendmob, /*sends a mob somewhere*/ -Removed due to it needing two sorting procs to work, which were executed every time an admin right-clicked. ~Errorage /client/proc/jumptoarea, diff --git a/code/modules/admin/ipintel.dm b/code/modules/admin/ipintel.dm index 687ee92410db..71c9a11acd53 100644 --- a/code/modules/admin/ipintel.dm +++ b/code/modules/admin/ipintel.dm @@ -1,4 +1,3 @@ -/* // BLUEMOON EDIT:START IPINTEL FROM TG /datum/ipintel var/ip var/intel = 0 @@ -135,381 +134,3 @@ /proc/log_ipintel(text) log_game("IPINTEL: [text]") debug_admins("IPINTEL: [text]") -*/ // BLUEMOON EDIT:END IPINTEL FROM TG - -// BLUEMOON EDIT:START IPINTEL FROM TG -GLOBAL_DATUM_INIT(ipintel_manager, /datum/ipintel_manager, new()) - -/datum/ipintel_manager - var/throttle = 0 - var/errors = 0 - - var/list/cache = list() - -// Represents an IP intel holder datum -/datum/ipintel - /// The IP being checked - var/ip - /// The current rating, 0-1 float. - var/intel = 0 - /// Whether this was loaded from the cache or not - var/cache = FALSE - /// How many minutes ago it was cached - var/cacheminutesago = 0 - /// The date it was cached - var/cachedate = "" - /// The real time it was cached - var/cacherealtime = 0 - -/datum/ipintel/New() - cachedate = SQLtime() - cacherealtime = world.realtime - -/datum/ipintel/proc/is_valid() - . = FALSE - if(intel < 0) - return - if(intel <= CONFIG_GET(number/bad_rating)) - if(world.realtime < cacherealtime + (CONFIG_GET(number/hours_save_good) HOURS)) - return TRUE - else - if(world.realtime < cacherealtime + (CONFIG_GET(number/hours_save_bad) HOURS)) - return TRUE - - - -/** - * Get IP intel - * - * Performs a lookup of the rating for an IP provided - * - * Arguments: - * * ip - The IP to lookup - * * bypasscache - Do we want to bypass the DB cache? - * * updatecache - Do we want to update the DB cache? - */ -/datum/ipintel_manager/proc/get_ip_intel(ip, bypasscache = FALSE, updatecache = TRUE) - var/datum/ipintel/res = new() - res.ip = ip - . = res - if(!ip || !CONFIG_GET(string/contact_email) || !CONFIG_GET(flag/ipintel_enabled)) - return - if(!bypasscache) - var/datum/ipintel/cachedintel = cache[ip] - if(cachedintel && cachedintel.is_valid()) - cachedintel.cache = TRUE - return cachedintel - - if(SSdbcore.IsConnected()) - var/datum/db_query/query_get_ip_intel = SSdbcore.NewQuery({" - SELECT date, intel, TIMESTAMPDIFF(MINUTE,date,NOW()) - FROM ipintel - WHERE - ip = INET_ATON(:ip) - AND (( - intel < :rating_bad - AND - date + INTERVAL :save_good HOUR > NOW() - ) OR ( - intel >= :rating_bad - AND - date + INTERVAL :save_bad HOUR > NOW() - )) - "}, list( - "ip" = ip, - "rating_bad" = CONFIG_GET(number/bad_rating), - "save_good" = CONFIG_GET(number/hours_save_good), - "save_bad" = CONFIG_GET(number/hours_save_bad), - )) - if(!query_get_ip_intel.warn_execute()) - qdel(query_get_ip_intel) - return - if(query_get_ip_intel.NextRow()) - res.cache = TRUE - res.cachedate = query_get_ip_intel.item[1] - res.intel = text2num(query_get_ip_intel.item[2]) - res.cacheminutesago = text2num(query_get_ip_intel.item[3]) - res.cacherealtime = world.realtime - (text2num(query_get_ip_intel.item[3])*10*60) - cache[ip] = res - qdel(query_get_ip_intel) - return - qdel(query_get_ip_intel) - res.intel = ip_intel_query(ip) - if(updatecache && res.intel >= 0) - cache[ip] = res - if(SSdbcore.IsConnected()) - var/datum/db_query/query_add_ip_intel = SSdbcore.NewQuery({" - INSERT INTO ipintel (ip, intel) VALUES (INET_ATON(:ip), :intel) - ON DUPLICATE KEY UPDATE intel = VALUES(intel), date = NOW()"}, - list( - "ip" = ip, - "intel" = res.intel - ) - ) - query_add_ip_intel.warn_execute() - qdel(query_add_ip_intel) - - - -/** - * Performs the remote IPintel lookup - * - * - * - * Arguments: - * * ip - The IP to lookup - * * retried - Was this attempt retried? - */ -/datum/ipintel_manager/proc/ip_intel_query(ip, retried = FALSE) - . = -1 //default - if(!ip) - return - if(throttle > world.timeofday) - return - - // Do not refactor this to use SShttp, because that requires the subsystem to be firing for requests to be made, and this will be triggered before the MC has finished loading - var/list/http[] = HTTPGet("http://[CONFIG_GET(string/ipintel_domain)]/check.php?ip=[ip]&contact=[CONFIG_GET(string/contact_email)]&format=json&flags=b") - - if(http) - var/status = text2num(http["STATUS"]) - - if(status == 200) - var/response = json_decode(http["CONTENT"]) - if(response) - if(response["status"] == "success") - var/intelnum = text2num(response["result"]) - if(isnum(intelnum)) - return text2num(response["result"]) - else - ipintel_handle_error("Bad intel from server: [response["result"]].", ip, retried) - if(!retried) - sleep(25) - return .(ip, 1) - else - ipintel_handle_error("Bad response from server: [response["status"]].", ip, retried) - if(!retried) - sleep(25) - return .(ip, 1) - - else if(status == 429) - ipintel_handle_error("Error #429: We have exceeded the rate limit.", ip, 1) - return - else - ipintel_handle_error("Unknown status code: [status].", ip, retried) - if(!retried) - sleep(25) - return .(ip, 1) - else - ipintel_handle_error("Unable to connect to API.", ip, retried) - if(!retried) - sleep(25) - return .(ip, 1) - - - -/** - * Error handler - * - * Handles an IP intel error, also throttling the susbystem if required - * - * Arguments: - * * error - The error description - * * ip - The IP that was tried - * * retried - Was this on a retried attempt - */ -/datum/ipintel_manager/proc/ipintel_handle_error(error, ip, retried) - if(retried) - errors++ - error += " Could not check [ip]. Disabling IPINTEL for [errors] minute[(errors == 1 ? "" : "s")]" - throttle = world.timeofday + (2 * errors MINUTES) - else - error += " Attempting retry on [ip]." - log_ipintel(error) - - - -/** - * Logs an IPintel error - * - * Pretty self explanatory. Logs errors regarding ipintel. - * - * Arguments: - * * text - Argument 1 - */ -/datum/ipintel_manager/proc/log_ipintel(text) - log_game("IPINTEL: [text]") - log_access("IPINTEL: [text]") - - - -/** - * IPIntel Ban Checker - * - * Checks if a user is banned due to IPintel. It will check configuration, DB, whitelist checks, and more - * - * Arguments: - * * t_ckey - The ckey to check - * * t_ip - The IP to check - */ -/datum/ipintel_manager/proc/ipintel_is_banned(t_ckey, t_ip) - if(!CONFIG_GET(string/contact_email)) - return FALSE - if(!CONFIG_GET(flag/ipintel_enabled)) - return FALSE - if(!CONFIG_GET(flag/whitelist_mode)) - return FALSE - if(!SSdbcore.IsConnected()) - return FALSE - if(!ipintel_badip_check(t_ip)) - return FALSE - if(vpn_whitelist_check(t_ckey)) - return FALSE - return TRUE - - - -/** - * IP Rating Checker - * - * Checks if a provided IP passes the config threshold for denial - * - * Arguments: - * * target_ip - The IP to check - */ -/datum/ipintel_manager/proc/ipintel_badip_check(target_ip) - var/rating_bad = CONFIG_GET(number/bad_rating) - if(!rating_bad) - log_access("ipintel_badip_check reports misconfigured rating_bad directive") - return FALSE - var/valid_hours = CONFIG_GET(number/hours_save_bad) - if(!valid_hours) - log_access("ipintel_badip_check reports misconfigured ipintel_save_bad directive") - return FALSE - var/datum/db_query/query_get_ip_intel = SSdbcore.NewQuery({" - SELECT * FROM ipintel WHERE ip = INET_ATON(:target_ip) - AND intel >= :rating_bad AND (date + INTERVAL :valid_hours HOUR) > NOW()"}, - list( - "target_ip" = target_ip, - "rating_bad" = rating_bad, - "valid_hours" = valid_hours - ) - ) - if(!query_get_ip_intel.warn_execute()) - log_access("ipintel_badip_check reports failed query execution") - qdel(query_get_ip_intel) - return FALSE - if(!query_get_ip_intel.NextRow()) - qdel(query_get_ip_intel) - return FALSE - qdel(query_get_ip_intel) - return TRUE - - - -/** - * VPN whitelist checker - * - * Checks if a ckey is whitelisted to be using a VPN against the DB - * - * Arguments: - * * target_ckey - The ckey to check - */ -/datum/ipintel_manager/proc/vpn_whitelist_check(target_ckey) - if(!CONFIG_GET(flag/whitelist_mode)) - return FALSE - var/datum/db_query/query_whitelist_check = SSdbcore.NewQuery("SELECT * FROM vpn_whitelist WHERE ckey=:ckey", list( - "ckey" = target_ckey - )) - if(!query_whitelist_check.warn_execute()) - qdel(query_whitelist_check) - return FALSE - if(query_whitelist_check.NextRow()) - qdel(query_whitelist_check) - return TRUE // At least one row in the whitelist names their ckey. That means they are whitelisted. - qdel(query_whitelist_check) - return FALSE - - - -/** - * VPN whitelist adder - * - * Adds a ckey to the VPN whitelist. Asks the admin to also provide a link to their request. - * - * Arguments: - * * target_ckey - The ckey to whitelist - */ -/datum/ipintel_manager/proc/vpn_whitelist_add(target_ckey) - var/reason_string = input(usr, "Enter link to the URL of their whitelist request on the forum.","Reason required") as message|null - if(!reason_string) - return FALSE - var/datum/db_query/query_whitelist_add = SSdbcore.NewQuery("INSERT INTO vpn_whitelist (ckey,reason) VALUES (:targetckey, :reason)", list( - "targetckey" = target_ckey, - "reason" = reason_string - )) - if(!query_whitelist_add.warn_execute()) - qdel(query_whitelist_add) - return FALSE - qdel(query_whitelist_add) - return TRUE - - - -/** - * VPN whitelist remover - * - * Removes a ckey from the VPN whitelist. Pretty simple. - * - * Arguments: - * * target_ckey - The ckey to remove - */ -/datum/ipintel_manager/proc/vpn_whitelist_remove(target_ckey) - var/datum/db_query/query_whitelist_remove = SSdbcore.NewQuery("DELETE FROM vpn_whitelist WHERE ckey=:targetckey", list( - "targetckey" = target_ckey - )) - if(!query_whitelist_remove.warn_execute()) - qdel(query_whitelist_remove) - return FALSE - qdel(query_whitelist_remove) - return TRUE - - - -/** - * VPN whitelist panel - * - * Doesnt actually open a panel, this is just a verb to handle the rest of the whitelist operations - * - * Arguments: - * * target_ckey - The ckey to add/remove - */ -/datum/ipintel_manager/proc/vpn_whitelist_panel(target_ckey as text) - if(!check_rights(R_ADMIN)) - return - if(!target_ckey) - return - var/is_already_whitelisted = vpn_whitelist_check(target_ckey) - if(is_already_whitelisted) - var/confirm = alert("[target_ckey] is already whitelisted. Remove them?", "Confirm Removal", "No", "Yes") - if(!confirm || confirm != "Yes") - to_chat(usr, "VPN whitelist alteration cancelled.") - return - else if(vpn_whitelist_remove(target_ckey)) - to_chat(usr, "[target_ckey] was removed from the VPN whitelist.") - else - to_chat(usr, "VPN whitelist unchanged.") - else - if(vpn_whitelist_add(target_ckey)) - to_chat(usr, "[target_ckey] was added to the VPN whitelist.") - else - to_chat(usr, "VPN whitelist unchanged.") - -/datum/admins/proc/vpn_whitelist() - set category = "Admin" - set name = "VPN Ckey Whitelist" - if(!check_rights(R_BAN)) - return - var/key = stripped_input(usr, "Enter ckey to add/remove, or leave blank to cancel:", "VPN Whitelist add/remove", max_length=32) - if(key) - GLOB.ipintel_manager.vpn_whitelist_panel(key) -// BLUEMOON EDIT:END IPINTEL FROM TG diff --git a/code/modules/client/client_procs.dm b/code/modules/client/client_procs.dm index 6c912111628f..5b1a5fad57e3 100644 --- a/code/modules/client/client_procs.dm +++ b/code/modules/client/client_procs.dm @@ -389,34 +389,35 @@ GLOBAL_LIST_INIT(blacklisted_builds, list( connection_realtime = world.realtime connection_timeofday = world.timeofday winset(src, null, "command=\".configure graphics-hwmode on\"") - var/cev = CONFIG_GET(number/client_error_version) - var/ceb = CONFIG_GET(number/client_error_build) - var/cwv = CONFIG_GET(number/client_warn_version) - if (byond_version < cev || (byond_version == cev && byond_build < ceb)) //Out of date client. - to_chat(src, "Your version of BYOND is too old:") - to_chat(src, CONFIG_GET(string/client_error_message)) - to_chat(src, "Your version: [byond_version].[byond_build]") - to_chat(src, "Required version: [cev].[ceb] or later") - to_chat(src, "Visit BYOND's website to get the latest version of BYOND.") + // Bluemoon Edit:Start Better byond warning + var/breaking_version = CONFIG_GET(number/client_error_version) + var/breaking_build = CONFIG_GET(number/client_error_build) + var/warn_version = CONFIG_GET(number/client_warn_version) + if (byond_version < breaking_version || (byond_version == breaking_version && byond_build < breaking_build)) //Out of date client. + to_chat_immediate(src, span_danger("Your version of BYOND is too old:")) + to_chat_immediate(src, CONFIG_GET(string/client_error_message)) + to_chat_immediate(src, "Your version: [byond_version].[byond_build]") + to_chat_immediate(src, "Required version: [breaking_version].[breaking_build] or later") + to_chat_immediate(src, "Visit BYOND's website to get the latest version of BYOND.") if (connecting_admin) - to_chat(src, "Because you are an admin, you are being allowed to walk past this limitation, But it is still STRONGLY suggested you upgrade") + to_chat_immediate(src, "Because you are an admin, you are being allowed to walk past this limitation, But it is still STRONGLY suggested you upgrade") + // Bluemoon Edit:End Better byond warning else qdel(src) return FALSE - else if (byond_version < cwv) //We have words for this client. + else if (byond_version < warn_version) // Bluemoon Edit: Better byond warning //We have words for this client. if(CONFIG_GET(flag/client_warn_popup)) var/msg = "Your version of byond may be getting out of date:
" msg += CONFIG_GET(string/client_warn_message) + "

" msg += "Your version: [byond_version]
" - msg += "Required version to remove this message: [cwv] or later
" + msg += "Required version to remove this message: [warn_version] or later
" // Bluemoon Edit: Better byond warning msg += "Visit BYOND's website to get the latest version of BYOND.
" src << browse(msg, "window=warning_popup") else to_chat(src, "Your version of byond may be getting out of date:") to_chat(src, CONFIG_GET(string/client_warn_message)) to_chat(src, "Your version: [byond_version]") - to_chat(src, "Required version to remove this message: [cwv] or later") - to_chat(src, "Visit BYOND's website to get the latest version of BYOND.") + to_chat(src, "Required version to remove this message: [warn_version] or later") // Bluemoon Edit: Better byond warning if (connection == "web" && !connecting_admin) if (!CONFIG_GET(flag/allow_webclient)) @@ -458,10 +459,9 @@ GLOBAL_LIST_INIT(blacklisted_builds, list( if (CONFIG_GET(flag/irc_first_connection_alert)) send2tgs_adminless_only("new_byond_user", "[key_name(src)] (IP: [address], ID: [computer_id]) is a new BYOND account [account_age] day[(account_age==1?"":"s")] old, created on [account_join_date].") get_message_output("watchlist entry", ckey) - //check_ip_intel() // BLUEMOON EDIT: IPINTEL FROM TG + check_ip_intel() validate_key_in_db() - check_ip_intel() // BLUEMOON EDIT: IPINTEL FROM TG send_resources() update_clickcatcher() @@ -515,6 +515,7 @@ GLOBAL_LIST_INIT(blacklisted_builds, list( menuitem.Load_checked(src) SSambience.remove_ambience_client(src) + view_size = new(src, getScreenSize(prefs.widescreenpref)) view_size.resetFormat() view_size.setZoomMode() @@ -607,14 +608,13 @@ GLOBAL_LIST_INIT(blacklisted_builds, list( qdel(query_client_in_db) return - var/client_is_in_db = query_client_in_db.NextRow() // BLUEMOON EDIT: IPINTEL FROM TG //If we aren't an admin, and the flag is set if(CONFIG_GET(flag/panic_bunker) && !holder && !GLOB.deadmins[ckey] && !(ckey in GLOB.bunker_passthrough)) var/living_recs = CONFIG_GET(number/panic_bunker_living) - //var/vpn_living_recs = CONFIG_GET(number/panic_bunker_living_vpn) + var/vpn_living_recs = CONFIG_GET(number/panic_bunker_living_vpn) //Relies on pref existing, but this proc is only called after that occurs, so we're fine. var/minutes = get_exp_living(pure_numeric = TRUE) - if((living_recs == 0 && !client_is_in_db) || living_recs >= minutes) // BLUEMOON EDIT: IPINTEL FROM TG //if((minutes <= living_recs) || (IsVPN() && (minutes < vpn_living_recs))) + if((minutes <= living_recs) || (IsVPN() && (minutes < vpn_living_recs))) var/reject_message = "Failed Login: [key] - Account attempting to connect during panic bunker, but they do not have the required living time [minutes]/[living_recs]" log_access(reject_message) message_admins("[reject_message]") @@ -873,7 +873,6 @@ GLOBAL_LIST_INIT(blacklisted_builds, list( create_message("note", key, system_ckey, message, null, null, 0, 0, null, 0, 0) -/*// BLUEMOON EDIT:START IPINTEL FROM TG /client/proc/check_ip_intel() set waitfor = 0 //we sleep when getting the intel, no need to hold up the client connection while we sleep if (CONFIG_GET(string/ipintel_email)) @@ -881,46 +880,6 @@ GLOBAL_LIST_INIT(blacklisted_builds, list( if (res.intel >= CONFIG_GET(number/ipintel_rating_bad)) message_admins("Proxy Detection: [key_name_admin(src)] IP intel rated [res.intel*100]% likely to be a Proxy/VPN.") ip_intel = res.intel -*/ // BLUEMOON EDIT:END IPINTEL FROM TG - -// BLUEMOON EDIT:START IPINTEL FROM TG -/client/proc/check_ip_intel() - set waitfor = 0 //we sleep when getting the intel, no need to hold up the client connection while we sleep - if(CONFIG_GET(flag/ipintel_enabled)) - if(CONFIG_GET(number/playtime_ignore_threshold) && CONFIG_GET(flag/use_exp_tracking)) - var/living_hours = text2num(prefs.exp[EXP_TYPE_LIVING]) / 60 - if(living_hours >= CONFIG_GET(number/playtime_ignore_threshold)) - return - - if(is_connecting_from_localhost()) - log_access("check_ip_intel: skip check for player [key_name_admin(src)] connecting from localhost.") - return - - if(GLOB.ipintel_manager.vpn_whitelist_check(ckey)) - log_access("check_ip_intel: skip check for player [key_name_admin(src)] [address] on whitelist.") - return - - var/datum/ipintel/res = GLOB.ipintel_manager.get_ip_intel(address) - ip_intel = res.intel - verify_ip_intel() - -/client/proc/verify_ip_intel() - if(ip_intel >= CONFIG_GET(number/bad_rating)) - var/detailsurl = CONFIG_GET(string/details_url) ? "(IP Info)" : "" - if(CONFIG_GET(flag/whitelist_mode)) - // Do not move this to isBanned(). This may sound weird, but: - // This needs to happen after their account is put into the DB - // This way, admins can then note people - spawn(40) // This is necessary because without it, they won't see the message, and addtimer cannot be used because the timer system may not have initialized yet - message_admins("IPIntel: [key_name_admin(src)] on IP [address] was rejected. [detailsurl]") - var/blockmsg = "Error: proxy/VPN detected. Proxy/VPN use is not allowed here. Deactivate it before you reconnect." - if(CONFIG_GET(string/banappeals)) - blockmsg += "\nIf you are not actually using a proxy/VPN, or have no choice but to use one, request whitelisting at: [CONFIG_GET(string/banappeals)]" - to_chat(src, blockmsg) - qdel(src) - else - message_admins("IPIntel: [key_name_admin(src)] on IP [address] is likely to be using a Proxy/VPN. [detailsurl]") -// BLUEMOON EDIT:END IPINTEL FROM TG /client/Click(atom/object, atom/location, control, params, ignore_spam = FALSE, extra_info) if(last_click > world.time - world.tick_lag) diff --git a/code/modules/client/client_vpn_detect.dm b/code/modules/client/client_vpn_detect.dm index 637110ae7bc0..bd35a65ef274 100644 --- a/code/modules/client/client_vpn_detect.dm +++ b/code/modules/client/client_vpn_detect.dm @@ -1,5 +1,3 @@ -/* BLUEMOON EDIT:START IPINTEL FROM TG /client/proc/IsVPN() var/datum/ipintel/res = get_ip_intel(address) return res.intel >= CONFIG_GET(number/ipintel_rating_bad) -*/ //BLUEMOON EDIT:END IPINTEL FROM TG diff --git a/config/bluemoon/ipintel.txt b/config/bluemoon/ipintel.txt deleted file mode 100644 index 847274bbee4e..000000000000 --- a/config/bluemoon/ipintel.txt +++ /dev/null @@ -1,21 +0,0 @@ -## IPINTEL: -## This section contains all the information for IPIntel (The Anti VPN system) -## This allows you to detect likely proxies by checking ips against getipintel.net -# Enable or disable IPIntel entirely -#IPINTEL_ENABLED TRUE -# Whitelist mode. If true, people on proxies/VPNs will need whitelisting if they arent past the threshold below. If false, admins are merely warned with no automatic action -#WHITELIST_MODE FALSE -# Threshold to kick people out (0-1 percentage float) -#BAD_RATING 0.98 -# Contact email (required, leaving blank disables this) -#CONTACT_EMAIL "ss13bluemoon@gmail.com" -# How many hours to save good matches for (IPIntel has rate limits) -#HOURS_SAVE_GOOD 72 -# How many hours to save bad matches for (IPIntel has rate limits) -#HOURS_SAVE_BAD 24 -# IPIntel Domain. Do not put http:// in front of it -#IPINTEL_DOMAIN "check.getipintel.net" -## Details URL for more info on an IP (such as ASN). IP is tacked on the end. -#DETAILS_URL "https://iphub.info/?ip=" -# Ignore checking IPs with more hours than the threshold below. Requires EXP tracking to be enabled -#PLAYTIME_IGNORE_THRESHOLD 90 diff --git a/config/config.txt b/config/config.txt index b6e24eb5079d..f0a4905baccd 100644 --- a/config/config.txt +++ b/config/config.txt @@ -56,6 +56,5 @@ $include splurt/donator.txt $include splurt/autocryo.txt # Bluemoon stuff! -$include entries/bluemoon.txt -$include bluemoon/ipintel.txt +$include bluemoon/bluemoon.txt $include bluemoon/discord.txt diff --git a/modular_bluemoon/phoenix404/code/controllers/configuration/entries/bluemoon_config_entries.dm b/modular_bluemoon/phoenix404/code/controllers/configuration/entries/bluemoon_config_entries.dm new file mode 100644 index 000000000000..4f39472d1b55 --- /dev/null +++ b/modular_bluemoon/phoenix404/code/controllers/configuration/entries/bluemoon_config_entries.dm @@ -0,0 +1,6 @@ +/// Defines whether or not mentors can see ckeys alongside mobnames. +/datum/config_entry/flag/mentors_mobname_only + +/// Defines whether the server uses the legacy mentor system with mentors.txt or the SQL system. +/datum/config_entry/flag/mentor_legacy_system + protection = CONFIG_ENTRY_LOCKED diff --git a/modular_bluemoon/phoenix404/modules/client/client_procs.dm b/modular_bluemoon/phoenix404/modules/client/client_procs.dm deleted file mode 100644 index 9469799fc647..000000000000 --- a/modular_bluemoon/phoenix404/modules/client/client_procs.dm +++ /dev/null @@ -1,5 +0,0 @@ -/client/proc/is_connecting_from_localhost() - var/static/list/localhost_addresses = list("127.0.0.1", "::1") - if((!address && !world.port) || (address in localhost_addresses)) - return TRUE - return FALSE diff --git a/modular_splurt/code/modules/client/client_procs.dm b/modular_splurt/code/modules/client/client_procs.dm index 9966699aaba6..7f82c94449da 100644 --- a/modular_splurt/code/modules/client/client_procs.dm +++ b/modular_splurt/code/modules/client/client_procs.dm @@ -1,4 +1,3 @@ -/* // BLUEMOON EDIT:START IPINTEL FROM TG /client/check_ip_intel() . = ..() if(!(ip_intel != initial(ip_intel) && ip_intel >= CONFIG_GET(number/ipintel_rating_bad))) @@ -21,7 +20,6 @@ log_admin(logg) message_admins(span_adminnotice(logg)) qdel(src) -*/ // BLUEMOON EDIT:END IPINTEL FROM TG /client/proc/toggle_quirk(mob/living/carbon/human/H) if (!istype(H)) diff --git a/tgstation.dme b/tgstation.dme index 21390adee8c5..965ecc3b13b8 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -23,7 +23,6 @@ #include "code\__BLUEMOONCODE\plug13.dm" #include "code\__BLUEMOONCODE\_DEFINES\bloodsuckers.dm" #include "code\__BLUEMOONCODE\_DEFINES\gamemode.dm" -#include "code\__BLUEMOONCODE\_DEFINES\ipintel.dm" #include "code\__BLUEMOONCODE\_DEFINES\language.dm" #include "code\__BLUEMOONCODE\_DEFINES\mail.dm" #include "code\__BLUEMOONCODE\_DEFINES\melee.dm" @@ -342,8 +341,6 @@ #include "code\__SPLURTCODE\DEFINES\traits.dm" #include "code\__SPLURTCODE\DEFINES\arousal\genitals.dm" #include "code\__SPLURTCODE\DEFINES\dcs\signals.dm" -#include "code\_BLUEMOONCODE\_HELPERS\time.dm" -#include "code\_BLUEMOONCODE\_HELPERS\unsorted.dm" #include "code\_globalvars\admin.dm" #include "code\_globalvars\bitfields.dm" #include "code\_globalvars\configuration.dm" @@ -443,7 +440,6 @@ #include "code\controllers\subsystem.dm" #include "code\controllers\configuration\config_entry.dm" #include "code\controllers\configuration\configuration.dm" -#include "code\controllers\configuration\bluemoon_entries\general.dm" #include "code\controllers\configuration\entries\admin.dm" #include "code\controllers\configuration\entries\alert.dm" #include "code\controllers\configuration\entries\antag_rep.dm" @@ -4548,8 +4544,8 @@ #include "modular_bluemoon\phoenix404\code\entries.dm" #include "modular_bluemoon\phoenix404\code\_HELPERS\admin.dm" #include "modular_bluemoon\phoenix404\code\_HELPERS\roundend.dm" +#include "modular_bluemoon\phoenix404\code\controllers\configuration\entries\bluemoon_config_entries.dm" #include "modular_bluemoon\phoenix404\modules\admin\code\player_ranks.dm" -#include "modular_bluemoon\phoenix404\modules\client\client_procs.dm" #include "modular_bluemoon\phoenix404\modules\mentor\code\mentor.dm" #include "modular_bluemoon\phoenix404\modules\player_ranks\code\player_rank_controller\_player_rank_controller.dm" #include "modular_bluemoon\phoenix404\modules\player_ranks\code\player_rank_controller\mentor_controller.dm" diff --git a/tgui/packages/tgui/interfaces/PlayerPanel2.js b/tgui/packages/tgui/interfaces/PlayerPanel2.js index 5a3824d68bfb..178452764f86 100644 --- a/tgui/packages/tgui/interfaces/PlayerPanel2.js +++ b/tgui/packages/tgui/interfaces/PlayerPanel2.js @@ -724,7 +724,6 @@ const PunishmentActions = (props, context) => { {data_player_join_date} {data_byond_version} {active_role_ban_count} - {active_role_ban_count}