private void chkEnableProxy_CheckedChanged(object sender, EventArgs e) { if (chkEnableProxy.Checked) { using (frmProxyConfig frm = new frmProxyConfig(_proxyType, _proxyAddress, _proxyPort, _proxyCredentials)) { if (frm.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { if (frm.ProxyType != NetProxyType.None) { _proxyType = frm.ProxyType; } _proxyAddress = frm.ProxyAddress; _proxyPort = frm.ProxyPort; _proxyCredentials = frm.ProxyCredentials; chkEnableProxy.Checked = (frm.ProxyType != NetProxyType.None); } else { chkEnableProxy.Checked = false; } } } _enableProxy = chkEnableProxy.Checked; }
public void ConfigureProxy(NetProxyType proxyType, string proxyAddress, ushort proxyPort, NetworkCredential proxyCredentials) { if (_type == MeshNodeType.Anonymous) { throw new NotSupportedException("Mesh tor profile does not support proxy configuration."); } if (proxyType == NetProxyType.None) { _proxy = null; } else { _proxy = new NetProxy(proxyType, proxyAddress, proxyPort, proxyCredentials); } //update proxy for networks lock (_networks) { foreach (KeyValuePair <BinaryNumber, MeshNetwork> network in _networks) { network.Value.ProxyUpdated(); } } }
static SettingConfig() { printerConfig = new ConfigUtil("Printer", "Config/settingConfig.ini"); _copy = int.Parse(printerConfig.Get("Copy")); _templatePath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, printerConfig.Get("Template")); _printerName = printerConfig.Get("PrinterName"); _printerType = (PrinterType)int.Parse(printerConfig.Get("PrinterType")); proxyConfig = new ConfigUtil("ProxyConfig", "Config/settingConfig.ini"); _netProxyType = NetProxy.GetNetProxyType(int.Parse(proxyConfig.Get("NetProxy"))); }
public static NetProxy CreateProxy(NetProxyType type, EndPoint proxyEP, NetworkCredential credential = null) { switch (type) { case NetProxyType.Http: return(new HttpProxy(proxyEP, credential)); case NetProxyType.Socks5: return(new SocksProxy(proxyEP, credential)); default: throw new NotSupportedException("Proxy type not supported."); } }
public static NetProxy CreateProxy(NetProxyType type, string address, int port, NetworkCredential credential = null) { switch (type) { case NetProxyType.Http: return(new HttpProxy(EndPointExtension.GetEndPoint(address, port), credential)); case NetProxyType.Socks5: return(new SocksProxy(EndPointExtension.GetEndPoint(address, port), credential)); default: throw new NotSupportedException("Proxy type not supported."); } }
public frmRegister(BitChatProfile profile, string profileFilePath, bool isPortableApp, string profileFolder, bool reissue) { _profile = profile; _profileFilePath = profileFilePath; _isPortableApp = isPortableApp; _profileFolder = profileFolder; if (profile.Proxy != null) { _proxyType = profile.Proxy.Type; } _enableProxy = (_profile.Proxy != null); _proxyAddress = _profile.ProxyAddress; _proxyPort = _profile.ProxyPort; _proxyCredentials = _profile.ProxyCredentials; InitializeComponent(); chkEnableProxy.Checked = _enableProxy; this.chkEnableProxy.CheckedChanged += new System.EventHandler(this.chkEnableProxy_CheckedChanged); if (reissue) { CertificateProfile certProfile = _profile.LocalCertificateStore.Certificate.IssuedTo; txtName.Text = certProfile.Name; txtEmail.Text = certProfile.EmailAddress.Address; txtEmail.ReadOnly = true; if (certProfile.Website != null) { txtWebsite.Text = certProfile.Website.AbsoluteUri; } txtPhone.Text = certProfile.PhoneNumber; txtStreetAddress.Text = certProfile.StreetAddress; txtCity.Text = certProfile.City; txtState.Text = certProfile.State; txtCountry.Text = certProfile.Country; txtPostalCode.Text = certProfile.PostalCode; } else { lblRegisteredEmail.Text = _profile.LocalCertificateStore.Certificate.IssuedTo.EmailAddress.Address; pnlRegister.Visible = false; pnlDownloadCert.Visible = true; } }
public NetProxy(NetProxyType type, string address, int port, NetworkCredential credential = null) { _type = type; switch (type) { case NetProxyType.Http: _httpProxy = new WebProxyEx(new Uri("http://" + address + ":" + port), false, new string[] { }, credential); break; case NetProxyType.Socks5: _socksProxy = new SocksClient(address, port, credential); break; default: throw new NotSupportedException("Proxy type not supported."); } }
public void ConfigureProxy(NetProxyType proxyType, string proxyAddress, int proxyPort, NetworkCredential proxyCredentials) { _proxyAddress = proxyAddress; _proxyPort = proxyPort; _proxyCredentials = proxyCredentials; switch (proxyType) { case NetProxyType.Http: _proxy = new NetProxy(new WebProxyEx(new Uri("http://" + _proxyAddress + ":" + _proxyPort), false, new string[] { }, _proxyCredentials)); break; case NetProxyType.Socks5: _proxy = new NetProxy(new SocksClient(_proxyAddress, _proxyPort, _proxyCredentials)); break; default: _proxy = null; break; } ProxyUpdated?.BeginInvoke(this, EventArgs.Empty, null, null); }
public frmProxyConfig(NetProxyType proxyType, string proxyAddress, int proxyPort, NetworkCredential proxyCredentials) { InitializeComponent(); if ((proxyPort == 9150) && (proxyAddress == "127.0.0.1")) { cmbProxy.SelectedIndex = 3; } else { cmbProxy.SelectedIndex = (int)proxyType; } txtProxyAddress.Text = proxyAddress; txtProxyPort.Text = proxyPort.ToString(); if (proxyCredentials != null) { chkProxyAuth.Checked = true; txtProxyUser.Text = proxyCredentials.UserName; txtProxyPass.Text = proxyCredentials.Password; } }
private void btnCheckProxy_Click(object sender, EventArgs e) { try { NetProxyType proxyType = this.ProxyType; NetProxy proxy; NetworkCredential credentials = null; if (chkProxyAuth.Checked) { credentials = new NetworkCredential(txtProxyUser.Text, txtProxyPass.Text); } switch (proxyType) { case NetProxyType.Http: proxy = new NetProxy(new WebProxyEx(new Uri("http://" + txtProxyAddress.Text + ":" + int.Parse(txtProxyPort.Text)), false, new string[] { }, credentials)); break; case NetProxyType.Socks5: proxy = new NetProxy(new SocksClient(txtProxyAddress.Text, int.Parse(txtProxyPort.Text), credentials)); break; default: return; } proxy.CheckProxyAccess(); MessageBox.Show("Mesh was able to connect to the proxy server successfully.", "Proxy Check Success!", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "Proxy Check Failed!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public NetProxy(SocksClient socksProxy) { _type = NetProxyType.Socks5; _socksProxy = socksProxy; }
public NetProxy(WebProxyEx httpProxy) { _type = NetProxyType.Http; _httpProxy = httpProxy; }
public NetProxy(NetProxyType type, string address, int port, NetworkCredential credential = null) : this(type, IPAddress.TryParse(address, out IPAddress ipAddress) ? (EndPoint) new IPEndPoint(ipAddress, port) : new DomainEndPoint(address, port), credential) { }
private NetProxy() { _type = NetProxyType.None; }
public ForwarderZone(string name, DnsTransportProtocol forwarderProtocol, string forwarder, bool dnssecValidation, NetProxyType proxyType, string proxyAddress, ushort proxyPort, string proxyUsername, string proxyPassword, string fwdRecordComments) : base(name) { _zoneTransfer = AuthZoneTransfer.Deny; _notify = AuthZoneNotify.None; DnsResourceRecord fwdRecord = new DnsResourceRecord(name, DnsResourceRecordType.FWD, DnsClass.IN, 0, new DnsForwarderRecordData(forwarderProtocol, forwarder, dnssecValidation, proxyType, proxyAddress, proxyPort, proxyUsername, proxyPassword)); if (!string.IsNullOrEmpty(fwdRecordComments)) { fwdRecord.SetComments(fwdRecordComments); } _entries[DnsResourceRecordType.FWD] = new DnsResourceRecord[] { fwdRecord }; }
protected NetProxy(NetProxyType type, EndPoint proxyEP, NetworkCredential credential = null) { _type = type; _proxyEP = proxyEP; _credential = credential; }
protected override void ReadPlainTextFrom(Stream s) { BincodingDecoder decoder = new BincodingDecoder(s, "BP"); if (decoder.Version != 7) { throw new BitChatException("BitChatProfile data version not supported."); } NetProxyType proxyType = NetProxyType.None; string proxyAddress = "127.0.0.1"; int proxyPort = 0; string username = null; string password = ""; while (true) { Bincoding value = decoder.DecodeNext(); if (value.Type == BincodingType.NULL) { break; } KeyValuePair <string, Bincoding> item = value.GetKeyValuePair(); switch (item.Key) { case "local_port": _localPort = item.Value.GetIntegerValue(); break; case "check_cert_revocation": _checkCertificateRevocationList = item.Value.GetBooleanValue(); break; case "enable_upnp": _enableUPnP = item.Value.GetBooleanValue(); break; case "allow_inbound_invitations": _allowInboundInvitations = item.Value.GetBooleanValue(); break; case "allow_only_local_inbound_invitations": _allowOnlyLocalInboundInvitations = item.Value.GetBooleanValue(); break; case "download_folder": _downloadFolder = item.Value.GetStringValue(); break; case "local_cert_store": _localCertStore = new CertificateStore(item.Value.GetValueStream()); break; case "profile_image_date_modified": _profileImageDateModified = item.Value.GetLongValue(); break; case "profile_image": case "profile_image_large": _profileImage = item.Value.Value; break; case "tracker_list": { List <Bincoding> trackerList = item.Value.GetList(); _trackerURIs = new Uri[trackerList.Count]; int i = 0; foreach (Bincoding trackerItem in trackerList) { _trackerURIs[i++] = new Uri(trackerItem.GetStringValue()); } } break; case "bitchat_info": { List <Bincoding> bitChatInfoList = item.Value.GetList(); _bitChatInfoList = new BitChatInfo[bitChatInfoList.Count]; int i = 0; foreach (Bincoding infoItem in bitChatInfoList) { _bitChatInfoList[i++] = new BitChatInfo(infoItem.GetValueStream()); } } break; case "dht_nodes": { try { List <Bincoding> dhtNodeList = item.Value.GetList(); _bootstrapDhtNodes = new IPEndPoint[dhtNodeList.Count]; int i = 0; foreach (Bincoding dhtItem in dhtNodeList) { _bootstrapDhtNodes[i++] = IPEndPointParser.Parse(dhtItem.GetValueStream()); } } catch (NotSupportedException) { _bootstrapDhtNodes = new IPEndPoint[] { }; } } break; case "proxy_type": proxyType = (NetProxyType)item.Value.GetByteValue(); break; case "proxy_address": proxyAddress = item.Value.GetStringValue(); break; case "proxy_port": proxyPort = item.Value.GetIntegerValue(); break; case "proxy_user": username = item.Value.GetStringValue(); break; case "proxy_pass": password = item.Value.GetStringValue(); break; case "client_data": if (item.Value.Type == BincodingType.BINARY) { _clientData = item.Value.Value; } break; } } if (string.IsNullOrEmpty(_downloadFolder)) { _downloadFolder = Path.Combine(_profileFolder, "Downloads"); if (!Directory.Exists(_downloadFolder)) { try { Directory.CreateDirectory(_downloadFolder); } catch { } } } //apply proxy settings NetworkCredential proxyCredentials = null; if (username != null) { proxyCredentials = new NetworkCredential(username, password); } ConfigureProxy(proxyType, proxyAddress, proxyPort, proxyCredentials); }
public NetProxy(NetProxyType type, IPAddress address, int port, NetworkCredential credential = null) : this(type, new IPEndPoint(address, port), credential) { }