2 #include "silcserver.h"
6 static void running(SilcServer server, void *context)
8 SILC_LOG_DEBUG(("***** RUNNING"));
11 static void stopped(SilcServer server, void *context)
13 SILC_LOG_DEBUG(("***** STOPPED"));
14 silc_schedule_stop(schedule);
17 int main(int argc, char **argv)
19 SilcBool success = FALSE;
21 SilcServerParams params;
22 SilcServerParamServerInfo info;
23 SilcServerParamInterface iface;
24 SilcServerParamClient client_all;
26 if (argc > 1 && !strcmp(argv[1], "-d")) {
28 silc_log_debug_hexdump(TRUE);
29 silc_log_set_debug_string("*server*,*skr*,*ske*,*connauth*,*packet*,*stream*,*net*");
32 SILC_LOG_DEBUG(("Allocating scheduler"));
33 schedule = silc_schedule_init(0, NULL);
35 silc_cipher_register_default();
36 silc_pkcs_register_default();
37 silc_hash_register_default();
38 silc_hmac_register_default();
40 SILC_LOG_DEBUG(("Allocating server params context"));
41 params = silc_server_params_alloc();
45 SILC_LOG_DEBUG(("Creating server params"));
47 info = silc_server_params_serverinfo_alloc();
50 info->server_name = strdup("test server");
52 if (!silc_load_key_pair("test.pub", "test.prv", "", NULL,
54 &info->private_key)) {
55 if (!silc_create_key_pair("rsa", 2048, "test.pub", "test.prv", NULL, "",
58 &info->private_key, FALSE)) {
63 iface = silc_calloc(1, sizeof(*iface));
66 iface->ip = strdup("127.0.0.1");
68 silc_server_params_serverinfo_add_iface(info, iface);
69 silc_server_params_set_serverinfo(params, info);
71 client_all = silc_calloc(1, sizeof(*client_all));
74 silc_server_params_add_client(params, client_all);
76 params->use_threads = TRUE;
78 SILC_LOG_DEBUG(("Allocating server context"));
79 server = silc_server_alloc(NULL, params, schedule);
81 SILC_LOG_DEBUG(("Error allocating server"));
85 SILC_LOG_DEBUG(("Running server"));
86 silc_server_run(server, running, NULL);
88 SILC_LOG_DEBUG(("Running scheduler"));
89 silc_schedule(schedule);
91 silc_server_free(server);
92 silc_server_params_free(params);
93 silc_schedule_uninit(schedule);
98 SILC_LOG_DEBUG(("Testing was %s", success ? "SUCCESS" : "FAILURE"));
99 fprintf(stderr, "Testing was %s\n", success ? "SUCCESS" : "FAILURE");