protected override void Execute(NativeActivityContext context) { if (!string.IsNullOrEmpty(ProxyHost.Get(context))) // Proxy defined { if (!string.IsNullOrEmpty(ProxyUsername.Get(context))) // Proxy authentication { connectionInfo = new PasswordConnectionInfo(Host.Get(context), Port.Get(context), Username.Get(context), Encoding.UTF8.GetBytes(Password.Get(context)), ProxyTypes.Http, ProxyHost.Get(context), ProxyPort.Get(context), ProxyUsername.Get(context), ProxyPassword.Get(context)); } else // No proxy authentication { connectionInfo = new PasswordConnectionInfo(Host.Get(context), Port.Get(context), Username.Get(context), Password.Get(context), ProxyTypes.Http, ProxyHost.Get(context), ProxyPort.Get(context)); } } else // No Proxy defined { connectionInfo = new PasswordConnectionInfo(Host.Get(context), Port.Get(context), Username.Get(context), Password.Get(context)); } sshClient = new SshClient(connectionInfo); sshClient.Connect(); if (Body != null) { //scheduling the execution of the child activities // and passing the value of the delegate argument context.ScheduleAction(Body, sshClient, OnCompleted, OnFaulted); } }
/// <summary> /// Returns a WebProxy instance configured to match the proxy settings /// in the client configuration. /// </summary> public WebProxy GetWebProxy() { const string httpPrefix = "http://"; WebProxy proxy = null; if (!string.IsNullOrEmpty(ProxyHost) && ProxyPort > 0) { // WebProxy constructor adds the http:// prefix, but doesn't // account for cases where it's already present which leads to // malformed addresses var host = ProxyHost.StartsWith(httpPrefix, StringComparison.OrdinalIgnoreCase) ? ProxyHost.Substring(httpPrefix.Length) : ProxyHost; proxy = new WebProxy(host, ProxyPort); if (ProxyCredentials != null) { proxy.Credentials = ProxyCredentials; } if (ProxyBypassList != null) { proxy.BypassList = ProxyBypassList.ToArray(); } proxy.BypassProxyOnLocal = ProxyBypassOnLocal; } return(proxy); }
public string PostReview([FromBody] dynamic id) { //ObservableCollection<Dictionary<string, object>> detailcollection = new ObservableCollection<Dictionary<string, object>>(); //Dictionary<string, object> InvoiceStatus = new Dictionary<string, object>(); string InvoiceId = string.Empty; try { ObservableCollection <IDictionary <string, object> > obj = JsonConvert.DeserializeObject <ObservableCollection <IDictionary <string, object> > >(Convert.ToString(id)); string Status = string.Empty; foreach (Dictionary <string, object> header in obj) { //Status = header["Status"].ToString(); prxyhost = JsonConvert.DeserializeObject <ProxyHost>(Convert.ToString(header["hostHeader"].ToString())); //Invoicedetail = JsonConvert.DeserializeObject<List<ProxyInvoiceDetails>>(Convert.ToString(header["SalesDetail"].ToString())); } TblReviews _tblReview = new TblReviews(); _tblReview.HostId = prxyhost.HostID; _tblReview.UserId = prxyhost.UserID; _tblReview.Review = prxyhost.Review; _TripstarContext.Add(_tblReview); _TripstarContext.SaveChanges(); //return _repository.PostInvoice(Status, Headerdata, Invoicedetail); return("true"); } catch (Exception ex) { return("false"); } }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (ProxyEnabled != null) { hashCode = hashCode * 59 + ProxyEnabled.GetHashCode(); } if (ProxyHost != null) { hashCode = hashCode * 59 + ProxyHost.GetHashCode(); } if (ProxyPort != null) { hashCode = hashCode * 59 + ProxyPort.GetHashCode(); } if (ProxyUser != null) { hashCode = hashCode * 59 + ProxyUser.GetHashCode(); } if (ProxyPassword != null) { hashCode = hashCode * 59 + ProxyPassword.GetHashCode(); } if (ProxyExceptions != null) { hashCode = hashCode * 59 + ProxyExceptions.GetHashCode(); } return(hashCode); } }
public ComplexTypeStubBackReference GetComplexObjectWithBackReference() { return(new ComplexTypeStubBackReference { ABC = "DEF", Proxy = ProxyHost.CreateProxy(this) }); }
public ComplexTypeWithProxy GetComplexTypeWithProxy() { return(new ComplexTypeWithProxy { ProxyName = "MyProxy", Proxy = ProxyHost.CreateProxy(new Value(23)) }); }
public ComplexTypeWithTransparentProxy GetComplexTypeWithTransparentProxy() { return(new ComplexTypeWithTransparentProxy { ProxyName = "MyProxy", Proxy = ProxyHost.CreateProxy(new Value(23)).Cast <IValue>().AsTransparentProxy() }); }
internal Proxy(ProxyHost host, int id, Type objectType) { _host = host; Id = id; _objectType = objectType; _isActivated = true; _disposeHelper = new AsyncDisposeHelper(DisposeInternalAsync); }
internal Proxy(ProxyHost proxyHost, int id, ActivationMode activationMode, object[] activationParameters) { _host = proxyHost; Id = id; ActivationMode = activationMode; ActivationParamers = activationParameters; _isActivated = false; _disposeHelper = new AsyncDisposeHelper(DisposeInternalAsync); }
public async Task OnStoppingServiceAsync(OperationContext context) { if (ProxyService != null) { await ProxyService.ShutdownAsync(context).IgnoreFailure(); } // Not passing cancellation token since it will already be signaled await ProxyHost.StopAsync(); ProxyHost.Dispose(); }
public async Task SyncCallWithResultTest() { using (var fs1 = new FloatingStream()) using (var fs2 = new FloatingStream()) using (var mux1 = new MultiplexStream(fs1, fs2)) using (var mux2 = new MultiplexStream(fs2, fs1)) { var remoteProxyHost = new ProxyHost(mux1, BuildServiceProvider()); var localProxyHost = new ProxyHost(mux2, BuildServiceProvider()); var fooProxy = await localProxyHost.CreateAsync <Foo>(cancellation : default);
public async Task OnStartingServiceAsync(OperationContext context) { OperationContext.Value = context; ConfigurationSource.Configuration = ProxyHost.Services.GetService <ProxyServiceConfiguration>(); // Get and start the DeploymentProxyService ProxyService = ProxyHost.Services.GetService <DeploymentProxyService>(); await ProxyService.StartupAsync(context).IgnoreFailure(); await ProxyHost.StartAsync(context.Token); }
/// <summary> /// Creates a remote TCP connection through a proxy server to the destination host on the destination port. /// </summary> /// <param name="destinationHost">Destination host name or IP address.</param> /// <param name="destinationPort">Port number to connect to on the destination host.</param> /// <param name="timeout">Timeout duration for the Connect attempt.</param> /// <returns> /// Returns an open TcpClient object that can be used normally to communicate /// with the destination server /// </returns> /// <remarks> /// This method creates a connection to the proxy server and instructs the proxy server /// to make a pass through connection to the specified destination host on the specified /// port. /// </remarks> public TcpClient CreateConnection(string destinationHost, int destinationPort, TimeSpan timeout) { try { // if we have no connection, create one if (TcpClient == null) { if (string.IsNullOrEmpty(ProxyHost)) { throw new ProxyException("ProxyHost property must contain a value"); } if (ProxyPort <= 0 || ProxyPort > 65535) { throw new ProxyException("ProxyPort value must be greater than zero and less than 65535"); } if (ProxyHost.Contains("://")) { throw new ProxyException("The proxy's hostname cannot contain a protocol prefix (eg http://)"); } // create new tcp client object to the proxy server TcpClient = tcpClientFactory(); // attempt to open the connection log.Write(EventType.Diagnostic, "Connecting to proxy at {0}:{1}", ProxyHost, ProxyPort); TcpClient.ConnectWithTimeout(ProxyHost, ProxyPort, timeout); } // send connection command to proxy host for the specified destination host and port SendConnectionCommand(destinationHost, destinationPort); // return the open proxied tcp client object to the caller for normal use return(TcpClient); } catch (AggregateException ae) { var se = ae.InnerExceptions.OfType <SocketException>().FirstOrDefault(); if (se != null) { throw new ProxyException($"Connection to proxy host {ProxyHost} on port {ProxyPort} failed: {se.Message}", se); } throw; } catch (SocketException ex) { throw new ProxyException($"Connection to proxy host {ProxyHost} on port {ProxyPort} failed: {ex.Message}", ex); } }
public static void Main(string[] args) { using (var fs1 = new FloatingStream()) using (var fs2 = new FloatingStream()) using (var mux1 = new MultiplexStream(fs1, fs2)) using (var mux2 = new MultiplexStream(fs2, fs1)) { var server = new ProxyHost(mux1, new ServiceCollection().BuildServiceProvider()); Task.Run(async() => { var client = new ProxyHost(mux2, new ServiceCollection().BuildServiceProvider()); var valueProxy = new Proxy <Value>(new Value(12), ownsInstance: true); var barProxy = await client.CreateAsync <Bar>(cancellation: default);
/// <summary> /// Returns true if ComDayCommonsHttpclientProperties instances are equal /// </summary> /// <param name="other">Instance of ComDayCommonsHttpclientProperties to be compared</param> /// <returns>Boolean</returns> public bool Equals(ComDayCommonsHttpclientProperties other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( ProxyEnabled == other.ProxyEnabled || ProxyEnabled != null && ProxyEnabled.Equals(other.ProxyEnabled) ) && ( ProxyHost == other.ProxyHost || ProxyHost != null && ProxyHost.Equals(other.ProxyHost) ) && ( ProxyUser == other.ProxyUser || ProxyUser != null && ProxyUser.Equals(other.ProxyUser) ) && ( ProxyPassword == other.ProxyPassword || ProxyPassword != null && ProxyPassword.Equals(other.ProxyPassword) ) && ( ProxyNtlmHost == other.ProxyNtlmHost || ProxyNtlmHost != null && ProxyNtlmHost.Equals(other.ProxyNtlmHost) ) && ( ProxyNtlmDomain == other.ProxyNtlmDomain || ProxyNtlmDomain != null && ProxyNtlmDomain.Equals(other.ProxyNtlmDomain) ) && ( ProxyExceptions == other.ProxyExceptions || ProxyExceptions != null && ProxyExceptions.Equals(other.ProxyExceptions) )); }
public virtual IWebProxy GetProxy() { if (!UseProxy) { return(null); } if (String.IsNullOrEmpty(ProxyHost) || ProxyPort.GetValueOrDefault() <= 0) { return(null); } var proxy = new WebProxy(ProxyHost?.Trim(), ProxyPort.GetValueOrDefault()); if (!String.IsNullOrEmpty(ProxyUserName)) { proxy.Credentials = new NetworkCredential(ProxyUserName?.Trim(), ProxyPassword?.Trim()); } return(proxy); }
public WebProxy GetWebProxy() { WebProxy webProxy = null; if (!string.IsNullOrEmpty(ProxyHost) && ProxyPort > 0) { webProxy = new WebProxy(ProxyHost.StartsWith("http://", StringComparison.OrdinalIgnoreCase) ? ProxyHost.Substring("http://".Length) : ProxyHost, ProxyPort); if (ProxyCredentials != null) { webProxy.Credentials = ProxyCredentials; } if (ProxyBypassList != null) { webProxy.BypassList = ProxyBypassList.ToArray(); } webProxy.BypassProxyOnLocal = ProxyBypassOnLocal; } return(webProxy); }
private async Task <IProxy <LogicalEndPointSkeleton> > CreateProxyAsync(CancellationToken cancellation) { ProxyHost proxyHost = null; IProxy <LogicalEndPointSkeleton> proxy; try { proxyHost = await _debugConnection.GetProxyHostAsync(cancellation); proxy = await proxyHost.CreateAsync <LogicalEndPointSkeleton>(new object[] { EndPoint }, cancellation); } catch (OperationCanceledException) { proxyHost?.Dispose(); throw; } return(proxy); }
private async Task <IProxy <CoordinationManagerSkeleton> > CreateProxyAsync(CancellationToken cancellation) { ProxyHost proxyHost = null; IProxy <CoordinationManagerSkeleton> proxy; try { proxyHost = await _debugConnection.GetProxyHostAsync(cancellation); proxy = await proxyHost.CreateAsync <CoordinationManagerSkeleton>(cancellation); } catch (OperationCanceledException) { proxyHost?.Dispose(); throw; } return(proxy); }
/// <summary> /// Returns true if OrgApacheHttpProxyconfiguratorProperties instances are equal /// </summary> /// <param name="other">Instance of OrgApacheHttpProxyconfiguratorProperties to be compared</param> /// <returns>Boolean</returns> public bool Equals(OrgApacheHttpProxyconfiguratorProperties other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( ProxyEnabled == other.ProxyEnabled || ProxyEnabled != null && ProxyEnabled.Equals(other.ProxyEnabled) ) && ( ProxyHost == other.ProxyHost || ProxyHost != null && ProxyHost.Equals(other.ProxyHost) ) && ( ProxyPort == other.ProxyPort || ProxyPort != null && ProxyPort.Equals(other.ProxyPort) ) && ( ProxyUser == other.ProxyUser || ProxyUser != null && ProxyUser.Equals(other.ProxyUser) ) && ( ProxyPassword == other.ProxyPassword || ProxyPassword != null && ProxyPassword.Equals(other.ProxyPassword) ) && ( ProxyExceptions == other.ProxyExceptions || ProxyExceptions != null && ProxyExceptions.Equals(other.ProxyExceptions) )); }
private async Task ExecuteWithTimeout(NativeActivityContext context, CancellationToken cancellationToken = default) { var sshPassword = new NetworkCredential("", Password.Get(context)).Password; var proxyPassword = new NetworkCredential("", ProxyPassword.Get(context)).Password; var sshTimeout = TimeSpan.FromMilliseconds(SSHTimeoutMS.Get(context)); ConnectionInfo connectionInfo; if (!string.IsNullOrEmpty(ProxyHost.Get(context))) // Proxy defined { if (!string.IsNullOrEmpty(ProxyUsername.Get(context))) // Proxy authentication { connectionInfo = new PasswordConnectionInfo(Host.Get(context), Port.Get(context), Username.Get(context), Encoding.UTF8.GetBytes(sshPassword), ProxyTypes.Http, ProxyHost.Get(context), ProxyPort.Get(context), ProxyUsername.Get(context), proxyPassword); } else // No proxy authentication { connectionInfo = new PasswordConnectionInfo(Host.Get(context), Port.Get(context), Username.Get(context), sshPassword, ProxyTypes.Http, ProxyHost.Get(context), ProxyPort.Get(context)); } } else // No Proxy defined { connectionInfo = new PasswordConnectionInfo(Host.Get(context), Port.Get(context), Username.Get(context), sshPassword); } connectionInfo.Timeout = sshTimeout; sshClient = new SshClient(connectionInfo); sshClient.Connect(); if (ShellExpectedPrompt.Expression != null) { var terminalMode = new Dictionary <TerminalModes, uint> { { TerminalModes.ECHO, 53 } }; expectedPromptRegex = new Regex(ShellExpectedPrompt.Get(context), RegexOptions.Compiled); currentShellStream = sshClient.CreateShellStream("UiPathTeam.SSHConnector.Shell", 0, 0, 0, 0, 4096, terminalMode); var welcomeMessage = SSHHelpers.Expect(currentShellStream, expectedPromptRegex, string.Empty, sshTimeout); ShellWelcomeMessage.Set(context, welcomeMessage); } }
protected override async Task <Action <NativeActivityContext> > ExecuteAsync(NativeActivityContext context, CancellationToken cancellationToken) { // Inputs var activityTimeout = TimeoutMS.Get(context); var host = Host.Get(context); var port = Port.Get(context); var username = Username.Get(context); var password = Password.Get(context); var shellExpectedPrompt = ShellExpectedPrompt.Get(context); var proxyHost = ProxyHost.Get(context); var proxyPort = ProxyPort.Get(context); var proxyUsername = ProxyUsername.Get(context); var proxyPassword = ProxyPassword.Get(context); // Set a timeout on the execution var task = ExecuteWithTimeout(context, cancellationToken); if (await Task.WhenAny(task, Task.Delay(activityTimeout, cancellationToken)) != task) { throw new TimeoutException(Resources.Timeout_Error); } if (task.Exception != null) { throw task.Exception; } _objectContainer.Add(sshClient); _objectContainer.Add(currentShellStream); _objectContainer.Add(expectedPromptRegex); return((ctx) => { // Schedule child activities if (Body != null) { ctx.ScheduleAction <IObjectContainer>(Body, _objectContainer, OnCompleted, OnFaulted); } }); }
public AutomaController(ILogger <AutomaController> logger, ProxyHost proxyHost) { _logger = logger; _proxyHost = proxyHost; }
static Proxy() { var remoteType = typeof(TRemote); ProxyHost.AddLoadedRemoteType(remoteType); }
private void SetupFilesystem() { Debug.WriteLine("SetupFilesystem {0},{1},{2},{3}", Host, Port, Username, ConnectionType.ToString()); ProxyTypes pt = ProxyTypes.None; switch (ProxyType) { case 1: pt = ProxyTypes.Http; break; case 2: pt = ProxyTypes.Socks4; break; case 3: pt = ProxyTypes.Socks5; break; } int ProxyPort = 8080; var Proxy = ProxyHost; if (ProxyHost != null) { var s = ProxyHost.Split(':'); if (s.Length > 1) { Int32.TryParse(s[1], out ProxyPort); Proxy = s[0]; } } ConnectionInfo info; switch (ConnectionType) { case ConnectionType.Pageant: var agent = new PageantProtocol(); if (pt == ProxyTypes.None) { info = new AgentConnectionInfo(Host, Port, Username, agent); } else if (ProxyUser.Length > 0) { info = new AgentConnectionInfo(Host, Port, Username, pt, Proxy, ProxyPort, ProxyUser, ProxyPass, agent); } else { info = new AgentConnectionInfo(Host, Port, Username, pt, Proxy, ProxyPort, agent); } break; case ConnectionType.PrivateKey: if (pt == ProxyTypes.None) { info = new PrivateKeyConnectionInfo(Host, Port, Username, new PrivateKeyFile(PrivateKey, Passphrase)); } else if (ProxyUser.Length > 0) { info = new PrivateKeyConnectionInfo(Host, Port, Username, pt, Proxy, ProxyPort, ProxyUser, ProxyPass, new PrivateKeyFile(PrivateKey, Passphrase)); } else { info = new PrivateKeyConnectionInfo(Host, Port, Username, pt, Proxy, ProxyPort, new PrivateKeyFile(PrivateKey, Passphrase)); } break; default: if (pt == ProxyTypes.None) { info = new PasswordConnectionInfo(Host, Port, Username, Password); } else if (ProxyUser.Length > 0) { info = new PasswordConnectionInfo(Host, Username, Password, pt, Proxy, ProxyPort, ProxyUser, ProxyPass); } else { info = new PasswordConnectionInfo(Host, Port, Username, Password, pt, Proxy, ProxyPort); } break; } _connection = Settings.Default.UseNetworkDrive ? String.Format("\\\\{0}\\{1}\\{2}", info.Host, Root, info.Username) : Name; _filesystem = new SftpFilesystem(info, Root, _connection, Settings.Default.UseOfflineAttribute, false, (int)Settings.Default.AttributeCacheTimeout, (int)Settings.Default.DirContentCacheTimeout); Debug.WriteLine("Connecting..."); _filesystem.KeepAliveInterval = new TimeSpan(0, 0, 60); _filesystem.Connect(); }
public IFoo GetFooTransparent() { return(ProxyHost.CreateProxy(new Foo(), ownsInstance: true).Cast <IFoo>().AsTransparentProxy()); }
public IProxy <Foo> GetFoo() { return(ProxyHost.CreateProxy(new Foo(), ownsInstance: true)); }
void IProxyInternal.Register(ProxyHost host, int proxyId, Action unregisterAction) { Proxy.Register(host, proxyId, unregisterAction); }
public string PostHost([FromBody] dynamic id) { //ObservableCollection<Dictionary<string, object>> detailcollection = new ObservableCollection<Dictionary<string, object>>(); //Dictionary<string, object> InvoiceStatus = new Dictionary<string, object>(); string InvoiceId = string.Empty; try { ObservableCollection <IDictionary <string, object> > obj = JsonConvert.DeserializeObject <ObservableCollection <IDictionary <string, object> > >(Convert.ToString(id)); string Status = string.Empty; foreach (Dictionary <string, object> header in obj) { //Status = header["Status"].ToString(); prxyhost = JsonConvert.DeserializeObject <ProxyHost>(Convert.ToString(header["hostHeader"].ToString())); //Invoicedetail = JsonConvert.DeserializeObject<List<ProxyInvoiceDetails>>(Convert.ToString(header["SalesDetail"].ToString())); } TblHost tblhost = new TblHost(); var rechost = (from rec in _TripstarContext.TblHost where rec.HostId == prxyhost.HostID && rec.UserId == prxyhost.UserID select rec).FirstOrDefault(); if (rechost == null) { var places = (from rec in _TripstarContext.TblPlaces where rec.Place == prxyhost.Place select rec).FirstOrDefault(); if (places != null) { tblhost.PlaceId = places.PlaceId; } //tblhost.Photo = prxyhost.photo; if (prxyhost.photo != null) { prxyhost.photo = prxyhost.photo.Replace("data:image/png;base64,", ""); byte[] data1 = Convert.FromBase64String(prxyhost.photo.Replace("data:image/jpeg;base64,", "")); tblhost.Photo = data1; } else { tblhost.Photo = null; } tblhost.Price = Convert.ToDecimal(prxyhost.Price); tblhost.Roomtype = prxyhost.Roomtype; tblhost.UserId = Convert.ToInt32(prxyhost.UserID); tblhost.Description = prxyhost.Description; tblhost.Type = prxyhost.Type; //tbluser.password _TripstarContext.Add(tblhost); } else { TblHost tblhostupdate = (from rec in _TripstarContext.TblHost where rec.HostId == prxyhost.HostID && rec.UserId == prxyhost.UserID select rec).FirstOrDefault(); tblhostupdate.Review = prxyhost.Review; } _TripstarContext.SaveChanges(); //return _repository.PostInvoice(Status, Headerdata, Invoicedetail); return("true"); } catch (Exception ex) { return("false"); } }