From 441320282f86028a5cdcd87ebb9387d9ed17bc37 Mon Sep 17 00:00:00 2001 From: Mat Date: Wed, 4 Sep 2024 18:39:47 +0300 Subject: [PATCH] Use const when possible --- src/client.d | 92 +++++++++++++++++++-------------------- src/db.d | 36 ++++++++-------- src/defines.d | 22 +++++----- src/message_codes.d | 102 ++++++++++++++++++++++---------------------- src/messages.d | 6 +-- src/pm.d | 2 +- src/server.d | 24 +++++------ src/soulsetup.d | 12 +++--- 8 files changed, 148 insertions(+), 148 deletions(-) diff --git a/src/client.d b/src/client.d index 5987159..6083f93 100644 --- a/src/client.d +++ b/src/client.d @@ -360,7 +360,7 @@ class User bool send_buffer() { - auto send_len = sock.send(out_buf); + const send_len = sock.send(out_buf); if (send_len == Socket.ERROR) return false; @@ -370,7 +370,7 @@ class User void send_message(Message msg) { - auto msg_buf = msg.bytes; + const msg_buf = msg.bytes; msg_size_buf.write(cast(uint) msg_buf.length); out_buf ~= msg_size_buf.toBytes; out_buf ~= msg_buf; @@ -385,7 +385,7 @@ class User bool recv_buffer() { ubyte[max_msg_size] receive_buf; - auto receive_len = sock.receive(receive_buf); + const receive_len = sock.receive(receive_buf); if (receive_len == Socket.ERROR || receive_len == 0) return false; @@ -414,7 +414,7 @@ class User private void proc_message() { auto msg_buf = in_buf[0 .. in_msg_size]; - auto code = msg_buf.read!(uint, Endian.littleEndian); + const code = msg_buf.read!(uint, Endian.littleEndian); in_buf = in_buf[in_msg_size .. $]; @@ -433,7 +433,7 @@ class User switch (code) { case Login: write("User logging in : "); - auto msg = new ULogin(msg_buf); + const msg = new ULogin(msg_buf); string error; if (!server.check_login(msg.username, msg.password, msg.major_version, @@ -463,12 +463,12 @@ class User return; case SetWaitPort: - auto msg = new USetWaitPort(msg_buf); + const msg = new USetWaitPort(msg_buf); port = cast(ushort) msg.port; break; case GetPeerAddress: - auto msg = new UGetPeerAddress(msg_buf); + const msg = new UGetPeerAddress(msg_buf); auto user = server.get_user(msg.user); uint address; uint port; @@ -482,7 +482,7 @@ class User break; case WatchUser: - auto msg = new UWatchUser(msg_buf); + const msg = new UWatchUser(msg_buf); bool exists; uint status = Status.offline; uint speed, upload_number, something; @@ -518,12 +518,12 @@ class User break; case UnwatchUser: - auto msg = new UUnwatchUser(msg_buf); + const msg = new UUnwatchUser(msg_buf); unwatch(msg.user); break; case GetUserStatus: - auto msg = new UGetUserStatus(msg_buf); + const msg = new UGetUserStatus(msg_buf); auto user = server.get_user(msg.user); uint status = Status.offline; bool privileged; @@ -551,7 +551,7 @@ class User break; case SayChatroom: - auto msg = new USayChatroom(msg_buf); + const msg = new USayChatroom(msg_buf); auto room = Room.get_room(msg.room); if (!room) break; @@ -568,13 +568,13 @@ class User break; case JoinRoom: - auto msg = new UJoinRoom(msg_buf); + const msg = new UJoinRoom(msg_buf); if (server.check_name(msg.room)) Room.join_room(msg.room, this); break; case LeaveRoom: - auto msg = new ULeaveRoom(msg_buf); + const msg = new ULeaveRoom(msg_buf); auto room = Room.get_room(msg.room); if (!room) break; @@ -584,12 +584,12 @@ class User break; case ConnectToPeer: - auto msg = new UConnectToPeer(msg_buf); + const msg = new UConnectToPeer(msg_buf); auto user = server.get_user(msg.user); if (!user) break; - auto ia = new InternetAddress(user.address, user.port); + const ia = new InternetAddress(user.address, user.port); debug (user) writeln( username, " cannot connect to ", msg.user, "/", ia, ", asking us to tell the other..." @@ -603,7 +603,7 @@ class User break; case MessageUser: - auto msg = new UMessageUser(msg_buf); + const msg = new UMessageUser(msg_buf); auto user = server.get_user(msg.user); if (msg.user == server_user) { @@ -611,7 +611,7 @@ class User } else if (user) { // user is connected auto pm = new PM(msg.message, username, msg.user); - auto new_message = true; + const new_message = true; PM.add_pm(pm); user.send_pm(pm, new_message); @@ -623,17 +623,17 @@ class User break; case MessageAcked: - auto msg = new UMessageAcked(msg_buf); + const msg = new UMessageAcked(msg_buf); PM.del_pm(msg.id); break; case FileSearch: - auto msg = new UFileSearch(msg_buf); + const msg = new UFileSearch(msg_buf); server.do_FileSearch(msg.token, msg.strng, username); break; case SetStatus: - auto msg = new USetStatus(msg_buf); + const msg = new USetStatus(msg_buf); set_status(msg.status); break; @@ -641,7 +641,7 @@ class User break; case SharedFoldersFiles: - auto msg = new USharedFoldersFiles(msg_buf); + const msg = new USharedFoldersFiles(msg_buf); debug (user) writeln( username, " is sharing ", msg.nb_files, " files and ", msg.nb_folders, " folders" @@ -658,7 +658,7 @@ class User break; case GetUserStats: - auto msg = new UGetUserStats(msg_buf); + const msg = new UGetUserStats(msg_buf); uint speed, upload_number, something; uint shared_files, shared_folders; @@ -675,27 +675,27 @@ class User break; case UserSearch: - auto msg = new UUserSearch(msg_buf); + const msg = new UUserSearch(msg_buf); server.do_UserSearch(msg.token, msg.query, username, msg.user); break; case AddThingILike: - auto msg = new UAddThingILike(msg_buf); + const msg = new UAddThingILike(msg_buf); add_thing_he_likes(msg.thing); break; case RemoveThingILike: - auto msg = new URemoveThingILike(msg_buf); + const msg = new URemoveThingILike(msg_buf); del_thing_he_likes(msg.thing); break; case AddThingIHate: - auto msg = new UAddThingIHate(msg_buf); + const msg = new UAddThingIHate(msg_buf); add_thing_he_hates(msg.thing); break; case RemoveThingIHate: - auto msg = new URemoveThingIHate(msg_buf); + const msg = new URemoveThingIHate(msg_buf); del_thing_he_hates(msg.thing); break; @@ -714,7 +714,7 @@ class User break; case UserInterests: - auto msg = new UUserInterests(msg_buf); + const msg = new UUserInterests(msg_buf); auto user = server.get_user(msg.user); if (!user) break; @@ -734,7 +734,7 @@ class User if (!server.db.is_admin(username)) break; - auto msg = new UAdminMessage(msg_buf); + const msg = new UAdminMessage(msg_buf); foreach (User user ; server.users) user.send_message(new SAdminMessage(msg.mesg)); @@ -746,12 +746,12 @@ class User break; case WishlistSearch: - auto msg = new UWishlistSearch(msg_buf); + const msg = new UWishlistSearch(msg_buf); server.do_FileSearch(msg.token, msg.strng, username); break; case ItemRecommendations: - auto msg = new UGetItemRecommendations(msg_buf); + const msg = new UGetItemRecommendations(msg_buf); auto recommendations = get_item_recommendations(msg.item); send_message( new SGetItemRecommendations(msg.item, recommendations) @@ -759,24 +759,24 @@ class User break; case ItemSimilarUsers: - auto msg = new UItemSimilarUsers(msg_buf); + const msg = new UItemSimilarUsers(msg_buf); auto similar_users = get_item_similar_users(msg.item); send_message(new SItemSimilarUsers(msg.item, similar_users)); break; case SetRoomTicker: - auto msg = new USetRoomTicker(msg_buf); + const msg = new USetRoomTicker(msg_buf); auto room = Room.get_room(msg.room); if (room) room.add_ticker(username, msg.tick); break; case RoomSearch: - auto msg = new URoomSearch(msg_buf); + const msg = new URoomSearch(msg_buf); server.do_RoomSearch(msg.token, msg.query, username, msg.room); break; case SendUploadSpeed: - auto msg = new USendUploadSpeed(msg_buf); + const msg = new USendUploadSpeed(msg_buf); auto user = server.get_user(username); if (!user) break; @@ -789,7 +789,7 @@ class User break; case UserPrivileged: - auto msg = new UUserPrivileged(msg_buf); + const msg = new UUserPrivileged(msg_buf); auto user = server.get_user(msg.user); if (!user) break; @@ -800,9 +800,9 @@ class User break; case GivePrivileges: - auto msg = new UGivePrivileges(msg_buf); + const msg = new UGivePrivileges(msg_buf); auto user = server.get_user(msg.user); - auto admin = server.db.is_admin(msg.user); + const admin = server.db.is_admin(msg.user); if (!user) break; if (msg.time > privileges && !admin) @@ -813,7 +813,7 @@ class User break; case ChangePassword: - auto msg = new UChangePassword(msg_buf); + const msg = new UChangePassword(msg_buf); server.db.user_update_field( username, "password", server.encode_password(msg.password) @@ -822,7 +822,7 @@ class User break; case MessageUsers: - auto msg = new UMessageUsers(msg_buf); + const msg = new UMessageUsers(msg_buf); bool new_message = true; foreach (target_username ; msg.users) { @@ -844,7 +844,7 @@ class User break; case CantConnectToPeer: - auto msg = new UCantConnectToPeer(msg_buf); + const msg = new UCantConnectToPeer(msg_buf); auto user = server.get_user(msg.user); if (user) user.send_message(new SCantConnectToPeer(msg.token)); @@ -864,10 +864,10 @@ class User return; } - private void login(ULogin msg) + private void login(const ULogin msg) { username = msg.username; - auto password = server.encode_password(msg.password); + const password = server.encode_password(msg.password); major_version = msg.major_version; minor_version = msg.minor_version; @@ -879,8 +879,8 @@ class User if (server.db.is_admin(username)) writeln(username, " is an admin."); server.add_user(this); - auto motd = server.get_motd(this); - auto supporter = privileges > 0; + const motd = server.get_motd(this); + const supporter = privileges > 0; send_message(new SLogin(true, motd, address, password, supporter)); send_message(new SRoomList(Room.room_stats)); @@ -890,7 +890,7 @@ class User set_status(Status.online); foreach (pm ; PM.get_pms_for(username)) { - auto new_message = false; + const new_message = false; debug (user) writeln( "Sending offline PM(id ", pm.id, ") to ", username ); diff --git a/src/db.d b/src/db.d index 8d02020..c683b93 100644 --- a/src/db.d +++ b/src/db.d @@ -20,13 +20,13 @@ class Sdb sqlite3* db; sqlite3_stmt* stmt; - const string users_table = "users"; - const string admins_table = "admins"; - const string config_table = "config"; + const users_table = "users"; + const admins_table = "admins"; + const config_table = "config"; - const string users_table_format = "CREATE TABLE IF NOT EXISTS %s(username TEXT PRIMARY KEY, password TEXT, speed INTEGER, ulnum INTEGER, files INTEGER, folders INTEGER, banned INTEGER, privileges INTEGER) WITHOUT ROWID;"; - const string admins_table_format = "CREATE TABLE IF NOT EXISTS %s(username TEXT PRIMARY KEY, level INTEGER) WITHOUT ROWID;"; - const string config_table_format = "CREATE TABLE IF NOT EXISTS %s(option TEXT PRIMARY KEY, value) WITHOUT ROWID;"; + const users_table_format = "CREATE TABLE IF NOT EXISTS %s(username TEXT PRIMARY KEY, password TEXT, speed INTEGER, ulnum INTEGER, files INTEGER, folders INTEGER, banned INTEGER, privileges INTEGER) WITHOUT ROWID;"; + const admins_table_format = "CREATE TABLE IF NOT EXISTS %s(username TEXT PRIMARY KEY, level INTEGER) WITHOUT ROWID;"; + const config_table_format = "CREATE TABLE IF NOT EXISTS %s(option TEXT PRIMARY KEY, value) WITHOUT ROWID;"; this(string file, bool update = false) { @@ -82,7 +82,7 @@ class Sdb string get_config_value(string option) { - auto res = query("SELECT value FROM %s WHERE option = '%s';".format( + const res = query("SELECT value FROM %s WHERE option = '%s';".format( config_table, option)); return res[0][0]; } @@ -101,7 +101,7 @@ class Sdb string[] admins() { - auto res = query("SELECT username FROM %s;".format(admins_table)); + const res = query("SELECT username FROM %s;".format(admins_table)); string[] ret; foreach (record ; res) ret ~= record[0]; @@ -110,7 +110,7 @@ class Sdb bool is_admin(string username) { - auto res = query("SELECT username FROM %s WHERE username = '%s';".format( + const res = query("SELECT username FROM %s WHERE username = '%s';".format( admins_table, escape(username))); return res.length > 0; } @@ -129,14 +129,14 @@ class Sdb bool user_exists(string username) { - auto res = query("SELECT username FROM %s WHERE username = '%s';".format( + const res = query("SELECT username FROM %s WHERE username = '%s';".format( users_table, escape(username))); return res.length > 0; } string get_pass(string username) { - auto res = query("SELECT password FROM %s WHERE username = '%s';".format( + const res = query("SELECT password FROM %s WHERE username = '%s';".format( users_table, escape(username))); return res[0][0]; } @@ -149,7 +149,7 @@ class Sdb bool is_banned(string username) { - auto res = query("SELECT banned FROM %s WHERE username = '%s';".format( + const res = query("SELECT banned FROM %s WHERE username = '%s';".format( users_table, escape(username))); if (res.length == 1) @@ -161,10 +161,10 @@ class Sdb bool get_user(string username, out uint speed, out uint upload_number, out uint something, out uint shared_files, out uint shared_folders) { debug(db) writeln("DB: Requested ", username, "'s info..."); - auto res = query("SELECT speed,ulnum,files,folders FROM %s WHERE username = '%s';".format( + const res = query("SELECT speed,ulnum,files,folders FROM %s WHERE username = '%s';".format( users_table, escape(username))); if (res.length > 0) { - auto u = res[0]; + const u = res[0]; speed = atoi(u[0]); upload_number = atoi(u[1]); @@ -179,10 +179,10 @@ class Sdb bool get_user(string username, string password, out uint speed, out uint upload_number, out uint shared_files, out uint shared_folders, out uint privileges) { debug(db) writeln("DB: Requested ", username, "'s info..."); - auto res = query("SELECT speed,ulnum,files,folders,privileges FROM %s WHERE username = '%s' AND password = '%s';".format( + const res = query("SELECT speed,ulnum,files,folders,privileges FROM %s WHERE username = '%s' AND password = '%s';".format( users_table, escape(username), escape(password))); if (res.length > 0) { - auto u = res[0]; + const u = res[0]; speed = atoi(u[0]); upload_number = atoi(u[1]); @@ -225,7 +225,7 @@ class Sdb while (res == SQLITE_ROW) { string[] record; - auto n = sqlite3_column_count(stmt); + const n = sqlite3_column_count(stmt); for (uint i ; i < n ; i++) record ~= sqlite3_column_text(stmt, i).to!string; @@ -253,7 +253,7 @@ class Sdb uint atoi(string str) { try { - auto i = to!uint(str); + const i = to!uint(str); return i; } catch (ConvException e) { diff --git a/src/defines.d b/src/defines.d index f2e2de8..9d983c9 100644 --- a/src/defines.d +++ b/src/defines.d @@ -6,16 +6,16 @@ module defines; @safe: -const string VERSION = "0.5.0-dev"; -const string default_db_file = "soulfind.db"; -const uint port = 2242; -const uint max_users = 65535; -const uint max_msg_size = 16384; -const string server_user = "server"; +const VERSION = "0.5.0-dev"; +const default_db_file = "soulfind.db"; +const port = 2242; +const max_users = 65535; +const max_msg_size = 16384; +const server_user = "server"; // colours -const char[] norm = "\033[0m"; // reset to normal -const char[] bold = "\033[1m"; // bold intensity -const char[] bg_w = "\033[30;107m"; // background white -const char[] blue = "\033[01;94m"; // foreground blue -const char[] red = "\033[01;91m"; // foreground red +const norm = "\033[0m"; // reset to normal +const bold = "\033[1m"; // bold intensity +const bg_w = "\033[30;107m"; // background white +const blue = "\033[01;94m"; // foreground blue +const red = "\033[01;91m"; // foreground red diff --git a/src/message_codes.d b/src/message_codes.d index 80e298d..c8ce210 100644 --- a/src/message_codes.d +++ b/src/message_codes.d @@ -15,59 +15,59 @@ const enum Status } // Server Messages -const uint Login = 1; -const uint SetWaitPort = 2; -const uint GetPeerAddress = 3; -const uint WatchUser = 5; -const uint UnwatchUser = 6; -const uint GetUserStatus = 7; -const uint SayChatroom = 13; -const uint JoinRoom = 14; -const uint LeaveRoom = 15; -const uint UserJoinedRoom = 16; -const uint UserLeftRoom = 17; -const uint ConnectToPeer = 18; -const uint MessageUser = 22; -const uint MessageAcked = 23; -const uint FileSearch = 26; -const uint SetStatus = 28; -const uint ServerPing = 32; -const uint SharedFoldersFiles = 35; -const uint GetUserStats = 36; -const uint Relogged = 41; -const uint UserSearch = 42; -const uint AddThingILike = 51; -const uint RemoveThingILike = 52; -const uint GetRecommendations = 54; -const uint GlobalRecommendations = 56; -const uint UserInterests = 57; -const uint RoomList = 64; -const uint AdminMessage = 66; -const uint CheckPrivileges = 92; -const uint WishlistSearch = 103; -const uint WishlistInterval = 104; -const uint SimilarUsers = 110; -const uint ItemRecommendations = 111; -const uint ItemSimilarUsers = 112; -const uint RoomTicker = 113; -const uint RoomTickerAdd = 114; -const uint RoomTickerRemove = 115; -const uint SetRoomTicker = 116; -const uint AddThingIHate = 117; -const uint RemoveThingIHate = 118; -const uint RoomSearch = 120; -const uint SendUploadSpeed = 121; -const uint UserPrivileged = 122; -const uint GivePrivileges = 123; -const uint ChangePassword = 142; -const uint MessageUsers = 149; -const uint JoinGlobalRoom = 150; -const uint LeaveGlobalRoom = 151; -const uint GlobalRoomMessage = 152; -const uint CantConnectToPeer = 1001; +const Login = 1; +const SetWaitPort = 2; +const GetPeerAddress = 3; +const WatchUser = 5; +const UnwatchUser = 6; +const GetUserStatus = 7; +const SayChatroom = 13; +const JoinRoom = 14; +const LeaveRoom = 15; +const UserJoinedRoom = 16; +const UserLeftRoom = 17; +const ConnectToPeer = 18; +const MessageUser = 22; +const MessageAcked = 23; +const FileSearch = 26; +const SetStatus = 28; +const ServerPing = 32; +const SharedFoldersFiles = 35; +const GetUserStats = 36; +const Relogged = 41; +const UserSearch = 42; +const AddThingILike = 51; +const RemoveThingILike = 52; +const GetRecommendations = 54; +const GlobalRecommendations = 56; +const UserInterests = 57; +const RoomList = 64; +const AdminMessage = 66; +const CheckPrivileges = 92; +const WishlistSearch = 103; +const WishlistInterval = 104; +const SimilarUsers = 110; +const ItemRecommendations = 111; +const ItemSimilarUsers = 112; +const RoomTicker = 113; +const RoomTickerAdd = 114; +const RoomTickerRemove = 115; +const SetRoomTicker = 116; +const AddThingIHate = 117; +const RemoveThingIHate = 118; +const RoomSearch = 120; +const SendUploadSpeed = 121; +const UserPrivileged = 122; +const GivePrivileges = 123; +const ChangePassword = 142; +const MessageUsers = 149; +const JoinGlobalRoom = 150; +const LeaveGlobalRoom = 151; +const GlobalRoomMessage = 152; +const CantConnectToPeer = 1001; // Useful for debugging -string[] message_name = [ +const message_name = [ 1 : "Login" , 2 : "SetWaitPort" , 3 : "GetPeerAddress" diff --git a/src/messages.d b/src/messages.d index c1b06b2..b53304e 100644 --- a/src/messages.d +++ b/src/messages.d @@ -119,7 +119,7 @@ class Message { // read a string auto slen = readi(); if (slen > in_buf.length) slen = cast(uint) in_buf.length; - auto str = cast(string) in_buf[0 .. slen].idup; + const str = cast(string) in_buf[0 .. slen].idup; in_buf = in_buf[slen .. $]; return str; @@ -691,7 +691,7 @@ class SJoinRoom : Message super(JoinRoom); writes(room); // the room the user just joined - auto n = usernames.length; + const n = usernames.length; writei(n); // number of user names we will send foreach (username ; usernames) writes(username); @@ -732,7 +732,7 @@ class SUserJoinedRoom : Message this(string room, string username, uint status, uint speed, uint upload_number, uint something, uint shared_files, uint shared_folders, - uint slots_full,string country_code) + uint slots_full, string country_code) { super(UserJoinedRoom); diff --git a/src/pm.d b/src/pm.d index bce4214..118a39a 100644 --- a/src/pm.d +++ b/src/pm.d @@ -29,7 +29,7 @@ class PM static PM[] get_pms_for(string user) { PM[] pms; - foreach (PM pm ; pm_list) if (pm.to == user) pms ~= pm; + foreach (pm ; pm_list) if (pm.to == user) pms ~= pm; return pms; } diff --git a/src/server.d b/src/server.d index 1e68301..bafa0b1 100644 --- a/src/server.d +++ b/src/server.d @@ -155,7 +155,7 @@ class Server auto nb = Socket.select( read_socks, write_socks, null, select_timeout ); - auto terminating = (nb == -1); + const terminating = (nb == -1); if (read_socks.isSet(sock)) { while (true) { @@ -313,7 +313,7 @@ class Server if (!db.is_admin(admin.username)) return; - auto command = message.split(" "); + const command = message.split(" "); if (command.length > 0) switch (command[0]) { case "help": @@ -352,7 +352,7 @@ class Server break; } - auto username = join(command[2 .. $], " "); + const username = join(command[2 .. $], " "); auto user = get_user(username); if (!user) { admin_pm( @@ -375,8 +375,8 @@ class Server admin_pm(admin, "Syntax is : info "); break; } - auto username = join(command[1 .. $], " "); - auto user_info = show_user(username); + const username = join(command[1 .. $], " "); + const user_info = show_user(username); admin_pm(admin, user_info); break; @@ -390,7 +390,7 @@ class Server admin_pm(admin, "Syntax is : kick "); break; } - auto username = join(command[1 .. $], " "); + const username = join(command[1 .. $], " "); kick_user(username); admin_pm( admin, "User %s kicked from the server".format(username) @@ -402,7 +402,7 @@ class Server admin_pm(admin, "Syntax is : ban "); break; } - auto username = join(command[1 .. $], " "); + const username = join(command[1 .. $], " "); ban_user(username); admin_pm( admin, "User %s banned from the server".format(username) @@ -414,7 +414,7 @@ class Server admin_pm(admin, "Syntax is : unban "); break; } - auto username = join(command[1 .. $], " "); + const username = join(command[1 .. $], " "); unban_user(username); admin_pm( admin, "User %s not banned anymore".format(username) @@ -422,7 +422,7 @@ class Server break; case "admins": - auto names = db.admins; + const names = db.admins; string list = "%d registered admins.".format(names.length); foreach (name ; names) list ~= "\n\t%s".format(name); admin_pm(admin, list); @@ -440,7 +440,7 @@ class Server admin_pm(admin, "Syntax is : message "); break; } - auto msg = join(command[1 .. $], " "); + const msg = join(command[1 .. $], " "); global_message(msg); break; @@ -531,8 +531,8 @@ class Server string get_motd(User user) { string motd; - auto motd_template = db.get_config_value("motd"); - auto client_version = "%d.%d".format( + const motd_template = db.get_config_value("motd"); + const client_version = "%d.%d".format( user.major_version, user.minor_version); motd = replace(motd_template, "%sversion%", VERSION); diff --git a/src/soulsetup.d b/src/soulsetup.d index dd28692..5b20548 100644 --- a/src/soulsetup.d +++ b/src/soulsetup.d @@ -93,7 +93,7 @@ void del_admin() void list_admins() { - auto names = sdb.admins; + const names = sdb.admins; writeln(format("\nAdmins (%d)...", names.length)); foreach (name ; names) writeln(format("\t%s", name)); @@ -118,7 +118,7 @@ void set_listen_port() { write("New listen port : "); - auto value = input.strip; + const value = input.strip; uint port; try {port = value.to!uint;} catch (ConvException) {} if (port <= 0 || port > ushort.max) { @@ -147,7 +147,7 @@ void set_max_users() { write("Max users : "); - auto value = input.strip; + const value = input.strip; uint num_users; try { num_users = value.to!uint; @@ -188,7 +188,7 @@ void set_motd() string motd_template; do { - auto line = input.chomp; + const line = input.chomp; if (line.strip == ".") break; if (motd_template.length > 0) motd_template ~= "\n"; @@ -243,7 +243,7 @@ void unban_user() void list_banned() { - auto users = sdb.usernames("banned"); + const users = sdb.usernames("banned"); writeln("\nBanned users (%d)...".format(users.length)); foreach (user ; users) writeln(format("\t%s", user)); @@ -286,7 +286,7 @@ class Menu writeln(format("%s. %s", index, entries[index])); write("\nYour choice : "); - auto choice = input.strip; + const choice = input.strip; if (choice !in actions) {