// -------------------------------------------------- Host UClientSocket::getLocalHost() { struct sockaddr_in localAddr; socklen_t len = sizeof(localAddr); if (getsockname(sockNum, (sockaddr *)&localAddr, &len) == 0) return Host(ntohl(localAddr.sin_addr.s_addr),0); else return Host(0,0); }
// -------------------------------------------------- Host WSAClientSocket::getLocalHost() { struct sockaddr_in localAddr; int len = sizeof(localAddr); if (getsockname(sockNum, (sockaddr *)&localAddr, &len) == 0) return Host(SWAP4(localAddr.sin_addr.s_addr),0); else return Host(0,0); }
EXPORT_C MStreamBuf* CDirectFileStore::DoCreateL(TStreamId& anId) // // Create a new stream and open for both reading and writing. // { return HDirectStoreBuf::CreateL(Host(),anId,HDirectStoreBuf::ERead|HDirectStoreBuf::EWrite); }
void build(const std::string& ip_prefix, int num_nodes) { test_utils::CassClusterPtr cluster(cass_cluster_new()); test_utils::initialize_contact_points(cluster.get(), ip_prefix, num_nodes, 0); cass_cluster_set_load_balance_round_robin(cluster.get()); cass_cluster_set_token_aware_routing(cluster.get(), cass_false); test_utils::CassSessionPtr session(test_utils::create_session(cluster.get())); for (int i = 0; i < num_nodes; ++i) { test_utils::CassStatementPtr statement( cass_statement_new("SELECT tokens, data_center FROM system.local", 0)); test_utils::CassFuturePtr future(cass_session_execute(session.get(), statement.get())); test_utils::wait_and_check_error(future.get()); test_utils::CassResultPtr result(cass_future_get_result(future.get())); const CassRow* row = cass_result_first_row(result.get()); const CassValue* data_center = cass_row_get_column_by_name(row, "data_center"); const CassValue* token_set = cass_row_get_column_by_name(row, "tokens"); CassString str; cass_value_get_string(data_center, &str.data, &str.length); std::string dc(str.data, str.length); std::string ip = cass::get_host_from_future(future.get()); test_utils::CassIteratorPtr iterator(cass_iterator_from_collection(token_set)); while (cass_iterator_next(iterator.get())) { cass_value_get_string(cass_iterator_get_value(iterator.get()), &str.data, &str.length); std::string token(str.data, str.length); tokens[boost::lexical_cast<int64_t>(token)] = Host(ip, dc); } } }
EXPORT_C MStreamBuf* CDirectFileStore::DoReadL(TStreamId anId) const // // Open a stream for reading. // { return HDirectStoreBuf::OpenL(Host(),anId,HDirectStoreBuf::ERead); }
util::Error LookupOwner(const std::string& user, const std::string& group, fs::Owner& owner) { auto dbConfig = config->Database(); try { mongo::DBClientConnection conn; conn.connect(dbConfig.Host()); if (!dbConfig.Login().empty()) { std::string errmsg; if (!conn.auth(dbConfig.Name(), dbConfig.Login(), dbConfig.Password(), errmsg)) throw mongo::DBException("Authentication failed", 0); } owner = fs::Owner(user.empty() ? -1 : LookupUID(conn, user), group.empty() ? -1 : LookupGID(conn, group)); } catch (const mongo::DBException& e) { return util::Error::Failure(e.what()); } catch (const util::RuntimeError& e) { return util::Error::Failure(e.Message()); } return util::Error::Success(); }
Host Host::autoRegister() { Host newHost = Host(); newHost.setName(Host::currentHostName()); newHost.setOnline(1); newHost.commit(); newHost.updateHardwareInfo(); Service ab = Service::recordByName("Assburner"); if( ab.isRecord() ) { HostService hs = HostService(); hs.setHost(newHost); hs.setService(ab); hs.commit(); } HostGroup hg = HostGroup::recordByName("All"); if( hg.isRecord() ) { HostGroupItem hgi = HostGroupItem(); hgi.setHost(newHost); hgi.setHostGroup(hg); hgi.commit(); } return newHost; }
void nsHttpConnectionInfo::SetOriginServer(const nsACString &host, int32_t port) { mHost = host; mPort = port == -1 ? DefaultPort() : port; // // build hash key: // // the hash key uniquely identifies the connection type. two connections // are "equal" if they end up talking the same protocol to the same server // and are both used for anonymous or non-anonymous connection only; // anonymity of the connection is setup later from nsHttpChannel::AsyncOpen // where we know we use anonymous connection (LOAD_ANONYMOUS load flag) // const char *keyHost; int32_t keyPort; if (mUsingHttpProxy && !mUsingConnect) { keyHost = ProxyHost(); keyPort = ProxyPort(); } else { keyHost = Host(); keyPort = Port(); } mHashKey.AssignLiteral("...."); mHashKey.Append(keyHost); mHashKey.Append(':'); mHashKey.AppendInt(keyPort); if (mUsingHttpProxy) mHashKey.SetCharAt('P', 0); if (mUsingSSL) mHashKey.SetCharAt('S', 1); // NOTE: for transparent proxies (e.g., SOCKS) we need to encode the proxy // info in the hash key (this ensures that we will continue to speak the // right protocol even if our proxy preferences change). // // NOTE: for SSL tunnels add the proxy information to the cache key. // We cannot use the proxy as the host parameter (as we do for non SSL) // because this is a single host tunnel, but we need to include the proxy // information so that a change in proxy config will mean this connection // is not reused if ((!mUsingHttpProxy && ProxyHost()) || (mUsingHttpProxy && mUsingConnect)) { mHashKey.AppendLiteral(" ("); mHashKey.Append(ProxyType()); mHashKey.Append(':'); mHashKey.Append(ProxyHost()); mHashKey.Append(':'); mHashKey.AppendInt(ProxyPort()); mHashKey.Append(')'); } }
/// Adds an address, port, transport tuple to the blacklist. void BaseResolver::blacklist(const AddrInfo& ai, int blacklist_ttl, int graylist_ttl) { std::string ai_str = ai.to_string(); TRC_DEBUG("Add %s to blacklist for %d seconds, graylist for %d seconds", ai_str.c_str(), blacklist_ttl, graylist_ttl); pthread_mutex_lock(&_hosts_lock); _hosts.erase(ai); _hosts.emplace(ai, Host(blacklist_ttl, graylist_ttl)); pthread_mutex_unlock(&_hosts_lock); }
MVisContainer* AVisWidget::GetVisContainer() { MVisContainer* res = NULL; Elem* eprntcp = Host()->GetNode("ConnPoint:Child"); if (eprntcp != NULL) { res = (MVisContainer*) eprntcp->GetSIfiC(MVisContainer::Type(), this); } else { Logger()->Write(MLogRec::EErr, this, "Input [Child] not exists"); } return res; }
NetTcpSocketErr LwipNetTcpSocket::accept(Host* pClient, NetTcpSocket** ppNewNetTcpSocket) { if( !m_pPcb ) //Pcb doesn't exist (anymore) return NETTCPSOCKET_MEM; //Dequeue a connection //if( m_lpInPcb.empty() ) if( m_lpInNetTcpSocket.empty() ) return NETTCPSOCKET_EMPTY; tcp_accepted( ((tcp_pcb*) m_pPcb) ); //Should fire proper events //WARN: m_pPcb is the GOOD param here (and not pInPcb) /* tcp_pcb* pInPcb = m_lpInPcb.front(); m_lpInPcb.pop();*/ if( (m_lpInNetTcpSocket.front()) == NULL ) { m_lpInNetTcpSocket.pop(); return NETTCPSOCKET_RST; } if( (m_lpInNetTcpSocket.front())->m_closed ) { Net::releaseTcpSocket(m_lpInNetTcpSocket.front()); m_lpInNetTcpSocket.pop(); return NETTCPSOCKET_RST; } ip_addr_t* ip = (ip_addr_t*) &( (m_lpInNetTcpSocket.front()->m_pPcb)->remote_ip); *ppNewNetTcpSocket = m_lpInNetTcpSocket.front(); *pClient = Host( IpAddr( ip ), m_lpInNetTcpSocket.front()->m_pPcb->remote_port ); m_lpInNetTcpSocket.pop(); // *pClient = Host( IpAddr(pInPcb->remote_ip), pInPcb->remote_port ); //Return a new socket // *ppNewNetTcpSocket = (NetTcpSocket*) new LwipNetTcpSocket(pInPcb); //tcp_accepted( ((tcp_pcb*) m_pPcb) ); //Should fire proper events //WARN: m_pPcb is the GOOD param here (and not pInPcb) /* if(*ppNewNetTcpSocket == NULL) { DBG("Not enough mem, socket dropped in LwipNetTcpSocket::accept.\n"); tcp_abort(pInPcb); }*/ return NETTCPSOCKET_OK; }
Host Discover::parseHost() { if (!m_reader.isStartElement() || m_reader.name() != "host") return Host(); QString address; QString hostName; QString status; QString mac; while(!(m_reader.tokenType() == QXmlStreamReader::EndElement && m_reader.name() == "host")){ m_reader.readNext(); if (m_reader.isStartElement() && m_reader.name() == "hostname") { QString name = m_reader.attributes().value("name").toString(); if (!name.isEmpty()) hostName = name; m_reader.readNext(); } if (m_reader.name() == "address") { QString addr = m_reader.attributes().value("addr").toString(); if (!addr.isEmpty()) address = addr; } if (m_reader.name() == "state") { QString state = m_reader.attributes().value("state").toString(); if (!state.isEmpty()) status = state; } if (m_reader.name() == "mac") { //TODO CHeck Keyword QString macAddress = m_reader.attributes().value("state").toString(); if (!macAddress.isEmpty()) mac = macAddress; } } return Host(hostName, address, mac, (status == "open" ? true : false)); }
NS_IMETHODIMP nsHttpChannelAuthProvider::AddAuthorizationHeaders() { LOG(("nsHttpChannelAuthProvider::AddAuthorizationHeaders? " "[this=%p channel=%p]\n", this, mAuthChannel)); NS_ASSERTION(mAuthChannel, "Channel not initialized"); nsCOMPtr<nsIProxyInfo> proxyInfo; nsresult rv = mAuthChannel->GetProxyInfo(getter_AddRefs(proxyInfo)); if (NS_FAILED(rv)) return rv; if (proxyInfo) { mProxyInfo = do_QueryInterface(proxyInfo); if (!mProxyInfo) return NS_ERROR_NO_INTERFACE; } uint32_t loadFlags; rv = mAuthChannel->GetLoadFlags(&loadFlags); if (NS_FAILED(rv)) return rv; // this getter never fails nsHttpAuthCache *authCache = gHttpHandler->AuthCache(); // check if proxy credentials should be sent const char *proxyHost = ProxyHost(); if (proxyHost && UsingHttpProxy()) SetAuthorizationHeader(authCache, nsHttp::Proxy_Authorization, "http", proxyHost, ProxyPort(), nullptr, // proxy has no path mProxyIdent); if (loadFlags & nsIRequest::LOAD_ANONYMOUS) { LOG(("Skipping Authorization header for anonymous load\n")); return NS_OK; } // check if server credentials should be sent nsCAutoString path, scheme; if (NS_SUCCEEDED(GetCurrentPath(path)) && NS_SUCCEEDED(mURI->GetScheme(scheme))) { SetAuthorizationHeader(authCache, nsHttp::Authorization, scheme.get(), Host(), Port(), path.get(), mIdent); } return NS_OK; }
int FTPLogin(const CKBehaviorContext& behcontext) { CKBehavior* beh = behcontext.Behavior; CKContext* ctx = behcontext.Context; if( beh->IsInputActive(0)){ beh->ActivateInput(0,FALSE); HWND win = (HWND)ctx->GetMainWindow(); FtpInit(win); //HFILE hLogFile = _lcreat (LOG_FILE, 0); //FtpLogTo (hLogFile); FtpSetDefaultTimeOut (30); FtpSetPassiveMode(TRUE); FtpSetAsynchronousMode(); int Port; beh->GetInputParameterValue(3,&Port); XString Host((CKSTRING) beh->GetInputParameterReadDataPtr(0)); XString User((CKSTRING) beh->GetInputParameterReadDataPtr(1)); XString Pw((CKSTRING) beh->GetInputParameterReadDataPtr(2)); int Login = FtpLogin(Host.Str(),User.Str(),Pw.Str(),win,0); beh->SetOutputParameterValue(0,&Login); if (Login == 0)beh->ActivateOutput(0); else{ beh->ActivateOutput(2); return CKBR_OK; } return CKBR_ACTIVATENEXTFRAME; } if( beh->IsInputActive(1)){ beh->ActivateInput(1,FALSE); FtpCloseConnection(); FtpRelease (); beh->ActivateOutput(1); return CKBR_OK; } return CKBR_ACTIVATENEXTFRAME; }
AbstractSocket::Status UdpSocket::bind(const uint16& port) { struct sockaddr_in addr; if (m_socketfd == -1) if ((m_socketfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) return getStatus(); addr = Host(IpAddress::Any, port).getHost(); if (::bind(m_socketfd, reinterpret_cast<sockaddr*>(&addr), sizeof(addr)) == -1) return getStatus(); return AbstractSocket::Done; }
Environment::Environment(void) { profile = profileFunction(); // Create a table of NB_HOSTS hosts hosts = new Host[DefVal::NB_HOSTS]; hosts_parent = new int[DefVal::NB_HOSTS]; for (int i = 0; i < DefVal::NB_HOSTS ; i++) { hosts[i] = Host(1); hosts_parent[i] = -1; } saveData(); // For the statistics ! }
int SyncedSDFileSystem::disk_initialize() { int ret; TCPSocketErr err; ret = SDFileSystem::disk_initialize(); dirty_ = vector<bool>(MAX_SYNCED_BLOCKS, false); block_md4_ = vector<struct block_hash>(MAX_SYNCED_BLOCKS); for (int i = 0; i < MAX_SYNCED_BLOCKS; ++i) { block_md4_[i].block_num = i; if (SDFileSystem::disk_read((char *)buffer_, i)) { // TODO: handle error } mdfour((unsigned char *) block_md4_[i].md4, buffer_, BLOCK_SIZE); } if (is_master_) { tcp_socket_->setOnEvent(this, &SyncedSDFileSystem::on_master_event); tcp_socket_->bind(Host(address_, SYNC_FS_PORT)); tcp_socket_->listen(); debug("MASTER: listening for connections"); } else { tcp_socket_->setOnEvent(this, &SyncedSDFileSystem::on_node_event); err = tcp_socket_->connect(Host(IpAddr(192, 168, 1, MASTER_ADDR), SYNC_FS_PORT)); if (err) { // TODO: retry master registration periodically tcp_socket_->close(); delete tcp_socket_; printf("SLAVE: failed to connect to master, entering standalone mode\n\r"); // TODO: handle offline mode by checking if tcp_socket_ == NULL } else { debug("SLAVE: connected to master"); } } return ret; }
bool GMPChild::RecvPGMPVideoEncoderConstructor(PGMPVideoEncoderChild* aActor) { auto vec = static_cast<GMPVideoEncoderChild*>(aActor); void* ve = nullptr; GMPErr err = mGetAPIFunc("encode-video", &vec->Host(), &ve); if (err != GMPNoErr || !ve) { return false; } vec->Init(static_cast<GMPVideoEncoder*>(ve)); return true; }
bool GMPChild::RecvPGMPVideoDecoderConstructor(PGMPVideoDecoderChild* aActor) { auto vdc = static_cast<GMPVideoDecoderChild*>(aActor); void* vd = nullptr; GMPErr err = mGetAPIFunc("decode-video", &vdc->Host(), &vd); if (err != GMPNoErr || !vd) { return false; } vdc->Init(static_cast<GMPVideoDecoder*>(vd)); return true; }
bool GMPContentChild::RecvPGMPAudioDecoderConstructor(PGMPAudioDecoderChild* aActor) { auto vdc = static_cast<GMPAudioDecoderChild*>(aActor); void* vd = nullptr; GMPErr err = mGMPChild->GetAPI(GMP_API_AUDIO_DECODER, &vdc->Host(), &vd); if (err != GMPNoErr || !vd) { return false; } vdc->Init(static_cast<GMPAudioDecoder*>(vd)); return true; }
bool AVisWidget::GetDataInt(const string& aInpUri, int& aData) { bool res = false; Elem* einp = Host()->GetNode(aInpUri); if (einp != NULL) { MDIntGet* mdata = (MDIntGet*) einp->GetSIfiC(MDIntGet::Type(), this); if (mdata != NULL) { aData = mdata->Value(); res = true; } } else { Logger()->Write(MLogRec::EErr, this, "Input [%s] not exists", aInpUri.c_str()); } return res; }
bool nsHttpConnectionInfo::HostIsLocalIPLiteral() const { PRNetAddr prAddr; // If the host/proxy host is not an IP address literal, return false. if (ProxyHost()) { if (PR_StringToNetAddr(ProxyHost(), &prAddr) != PR_SUCCESS) { return false; } } else if (PR_StringToNetAddr(Host(), &prAddr) != PR_SUCCESS) { return false; } NetAddr netAddr; PRNetAddrToNetAddr(&prAddr, &netAddr); return IsIPAddrLocal(&netAddr); }
long MPINodeStartPosn(long datasets) { int nodework, startp, SIZE, IAM, i; MPI_Comm_rank(MPI_COMM_WORLD, &IAM); MPI_Comm_size(MPI_COMM_WORLD, &SIZE); if (Host(IAM)) startp=1; else { startp=1; for(i=0;i<IAM;i++) { nodework=datasets/SIZE; if ((datasets % SIZE) > i) nodework++; startp=startp+nodework; } } return (startp); }
bool GMPContentChild::RecvPGMPVideoEncoderConstructor(PGMPVideoEncoderChild* aActor) { auto vec = static_cast<GMPVideoEncoderChild*>(aActor); void* ve = nullptr; GMPErr err = mGMPChild->GetAPI(GMP_API_VIDEO_ENCODER, &vec->Host(), &ve); if (err != GMPNoErr || !ve) { NS_WARNING("GMPGetAPI call failed trying to construct encoder."); return false; } vec->Init(static_cast<GMPVideoEncoder*>(ve)); return true; }
void nsHttpConnectionInfo::SetOriginServer(const nsACString &host, PRInt32 port) { mHost = host; mPort = port == -1 ? DefaultPort() : port; // // build hash key: // // the hash key uniquely identifies the connection type. two connections // are "equal" if they end up talking the same protocol to the same server // and are both used for anonymous or non-anonymous connection only; // anonymity of the connection is setup later from nsHttpChannel::AsyncOpen // where we know we use anonymous connection (LOAD_ANONYMOUS load flag) // const char *keyHost; PRInt32 keyPort; if (mUsingHttpProxy && !mUsingSSL) { keyHost = ProxyHost(); keyPort = ProxyPort(); } else { keyHost = Host(); keyPort = Port(); } mHashKey.AssignLiteral("..."); mHashKey.Append(keyHost); mHashKey.Append(':'); mHashKey.AppendInt(keyPort); if (mUsingHttpProxy) mHashKey.SetCharAt('P', 0); if (mUsingSSL) mHashKey.SetCharAt('S', 1); // NOTE: for transparent proxies (e.g., SOCKS) we need to encode the proxy // type in the hash key (this ensures that we will continue to speak the // right protocol even if our proxy preferences change). if (!mUsingHttpProxy && ProxyHost()) { mHashKey.AppendLiteral(" ("); mHashKey.Append(ProxyType()); mHashKey.Append(')'); } }
const BString& BUrl::Authority() const { if (!fAuthorityValid) { fAuthority.Truncate(0); if (HasUserInfo()) fAuthority << UserInfo() << '@'; fAuthority << Host(); if (HasPort()) fAuthority << ':' << fPort; fAuthorityValid = true; } return fAuthority; }
void NetPlaySetupDialog::accept() { SaveSettings(); if (m_tab_widget->currentIndex() == 0) { emit Join(); } else { auto items = m_host_games->selectedItems(); if (items.size() == 0) { QMessageBox::critical(this, tr("Error"), tr("You must select a game to host!")); return; } emit Host(items[0]->text()); } }
bool Job::updateJobStatuses( JobList jobs, const QString & jobStatus, bool resetTasks, bool restartHosts ) { if( jobs.isEmpty() ) return false; QString keys = jobs.keyString(); Database::current()->beginTransaction(); if( restartHosts ){ // Update each of the hosts that were working on the job if( !Database::current()->exec("UPDATE HostStatus SET slaveStatus = 'starting' WHERE fkeyJob IN(" + keys + ");").isActive() ) { Database::current()->rollbackTransaction(); return false; } } if( resetTasks ) { foreach( Job j, jobs ) { JobDepList jdl = JobDep::recordsByJob(j); JobTaskList jtl = j.jobTasks().filter("status", "cancelled", /*keepMatches*/ false); bool isSoftDep = false; foreach(JobDep jd, jdl){ if( jd.depType() == 2 ) { isSoftDep = true; break; } } if( !isSoftDep ) jtl.setStatuses("new"); else jtl.setStatuses("holding"); jtl.setColumnLiteral("fkeyjoboutput","NULL"); if( j.packetType() != "preassigned" ) jtl.setHosts(Host()); jtl.commit(); } }
Client::Client(int width, int height, const std::string& hostname, HeaderCallbackFunc callback, void* userData) : outputWidth(0), outputHeight(0), sps(0), spss(0), pps(0), ppss(0), headerCallback(callback), headerUserData(userData) { stream.setCallback(streamCallback, this); control.setDataCallback(controlCallback, this); if (!control.connect(Host(hostname, 21047))) { fprintf(stderr, "Unable to connect to server\n"); return; } char data[14]; int sz = htonl(10); uint32_t w = htonl(width), h = htonl(height); uint16_t p = htons(UDP_PORT); memcpy(data, &sz, 4); memcpy(data + 4, &p, 2); memcpy(data + 6, &w, 4); memcpy(data + 10, &h, 4); control.send(data, 14); }
Host::Host(TiXmlNode *host_node){ TiXmlNode *share; TiXmlNode *child; // cout << "type: " << host_node->Type(); // cout << " value: " << host_node->ValueStr() << endl; if ( host_node->ValueStr() != "HOST" ){ cout << "Error, this is not a HOST node"; Host(); return; } share = host_node->FirstChild("HOST_SHARE"); child = host_node->FirstChild("ID"); // cout << "ID type: " << child->Type() << endl; // cout << "ID child type: " << child->FirstChild()->Type() << endl; // cout << "id child value: " << child->FirstChild()->Value() << endl; this->id = atoi( child->FirstChild()->Value() ); child = host_node->FirstChild("NAME"); this->name = child->FirstChild()->ValueStr(); child = host_node->FirstChild("STATE"); this->state = atoi( child->FirstChild()->Value() ); child = share->FirstChild("MAX_MEM"); this->max_mem = atoi( child->FirstChild()->Value() ); child = share->FirstChild("USED_MEM"); this->used_mem = atoi( child->FirstChild()->Value() ); child = share->FirstChild("MAX_CPU"); this->max_cpu = atoi( child->FirstChild()->Value() ); this->cores = this->max_cpu / 100; // this seems to be the percentage per core child = share->FirstChild("USED_CPU"); this->used_cpu = atoi( child->FirstChild()->Value() ); }