Пример #1
0
static jobject getProxyInfo(JNIEnv *env, CFDictionaryRef proxy) {
    CFStringRef type = CFDictionaryGetValue(proxy, kCFProxyTypeKey);
    CFStringRef host = CFDictionaryGetValue(proxy, kCFProxyHostNameKey);
    CFNumberRef port = CFDictionaryGetValue(proxy, kCFProxyPortNumberKey);
    CFStringRef user = CFDictionaryGetValue(proxy, kCFProxyUsernameKey);
    CFStringRef pass = CFDictionaryGetValue(proxy, kCFProxyPasswordKey);
    return (*env)->NewObject(
        env, pi_cls, pi_ctrID, getProxyType(type), getJString(env, host),
        getJInt(port), getJString(env, user), getJString(env, pass));
}
Пример #2
0
void ProxyDialog::setApplicationProxy()
{
    if (ui->checkProxyStatus->checkState() == Qt::Checked)
    {
        QNetworkProxy proxy;
        proxy.setType(getProxyType());
        proxy.setHostName(ui->editAddress->text());
        proxy.setPort(ui->editPort->text().toInt());
        proxy.setUser(ui->editUserName->text());
        proxy.setPassword(ui->editPassword->text());
        QNetworkProxy::setApplicationProxy(proxy);
    }
    else
    {
        QNetworkProxy::setApplicationProxy(QNetworkProxy::NoProxy);
    }
}
Пример #3
0
/** Applies the current network configuration settings to Tor. If
 * <b>errmsg</b> is specified and an error occurs while applying the settings,
 * it will be set to a string describing the error. */
bool
NetworkSettings::apply(QString *errmsg)
{
  QMultiHash<QString, QString> conf;
  quint32 torVersion = torControl()->getTorVersion();

  conf.insert(SETTING_REACHABLE_ADDRESSES,
    (getFascistFirewall() ? 
      localValue(SETTING_REACHABLE_ADDRESSES).toStringList().join(",") : ""));
 
  QString socks4, socks5, http, https;
  QString addr, user, pass, auth;

  addr = localValue(SETTING_PROXY_ADDRESS).toString();
  user = localValue(SETTING_PROXY_USERNAME).toString();
  pass = localValue(SETTING_PROXY_PASSWORD).toString();

  if (!user.isEmpty() || !pass.isEmpty())
    auth = QString("%1:%2").arg(user).arg(pass);
 
  switch (getProxyType()) {
    case NoProxy:
      break;
    case Socks4Proxy:
      socks4 = addr;
      break;
    case Socks5Proxy:
      socks5 = addr;
      break;
    case HttpHttpsProxy:
      http = addr;
      https = http;
      break;
  }

  if (torVersion >= 0x020201) {
    /* SOCKS support was implemented in 0.2.2.1 */
    conf.insert(SETTING_SOCKS4_PROXY, socks4);
    conf.insert(SETTING_SOCKS5_PROXY, socks5);
    conf.insert(SETTING_SOCKS5_USERNAME, user);
    conf.insert(SETTING_SOCKS5_PASSWORD, pass);
  }

  conf.insert(SETTING_HTTPS_PROXY, https);
  conf.insert(SETTING_HTTPS_PROXY_AUTH, auth);

  if (getUseBridges()) {
    /* We want to always enable TunnelDirConns and friends when using
     * bridge relays. */
    conf.insert(SETTING_TUNNEL_DIR_CONNS, "1");
    conf.insert(SETTING_PREFER_TUNNELED_DIR_CONNS, "1");
  } else if (torVersion <= 0x020021) {
    /* TunnelDirConns is enabled by default on Tor >= 0.2.0.22-rc, so don't
     * disable it if our Tor is recent enough. */
    conf.insert(SETTING_TUNNEL_DIR_CONNS, "0");
    conf.insert(SETTING_PREFER_TUNNELED_DIR_CONNS, "0");
  }

  if (torVersion >= 0x020003) {
    /* Do the bridge stuff only on Tor >= 0.2.0.3-alpha */
    QStringList bridges = localValue(SETTING_BRIDGE_LIST).toStringList();
    if (getUseBridges() && !bridges.isEmpty()) {
      conf.insert(SETTING_USE_BRIDGES, "1");
      conf.insert(SETTING_UPDATE_BRIDGES, "1");
      foreach (QString bridge, bridges) {
        conf.insert(SETTING_BRIDGE_LIST, bridge);
      }