Exemplo n.º 1
0
int
main(int argc, char **argv)
{
    int ret;

    settings_init();

    if (set_signal_handler(signals) == -1) {
        return -1;
    }

    tc_time_init();

    if (read_args(argc, argv) == -1) {
        return -1;
    }

    if (srv_settings.log_path == NULL) {
        srv_settings.log_path = "error_intercept.log";  
    }

    if (tc_log_init(srv_settings.log_path) == -1) {
        return -1;
    }

    ret = tc_event_loop_init(&s_event_loop, MAX_FD_NUM);
    if (ret == TC_EVENT_ERROR) {
        tc_log_info(LOG_ERR, 0, "event loop init failed");
        return -1;
    }

    /* output debug info */
    output_for_debug();
    if (set_details() == -1) {
        return -1;
    }

    if (interception_init(&s_event_loop, srv_settings.binded_ip,
                          srv_settings.port) == TC_ERROR)
    {
        return -1;
    }

    if (set_timer() == -1) {
        return -1;
    }

#if (INTERCEPT_COMBINED)
    tc_event_timer_add(&s_event_loop, CHECK_INTERVAL, interception_push);
#endif
    tc_event_timer_add(&s_event_loop, OUTPUT_INTERVAL,
            interception_output_stat);

    /* run now */
    tc_event_process_cycle(&s_event_loop);

    server_release_resources();

    return 0;
}
Exemplo n.º 2
0
/*
 * main entry point
 */
int
main(int argc, char **argv)
{
    int ret;

    settings_init();

    tc_time_init();

    if (read_args(argc, argv) == -1) {
        return -1;
    }
    
    if (clt_settings.log_path == NULL) {
        clt_settings.log_path = "error_tcpcopy.log";
    }   

    if (tc_log_init(clt_settings.log_path) == -1) {
        return -1;
    }

    /* output debug info */
    output_for_debug(argc, argv);

    /* set details for running */
    if (set_details() == -1) {
        return -1;
    }

    ret = tc_event_loop_init(&event_loop, MAX_FD_NUM);
    if (ret == TC_EVENT_ERROR) {
        tc_log_info(LOG_ERR, 0, "event loop init failed");
        return -1;
    }

    ret = tcp_copy_init(&event_loop);
    if (ret == TC_ERROR) {
        exit(EXIT_FAILURE);
    }

    /* run now */
    tc_event_process_cycle(&event_loop);

    tcp_copy_release_resources();

    return 0;
}
Exemplo n.º 3
0
int
main(int argc, char **argv)
{
    int ret;

    settings_init();

    tc_time_init();

    if (read_args(argc, argv) == -1) {
        return -1;
    }

    if (tc_log_init(srv_settings.log_path) == -1) {
        return -1;
    }

    ret = tc_event_loop_init(&s_event_loop, MAX_FD_NUM);
    if (ret == TC_EVENT_ERROR) {
        tc_log_info(LOG_ERR, 0, "event loop init failed");
        return -1;
    }

    /* output debug info */
    output_for_debug();
    if (set_details() == -1) {
        return -1;
    }

    if (interception_init(&s_event_loop, srv_settings.binded_ip,
                          srv_settings.port) == TC_ERROR)
    {
        return -1;
    }

    /* run now */
    tc_event_process_cycle(&s_event_loop);

    return 0;
}
Exemplo n.º 4
0
/*
 * main entry point
 */
int
main(int argc, char **argv)
{
    int ret;

    settings_init();

#if (TCPCOPY_SIGACTION)
    if (set_signal_handler(signals) == -1) {
        return -1;
    }
#else
    signal(SIGALRM, tc_time_sig_alarm);
    signal(SIGINT,  tcp_copy_over);
    signal(SIGPIPE, tcp_copy_over);
    signal(SIGHUP,  tcp_copy_over);
    signal(SIGTERM, tcp_copy_over);
#endif

    tc_time_init();

    if (read_args(argc, argv) == -1) {
        return -1;
    }
    
    if (clt_settings.log_path == NULL) {
        clt_settings.log_path = "error_tcpcopy.log";
    }   

    if (tc_log_init(clt_settings.log_path) == -1) {
        return -1;
    }

    /* output debug info */
    output_for_debug(argc, argv);

    /* set details for running */
    if (set_details() == -1) {
        return -1;
    }

#if (TCPCOPY_MYSQL_ADVANCED) 
    tc_init_digests();
    if (!tc_init_sha1()) {
        return -1;
    }
#endif

    ret = tc_event_loop_init(&event_loop, MAX_FD_NUM);
    if (ret == TC_EVENT_ERROR) {
        tc_log_info(LOG_ERR, 0, "event loop init failed");
        return -1;
    }

    ret = tcp_copy_init(&event_loop);
    if (ret == TC_ERROR) {
        exit(EXIT_FAILURE);
    }

    if (set_timer() == -1) {
        return -1;
    }

    /* run now */
    tc_event_process_cycle(&event_loop);

    tcp_copy_release_resources();

    return 0;
}
Exemplo n.º 5
0
/*
 * main entry point
 */
