private void InitializationNetwork() { try { ConsoleSystem.Log("[VirtualServer]: Служба Network запускается..."); BaseServer = new RakNet.Server { ip = "0.0.0.0", port = 28001, OnRakNetPacket = OUT_OnRakNetMessage, onMessage = OUT_OnNetworkMessage, OnNewConnectionCallback = OnNewConnection, onDisconnected = OUT_OnDisconnected }; BaseClient = new RakNet.Client() { onMessage = IN_OnNetworkMessage, OnRakNetPacket = IN_OnRakNetMessage, onDisconnected = IN_OnDisconnected }; BaseServer.cryptography = new NetworkCryptographyServer(); BaseClient.cryptography = new NetworkCryptographyServer(); BaseServer.Start(); ConsoleSystem.Log("[VirtualServer]: Служба Network успешно запущена!"); } catch (Exception ex) { ConsoleSystem.LogError("[VirtualServer]: Исключение в InitializationNetwork(): " + ex.Message); } }
void OnRPC_ClProject(Message packet) { ProjectileShoot projectileShoot = ProjectileShoot.Deserialize(packet.read); if (projectileShoot.projectiles.Count > ItemOwner.Information.BaseProjectile.ProjectilesPerShot) { ConsoleSystem.Log($"projectiles.Count[{projectileShoot.projectiles.Count}] > ProjectilesPerShot[{ItemOwner.Information.BaseProjectile.ProjectilesPerShot}]"); Release(); return; } if (AmmoCount <= 0) { ConsoleSystem.Log($"AmmoCount[{AmmoCount}] <= 0"); Release(); return; } AmmoCount--; foreach (var projectile in projectileShoot.projectiles) { PlayerOwner.firedProjectiles.Add(projectile.projectileID, ItemOwner.Information); } base.SignalBroadcast(E_Signal.Attack, string.Empty, packet.connection); Release(); void Release() { projectileShoot.Dispose(); Pool.Free(ref projectileShoot); } }
public static void Initialize() { Type[] assemblyTypes = Assembly.GetExecutingAssembly().GetTypes() .Where(type => typeof(BaseNetworkable).IsAssignableFrom(type)).ToArray(); for (int i = 0; i < assemblyTypes.Length; ++i) { var type = assemblyTypes[i]; MethodInfo[] typeMethods = type.GetMethods(BindingFlags.CreateInstance | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Public); for (int j = 0; j < typeMethods.Length; ++j) { var method = typeMethods[j]; object[] customAttributes = method.GetCustomAttributes(typeof(RPCMethodAttribute), true); if (customAttributes.Length >= 1) { var methodName = ((RPCMethodAttribute)customAttributes[0]).MethodName; var parameters = method.GetParameters(); if (parameters.Length != 2 || parameters[0].ParameterType != typeof(ERPCNetworkType) || parameters[1].ParameterType != typeof(Message)) { ConsoleSystem.LogError($"[RPCManager]: Invalid Parameters for {type.Name}.{method.Name} " + $"({string.Join(", ",parameters.Select(p=>p.ParameterType.Name).ToArray())})\n" + $"Should be ({nameof(ERPCNetworkType)}, {nameof(Message)})"); continue; } RPCMethods[methodName] = new FastMethodInfo(method); } } } ConsoleSystem.Log($"Loaded <{RPCMethods.Count}> RPCMethods!"); }
public void Connect(string ip, int port) { try { ConsoleSystem.Log($"[VirtualServer]: Подключаемся к игровому серверу [{ip}:{port}]"); if (BaseClient.Connect(ip, port)) { if (BaseClient.write.Start()) { BaseClient.write.UInt8(19); BaseClient.write.Send(new SendInfo(BaseClient.Connection)); } ConsoleSystem.Log("[VirtualServer]: Инициализация подключения успешно завершена!"); } else { ConsoleSystem.LogError("[VirtualServer]: В попытке подключения отказано!"); } } catch (Exception ex) { ConsoleSystem.LogError("[VirtualServer]: Исключение в OnNewConnection(): " + ex.Message); } }
public bool SendMeleeAttack(BaseEntity target, EHumanBone bone, Vector3 position) { ConsoleSystem.Log(bone.ToString()); var attackInfo = OpCodes.GetTargetHitInfo(bone); PlayerAttack attack = new PlayerAttack() { projectileID = 0, attack = new Attack() { hitID = target.UID, hitItem = 0, hitBone = attackInfo.HitBone, hitMaterialID = 97517300, hitPartID = attackInfo.HitPartID, pointEnd = position, pointStart = position, hitPositionLocal = attackInfo.HitLocalPos, hitPositionWorld = position, hitNormalLocal = attackInfo.HitNormalPos, hitNormalWorld = position } }; if (VirtualServer.BaseClient.write.Start()) { VirtualServer.BaseClient.write.PacketID(Message.Type.RPCMessage); VirtualServer.BaseClient.write.EntityID(this.UID); VirtualServer.BaseClient.write.UInt32((UInt32)ERPCMethodUID.PlayerAttack); PlayerAttack.Serialize(VirtualServer.BaseClient.write, attack); VirtualServer.BaseClient.Send(); } return(true); }
private bool RPC_OnProjectileAttack(ERPCNetworkType type, Message message) { using (PlayerProjectileAttack attack = PlayerProjectileAttack.Deserialize(message.read)) { UInt32 hitId = attack.playerAttack.attack.hitID; UInt32 hitBone = attack.playerAttack.attack.hitBone; var hitPlayer = Get <BasePlayer>(hitId); if (Settings.Aimbot_Range_Silent) { if (hitId == 0) { return(RangeAim.Silent(attack)); } if (hitPlayer == null && hitId != 0 && RangeAim.Instance.TargetPlayer != null) { var hitPost = attack.playerAttack.attack.hitPositionWorld; if (Vector3.Distance(Position, RangeAim.Instance.TargetPlayer.Position) < 2.5f || Vector3.Distance(Position, hitPost) > 2.5f) { ConsoleSystem.Log("near wall not found"); return(RangeAim.Silent(attack)); } ConsoleSystem.Log("Ignore because near wall"); return(false); } } if (hitPlayer && hitPlayer.IsAlive) { RangeAim.Instance.TargetPlayer = Get <BasePlayer>(hitId); return(RangeAim.Manual(attack)); } } return(false); }
private void LaunchRust() { _username = _steamFriends.GetPersonaName(); ConsoleSystem.Log("Logged in! Launching Rust..."); // we've logged into the account // now we need to inform the steam server that we're playing dota (in order to receive GC messages) // steamkit doesn't expose the "play game" message through any handler, so we'll just send the message manually var playGame = new ClientMsgProtobuf <CMsgClientGamesPlayed>(EMsg.ClientGamesPlayed); playGame.Body.games_played.Add(new CMsgClientGamesPlayed.GamePlayed { game_id = new GameID(252490) // or game_id = APPID, }); // send it off // notice here we're sending this message directly using the SteamClient _steamClient.Send(playGame); // delay a little to give steam some time to establish a GC connection to us Thread.Sleep(5000); var index = GetAuthSessionTicket(252490, 327684); var bytes = GetAuthTicket(index); Framework.RunToMainThread(o => { _quitAfterDisconnect = false; var server = Framework.Bootstraper.AddType <VirtualServer>(); server.Init(_steamUser.SteamID.ConvertToUInt64(), _username, bytes.Ticket, _quitAfterConnected); server.Connect(_ip, _port); }, null); }
private void OnSessionClose(BaseServerSession sender, SessionDisconnectEventArgs e) { _ActiveSessions.Remove(sender.RemoteIP.ToString()); _ActiveSessionList = _ActiveSessionList.ToList(); _ActiveSessionList.Remove(sender); ConsoleSystem.Log($"[{sender.RemoteIP}] disconnected!"); }
private void OnSessionOpen(BaseServerSession session, string address) { _ActiveSessions[address] = session; _ActiveSessionList = _ActiveSessionList.ToList(); _ActiveSessionList.Add(session); ConsoleSystem.Log($"[{address}] connected!"); }
public void OnChangeActiveItem(UInt32 activeItem) { this.ActiveItem = (BaseHeldEntity)ListNetworkables[activeItem + 1]; if (this.IsLocalPlayer && this.HasActiveItem) { ConsoleSystem.Log("You use: " + this.ActiveItem.PrefabID + " Ammotype =>" + this.ActiveItem.AmmoType); } }
internal static void Initialization() { string filepath = Path.Combine(BuildingInformation.DirectoryBase, "items.json"); itemlist = JsonConvert.DeserializeObject <List <ItemInformation> >(File.ReadAllText(filepath)); itemDictionary = itemlist.ToDictionary(item => item.ItemID, item => item); ConsoleSystem.Log($"[{nameof(ItemManager)}] Loaded <{itemlist.Count}> items!"); }
public override void OnAwake() { ConsoleSystem.ShowCallerInLog = false; BaseServer = new NetworkServer(new NetworkConfiguration(0x00) { ServerPort = 10015, Cryptor = new Crypto() }); BaseServer.OnConnected = connection => { connection.IsEncryption = true; ConsoleSystem.Log("BaseServer.OnConnected"); }; BaseServer.OnDisconnected = (connection, s) => { ConsoleSystem.Log("BaseServer.OnDisconnected: " + s); }; BaseServer.OnMessage = connection => { ConsoleSystem.Log("BaseServer.OnMessage => " + connection.Peer.Read.String()); // connection.Peer.Write.Start(); // connection.Peer.Write.String("Hello"); // connection.Peer.Write.SendTo(connection); }; BaseServer.Start(); BaseClient = new NetworkClient(new NetworkConfiguration(0x00) { Cryptor = new Crypto() }); // BaseClient.OnConnected = connection => // { // connection.IsEncryption = true; // ConsoleSystem.Log("BaseClient.OnConnected"); // // connection.Peer.Write.Start(); // connection.Peer.Write.String("Hello"); // connection.Peer.Write.SendTo(connection); // }; // BaseClient.OnDisconnected = (connection, s) => // { // ConsoleSystem.Log("BaseClient.OnDisconnected: " + s); // }; // BaseClient.OnMessage = connection => // { // ConsoleSystem.Log("BaseServer.OnMessage => " + connection.Peer.Read.String()); // }; // this.BaseClient.Connect("127.0.0.1", 10015); // // // SapphireEngine.Functions.Timer.SetTimeout(() => // { // SapphireEngine.Functions.Timer.SetTimeout(() => { SapphireEngine.Functions.Timer.SetTimeout(() => { }, 10);}, 10); // // }, 10); }
private void OnDisconnected(string _reasone, Connection _connection) { BasePlayer player = Extended.Rust.ToPlayer(_connection); if (player != null) { player.Network.OnDisconnected(); } ConsoleSystem.Log(string.Format(Data.Base.DefaultMessages.Network_Connection_NewDisconnected, _connection.userid, _connection.username, _reasone)); }
public override void OnUpdate() { Time += DeltaTime; if (Time > 1) { Time -= 1; ConsoleSystem.Log("Kek"); } }
private bool RPC_StartLoading(ERPCNetworkType type, Message message) { ConsoleSystem.Log("StartLoading"); EACServer.OnStartLoading(VirtualServer.BaseClient.Connection); EACServer.OnStartLoading(VirtualServer.BaseServer.connections[0]); BaseNetworkable.DestroyAll(); ListNetworkables.Add(this.UID, this); ListPlayers.Add(this); return(false); }
public static void Initialization() { for (int x = MapXMin; x <= MapXMax; ++x) { ListGameZones[x] = new Dictionary <int, GameZona>(); for (int y = MapYMin; y <= MapYMax; ++y) { ListGameZones[x][y] = new GameZona(x, y); } } ConsoleSystem.Log("[ZonaManager]: Initialized zones " + Settings.MapZonaCount * Settings.MapZonaCount + " count from " + Settings.MapZonaSize * Settings.MapZonaCount + " size."); }
private void OnDisconnected(SteamKit2.SteamClient.DisconnectedCallback callback) { if (_quitAfterDisconnect) { ConsoleSystem.Log("Disconnected from Steam, quiting..."); Framework.Quit(); } else { ConsoleSystem.Log("Disconnected from Steam!"); } }
private void OnConnected(SteamKit2.SteamClient.ConnectedCallback callback) { ConsoleSystem.Log("Connected to Steam! Logging in '{0}'...", _user); _steamUser.LogOn(new SteamUser.LogOnDetails { Username = _user, Password = _password, AuthCode = _authCode, TwoFactorCode = _twoFactorAuth }); }
public static void DoShutdown() { client2connection.Clear(); connection2client.Clear(); connection2status.Clear(); if (easyAntiCheat != null) { ConsoleSystem.Log("EasyAntiCheat Server Shutting Down"); easyAntiCheat.Dispose(); easyAntiCheat = null; } }
public override void OnAwake() { ConsoleSystem.OutputPath = Bootstrap.OutputPath; ConsoleSystem.Log("[Bootstrap]: Приложение запущено"); DatabaseLoader.Load <Database>(); RPCManager.Initialize(); this.AddType <VirtualServer>(); this.AddType <NetworkManager>(); this.AddType <RangeAim>(); this.AddType <MeleeAim>(); this.AddType <AutoGather>(); this.AddType <WallHack>(); }
private void InitializationEAC() { try { ConsoleSystem.Log("[VirtualServer]: ParseEncryptionHash запускается..."); EACServer.DoStartup(); Timer.SetInterval(EACServer.DoUpdate, 1f); ConsoleSystem.Log("[VirtualServer]: ParseEncryptionHash успешно запущен!"); } catch (Exception ex) { ConsoleSystem.LogError("[VirtualServer]: Исключение в InitializationEAC(): " + ex.Message); } }
public static bool RunRPCMethod(uint entity, ERPCMethodUID method, ERPCNetworkType networkType, Message message) { try { if (BaseNetworkable.HasNetworkable(entity) && HasRPCMethod(method)) { return((bool)(RPCMethods[method]?.Invoke(BaseNetworkable.ListNetworkables[entity], new object[] { networkType, message }) ?? false)); } } catch (Exception ex) { ConsoleSystem.Log("Exception: RunRPCMethod(" + (BaseNetworkable.HasNetworkable(entity) ? BaseNetworkable.ListNetworkables[entity].ToString() : "NoHaveEntity") + ", " + method + ", " + networkType + ") => " + ex.Message); } return(false); }
private void OnLoggedOn(SteamUser.LoggedOnCallback callback) { var isSteamGuard = callback.Result == EResult.AccountLogonDenied; var is2Fa = callback.Result == EResult.AccountLoginDeniedNeedTwoFactor; if (isSteamGuard || is2Fa) { ConsoleSystem.Log("This account is SteamGuard protected!"); if (is2Fa) { Console.Write("Please enter your 2 factor auth code from your authenticator app: "); _twoFactorAuth = Console.ReadLine(); } else { Console.Write("Please enter the auth code sent to the email at {0}: ", callback.EmailDomain); _authCode = Console.ReadLine(); } return; } if (callback.Result != EResult.OK) { if (callback.Result == EResult.AccountLogonDenied) { // if we recieve AccountLogonDenied or one of it's flavors (AccountLogonDeniedNoMailSent, etc) // then the account we're logging into is SteamGuard protected // see sample 5 for how SteamGuard can be handled ConsoleSystem.Log("Unable to logon to Steam: This account is SteamGuard protected."); _isRunning = false; return; } ConsoleSystem.Log("Unable to logon to Steam: {0} / {1}", callback.Result, callback.ExtendedResult); _isRunning = false; return; } _publicIp = callback.PublicIP; ConsoleSystem.Log("Successfully logged on!"); GetAppOwnershipTicketAsync(252490); }
private static void PrintLogType(LogType logType, string message, bool log = false) { if (global.logprint) { switch (logType) { case LogType.Error: { ConsoleSystem.LogError(message); return; } case LogType.Warning: { ConsoleSystem.LogWarning(message); return; } case LogType.Log: { ConsoleSystem.Log(message); return; } } } if (log && !ConsoleSystem.LogCallbackWritesToConsole) { try { ((logType != LogType.Log ? Console.Error : Console.Out)).WriteLine("Print{0}:{1}", logType, message); } catch (Exception exception) { Console.Error.WriteLine("PrintLogType Log Exception\n:{0}", exception); } } if (ConsoleSystem.RegisteredLogCallback) { try { ConsoleSystem.LogCallback(message, string.Empty, logType); } catch (Exception exception1) { Console.Error.WriteLine("PrintLogType Exception\n:{0}", exception1); } } }
private byte[] GetAppOwnershipTicket(uint appId) { if (_ownershipTicketStore.TryGetValue(appId, out var result)) { return(result); } ConsoleSystem.Log("Waiting for app ownership ticket..."); // Request an app ownership ticket from steam var job = _steamApps.GetAppOwnershipTicket(appId); var res = job.GetAwaiter().GetResult().Result; // Get the now stored ticket return(_ownershipTicketStore[appId]); }
public override void Stop(string shutdownMsg) { if (this.peer == null) { return; } ConsoleSystem.Log(string.Concat("[Raknet] Server Shutting Down (", shutdownMsg, ")")); (this.write as StreamWrite).Shutdown(); (this.read as StreamRead).Shutdown(); using (TimeWarning timeWarning = TimeWarning.New("ServerStop", 0.1f)) { this.peer.Close(); this.peer = null; base.Stop(shutdownMsg); } }
public void OnChangeActiveItem(Item newItem) { if (this.ActiveItem?.HeldEntity != null) { this.ActiveItem.HeldEntity.SetHeld(false); this.ActiveItem.HeldEntity.SendNetworkUpdate(); } this.ActiveItem = newItem; if (this.ActiveItem?.HeldEntity != null) { this.ActiveItem.HeldEntity.SetHeld(true); this.ActiveItem.HeldEntity.SendNetworkUpdate(); } ConsoleSystem.Log($"{this.Username} have active heldEntity: {(this.ActiveItemUID)}"); }
public void OnNewConnection(Connection connection) { try { if (BaseServer.connections.Count <= 1) { ConsoleSystem.Log($"[VirtualServer]: Есть новое подключение [{BaseServer.connections[0].ipaddress}]"); ConsoleSystem.Log($"[VirtualServer]: Подключаемся к игровому серверу [{Settings.TargetServer_IP}:{Settings.TargetServer_Port}]"); if (BaseClient.Connect(Settings.TargetServer_IP, Settings.TargetServer_Port)) { BaseClient.Connection.ipaddress = "127.0.0.1"; BaseClient.Connection.userid = Settings.Connection1_SteamID; BaseClient.Connection.ownerid = Settings.Connection1_SteamID; BaseClient.Connection.username = Settings.Connection1_Username; BaseClient.Connection.authLevel = 1; EACServer.OnJoinGame(BaseClient.Connection); //EACServer.OnStartLoading(BaseClient.Connection); //EACServer.OnFinishLoading(BaseClient.Connection); BaseServer.connections[0].ipaddress = "127.0.0.1"; BaseServer.connections[0].userid = Settings.Connection2_SteamID; BaseServer.connections[0].ownerid = Settings.Connection2_SteamID; BaseServer.connections[0].username = Settings.Connection2_Username; BaseServer.connections[0].authLevel = 1; EACServer.OnJoinGame(BaseServer.connections[0]); //EACServer.OnStartLoading(BaseServer.connections[0]); //EACServer.OnFinishLoading(BaseServer.connections[0]); ConsoleSystem.Log("[VirtualServer]: Инициализация подключения успешно завершена!"); } else { ConsoleSystem.LogError($"[VirtualServer]: В попытке подключения отказано!"); } } else { ConsoleSystem.LogError($"[VirtualServer]: Уже есть одно подключение, больше подключений не может быть!"); } } catch (Exception ex) { ConsoleSystem.LogError("[VirtualServer]: Исключение в OnNewConnection(): " + ex.Message); } }
public static void Load() { if (File.Exists(PathFileBase)) { Dictionary <string, string> lines_from_file = new Dictionary <string, string>(); var lines = File.ReadAllLines(PathFileBase); for (int i = 0; i < lines.Length; ++i) { if (lines[i].Length >= 2) { int indexSpliter = lines[i].IndexOf('='); if (indexSpliter > 0) { string key = lines[i].Substring(0, indexSpliter).ToLower(); key = key.Trim(); string value = string.Empty; if (indexSpliter + 1 < lines[i].Length) { value = lines[i].Remove(0, indexSpliter + 1); value = value.Trim(); } lines_from_file[key] = value; } } } var props = typeof(DefaultMessages).GetProperties(BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public); for (int i = 0; i < props.Length; ++i) { var prop_name = props[i].Name.ToLower(); if (lines_from_file.ContainsKey(prop_name)) { props[i].SetValue(null, lines_from_file[prop_name], new object[0]); } } ConsoleSystem.Log("[Data.Base.Message] Loaded!"); } else { ConsoleSystem.LogWarning("[Data.Base.Message] Not found file: " + PathFileBase); } }
private void InitializationNetwork() { try { ConsoleSystem.Log("[VirtualServer]: Служба Network запускается..."); BaseClient = new RakNet.Client { OnMessage = IN_OnNetworkMessage, onDisconnected = IN_OnDisconnected, Cryptography = new NetworkCryptographyClient() }; ConsoleSystem.Log("[VirtualServer]: Служба Network успешно запущена!"); } catch (Exception ex) { ConsoleSystem.LogError("[VirtualServer]: Исключение в InitializationNetwork(): " + ex.Message); } }