public Static(IStaticFileServer fileServer, TcpSettings tcpSettings) { Validation.RequireValidTcpSettings(tcpSettings); _fileServer = fileServer ?? throw new ArgumentNullException(nameof(fileServer)); _tcpSettings = tcpSettings; }
/// <summary> /// LoadTcpConfigServer /// </summary> /// <param name="configHost"></param> /// <returns></returns> public static TcpSettings LoadTcpConfigServer(string configHost) { if (string.IsNullOrEmpty(configHost)) { throw new ArgumentNullException("TcpQueueSettings.LoadTcpConfigServer name"); } //TODO //return null; var config = QueueServerConfig.GetConfig(); var settings = config.FindTcpServer(configHost); if (settings == null) { throw new ArgumentException("Invalid TcpQueueSettings with TcpName:" + configHost); } return(new TcpSettings() { HostName = settings.HostName, Address = TcpSettings.EnsureHostAddress(settings.Address), Port = settings.Port, IsAsync = settings.IsAsync, ReceiveBufferSize = settings.ReceiveBufferSize, SendBufferSize = settings.SendBufferSize, ConnectTimeout = settings.ConnectTimeout, //ReceiveTimeout = settings.ReceiveTimeout, ReadTimeout = settings.ReadTimeout, //ProcessTimeout = settings.ProcessTimeout, MaxSocketError = settings.MaxSocketError, MaxServerConnections = Math.Max(1, settings.MaxServerConnections) }); }
public static void DoSbscriberListener() { var settings = new TcpSettings() { Address = "127.0.0.1", ConnectTimeout = 5000, HostName = "Netcell", Port = 15002, IsAsync = false }; var host = QueueHost.Parse(string.Format("file:{0}:Queues?{1}", Assists.EXECPATH, settings.HostName)); host.CoverMode = CoverMode.FileStream; host.CommitMode = PersistCommitMode.OnMemory; host.ReloadOnStart = true; var listener = new TopicSbscriberListener(host, true) { OnItemReceived = (IQueueItem message) => { Console.WriteLine("State:{0},Arrived:{1},Host:{2},Label:{3}, Identifier:{4}", message.MessageState, message.ArrivedTime, message.Host, message.Label, message.Identifier); return(new QueueAck(Nistec.Messaging.MessageState.Received, message).ToTransStream()); }, OnError = (string message) => { Console.WriteLine("OnError:{0}", message); } }; string logpath = NetlogSettings.GetDefaultPath("topicSubs"); listener.Logger = new Logger(logpath, LoggerMode.Console | LoggerMode.File); listener.InitServerQueue(settings, true); //listener.PausePersistQueue(true); }
protected override async void OnInitialized() { InitializeComponent(); FritzSettings FritzDeviceSettings = new FritzSettings(); TcpSettings TcpDeviceSettings = new TcpSettings(); await NavigationService.NavigateAsync("MainPage").ConfigureAwait(false); }
public NoContent(TcpSettings tcpSettings, IContentSettingsReadOnly contentSettings) { Validation.RequireValidTcpSettings(tcpSettings); _tcpSettings = tcpSettings; _contentSettings = contentSettings ?? throw new ArgumentNullException(nameof(contentSettings)); }
public StaticFileServer( IReadOnlyList <IVirtualHostConfigReadOnly> vhostConfig, TcpSettings tcpSettings, IReadOnlyDictionary <StringCI, MimeTypeEntry> mimeTypes, IContentSettingsReadOnly contentSettings) { Validation.RequireValidTcpSettings(tcpSettings); _vhosts = vhostConfig ?? throw new ArgumentNullException(nameof(vhostConfig)); _tcpSettings = tcpSettings; _mimeTypes = mimeTypes; _contentSettings = contentSettings ?? throw new ArgumentNullException(nameof(contentSettings)); }
/// <summary> /// Get Tcp Client Settings /// </summary> /// <param name="hostName"></param> /// <returns></returns> public static TcpSettings GetTcpClientSettings(string hostName) { TcpSettings settings = null; if (ClientSettingsQueue.TryGetValue(hostName, out settings)) { return(settings); } settings = LoadTcpConfigClient(hostName); if (settings == null) { throw new Exception("Invalid configuration for tcp cache client settings with host name:" + hostName); } ClientSettingsQueue[hostName] = settings; return(settings); }
public void InitTcpServerQueue(TcpSettings settings) { _ChannelService = new TcpServerQueue(settings, this); }
/// <summary> /// Constractor with settings parameters /// </summary> /// <param name="settings"></param> public TcpClientQueue(TcpSettings settings) : base(settings) { }
/// <summary> /// Constractor using <see cref="TcpSettings"/> settings. /// </summary> /// <param name="qChannel"></param> /// <param name="settings"></param> public TcpServerChannel(QueueChannel qChannel, TcpSettings settings) //: base() { Settings = settings; QueueChannel = qChannel; }
private void stackBrowser1_OnTcpServerAdded(TcpSettings s) { sm.AddTCPv4Server(s.name, s.level, s.timeout, s.address, s.port); }
/// <summary> /// Constractor using <see cref="TcpSettings"/> settings. /// </summary> /// <param name="settings"></param> public TcpServerListener(TcpSettings settings) { Settings = settings; }
private static void boundStreamSettings(VMess server, ref StreamSettings streamSettings) { try { streamSettings.network = server.TransferProtocol; var host = server.Host; if (server.TLSSecure) { streamSettings.security = "tls"; var tlsSettings = new TlsSettings { allowInsecure = Global.Settings.V2RayConfig.AllowInsecure }; if (!string.IsNullOrWhiteSpace(host)) { tlsSettings.serverName = host; } streamSettings.tlsSettings = tlsSettings; } else { streamSettings.security = ""; } switch (server.TransferProtocol) { case "kcp": var kcpSettings = new KcpSettings { mtu = Global.Settings.V2RayConfig.KcpConfig.mtu, tti = Global.Settings.V2RayConfig.KcpConfig.tti, uplinkCapacity = Global.Settings.V2RayConfig.KcpConfig.uplinkCapacity, downlinkCapacity = Global.Settings.V2RayConfig.KcpConfig.downlinkCapacity, congestion = Global.Settings.V2RayConfig.KcpConfig.congestion, readBufferSize = Global.Settings.V2RayConfig.KcpConfig.readBufferSize, writeBufferSize = Global.Settings.V2RayConfig.KcpConfig.writeBufferSize, header = new Header { type = server.FakeType }, seed = !string.IsNullOrWhiteSpace(server.Path) ? server.Path : null }; streamSettings.kcpSettings = kcpSettings; break; case "ws": var path = server.Path; var wsSettings = new WsSettings { connectionReuse = true, headers = !string.IsNullOrWhiteSpace(host) ? new Headers { Host = host } : null, path = !string.IsNullOrWhiteSpace(path) ? path : null }; streamSettings.wsSettings = wsSettings; break; case "h2": var httpSettings = new HttpSettings { host = new List <string> { string.IsNullOrWhiteSpace(server.Host) ? server.Hostname : server.Host }, path = server.Path }; streamSettings.httpSettings = httpSettings; break; case "quic": var quicSettings = new QuicSettings { security = host, key = server.Path, header = new Header { type = server.FakeType } }; if (server.TLSSecure) { streamSettings.tlsSettings.serverName = server.Hostname; } streamSettings.quicSettings = quicSettings; break; case "xtls": streamSettings.security = server.TransferProtocol; var xtlsSettings = new TlsSettings { allowInsecure = Global.Settings.V2RayConfig.AllowInsecure }; if (!string.IsNullOrWhiteSpace(host)) { xtlsSettings.serverName = host; } streamSettings.xtlsSettings = xtlsSettings; break; default: if (server.FakeType == "http") { var tcpSettings = new TcpSettings { connectionReuse = true, header = new Header { type = server.FakeType, request = new TCPRequest { path = string.IsNullOrWhiteSpace(server.Path) ? "/" : server.Path, headers = new TCPRequestHeaders { Host = string.IsNullOrWhiteSpace(server.Host) ? server.Hostname : server.Host } } } }; streamSettings.tcpSettings = tcpSettings; } break; } } catch { // ignored } }
/// <summary> /// Constractor using <see cref="TcpSettings"/> settings. /// </summary> /// <param name="settings"></param> public TcpServerQueue(TcpSettings settings) //: base() { Settings = settings; }
/// <summary> /// Constractor using <see cref="TcpSettings"/> settings. /// </summary> /// <param name="settings"></param> /// <param name="controller"></param> public TcpServerQueue(TcpSettings settings, IControllerHandler controller) { Settings = settings; Controller = controller; }
/// <summary> /// vmess协议远程服务器底层传输配置 /// </summary> /// <param name="config"></param> /// <param name="iobound"></param> /// <param name="streamSettings"></param> /// <returns></returns> private static int boundStreamSettings(Config config, string iobound, ref StreamSettings streamSettings) { try { //远程服务器底层传输配置 streamSettings.network = config.network(); streamSettings.security = config.streamSecurity(); //streamSettings switch (config.network()) { //kcp基本配置暂时是默认值,用户能自己设置伪装类型 case "kcp": Kcpsettings kcpsettings = new Kcpsettings(); kcpsettings.mtu = 1350; kcpsettings.tti = 50; if (iobound.Equals("out")) { kcpsettings.uplinkCapacity = 12; kcpsettings.downlinkCapacity = 100; } else if (iobound.Equals("in")) { kcpsettings.uplinkCapacity = 100; kcpsettings.downlinkCapacity = 100; } else { kcpsettings.uplinkCapacity = 12; kcpsettings.downlinkCapacity = 100; } kcpsettings.congestion = false; kcpsettings.readBufferSize = 2; kcpsettings.writeBufferSize = 2; kcpsettings.header = new Header(); kcpsettings.header.type = config.headerType(); streamSettings.kcpsettings = kcpsettings; break; //ws case "ws": break; default: //tcp带http伪装 if (config.headerType().Equals(Global.TcpHeaderHttp)) { TcpSettings tcpSettings = new TcpSettings(); tcpSettings.connectionReuse = true; tcpSettings.header = new Header(); tcpSettings.header.type = config.headerType(); //request填入自定义Host string request = Utils.GetEmbedText(Global.v2raySampleHttprequestFileName); request = request.Replace("$requestHost$", string.Format("\"{0}\"", config.requestHost())); string response = Utils.GetEmbedText(Global.v2raySampleHttpresponseFileName); tcpSettings.header.request = Utils.FromJson <object>(request); tcpSettings.header.response = Utils.FromJson <object>(response); streamSettings.tcpSettings = tcpSettings; } break; } } catch { } return(0); }
/// <summary> /// Constractor using <see cref="TcpSettings"/> settings. /// </summary> /// <param name="settings"></param> public TcpManagerServer(TcpSettings settings) : base(settings) { }
/// <summary> /// vmess协议远程服务器底层传输配置 /// </summary> /// <param name="config"></param> /// <param name="iobound"></param> /// <param name="streamSettings"></param> /// <returns></returns> private static int boundStreamSettings(Config config, string iobound, ref StreamSettings streamSettings) { try { //远程服务器底层传输配置 streamSettings.network = config.network(); streamSettings.security = config.streamSecurity(); //streamSettings switch (config.network()) { //kcp基本配置暂时是默认值,用户能自己设置伪装类型 case "kcp": KcpSettings kcpSettings = new KcpSettings(); kcpSettings.mtu = config.kcpItem.mtu; kcpSettings.tti = config.kcpItem.tti; if (iobound.Equals("out")) { kcpSettings.uplinkCapacity = config.kcpItem.uplinkCapacity; kcpSettings.downlinkCapacity = config.kcpItem.downlinkCapacity; } else if (iobound.Equals("in")) { kcpSettings.uplinkCapacity = config.kcpItem.downlinkCapacity;; kcpSettings.downlinkCapacity = config.kcpItem.downlinkCapacity; } else { kcpSettings.uplinkCapacity = config.kcpItem.uplinkCapacity; kcpSettings.downlinkCapacity = config.kcpItem.downlinkCapacity; } kcpSettings.congestion = config.kcpItem.congestion; kcpSettings.readBufferSize = config.kcpItem.readBufferSize; kcpSettings.writeBufferSize = config.kcpItem.writeBufferSize; kcpSettings.header = new Header(); kcpSettings.header.type = config.headerType(); streamSettings.kcpSettings = kcpSettings; break; //ws case "ws": WsSettings wsSettings = new WsSettings(); wsSettings.connectionReuse = true; string host2 = config.requestHost().Replace(" ", ""); string path = config.path().Replace(" ", ""); if (!string.IsNullOrWhiteSpace(host2)) { wsSettings.headers = new Headers(); wsSettings.headers.Host = host2; } if (!string.IsNullOrWhiteSpace(path)) { wsSettings.path = path; } streamSettings.wsSettings = wsSettings; TlsSettings tlsSettings = new TlsSettings(); tlsSettings.allowInsecure = config.allowInsecure(); streamSettings.tlsSettings = tlsSettings; break; //h2 case "h2": HttpSettings httpSettings = new HttpSettings(); string host3 = config.requestHost().Replace(" ", ""); if (!string.IsNullOrWhiteSpace(host3)) { httpSettings.host = Utils.String2List(host3); } httpSettings.path = config.path().Replace(" ", ""); streamSettings.httpSettings = httpSettings; TlsSettings tlsSettings2 = new TlsSettings(); tlsSettings2.allowInsecure = config.allowInsecure(); streamSettings.tlsSettings = tlsSettings2; break; default: //tcp带http伪装 if (config.headerType().Equals(Global.TcpHeaderHttp)) { TcpSettings tcpSettings = new TcpSettings(); tcpSettings.connectionReuse = true; tcpSettings.header = new Header(); tcpSettings.header.type = config.headerType(); //request填入自定义Host string request = Utils.GetEmbedText(Global.v2raySampleHttprequestFileName); string[] arrHost = config.requestHost().Replace(" ", "").Split(','); string host = string.Join("\",\"", arrHost); request = request.Replace("$requestHost$", string.Format("\"{0}\"", host)); //request = request.Replace("$requestHost$", string.Format("\"{0}\"", config.requestHost())); string response = Utils.GetEmbedText(Global.v2raySampleHttpresponseFileName); tcpSettings.header.request = Utils.FromJson <object>(request); tcpSettings.header.response = Utils.FromJson <object>(response); streamSettings.tcpSettings = tcpSettings; } break; } } catch { } return(0); }
private void stackBrowser1_OnTcpClientAdded(TcpSettings s) { sm.AddTCPClient(s.name, s.level, s.timeout, s.address, s.port); }