const std = @import("std"); pub const Identity = union(enum) { domain: []const u8, addr: std.Io.net.IpAddress, }; pub const Message = struct { str: []const u8, cmd: Command, client: Identity, }; pub const Command = enum { EHLO, HELO, MAIL, RCPT, DATA, RSET, NOOP, QUIT, VRFY, pub fn fromStr(msg: []const u8) ?Command { var MSG: [4]u8 = undefined; if (msg.len != 4) return null; _ = std.ascii.upperString(&MSG, msg); if (std.mem.eql(u8, &MSG, "EHLO")) return .EHLO; if (std.mem.eql(u8, &MSG, "HELO")) return .HELO; if (std.mem.eql(u8, &MSG, "MAIL")) return .MAIL; if (std.mem.eql(u8, &MSG, "RCPT")) return .RCPT; if (std.mem.eql(u8, &MSG, "DATA")) return .DATA; if (std.mem.eql(u8, &MSG, "RSET")) return .RSET; if (std.mem.eql(u8, &MSG, "NOOP")) return .NOOP; if (std.mem.eql(u8, &MSG, "QUIT")) return .QUIT; if (std.mem.eql(u8, &MSG, "VRFY")) return .VRFY; return null; } }; const Response = enum(u32) { OK = 250, }; pub fn ehlo_rsp() Response {}