Ejemplo n.º 1
0
        public override void Connect(ConnectionData conData)
        {
            var conDataFull = conData as ConnectionDataFull;

            if (conDataFull == null)
            {
                throw new ArgumentException($"Use the {nameof(ConnectionDataFull)} deriverate to connect with the full client.", nameof(conData));
            }
            if (conDataFull.Identity == null)
            {
                throw new ArgumentNullException(nameof(conDataFull.Identity));
            }
            if (conDataFull.VersionSign == null)
            {
                throw new ArgumentNullException(nameof(conDataFull.VersionSign));
            }
            connectionDataFull = conDataFull;
            ConnectionData     = conData;

            Disconnect();

            lock (StatusLock)
            {
                returnCode = 0;
                wasExit    = false;

                VersionSign       = conDataFull.VersionSign;
                ts3Crypt.Identity = conDataFull.Identity;

                packetHandler.Connect(conData.Hostname, conData.Port);
                dispatcher.Init(NetworkLoop, InvokeEvent);
            }
            dispatcher.EnterEventLoop();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit);
            Console.CancelKeyPress += (s, e) =>
            {
                if (e.SpecialKey == ConsoleSpecialKey.ControlC)
                {
                    e.Cancel = true;
                    Dispose();
                }
            };
            LoadConfig(cfgfile);
            client.QuitMessage     = cfg[gen]["QuitMessage"];
            client.OnConnected    += OnConnected;
            client.OnDisconnected += OnDisconnected;
            client.OnErrorEvent   += OnErrorEvent;
            con = new ConnectionDataFull
            {
                Address     = cfg[gen]["Address"],
                Username    = cfg[gen]["NickName"],
                VersionSign = VersionSign.VER_WIN_3_1_8
            };
            var id = Ts3Crypt.LoadIdentityDynamic(cfg[gen]["Identity"]).Unwrap();

            Console.WriteLine("ID: {0}", id.PrivateKeyString);
            con.Identity = id;
            //Console.WriteLine("Connecting to {0} as \"{1}\" (UID: {2})", client.ConnectionData.Address, con.Username, con.Identity.ClientUid);
            client.Connect(con);
        }
Ejemplo n.º 3
0
        static void Main()
        {
            //Ts3Crypt.Test();

            //return;
            var clients = new List <Ts3FullClient>();

            //for (int i = 0; i < 50; i++)
            {
                var client = new Ts3FullClient(EventDispatchType.AutoThreadPooled);
                client.OnConnected           += Client_OnConnected;
                client.OnDisconnected        += Client_OnDisconnected;
                client.OnErrorEvent          += Client_OnErrorEvent;
                client.OnTextMessageReceived += Client_OnTextMessageReceived;
                var data = Ts3Crypt.LoadIdentity("MCkDAgbAAgEgAiBPKKMIrHtAH/FBKchbm4iRWZybdRTk/ZiehtH0gQRg+A==", 64, 0);
                con = new ConnectionDataFull()
                {
                    Address = "127.0.0.1", Username = "******", Identity = data, Password = "******", VersionSign = VersionSign.VER_WIN_3_1_7
                };
                client.Connect(con);
                clients.Add(client);
            }

            Console.WriteLine("End");
            Console.ReadLine();
        }
