Esempio n. 1
0
        private void Init(IPEndPoint listen, EndPoint proxy, EndPoint dest)
        {
            logger.Info("Initializing transfer server");
            var s = new Socket(SocketType.Stream, ProtocolType.Tcp);

            s.Bind(listen);
            s.Listen((int)MAX_CONN);
            Task.Run(() => SocketAccept(s, proxy, dest)).ContinueWith(SocketAcceptContinueWith);
        }
Esempio n. 2
0
        /// <summary>
        /// Connect to the broker.
        /// </summary>
        public virtual Task Connect()
        {
            _serializer = (BaseSerializer)Activator.CreateInstance(
                Serializers.Types[_config.CommunicationFormatUsed]
                );
            ConnectionState = ConnectionState.Connecting;
            _logger.Info("Connecting");

            return(Task.CompletedTask);
        }
Esempio n. 3
0
        public static void TestLogging()
        {
            BaseLogger logger = Logger.GetLogger(typeof(Logging));

            logger.Debug("Debug message");
            logger.Info("Info message");
            logger.Error("Error message");
        }
Esempio n. 4
0
        protected Connector(Configuration config, BaseLogger logger)
        {
            _config         = config;
            _logger         = logger;
            ConnectionState = ConnectionState.Disconnected;
            _msgId          = new IncrementingIndex();

            OnOpen += () =>
            {
                ConnectionState = ConnectionState.Connected;
                _logger.Info($"Connected to {WsUrl}");
            };

            OnClose += () =>
            {
                ConnectionState = ConnectionState.Disconnected;
                _logger.Info("Disconnected");
            };
        }
Esempio n. 5
0
        public static void Info(object message, params object[] argv)
        {
            if (LogLevel.INFO == (BaseLogger.currentLogLevels & LogLevel.INFO))
            {
#if !GAME_PUBLISH
                if (!IsInInfoFilterList(message.ToString()))
                {
                    return;
                }
#endif
                BaseLogger.Info(message, argv);
            }
        }
Esempio n. 6
0
        public bool Start()
        {
            if (!check())
            {
                return(false);
            }

            //			opendSocks5Client.OnDataReceived += OpendSocks5Client_OnDataReceived;
            opendSocks5Client.OnDisconnected += OpendSocks5Client_OnDisconnected;

            logger.Info(this.GetHashCode() + "=>" + (opendSocks5Client.Client.Sock.LocalEndPoint as IPEndPoint) + "<->" + (opendSocks5Client.Client.Sock.RemoteEndPoint as IPEndPoint));

            CachedTasks = new[] {
                Task.Run(() =>
                {
                    while (true)
                    {
                        LoopTranClient();
                    }
                    logger.Info("opendSocks5Client:" + opendSocks5Client.Connected + "");
                }, source.Token)
                .ContinueWith((x, y) =>
                {
                    var args = (y as List <object>);

                    logger.Info("closing client");
                    if (x.IsFaulted)
                    {
                        args.Add(x.Exception);
                    }
                }, tmpArgs),

                Task.Run(() =>
                {
                    while (!this.breakLoopTrace)
                    {
                        LoopTran();
                    }

                    logger.Info("opendSocket:" + this.opendSocket.Connected + "");
                }, source.Token)
                .ContinueWith((x, y) =>
                {
                    var args = (y as List <object>);

                    //(args[1] as Socks5Client)?.Close();
                    logger.Info("closing socket");
                    //OnCloseHandler?.Invoke(this, new AdapterOnCloseEventArgs()
                    //{
                    //	S = (args[0] as Socket),
                    //	Client = (args[1] as Socks5Client),
                    //	Adapter = this

                    //});
                    if (x.IsCanceled)
                    {
                    }
                    else if (x.IsFaulted)
                    {
                        args.Add(x.Exception);
                    }
                }, tmpArgs)
            };

            Task.WhenAll(CachedTasks).ContinueWith(x =>
            {
                this.opendSocket.Shutdown(SocketShutdown.Both);
                this.opendSocks5Client.Client.Sock.Shutdown(SocketShutdown.Both);
                this.opendSocket.Close();
                this.opendSocks5Client.Close();
                OnCloseHandler?.Invoke(this, new AdapterOnCloseEventArgs()
                {
                    S       = this.opendSocket,
                    Client  = this.opendSocks5Client,
                    Adapter = this
                });
            });


            return(true);
        }
Esempio n. 7
0
 public new static void Info(string message)
 {
     Singleton.Info(message);
 }