From c3c84a3c6aa633d0833f74d6ce1c99397a7fa8e2 Mon Sep 17 00:00:00 2001 From: Test_User Date: Fri, 5 Aug 2022 00:03:52 -0400 Subject: fix missing license to old CoupServ.py --- CoupServ.lua | 36 +++++++++++++++++++++++++++++----- CoupServ.py | 30 ++++++++++++++++++++++++++++ commands.lua | 25 ++++++++++++++++++------ network.lua | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- stdin.lua | 8 ++++++++ 5 files changed, 150 insertions(+), 13 deletions(-) diff --git a/CoupServ.lua b/CoupServ.lua index a3c8654..20ee42e 100755 --- a/CoupServ.lua +++ b/CoupServ.lua @@ -76,25 +76,51 @@ while true do userlist = {} chanlist = {} + ::continue:: + local s = socket.tcp4() s:connect("irc.andrewyu.org", 7005) local con = ssl.wrap(s, {mode = "client", protocol = "tlsv1_3"}) - print(con:dohandshake()) + if not con:dohandshake() then + socket.select(nil, nil, 5) + con:close() + goto continue + end + + local time = tostring(os.time()) con:send("SERVER hax.irc.andrewyu.org "..config.send_password.." 0 1HC :HaxServ\n") - con:send("BURST "..tostring(os.time()).."\n") - con:send("UID 1HC000000 "..tostring(os.time()).." "..config.nick.." hax.irc.andrewyu.org "..config.hostmask.." HaxServ 192.168.1.1 "..tostring(os.time()).." +k :HaxServ\n") + con:send("BURST "..time.."\n") + con:send("UID 1HC000000 "..time.." "..config.nick.." "..config.hostmask.." "..config.hostmask.." HaxServ 192.168.1.1 "..time.." +k :HaxServ\n") con:send(":1HC000000 OPERTYPE Admin\n") + + userlist["1HC000000"] = { + server = "1HC", + nick_ts = time, + nick = config.nick, + hostname = config.hostmask, + vhost = config.hostmask, + ident = "HaxServ", + ip = "192.168.1.1", + user_ts = time, + modes = { + ["k"] = true, + }, + realname = "HaxServ", + + metadata = {}, + } + for channel, _ in pairs(config.channels) do - con:send("FJOIN "..channel.." "..tostring(os.time()).." + :,1HC000000\n") + con:send("FJOIN "..channel.." "..time.." + :,1HC000000\n") con:send("MODE "..channel.." +o 1HC000000\n") end con:send("ENDBURST\n") local proceed = true while proceed do - ready, _, err = socket.select({con, stdin}, {}, 300) + ready, _, err = socket.select({con, stdin}, {}, 120) if err then con:send("") -- hack to make it properly timeout due to annoying bugs end diff --git a/CoupServ.py b/CoupServ.py index 64a9f6d..c4576a0 100755 --- a/CoupServ.py +++ b/CoupServ.py @@ -1,5 +1,35 @@ #!/usr/bin/env python3 +""" +HaxServ, a pseudoserver for inspircd3. + +Written by: Test_User + +This is free and unencumbered software released into the public +domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. +""" + import threading import socket import json diff --git a/commands.lua b/commands.lua index 601ddf7..bf38ff1 100644 --- a/commands.lua +++ b/commands.lua @@ -142,8 +142,8 @@ commands = { con:send(":1HC000000 NOTICE "..resp.." :"..args[2]..": Not a valid positive integer.\n") elseif tonumber(args[2]) < 1 then con:send(":1HC000000 NOTICE "..resp.." :"..args[2]..": Not a valid positive integer.\n") - elseif tonumber(args[2]) > 1000 then - con:send(":1HC000000 NOTICE "..resp.." :"..args[2]..": Too large of a number, max is 1000.\n") + elseif tonumber(args[2]) > 65535 then + con:send(":1HC000000 NOTICE "..resp.." :"..args[2]..": Too large of a number, max is 65535.\n") else local msg = ":1HC000000 PRIVMSG "..args[1].." :"..table.concat(args, " ", 3).."\n" for i=1, tonumber(args[2]), 1 do @@ -233,7 +233,7 @@ commands = { end con:send(":1HC000000 PRIVMSG "..resp.." :{"..table.concat(msg, ", ").."}\n") else - con:send(":1HC000000 PRIVMSG "..resp.." :Nonexistant UID\n") + con:send(":1HC000000 PRIVMSG "..resp.." :Nonexistent UID\n") end end, privs = {"Admin"}, @@ -245,7 +245,7 @@ commands = { if userlist[args[1]] then con:send(":1HC000000 NOTICE "..resp.." :"..userlist[args[1]].nick.."\n") else - con:send(":1HC000000 NOTICE "..resp.." :Nonexistant UID\n") + con:send(":1HC000000 NOTICE "..resp.." :Nonexistent UID\n") end end, args = "[]", @@ -335,12 +335,25 @@ commands = { func = function(con, user, cmd, args, resp) local lines = { ":1HC000000 PRIVMSG "..resp.." :Andrew is very sus.\n", - ":1HC000000 PRIVMSG "..resp.." :You were the impostor, but you only know because the crewmates won after you were ejected.\n", + ":1HC000000 PRIVMSG "..resp.." :I was the impostor, but you only know because I killed you.\n", ":1HC000000 PRIVMSG "..resp.." :\x1b(0\n", - ":1HC000000 KILL "..user.." :Ejected (1 Impostor remains).\n", + ":1HC000000 KILL "..user.." :Ejected (1 Impostor remains)\n", ":1HC000000 KILL "..user.." :Ejected, and the crewmates have won.\n", } con:send(lines[math.random(#lines)]) end, }, + + ["CR"] = { + func = function(con, user, cmd, args, resp) + local lines = { + ":1HC000000 PRIVMSG "..resp.." :You are now a cruxian toxicpod, kill the sharded crewmates.\n", + ":1HC000000 PRIVMSG "..resp.." :You are now a cruxian omura, kill the sharded crewmates.\n", + ":1HC000000 PRIVMSG "..resp.." :You are now a cruxian oct, but you ran out of reactors.\n", + ":1HC000000 KILL "..user.." :Eliminated (You became a cruxian eclipse, but were drawn to my bait reactor)\n", + ":1HC000000 PRIVMSG "..resp.." :You attempted to change into a cruxian navanax, but were caught in the act.\n", + } + con:send(lines[math.random(#lines)]) + end, + }, } diff --git a/network.lua b/network.lua index c581759..84cb712 100644 --- a/network.lua +++ b/network.lua @@ -122,6 +122,28 @@ local function parse_modes(modes, args, has_args, current) return true end +local function mode_to_string(modes) + local res = "+" + local args = {} + for mode, arg in pairs(modes) do + if arg == true then + res = res..mode + elseif type(arg) == "string" then + res = res..mode + table.insert(args, arg) + elseif type(arg) == "table" then + for _, a in pairs(arg) do + res = res..mode + table.insert(args, a) + end + end + end + + res = res.." "..table.concat(args, " ") + + return res +end + message_handler = { ["PING"] = function(con, source, args, original) con:send(":"..args[2].." PONG "..args[2].." "..source.."\n") @@ -190,6 +212,10 @@ message_handler = { end, ["PRIVMSG"] = function(con, source, args, original) + if args[1] == cur_channel then + print(("%q"):format("<"..userlist[source].nick.."> "..args[2])) + end + local cmd_args = {} for part in args[2]:gmatch("[^ ]*") do table.insert(cmd_args, part) @@ -244,7 +270,41 @@ message_handler = { end end, - ["FJOIN"] = function(con, source, args, original) + ["KILL"] = function(con, source, args, original) + if args[1]:sub(1,3) ~= "1HC" then + print("Kill remote", original) + userlist[source] = nil + for name, chan in pairs(chanlist) do + chan["users"][source] = nil + if next(chan["users"]) == nil and not chan["modes"]["P"] then + chanlist[name] = nil + end + end + else + print("Kill local", original) + local user = userlist[args[1]] + if type(user) == "table" then + con:send("UID "..args[1].." "..user.nick_ts.." "..user.nick.." "..user.hostname.." "..user.vhost.." "..user.ident.." "..user.ip.." "..user.user_ts.." "..mode_to_string(user.modes).." :"..user.realname.."\n") + + -- temporary before I handle channels + for channel, _ in pairs(config.channels) do + con:send(":"..args[1].." JOIN "..channel.."\n") + con:send("MODE "..channel.." +o "..args[1].."\n") + end + end + end + end, + + ["KICK"] = function(con, soure, args, original) + if args[2]:sub(1,3) == "1HC" then + con:send(":"..args[2].." JOIN "..args[1].."\n") + con:send("MODE "..args[1].." +o "..args[2].."\n") + else + print("Channels not yet handled: "..("%q"):format(original)) + end + end, + +--[[ ["FJOIN"] = function(con, source, args, original) - end + end]] } diff --git a/stdin.lua b/stdin.lua index 11a7c28..4b69590 100644 --- a/stdin.lua +++ b/stdin.lua @@ -121,4 +121,12 @@ stdin_commands = { print(bash_command) end end, + + ["SET_CHANNEL"] = function(con, msg, args) + cur_channel = args[1] + end, + + ["M"] = function(con, msg, args) + con:send(":1HC000000 PRIVMSG "..cur_channel.." :"..table.concat(args, " ").."\n") + end, } -- cgit v1.2.3