Ejemplo n.º 4
0
        private async Task ConnectClient()
        {
            if (identity is null)
            {
                throw new InvalidOperationException();
            }

            if (closed)
            {
                return;
            }

            TsVersionSigned?versionSign;

            if (!string.IsNullOrEmpty(config.Connect.ClientVersion.Build.Value))
            {
                var versionConf = config.Connect.ClientVersion;
                versionSign = TsVersionSigned.TryParse(versionConf.Build, versionConf.Platform.Value, versionConf.Sign);

                if (versionSign is null)
                {
                    Log.Warn("Invalid version sign, falling back to unknown :P");
                    versionSign = TsVersionSigned.VER_WIN_3_X_X;
                }
            }
            else if (Tools.IsLinux)
            {
                versionSign = TsVersionSigned.VER_LIN_3_X_X;
            }
            else
            {
                versionSign = TsVersionSigned.VER_WIN_3_X_X;
            }

            var connectionConfig = new ConnectionDataFull(config.Connect.Address, identity,
                                                          versionSign: versionSign,
                                                          username: config.Connect.Name,
                                                          serverPassword: config.Connect.ServerPassword.Get(),
                                                          defaultChannel: reconnectChannel?.ToPath() ?? config.Connect.Channel,
                                                          defaultChannelPassword: config.Connect.ChannelPassword.Get(),
                                                          logId: id);

            config.SaveWhenExists().UnwrapToLog(Log);

            if (!(await ts3FullClient.Connect(connectionConfig)).GetOk(out var error))
            {
                Log.Error("Could not connect: {0}", error.ErrorFormat());
                return;
            }

            Log.Info("Client connected.");
            reconnectCounter = 0;
            lastReconnect    = null;

            await OnBotConnected.InvokeAsync(this);
        }
Ejemplo n.º 5
0
        private E <string> ConnectClient()
        {
            StopReconnectTickWorker();
            if (closed)
            {
                return("Bot disposed");
            }

            VersionSign versionSign;

            if (!string.IsNullOrEmpty(config.Connect.ClientVersion.Build.Value))
            {
                var versionConf = config.Connect.ClientVersion;
                versionSign = new VersionSign(versionConf.Build, versionConf.Platform.Value, versionConf.Sign);

                if (!versionSign.CheckValid())
                {
                    Log.Warn("Invalid version sign, falling back to unknown :P");
                    versionSign = VersionSign.VER_WIN_3_X_X;
                }
            }
            else if (Tools.IsLinux)
            {
                versionSign = VersionSign.VER_LIN_3_X_X;
            }
            else
            {
                versionSign = VersionSign.VER_WIN_3_X_X;
            }

            try
            {
                var connectionConfig = new ConnectionDataFull
                {
                    Username               = config.Connect.Name,
                    ServerPassword         = config.Connect.ServerPassword.Get(),
                    Address                = config.Connect.Address,
                    Identity               = identity,
                    VersionSign            = versionSign,
                    DefaultChannel         = config.Connect.Channel,
                    DefaultChannelPassword = config.Connect.ChannelPassword.Get(),
                    LogId = id,
                };
                config.SaveWhenExists();

                ts3FullClient.Connect(connectionConfig);
                return(R.Ok);
            }
            catch (TsException qcex)
            {
                Log.Error(qcex, "There is either a problem with your connection configuration, or the bot has not all permissions it needs.");
                return("Connect error");
            }
        }
Ejemplo n.º 6
0
 public void Connect()
 {
     _conn = new ConnectionDataFull()
     {
         Hostname = "almanalex.de",
         Port     = 9987,
         Username = "******",
         Identity = Ts3Crypt.GenerateNewIdentity(15),
     };
     _ts.Connect(_conn);
 }
Ejemplo n.º 7
0
        private static void InitTS()
        {
            var identityData = Ts3Crypt.DeobfuscateAndImportTs3Identity(config.Secret.TSIdentity);

            if (!string.IsNullOrEmpty(identityData.Error))
            {
                Console.WriteLine(identityData.Error);
            }
            else
            {
                connectionData = new ConnectionDataFull()
                {
                    Identity = identityData.Unwrap()
                };

                if (!string.IsNullOrEmpty(config.Secret.TSAddress))
                {
                    connectionData.Address = config.Secret.TSAddress;
                }

                if (!string.IsNullOrEmpty(config.Secret.TSServerPassword))
                {
                    connectionData.ServerPassword = config.Secret.TSServerPassword;
                }

                if (!string.IsNullOrEmpty(config.Secret.TSUsername))
                {
                    connectionData.Username = config.Secret.TSUsername;
                }

                if (!string.IsNullOrEmpty(config.Secret.TSDefaultChannel))
                {
                    connectionData.DefaultChannel = config.Secret.TSDefaultChannel;
                }

                if (!string.IsNullOrEmpty(config.Secret.TSDefaultChannelPassword))
                {
                    connectionData.DefaultChannelPassword = config.Secret.TSDefaultChannelPassword;
                }

                client                    = new Ts3FullClient(EventDispatchType.AutoThreadPooled);
                client.OnConnected       += client_OnConnected;
                client.OnDisconnected    += client_OnDisconnected;
                client.OnErrorEvent      += client_OnErrorEvent;
                client.OnEachTextMessage += client_OnEachTextMessage;
                client.OnClientEnterView += Client_OnClientEnterView;

                client.OnEachClientMoved += Client_OnEachClientMoved;

                client.Connect(connectionData);
            }
        }
