public FileEntity(string url, string location, File.Type type) { Interlocked.Increment(ref _id); _url = url; _location = location; _type = type; }
public FileEntity(File.Type type) { _type = type; Interlocked.Increment(ref _id); _url = ""; _location = ""; }
public static byte[] PurchaseSoftwareMessage(File.Type fileType) { FlatBufferBuilder bb = new FlatBufferBuilder(2); var messageOffset = MessagesInternal.PurchaseSoftwareMessage.CreatePurchaseSoftwareMessage( bb, (sbyte)fileType); var baseOffset = MessagesInternal.MessageBase.CreateMessageBase(bb, MessagesInternal.MessageContainer.PurchaseSoftwareMessage, messageOffset.Value); bb.Finish(baseOffset.Value); return(PrefixMessageLength(bb)); }
public SoftwareEntry(string name, File.Type type, int price) { Name = name; Type = type; Price = price; }
static public File Create(File.Type type) { File file = new File(); switch (type) { case File.Type.Generic: file.CanBeExecuted = File.Permission.Never; file.CanBeDeleted = File.Permission.Always; break; ///////////////////////////////////////////////////////// // Various types of ICE ///////////////////////////////////////////////////////// case File.Type.Obfuscator: file.Name = "obfuscator"; break; case File.Type.PasswordGate: file.Name = "password_gate"; break; case File.Type.Firewall: file.Name = "firewall"; break; case File.Type.ConnectionSentry: file.Name = "connection_sentry"; break; case File.Type.Proxy: // Technically a proxy would actually be a separate server rather than something that can be executed. // For all intents and purposes, it is hidden from the player as a file. file.Name = "proxy_server"; file.CanBeExecuted = File.Permission.Never; file.CanBeDeleted = File.Permission.Never; file.MemoryUsage = 0; file.DiskSpaceUsage = 0; file.Visible = false; break; case File.Type.NoiseWall: file.Name = "noise_wall"; break; case File.Type.QuantumGate: file.Name = "quantum_gate"; break; case File.Type.ServiceHTTP: file.Name = "service_http"; break; case File.Type.ServiceFTP: file.Name = "service_ftp"; break; case File.Type.ServiceSSH: file.Name = "service_ssh"; break; case File.Type.ServiceSMTP: file.Name = "service_smtp"; break; case File.Type.ServiceDatabase: file.Name = "service_database"; break; ///////////////////////////////////////////////////////// // Icebreakers ///////////////////////////////////////////////////////// case File.Type.NodeAnalyser: file.Name = "node_analyser"; file.DiskSpaceUsage = 5; break; case File.Type.Cracker: file.Name = "cracker"; break; case File.Type.Fracter: file.Name = "fracter"; break; case File.Type.SSHTunnel: file.Name = "ssh_tunnel"; break; case File.Type.ProxyBypasser: file.Name = "proxy_bypasser"; break; case File.Type.FeedbackLoop: file.Name = "feedback_loop"; break; case File.Type.ExploitHTTP: file.Name = "exploit_http"; break; case File.Type.ExploitFTP: file.Name = "exploit_ftp"; break; case File.Type.ExploitSSH: file.Name = "exploit_ssh"; break; case File.Type.ExploitSMTP: file.Name = "exploit_smtp"; break; case File.Type.ExploitDatabase: file.Name = "exploit_database"; break; case File.Type.Siphon: file.Name = "siphon"; break; ///////////////////////////////////////////////////////// // Utility ///////////////////////////////////////////////////////// case File.Type.Tracer: file.Name = "tracer"; break; case File.Type.TraceKill: file.Name = "trace_kill"; file.SingleUse = true; break; case File.Type.VirtualIntelligence: file.Name = "virtual_intelligence"; file.Upgradeable = false; break; case File.Type.ArtificialIntelligence: file.Name = "artificial_intelligence"; file.Unique = true; break; ///////////////////////////////////////////////////////// // Viruses ///////////////////////////////////////////////////////// case File.Type.MinerVirus: file.Name = "miner_virus"; file.CanBeExecuted = File.Permission.RemoteOnly; break; case File.Type.FeedbackVirus: file.Name = "feedback_virus"; file.CanBeExecuted = File.Permission.RemoteOnly; break; default: Debug.Assert(false); break; } return(file); }
public static bool OnMessageReceived(Socket handler, byte[] buffer) { // The messages always have the same structure: // A MessageBase which contains an union of all the valid messages. ByteBuffer bb = new ByteBuffer(buffer); MessageBase messageBase = MessageBase.GetRootAsMessageBase(bb); switch (messageBase.DataType) { case MessageContainer.CreateAccountMessage: { CreateAccountMessage?message = messageBase.Data <CreateAccountMessage>(); if (message == null) { return(false); } Messages.CreateAccountResult result = CreateAccount(message.Value.Username, message.Value.Email, message.Value.Password); AsyncSocketListener.Send(handler, Messages.CreateAccountResultMessage(result)); break; } case MessageContainer.LoginMessage: { LoginMessage?message = messageBase.Data <LoginMessage>(); if (message == null) { return(false); } Messages.LoginResult result = TryLogin(message.Value.Username, message.Value.Password); AsyncSocketListener.Send(handler, Messages.LoginResultMessage(result)); if (result == Messages.LoginResult.Success) { // TODO: a second find shouldn't be needed, as we're doing one in the login Account account = Account.Find(message.Value.Username); Client client = m_SocketToClient[handler]; client.AssociateAccount(account); OnClientLogin(client); AsyncSocketListener.Send(handler, Messages.UpdateAddressMessage(client.Node.NodeAddress.Value, account.Username)); AsyncSocketListener.Send(handler, Messages.UpdateCreditsMessage(account.Credits)); AsyncSocketListener.Send(handler, Messages.UpdateReputationMessage(account.Reputation)); SendAllKnownAddresses(client); } break; } case MessageContainer.NodeConnectMessage: { NodeConnectMessage?message = messageBase.Data <NodeConnectMessage>(); if (message == null || message.Value.RouteLength == 0) { return(false); } List <string> route = new List <string>(); for (int i = 0; i < message.Value.RouteLength; ++i) { route.Add(message.Value.Route(i)); } int nodeErrorIndex; Messages.NodeConnectResult result = NodeConnect(route, out nodeErrorIndex); AsyncSocketListener.Send(handler, Messages.NodeConnectResultMessage(result, nodeErrorIndex)); break; } case MessageContainer.PurchaseSoftwareMessage: { PurchaseSoftwareMessage?message = messageBase.Data <PurchaseSoftwareMessage>(); if (message == null) { return(false); } Client client = m_SocketToClient[handler]; File.Type softwareToBuy = (File.Type)message.Value.Software; Messages.PurchaseSoftwareResult result = TryPurchaseSoftware(client, softwareToBuy); AsyncSocketListener.Send(handler, Messages.PurchaseSoftwareResultMessage(result)); break; } default: return(false); } return(true); }
private static Messages.PurchaseSoftwareResult TryPurchaseSoftware(Client client, File.Type softwareToBuy) { return(Messages.PurchaseSoftwareResult.Success); }