示例#1
0
void getClient(char * serverAddress) {
    int sockFd = makeSocketOrDie();
    struct addrinfo * serverInfo = getServerInfo(serverAddress);
	printf("Connecting to server\n");
    connectOrDie(sockFd, serverInfo);
	printf("Connected to server.  Making LIBSSH2 session\n");
    LIBSSH2_SESSION * session = makeSession();
    libssh2_session_set_blocking(session, 1);
	libssh2_session_set_timeout(session, 5000);
	printf("Made session, handshaking\n");
    int result = libssh2_session_handshake(session, sockFd);
    //const char * fingerprint = libssh2_hostkey_hash(session, LIBSSH_HOSTKEY_HASH_SHA1);
    //TODO: Match the fingerprint against something.
    if (result) {
		char * errorMessage;
		libssh2_session_last_error(session, &errorMessage, NULL, 0);
		fprintf(stderr, "Error %s handshaking\n", errorMessage);
		exit(EXIT_FAILURE);
	}
    printf("Handshake completed, making SFTP Session\n");
	libssh2_userauth_password(session, NETID, PWD);
    LIBSSH2_SFTP * sftpSession = makeSFTPSession(session);
	printf("Started SFTP - Downloading file\n");
    LIBSSH2_SFTP_HANDLE * fileHandle = libssh2_sftp_open(sftpSession, serverFilePath, LIBSSH2_FXF_READ, 0);
	readFile(session, sftpSession, fileHandle);
    libssh2_sftp_shutdown(sftpSession);
    libssh2_session_disconnect(session, "Done.\n");
    libssh2_session_free(session);
    freeaddrinfo(serverInfo);
    close(sockFd);
}
示例#2
0
文件: TimeInfo.cpp 项目: mvxi/icetest
::Ice::DispatchStatus
Temp::TimeInfo::___getServerInfo(::IceInternal::Incoming& __inS, const ::Ice::Current& __current)
{
    __checkMode(::Ice::Normal, __current.mode);
    __inS.is()->skipEmptyEncaps();
    ::IceInternal::BasicStream* __os = __inS.os();
    ::std::string __ret = getServerInfo(__current);
    __os->write(__ret);
    return ::Ice::DispatchOK;
}
示例#3
0
int startServer(void) {
    if(verbosity > NO_VERBOSE) printf("%s: Starting server...\n", prog);

    if(getServerInfo(port) == ERR || bindToSocket() == ERR || listen(listenSocket, BACKLOG) != 0) {
        fprintf(stderr, "%s: Failed to start server: %s\n", prog, strerror(errno));
        exit(ABNORMAL_EXIT);
    }

    childPid = NO_CHILD;

    if(verbosity >= DBL_VERBOSE) printf("%s: Server started.\n", prog);
    return SUCCESS;
}
示例#4
0
LoginConfig::LoginConfig(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::LoginConfig),
    fadeEffect(this)
{
    ui->setupUi(this);

    setWindowFlags(Qt::FramelessWindowHint);
    setAttribute(Qt::WA_TranslucentBackground);

 //   fadeEffect.startFadeInOut(FADEIN);

    getServerInfo();
    ui->serverIPText->setText(serverIP);
    ui->serverPortText->setText(serverPort);
}
示例#5
0
void NWFInfo::execute(FramesInfo& info)
{
    if(!isReady())
        throw std::runtime_error("Cannot execute NWF if not ready");
    const NWFServerInfo serverInfo = getServerInfo();
    serverInfos_.pop();
    for(NWFPlayerInfo& player : playerInfos_)
    {
        if(player.commands.empty())
            throw std::runtime_error("Cannot execute NWF if not ready");
        player.commands.pop();
    }

    info.gf_length = FramesInfo::milliseconds32_t(serverInfo.newGFLen);
    info.nwf_length = serverInfo.nextNWF - serverInfo.gf;
    nextNWF_ = serverInfo.nextNWF;
}
示例#6
0
文件: server.c 项目: butch2k/luafcgi
void serverVar() {
    LuaFCGI_ServerInfo serverInfo = getServerInfo();

    // Create table to hold these values for Lua to read from
    lua_createtable(Lua, 0, 0);

    lua_pushstring(Lua, "query_string");
    lua_pushstring(Lua, serverInfo.query_string);
    lua_rawset(Lua, -3);

    lua_pushstring(Lua, "request_method");
    lua_pushstring(Lua, serverInfo.request_method);
    lua_rawset(Lua, -3);

    lua_pushstring(Lua, "content_type");
    lua_pushstring(Lua, serverInfo.content_type);
    lua_rawset(Lua, -3);

    lua_pushstring(Lua, "content_length");
    lua_pushstring(Lua, serverInfo.content_length);
    lua_rawset(Lua, -3);

    lua_pushstring(Lua, "script_filename");
    lua_pushstring(Lua, serverInfo.script_filename);
    lua_rawset(Lua, -3);

    lua_pushstring(Lua, "script_name");
    lua_pushstring(Lua, serverInfo.script_name);
    lua_rawset(Lua, -3);

    lua_pushstring(Lua, "request_uri");
    lua_pushstring(Lua, serverInfo.request_uri);
    lua_rawset(Lua, -3);

    lua_pushstring(Lua, "document_uri");
    lua_pushstring(Lua, serverInfo.document_uri);
    lua_rawset(Lua, -3);

    lua_pushstring(Lua, "document_root");
    lua_pushstring(Lua, serverInfo.document_root);
    lua_rawset(Lua, -3);

    lua_pushstring(Lua, "server_protocol");
    lua_pushstring(Lua, serverInfo.server_protocol);
    lua_rawset(Lua, -3);

    lua_pushstring(Lua, "gateway_interface");
    lua_pushstring(Lua, serverInfo.gateway_interface);
    lua_rawset(Lua, -3);

    lua_pushstring(Lua, "server_software");
    lua_pushstring(Lua, serverInfo.server_software);
    lua_rawset(Lua, -3);

    lua_pushstring(Lua, "remote_address");
    lua_pushstring(Lua, serverInfo.remote_address);
    lua_rawset(Lua, -3);

    lua_pushstring(Lua, "remote_port");
    lua_pushstring(Lua, serverInfo.remote_port);
    lua_rawset(Lua, -3);

    lua_pushstring(Lua, "server_address");
    lua_pushstring(Lua, serverInfo.server_address);
    lua_rawset(Lua, -3);

    lua_pushstring(Lua, "server_port");
    lua_pushstring(Lua, serverInfo.server_port);
    lua_rawset(Lua, -3);

    lua_pushstring(Lua, "server_name");
    lua_pushstring(Lua, serverInfo.server_name);
    lua_rawset(Lua, -3);

    lua_pushstring(Lua, "https");
    lua_pushstring(Lua, serverInfo.https);
    lua_rawset(Lua, -3);

    // Set table as SERVER variable in lua
    lua_setglobal(Lua, "SERVER");
}
void MoodBoxServer::getServerInfo(Callback callback)
{
    getServerInfo(callback, QVariant());
}