__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

aptanhua@216.73.216.200: ~ $
#pragma once

#include "php_swoole_cxx.h"
#include "php_swoole_ssh2_def.h"

#include <libssh2.h>
#include <libssh2_sftp.h>
#include <libssh2_publickey.h>

typedef struct _php_ssh2_session_data {
    /* Userspace callback functions */
    zval *ignore_cb;
    zval *debug_cb;
    zval *macerror_cb;
    zval *disconnect_cb;

    SocketImpl *socket;
} php_ssh2_session_data;

static inline swoole::EventType ssh2_get_event_type(LIBSSH2_SESSION *session) {
    int dir = libssh2_session_block_directions(session);
    if (dir & LIBSSH2_SESSION_BLOCK_OUTBOUND) {
        return SW_EVENT_WRITE;
    } else {
        return SW_EVENT_READ;
    }
}

static inline SocketImpl *ssh2_get_socket(LIBSSH2_SESSION *session) {
    auto session_data = (php_ssh2_session_data **) libssh2_session_abstract(session);
    return (*session_data)->socket;
}

static inline void ssh2_set_socket_timeout(LIBSSH2_SESSION *session, int timeout_ms) {
    auto sock = ssh2_get_socket(session);
    sock->set_timeout(timeout_ms / 1000, SW_TIMEOUT_ALL);
}

class ResourceGuard {
    zval zres_;

  public:
    ResourceGuard(zval *zres) {
        zval_addref_p(zres);
        zres_ = *zres;
    }
    ~ResourceGuard() {
        zval_ptr_dtor(&zres_);
    }
};

static inline int ssh2_async_call(LIBSSH2_SESSION *session, const std::function<int(void)> &fn) {
    auto event = ssh2_get_event_type(session);
    auto socket = ssh2_get_socket(session);

    socket->check_bound_co(SW_EVENT_READ);
    socket->check_bound_co(SW_EVENT_WRITE);

    int rc = 0;
    while (1) {
        rc = fn();
        if (rc == LIBSSH2_ERROR_EAGAIN) {
            if (!socket->poll(event)) {
                return LIBSSH2_ERROR_SOCKET_NONE;
            }
            continue;
        }
        break;
    }
    return rc;
}

template <typename T>
static inline T *ssh2_async_call_ex(LIBSSH2_SESSION *session, const std::function<T *(void)> &fn) {
    auto event = ssh2_get_event_type(session);
    auto socket = ssh2_get_socket(session);

    socket->check_bound_co(SW_EVENT_READ);
    socket->check_bound_co(SW_EVENT_WRITE);

    T *handle;
    while (1) {
        handle = fn();
        if (handle) {
            return handle;
        }
        if (libssh2_session_last_errno(session) == LIBSSH2_ERROR_EAGAIN && socket->poll(event)) {
            continue;
        }
        break;
    }
    return nullptr;
}

Filemanager

Name Type Size Permission Actions
php_swoole_call_stack.h File 1.81 KB 0644
php_swoole_client.h File 2.79 KB 0644
php_swoole_coroutine.h File 9.85 KB 0644
php_swoole_coroutine_system.h File 1.89 KB 0644
php_swoole_curl.h File 5.07 KB 0644
php_swoole_cxx.h File 27.05 KB 0644
php_swoole_firebird.h File 4.87 KB 0644
php_swoole_ftp_def.h File 1.17 KB 0644
php_swoole_http.h File 16.25 KB 0644
php_swoole_http_server.h File 4.12 KB 0644
php_swoole_library.h File 425.52 KB 0644
php_swoole_odbc.h File 5.62 KB 0644
php_swoole_oracle.h File 2.97 KB 0644
php_swoole_pgsql.h File 2.55 KB 0644
php_swoole_private.h File 44.83 KB 0644
php_swoole_process.h File 1.52 KB 0644
php_swoole_server.h File 6.87 KB 0644
php_swoole_sqlite.h File 2.2 KB 0644
php_swoole_ssh2.h File 2.31 KB 0644
php_swoole_ssh2_def.h File 1.28 KB 0644
php_swoole_ssh2_hook.h File 21.9 KB 0644
php_swoole_stdext.h File 1.84 KB 0644
php_swoole_thread.h File 10.78 KB 0644
php_swoole_websocket.h File 2.49 KB 0644
swoole_curl_interface.h File 2.31 KB 0644