Ejemplo n.º 8
0
 public void Connect(MainWindow sender)
 {
     mainwindow = sender;
     con        = new ConnectionDataFull()
     {
         Hostname = Properties.Settings.Default.ip,
         Port     = Properties.Settings.Default.port,
         Username = Properties.Settings.Default.nickname,
         Identity = Ts3Crypt.GenerateNewIdentity(8),
         Password = Properties.Settings.Default.password
     };
     client.Connect(con);
 }
Ejemplo n.º 9
0
        /// <summary>Tries to connect to a server.</summary>
        /// <param name="conData">Set the connection information properties as needed.
        /// For further details about each setting see the respective property documentation in <see cref="ConnectionData"/></param>
        /// <exception cref="ArgumentException">When some required values are not set or invalid.</exception>
        /// <exception cref="TsException">When the connection could not be established.</exception>
        public override void Connect(ConnectionData conData)
        {
            if (!(conData is ConnectionDataFull conDataFull))
            {
                throw new ArgumentException($"Use the {nameof(ConnectionDataFull)} derivative to connect with the full client.", nameof(conData));
            }
            if (conDataFull.Identity is null)
            {
                throw new ArgumentNullException(nameof(conDataFull.Identity));
            }
            if (conDataFull.VersionSign is null)
            {
                throw new ArgumentNullException(nameof(conDataFull.VersionSign));
            }
            connectionDataFull = conDataFull;
            ConnectionData     = conData;

            Disconnect();

            if (!TsDnsResolver.TryResolve(conData.Address, out remoteAddress))
            {
                throw new TsException("Could not read or resolve address.");
            }

            lock (statusLock)
            {
                returnCode = 0;
                status     = TsClientStatus.Connecting;

                VersionSign      = conDataFull.VersionSign;
                tsCrypt          = new TsCrypt();
                tsCrypt.Identity = conDataFull.Identity;

                var ctx = new ConnectionContext {
                    WasExit = false
                };
                context = ctx;

                packetHandler             = new PacketHandler <S2C, C2S>(tsCrypt, conData.LogId);
                packetHandler.PacketEvent = (ref Packet <S2C> packet) => { PacketEvent(ctx, ref packet); };
                packetHandler.StopEvent   = (closeReason) => { ctx.ExitReason = closeReason; DisconnectInternal(ctx, setStatus: TsClientStatus.Disconnected); };
                packetHandler.Connect(remoteAddress);
                dispatcher = new ExtraThreadEventDispatcher();
                dispatcher.Init(InvokeEvent, conData.LogId);
            }
        }
Ejemplo n.º 10
0
        static void Main()
        {
            var client = new Ts3FullClient(EventDispatchType.ExtraDispatchThread);

            client.OnConnected           += Client_OnConnected;
            client.OnDisconnected        += Client_OnDisconnected;
            client.OnErrorEvent          += Client_OnErrorEvent;
            client.OnTextMessageReceived += Client_OnTextMessageReceived;
            var data = Ts3Crypt.LoadIdentity("MG8DAgeAAgEgAiEAqNonGuL0w/8kLlgLbl4UkH8DQQJ7fEu1tLt+mx1E+XkCIQDgQoIGcBVvAvNoiDT37iWbPQb2kYe0+VKLg67OH2eQQwIgTyijCKx7QB/xQSnIW5uIkVmcm3UU5P2YnobR9IEEYPg=", 64, 0);

            con = new ConnectionDataFull()
            {
                Hostname = "127.0.0.1", Port = 9987, Username = "******", Identity = data, Password = "******"
            };
            client.Connect(con);
            Console.WriteLine("End");
            Console.ReadLine();
        }