int
main(int argc, char **argv)
{
    int ret, is_continue = 1;

    settings_init();

#if (TC_SIGACTION)
    if (set_signal_handler(signals) == -1) {
        return -1;
    }
#else
    signal(SIGINT,  tcp_copy_over);
    //signal(SIGPIPE, tcp_copy_over);
    //signal(SIGHUP,  tcp_copy_over);
    signal(SIGTERM, tcp_copy_over);
#endif

    tc_time_init();

    if (read_args(argc, argv) == -1) {
        return -1;
    }

    if (tc_log_init(clt_settings.log_path) == -1) {
        return -1;
    }

    clt_settings.pool = tc_create_pool(TC_DEFAULT_POOL_SIZE, 0, 0);

    if (clt_settings.pool == NULL) {
        return -1;
    }

    /* output debug info */
    output_for_debug();

    /* set details for running */
    if (set_details() == -1) {
        return -1;
    }

#if (TC_DIGEST)
    tc_init_digests();
    if (!tc_init_sha1()) {
        return -1;
    }
#endif

#if (MINGW32)
    WSADATA wsadata;
    if(WSAStartup(MAKEWORD(2,2),&wsadata)==SOCKET_ERROR)
    {
        tc_log_info(LOG_ERR, 0, "WSAStartup failed");
        return -1;
    }
#endif

    tc_event_timer_init();

    ret = tc_event_loop_init(&event_loop, MAX_FD_NUM);
    if (ret == TC_EVENT_ERROR) {
        tc_log_info(LOG_ERR, 0, "event loop init failed");
        is_continue = 0;
    }

    if (is_continue) {
        ret = tcp_copy_init(&event_loop);
        if (ret == TC_ERR) {
            is_continue = 0;
        }
    }

    if (is_continue) {
        /* run now */
        tc_log_info(LOG_NOTICE, 0, "starting event handling loop....");
        tc_event_proc_cycle(&event_loop);
    }

    tcp_copy_release_resources();

#if (MINGW32)
    tc_log_info(LOG_INFO, 0, "WSACleanup");
    WSACleanup();
#endif

    return 0;
}
Exemplo n.º 6
0
int
main(int argc, char **argv)
{
    int ret;

    settings_init();

    if (set_signal_handler(signals) == -1) {
        return -1;
    }

    tc_time_init();

    if (read_args(argc, argv) == -1) {
        return -1;
    }

    if (tc_log_init(srv_settings.log_path) == -1) {
        return -1;
    }

    srv_settings.pool = tc_create_pool(TC_DEFAULT_POOL_SIZE, 0);
    if (srv_settings.pool == NULL) {
        return -1;
    }
    srv_settings.cpool = tc_create_pool(TC_DEFAULT_POOL_SIZE, 0);
    if (srv_settings.cpool == NULL) {
        tc_destroy_pool(srv_settings.pool);
        return -1;
    }

    ret = tc_event_loop_init(&s_evt_loop, MAX_FD_NUM);
    if (ret == TC_EVENT_ERROR) {
        tc_log_info(LOG_ERR, 0, "event loop init failed");
        return -1;
    }

    /* output debug info */
    output_for_debug();
    if (set_details() == -1) {
        return -1;
    }

    tc_event_timer_init();

    if (server_init(&s_evt_loop, srv_settings.bound_ip, srv_settings.port) == 
            TC_ERR)
    {
        return -1;
    }

#if (TC_COMBINED)
    tc_event_add_timer(s_evt_loop.pool, CHECK_INTERVAL, NULL, server_push);
#endif
    tc_event_add_timer(s_evt_loop.pool, OUTPUT_INTERVAL, NULL, server_stat);

    /* run now */
    tc_event_proc_cycle(&s_evt_loop);

    server_release_resources();

    return 0;
}
Exemplo n.º 7
0
/*
 * main entry point
 */
int
main(int argc, char **argv)
{
    int ret, is_continue = 1;

    settings_init();

#if (GRYPHON_SIGACTION)
    if (set_signal_handler(signals) == -1) {
        return -1;
    }
#else
    signal(SIGALRM, tc_time_sig_alarm);
    signal(SIGINT,  gryphon_over);
    signal(SIGPIPE, gryphon_over);
    signal(SIGHUP,  gryphon_over);
    signal(SIGTERM, gryphon_over);
#endif

    tc_time_init();

    if (read_args(argc, argv) == -1) {
        return -1;
    }

    if (clt_settings.log_path == NULL) {
        clt_settings.log_path = "error_gryphon.log";
    }

    if (tc_log_init(clt_settings.log_path) == -1) {
        return -1;
    }

    /* output debug info */
    output_for_debug(argc, argv);


    /* set details for running */
    if (set_details() == -1) {
        return -1;
    }

    if (set_timer() == -1) {
        return -1;
    }

    ret = tc_event_loop_init(&event_loop, MAX_FD_NUM);
    if (ret == TC_EVENT_ERROR) {
        tc_log_info(LOG_ERR, 0, "event loop init failed");
        is_continue = 0;
    }

    if (is_continue) {
        ret = tc_build_session_table(65536);
        if (ret == TC_ERROR) {
            is_continue = 0;
        } else {
            ret = gryphon_init(&event_loop);
            if (ret == TC_ERROR) {
                is_continue = 0;
            } else {
                if (!tc_build_users(clt_settings.client_mode,
                                    clt_settings.users, clt_settings.valid_ips,
                                    clt_settings.valid_ip_num))
                {
                    is_continue = 0;
                }
            }
        }
    }

    if (is_continue) {
        if (set_timer() == -1) {
            is_continue = 0;
        }
    }

    if (is_continue) {
        /* run now */
        tc_event_process_cycle(&event_loop);
    }

    gryphon_release_resources();

    return 0;
}