NOEXPORT char *socks_server(CLI *c, SERVICE_OPTIONS *opt, const PHASE phase) {
    uint8_t version;

    switch(phase) {
    case PROTOCOL_CHECK:
        opt->option.protocol_endpoint=1;
        break;
    case PROTOCOL_MIDDLE:
        s_log(LOG_DEBUG, "Waiting for the SOCKS request");
        s_ssl_read(c, &version, sizeof version);
        switch(version) {
        case 4:
            socks4_server(c);
            break;
        case 5:
            socks5_server_method(c);
            socks5_server(c);
            break;
        default:
            s_log(LOG_ERR, "Unsupported SOCKS version 0x%02x", version);
            throw_exception(c, 1);
        }
        break;
    case PROTOCOL_LATE:
        /* TODO: send the SOCKS reply *after* the target is connected */
        /* FIXME: the SOCKS replies do not report CONNECT failures */
        /* FIXME: the SOCKS replies do not contain the bound IP address */
        break;
    default:
        break;
    }
    return NULL;
}
NOEXPORT char *socks_server(CLI *c, SERVICE_OPTIONS *opt, const PHASE phase) {
    uint8_t version;

    switch(phase) {
    case PROTOCOL_CHECK:
        opt->option.protocol_endpoint=1;
        break;
    case PROTOCOL_MIDDLE:
        s_log(LOG_DEBUG, "Waiting for the SOCKS request");
        s_ssl_read(c, &version, sizeof version);
        switch(version) {
        case 4:
            socks4_server(c);
            break;
        case 5:
            socks5_server_method(c);
            socks5_server(c);
            break;
        default:
            s_log(LOG_ERR, "Unsupported SOCKS version 0x%02x", version);
            throw_exception(c, 1);
        }
        break;
    case PROTOCOL_LATE:
         
         
         
        break;
    default:
        break;
    }
    return NULL;
}