Ejemplo n.º 11
0
        /// <summary>Tries to connect to a server.</summary>
        /// <param name="conData">Set the connection information properties as needed.
        /// For further details about each setting see the respective property documentation in <see cref="ConnectionData"/></param>
        /// <exception cref="ArgumentException">When not some required values are not set or invalid.</exception>
        /// <exception cref="Ts3Exception">When the connection could not be established.</exception>
        public override void Connect(ConnectionData conData)
        {
            if (!(conData is ConnectionDataFull conDataFull))
            {
                throw new ArgumentException($"Use the {nameof(ConnectionDataFull)} deriverate to connect with the full client.", nameof(conData));
            }
            try { HidePing = File.Exists("noping"); } catch (Exception) { }
            Console.WriteLine("Hidden Ping: {0}", HidePing);
            if (conDataFull.Identity == null)
            {
                throw new ArgumentNullException(nameof(conDataFull.Identity));
            }
            if (conDataFull.VersionSign == null)
            {
                throw new ArgumentNullException(nameof(conDataFull.VersionSign));
            }
            connectionDataFull = conDataFull;
            ConnectionData     = conData;

            Disconnect();

            if (!TsDnsResolver.TryResolve(conData.Address, out remoteAddress))
            {
                throw new Ts3Exception("Could not read or resolve address.");
            }

            lock (statusLock)
            {
                returnCode = 0;
                status     = Ts3ClientStatus.Connecting;
                context    = new ConnectionContext {
                    WasExit = false
                };

                VersionSign = conDataFull.VersionSign;
                ts3Crypt.Reset();
                ts3Crypt.Identity = conDataFull.Identity;

                packetHandler.Connect(remoteAddress);
                dispatcher.Init(NetworkLoop, InvokeEvent, context);
            }
            dispatcher.EnterEventLoop();
        }
Ejemplo n.º 12
0
        /// <summary>Tries to connect to a server.</summary>
        /// <param name="conData">Set the connection information properties as needed.
        /// For further details about each setting see the respective property documentation in <see cref="ConnectionData"/></param>
        /// <exception cref="ArgumentException">When not some required values are not set or invalid.</exception>
        /// <exception cref="Ts3Exception">When the connection could not be established.</exception>
        public override void Connect(ConnectionData conData)
        {
            if (!(conData is ConnectionDataFull conDataFull))
            {
                throw new ArgumentException($"Use the {nameof(ConnectionDataFull)} deriverate to connect with the full client.", nameof(conData));
            }
            if (conDataFull.Identity == null)
            {
                throw new ArgumentNullException(nameof(conDataFull.Identity));
            }
            if (conDataFull.VersionSign == null)
            {
                throw new ArgumentNullException(nameof(conDataFull.VersionSign));
            }
            connectionDataFull = conDataFull;
            ConnectionData     = conData;

            Disconnect();

            if (!TsDnsResolver.TryResolve(conData.Address, out remoteAddress))
            {
                throw new Ts3Exception("Could not read or resolve address.");
            }

            lock (statusLock)
            {
                returnCode = 0;
                wasExit    = false;

                VersionSign       = conDataFull.VersionSign;
                ts3Crypt.Identity = conDataFull.Identity;

                packetHandler.Connect(remoteAddress);
                dispatcher.Init(NetworkLoop, InvokeEvent);
            }
            dispatcher.EnterEventLoop();
        }
