コード例 #1
0
        static void Main(string[] args)
        {
            const string serverUrl = "http://localhost:12345/";

            var transferServer = new TransferServer(new RequestHandler());

            using (new HttpListenerTransferEndpoint(serverUrl, transferServer))
            {
                var transferClient = new SOAPClient(serverUrl);

                Console.Write("Create...");
                var address = transferClient.BuildMessage().Create(new SampleData());
                Console.WriteLine(address.Address);
                Console.Write("Put...");
                var data = transferClient.BuildMessage().Put <SampleData>(new SampleData {
                    A = "AAA"
                });
                Console.WriteLine(data.A);
                Console.Write("Get...");
                data = transferClient.BuildMessage().Get <SampleData>();
                Console.WriteLine(data.A);
                Console.Write("Delete...");
                transferClient.BuildMessage();
                Console.WriteLine("OK");
                Console.WriteLine("Press any key to exit");
                Console.ReadKey();
            }
        }
コード例 #2
0
ファイル: UnitTest.cs プロジェクト: briteming/Socks5Listener
        private bool TestTTTService(string ip, int listenPortForService, string serviceListeningip, string testServerEPAddress, out TransferServer ts)
        {
            ts = null;
            var result = false;

            if (!IPEndPointHelper.TryParseEndPoint(ip + ":" + listenPortForService, out var ep, out var msg))
            {
                output.WriteLine(msg);
                return(result);
            }
            if (!IPEndPointHelper.TryParseEndPoint(serviceListeningip, out var listenEp, out var msg2))
            {
                output.WriteLine(msg2);
                return(result);
            }
            if (!IPEndPointHelper.TryParseEndPoint(testServerEPAddress, out var testServerEP, out var msg3))
            {
                output.WriteLine(msg3);
                return(result);
            }

            ts     = new TransferServer(listenEp, ep, testServerEP, new BaseLogger(new TestLogger(output)));
            result = true;
            return(result);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: briteming/Socks5Listener
        public static TransferServer GetTransferServer(string[] listenAddr, string[] proxyAddr, string[] destAddr, BaseLogger logger)
        {
            var       tuple = GetTransferServerParameter(listenAddr, proxyAddr, destAddr);
            IPAddress ip    = null;

            if (listenAddr[0] == "0.0.0.0")
            {
                ip = IPAddress.Any;
            }
            else
            {
                var hostEntry = Dns.GetHostEntry(tuple.listen.Host);
                if (hostEntry.AddressList.Count() == 0)
                {
                    ip = IPAddress.Parse(tuple.listen.Host);
                }
                else
                {
                    ip = IPAddress.Any;
                }
            }

            TransferServer server = new TransferServer(new IPEndPoint(ip, tuple.listen.Port), tuple.proxy, tuple.dest, logger);

            return(server);
        }
コード例 #4
0
 public ManagementServer()
 {
     _managementHandler  = new ManagementTransferRequestHandler();
     _transferServer     = new TransferServer(_managementHandler);
     _enumerationServer  = new EnumerationServer();
     _pullDeliveryServer = new EventingPullDeliveryServer();
     _eventingServer     = new EventingServer(_pullDeliveryServer);
 }
コード例 #5
0
        public static void RegisterRoutes(RouteCollection routes)
        {
            var handler = new ManagementTransferRequestHandler();

            handler.Bind(ResourceUri, new Handler());
            var transferServer = new TransferServer(handler);

            routes.Add(new Route("management", new SOAPRouteHandler(transferServer)));
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: briteming/Socks5Listener
        /// <summary>
        /// deprecated.
        /// </summary>
        /// <returns>The async started transfer server.</returns>
        /// <param name="listenAddr">Listen address.</param>
        /// <param name="proxyAddr">Proxy address.</param>
        /// <param name="destAddr">Destination address.</param>
        /// <param name="logger">Logger.</param>
        /// <param name="serverTask">Server task.</param>
        public static TransferServer GetAsyncStartedTransferServer(string[] listenAddr, string[] proxyAddr, string[] destAddr, BaseLogger logger, out Task <TransferServer> serverTask)
        {
            var tuple = GetTransferServerParameter(listenAddr, proxyAddr, destAddr);

            var server = new TransferServer(new IPEndPoint(Dns.GetHostEntry(tuple.listen.Host).AddressList[0], tuple.listen.Port), tuple.proxy, tuple.dest, logger);

            serverTask = new Task <TransferServer>((state) =>
            {
                var temp = state as TransferServer;
                return(temp);
            }, server);

            return(server);
        }
コード例 #7
0
        static void Main(string[] args)
        {
            XmlConfigurator.Configure();
            var handler = new ManagementTransferRequestHandler();

            handler.Bind(ResourceUri, new Handler());

            var transferServer = new TransferServer(handler);

            using (new HttpListenerTransferEndpoint("http://localhost:12345/", transferServer))
            {
                Client.PerformTest();
                Console.WriteLine("Press any key to exit.");
                Console.ReadKey();
            }
        }
コード例 #8
0
ファイル: AudioServer.cs プロジェクト: zouhunter/SAEA
        public AudioServer(IPEndPoint endPoint)
        {
            _audioServer = new TransferServer<T>(endPoint);

            _audioServer.OnReceive += (data) => OnReceive?.Invoke(data);
        }
コード例 #9
0
ファイル: UnitTest.cs プロジェクト: briteming/Socks5Listener
        private bool TestBaseConnectionFunction(string path, out string msg)
        {
            bool           result       = false;
            Socket         testServer   = null;
            Process        rcsocks      = null;
            Process        rssocks      = null;
            TransferServer ts           = null;
            Socket         clientSocket = null;

            try
            {
                msg = "";
                if (!TestTCPServer(TestContent, IPEndpoint, out testServer))
                {
                    return(result);
                }



                if (!TestStartRcSocks(path, ListenServicePort, RelayPort, out rcsocks))
                {
                    return(result);
                }

                if (!TestStartRsSocks(path, $"{RelayToIp}:{RelayPort}", MaxConnections, out rssocks))
                {
                    return(result);
                }

                if (!TestTTTService("localhost", ListenServicePort, ServiceListeningIP, IPEndpoint, out ts))
                {
                    return(result);
                }

                if (!TestClient(TestContent, ServiceListeningIP, out clientSocket))
                {
                    return(result);
                }

                result = true;
                return(result);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
            finally
            {
                if (testServer != null)
                {
                    testServer.Close();
                    testServer.Dispose();
                }
                if (rcsocks != null)
                {
                    rcsocks.Kill();
                    rcsocks.Close();
                }
                if (rssocks != null)
                {
                    rssocks.Kill();
                    rssocks.Close();
                }
                if (ts != null)
                {
                    ts.Close();
                }
                if (clientSocket != null)
                {
                    clientSocket.Disconnect(false);
                    clientSocket.Close();
                    clientSocket.Dispose();
                }
            }
        }