Task <string> ICommunicationListener.OpenAsync(CancellationToken cancellationToken) { string ip = this.serviceContext.NodeContext.IPAddressOrFQDN; EndpointResourceDescription serviceEndpoint = this.serviceContext.CodePackageActivationContext.GetEndpoint(this.endpointName); EndpointProtocol protocol = serviceEndpoint.Protocol; int port = serviceEndpoint.Port; string host = "+"; string listenUrl; string path = this.appPath != null?this.appPath.TrimEnd('/') + "/" : ""; if (this.serviceContext is StatefulServiceContext) { StatefulServiceContext statefulContext = this.serviceContext as StatefulServiceContext; listenUrl = $"{serviceEndpoint.Protocol}://{host}:{serviceEndpoint.Port}/{path}{statefulContext.PartitionId}/{statefulContext.ReplicaId}/{Guid.NewGuid()}"; } else { listenUrl = $"{serviceEndpoint.Protocol}://{host}:{serviceEndpoint.Port}/{path}"; } this.webHost = this.build(listenUrl); this.webHost.Start(); return(Task.FromResult(listenUrl.Replace("://+", "://" + ip))); }
private SecuritySetting() { this.configStore = NativeConfigStore.FabricGetConfigStore(this); string serverAuthCredentialTypeName = configStore.ReadUnencryptedString(SecurityConfigSectionName, ServerAuthCredentialTypeName); CredentialType serverAuthCredentialType = CredentialType.None; if ((!string.IsNullOrEmpty(serverAuthCredentialTypeName)) && (!Enum.TryParse <CredentialType>(serverAuthCredentialTypeName, out serverAuthCredentialType))) { EventStoreLogger.Logger.LogWarning( "Unable to convert configuration value serverAuthCredentialTypeName {0} for {1} type.", serverAuthCredentialTypeName, serverAuthCredentialType); } this.ServerAuthCredentialType = serverAuthCredentialType; if (ServerAuthCredentialType == CredentialType.X509) { this.EndpointProtocol = EndpointProtocol.Https; } else { this.EndpointProtocol = EndpointProtocol.Http; } this.AllowedClientCertThumbprints = null; this.AllowedClientIdentities = null; this.AllowedClientCertCommonNames = null; this.InitializeFromConfig(); }
internal static SecuritySetting GetClusterSecurityForTesting(EndpointProtocol endpointProtocol) { if (instance == null) { lock (instanceCreationLockObject) { if (instance == null) { instance = new SecuritySetting(endpointProtocol); } } } return(instance); }
private static ServiceModel.EndpointTypeProtocol GetServiceModelProtocol(EndpointProtocol endpointProtocol) { switch (endpointProtocol) { case EndpointProtocol.Http: return(ServiceModel.EndpointTypeProtocol.http); case EndpointProtocol.Https: return(ServiceModel.EndpointTypeProtocol.https); case EndpointProtocol.Tcp: return(ServiceModel.EndpointTypeProtocol.tcp); } throw new ArgumentException("endpointProtocol"); }
private ICommunicationListener CreateZkprListener(StatefulServiceContext context) { // Partition replica's URL is the node's IP, port, PartitionId, ReplicaId, Guid EndpointResourceDescription internalEndpoint = null; EndpointProtocol protocol = EndpointProtocol.Tcp; try { internalEndpoint = context.CodePackageActivationContext.GetEndpoint("ZkprServiceEndpoint"); this.zkprPort = Convert.ToUInt16(internalEndpoint.Port); protocol = internalEndpoint.Protocol; RingMasterServiceEventSource.Log.CreateListener("ZookeeperProtocol", this.zkprPort, ushort.MaxValue); } catch (Exception ex) { RingMasterServiceEventSource.Log.CreateListener_GetEndpointFailed(string.Format("Listener:{0}, Exception:{1}", "ZookeeperProtocol", ex.ToString())); throw; } string uri = $"{protocol}://+:{this.zkprPort}/"; string nodeIp = context.NodeContext.IPAddressOrFQDN; if (nodeIp.Equals("LocalHost", StringComparison.InvariantCultureIgnoreCase)) { nodeIp = GetHostIp(Dns.GetHostName()); } uri = uri.Replace("+", nodeIp); return(new ZooKeeperTcpListener( this.zkprPort, uri, this.executor, this.zooKeeperServerInstrumentation, new ZkprCommunicationProtocol(), ZkprCommunicationProtocol.MaximumSupportedVersion)); }
public Task <string> OpenAsync(CancellationToken cancellationToken) { EndpointResourceDescription serviceEndpoint = serviceContext.CodePackageActivationContext.GetEndpoint("ServiceEndpoint"); int port = serviceEndpoint.Port; EndpointProtocol protocol = serviceEndpoint.Protocol; listeningAddress = String.Format( CultureInfo.InvariantCulture, "{0}://+:{1}/{2}", protocol, port, String.IsNullOrWhiteSpace(appRoot) ? String.Empty : appRoot.TrimEnd('/') + '/'); try { serverHandle = WebApp.Start(listeningAddress, appBuilder => startup.Configuration(appBuilder)); } catch (TargetInvocationException tie) { ServiceEventSource.Current.Message("TargetInvocationException during open, {0}", tie); throw; } catch (Exception e) { ServiceEventSource.Current.Message("Exception during open, {0}", e); throw; } string resultAddress = listeningAddress.Replace("+", FabricRuntime.GetNodeContext().IPAddressOrFQDN); ServiceEventSource.Current.Message("Listening on {0}", resultAddress); return(Task.FromResult(resultAddress)); }
private SecuritySetting(EndpointProtocol endpointProtocol) { this.ServerAuthCredentialType = endpointProtocol == EndpointProtocol.Https ? CredentialType.X509 : CredentialType.None; this.EndpointProtocol = endpointProtocol; }
private void EndpointProtocolTestHelper(string nativeProtocol, string uriScheme, EndpointProtocol protocol) { HelperInstance.ParseTestHelper( (info) => info.Protocol = nativeProtocol, (description) => description.Protocol = protocol); }