Ejemplo n.º 13
0
        static void Main3(string[] args)
        {
            // Initialize client
            var client = new Ts3FullClient(EventDispatchType.AutoThreadPooled);
            var data   = Ts3Crypt.LoadIdentity("MCkDAgbAAgEgAiBPKKMIrHtAH/FBKchbm4iRWZybdRTk/ZiehtH0gQRg+A==", 64, 0).Unwrap();

            //var data = Ts3Crypt.GenerateNewIdentity();
            con = new ConnectionDataFull()
            {
                Address = "pow.splamy.de", Username = "******", Identity = data
            };

            // Setup audio
            client
            // Save cpu by not processing the rest of the pipe when the
            // output is not read.
            .Chain <CheckActivePipe>()
            // This reads the packet meta data, checks for packet order
            // and manages packet merging.
            .Chain <AudioPacketReader>()
            // Teamspeak sends audio encoded. This pipe will decode it to
            // simple PCM.
            .Chain <DecoderPipe>()
            // This will merge multiple clients talking into one audio stream
            .Chain <ClientMixdown>()
            // Reads from the ClientMixdown buffer with a fixed timing
            .Into <PreciseTimedPipe>(x => x.Initialize(new SampleInfo(48_000, 2, 16)))
            // Reencode to the codec of our choice
            .Chain(new EncoderPipe(Codec.OpusMusic))
            // Define where to send to.
            .Chain <StaticMetaPipe>(x => x.SetVoice())
            // Send it with our client.
            .Chain(client);

            // Connect
            client.Connect(con);
        }
Ejemplo n.º 14
0
        public static void Main()
        {
            foreach (var ver in vers.Skip(0))
            {
                Ts3Server serv = null;
                Process   ts3  = null;
                try
                {
                    serv = new Ts3Server();
                    serv.Listen(new IPEndPoint(IPAddress.Any, 9987));
                    // http://ftp.4players.de/pub/hosted/ts3/updater-images/client/
                    // .\CAnydate.exe C:\TS\Any http://files.teamspeak-services.com/updater-images/client/1516349129 win32

                    Process anyd = new Process()
                    {
                        StartInfo = new ProcessStartInfo
                        {
                            FileName  = @"C:\TS\CAnydate.exe",
                            Arguments = $@"C:\TS\Any http://ftp.4players.de/pub/hosted/ts3/updater-images/client/{ver} win32"
                        }
                    };
                    anyd.Start();
                    anyd.WaitForExit();

                    ts3 = new Process()
                    {
                        StartInfo = new ProcessStartInfo
                        {
                            FileName = @"C:\TS\Any\ts3client_win32.exe",
                        }
                    };
                    ts3.Start();

                    for (int i = 0; i < 240; i++)
                    {
                        if (serv.Init)
                        {
                            break;
                        }
                        Thread.Sleep(1000);
                    }

                    if (!serv.Init)
                    {
                        Console.WriteLine("ERR! {0}", ver);
                        File.WriteAllText("sign.out", $"ERR! {ver}");
                        continue;
                    }
                }
                catch (Exception)
                {
                }
                finally
                {
                    try
                    {
                        ts3?.Kill();
                    }
                    catch { }
                    serv?.Dispose();
                }
            }

            //var crypt = new Ts3Crypt();
            //crypt.Test();
            //return;

            var clients = new List <Ts3FullClient>();

            //for (int i = 0; i < 50; i++)
            {
                var client = new Ts3FullClient(EventDispatchType.AutoThreadPooled);
                client.OnConnected       += Client_OnConnected;
                client.OnDisconnected    += Client_OnDisconnected;
                client.OnErrorEvent      += Client_OnErrorEvent;
                client.OnEachTextMessage += Client_OnTextMessageReceived;
                var data = Ts3Crypt.LoadIdentity("MCkDAgbAAgEgAiBPKKMIrHtAH/FBKchbm4iRWZybdRTk/ZiehtH0gQRg+A==", 64, 0);
                var con  = new ConnectionDataFull()
                {
                    Address = "127.0.0.1", Username = "******", Identity = data.Unwrap(), ServerPassword = "******", VersionSign = VersionSign.VER_WIN_3_1_8
                };
                client.Connect(con);
                clients.Add(client);
            }

            Console.WriteLine("End");
            Console.ReadLine();
        }