예제 #1
0
        public HeadlessClient(Legacy legacyApi, IConsole console, HeadlessStartConfig startConfig)
        {
            this.legacyApi             = legacyApi;
            this.console               = console;
            this.startConfig           = startConfig;
            packetRegistry             = PacketDefinitionRegistryFactory.CreateClassicClient(startConfig.ClientVersion);
            diagnosticProvider         = new InfusionDiagnosticPushStreamProvider(LogConfig, console);
            serverDiagnosticPushStream =
                new CompositeDiagnosticPushStream(new ConsoleDiagnosticPushStream(packetLogger, "headless -> server", packetRegistry),
                                                  new InfusionBinaryDiagnosticPushStream(DiagnosticStreamDirection.ClientToServer, diagnosticProvider.GetStream));
            serverDiagnosticPullStream = new ConsoleDiagnosticPullStream(packetLogger, "server -> headless", packetRegistry);

            serverConnection = new ServerConnection(ServerConnectionStatus.Initial, serverDiagnosticPullStream,
                                                    serverDiagnosticPushStream, packetRegistry, startConfig.Encryption);
            serverConnection.PacketReceived += ServerConnectionOnPacketReceived;
            ultimaServer = new UltimaServer(serverPacketHandler, SendToServer, packetRegistry);

            serverPacketHandler = new ServerPacketHandler(packetRegistry);
            clientPacketHandler = new ClientPacketHandler(packetRegistry);
            serverEndpoint      = startConfig.ServerEndPoint;

            ultimaClient = new UltimaClient(clientPacketHandler, SendToClient);

            serverPacketHandler.RegisterFilter(FilterServerPacket);
            serverPacketHandler.Subscribe(PacketDefinitions.GameServerList, HandleGameServerList);
            serverPacketHandler.Subscribe(PacketDefinitions.CharactersStartingLocations, HandleCharactersStartingLocationsPacket);
            serverPacketHandler.Subscribe(PacketDefinitions.EnableLockedClientFeatures, HandleEnableLockedClientFeatures);

            clientPacketHandler.Subscribe(PacketDefinitions.LoginRequest, HandleLoginRequest);
            clientPacketHandler.Subscribe(PacketDefinitions.GameServerLoginRequest, HandleGameServerLoginRequest);
            clientPacketHandler.Subscribe(PacketDefinitions.SelectServerRequest, HandleSelectServerRequest);
        }
예제 #2
0
        public Task Start(ProxyStartConfig config)
        {
            proxyStartConfig = config;

            Console.Info($"Default protocol version: {config.ProtocolVersion}");
            Console.Info($"Encryption: {config.Encryption}");
            if (config.LoginEncryptionKey.HasValue)
            {
                Console.Info($"Encryption key {config.LoginEncryptionKey.Value}");
            }
            packetRegistry = PacketDefinitionRegistryFactory.CreateClassicClient(proxyStartConfig.ProtocolVersion);

            serverPacketHandler = new ServerPacketHandler(packetRegistry);
            clientPacketHandler = new ClientPacketHandler(packetRegistry);
            serverPacketHandler.RegisterFilter(RedirectConnectToGameServer);
            clientPacketHandler.Subscribe(PacketDefinitions.ExtendedLoginSeed, HandleExtendedLoginSeed);

            LegacyApi = new Legacy(LogConfig, commandHandler, new UltimaServer(serverPacketHandler, SendToServer, packetRegistry), new UltimaClient(clientPacketHandler, SendToClient), Console,
                                   packetRegistry, ConfigRepository, injectionWindow, SoundPlayer);
            UO.Initialize(LegacyApi);

            commandHandler.RegisterCommand(new Command("dump", DumpPacketLog, false, true,
                                                       "Dumps packet log - log of network communication between game client and server. Network communication logs are very useful for diagnosing issues like crashes.",
                                                       executionMode: CommandExecutionMode.Direct));
            commandHandler.RegisterCommand(new Command("help", HelpCommand, false, true, "Shows command help."));

            commandHandler.RegisterCommand(new Command(ListCommandName, ListRunningCommands, false, true,
                                                       "Lists running commands"));

            commandHandler.RegisterCommand(new Command("proxy-latency", PrintProxyLatency, false, true, "Shows proxy latency."));

            serverEndpoint = config.ServerEndPoint;
            return(Main(config.LocalProxyPort, packetRingBufferLogger));
        }