📄 options.c
字号:
o->persist_mode = 1;#endif o->local_port = o->remote_port = 5000; o->verbosity = 1; o->status_file_update_freq = 60; o->bind_local = true; o->tun_mtu = TUN_MTU_DEFAULT; o->link_mtu = LINK_MTU_DEFAULT; o->mtu_discover_type = -1; o->occ = true; o->mssfix = MSSFIX_DEFAULT; o->rcvbuf = 65536; o->sndbuf = 65536;#ifdef USE_LZO o->comp_lzo_adaptive = true;#endif#ifdef TARGET_LINUX o->tuntap_options.txqueuelen = 100;#endif#ifdef WIN32 o->tuntap_options.ip_win32_type = IPW32_SET_DHCP_MASQ; o->tuntap_options.dhcp_lease_time = 31536000; /* one year */ o->tuntap_options.dhcp_masq_offset = 0; /* use network address as internal DHCP server address */#endif#ifdef USE_PTHREAD o->n_threads = 1;#endif#if P2MP o->real_hash_size = 256; o->virtual_hash_size = 256; o->n_bcast_buf = 256;#endif#ifdef USE_CRYPTO o->ciphername = "BF-CBC"; o->ciphername_defined = true; o->authname = "SHA1"; o->authname_defined = true; o->replay = true; o->replay_window = DEFAULT_SEQ_BACKTRACK; o->replay_time = DEFAULT_TIME_BACKTRACK; o->use_iv = true; o->key_direction = KEY_DIRECTION_BIDIRECTIONAL;#ifdef USE_SSL o->key_method = 2; o->tls_timeout = 2; o->renegotiate_seconds = 3600; o->handshake_window = 60; o->transition_window = 3600;#endif#endif}voiduninit_options (struct options *o){ gc_free (&o->gc);}#define SHOW_PARM(name, value, format) msg(D_SHOW_PARMS, " " #name " = " format, (value))#define SHOW_STR(var) SHOW_PARM(var, (o->var ? o->var : "[UNDEF]"), "'%s'")#define SHOW_INT(var) SHOW_PARM(var, o->var, "%d")#define SHOW_UINT(var) SHOW_PARM(var, o->var, "%u")#define SHOW_UNSIGNED(var) SHOW_PARM(var, o->var, "0x%08x")#define SHOW_BOOL(var) SHOW_PARM(var, (o->var ? "ENABLED" : "DISABLED"), "%s");voidsetenv_settings (const struct options *o){ setenv_str ("config", o->config); setenv_str ("proto", proto2ascii (o->proto, false)); setenv_str ("local", o->local); setenv_int ("local_port", o->local_port);#if 0 // JYFIXME -- set remote and remote_port environmental variables setenv_str ("remote", o->remote); setenv_int ("remote_port", o->remote_port);#endif}static in_addr_tget_ip_addr (const char *ip_string){ return getaddr (GETADDR_FATAL | GETADDR_HOST_ORDER | GETADDR_FATAL_ON_SIGNAL, ip_string, 0, NULL, NULL);}static char *string_substitute (const char *src, int from, int to, struct gc_arena *gc){ char *ret = (char *) gc_malloc (strlen (src) + 1, true, gc); char *dest = ret; char c; do { c = *src++; if (c == from) c = to; *dest++ = c; } while (c); return ret;}boolis_persist_option (const struct options *o){ return o->persist_tun || o->persist_key || o->persist_local_ip || o->persist_remote_ip || (o->remote_list && o->remote_list->len > 1);}#ifdef WIN32static voidshow_dhcp_option_addrs (const char *name, const in_addr_t *array, int len){ struct gc_arena gc = gc_new (); int i; for (i = 0; i < len; ++i) { msg (D_SHOW_PARMS, " %s[%d] = %s", name, i, print_in_addr_t (array[i], false, &gc)); } gc_free (&gc);}static voidshow_tuntap_options (const struct tuntap_options *o){ SHOW_BOOL (ip_win32_defined); SHOW_INT (ip_win32_type); SHOW_INT (dhcp_masq_offset); SHOW_INT (dhcp_lease_time); SHOW_INT (tap_sleep); SHOW_BOOL (dhcp_options); SHOW_STR (domain); SHOW_STR (netbios_scope); SHOW_INT (netbios_node_type); show_dhcp_option_addrs ("DNS", o->dns, o->dns_len); show_dhcp_option_addrs ("WINS", o->wins, o->wins_len); show_dhcp_option_addrs ("NTP", o->ntp, o->ntp_len); show_dhcp_option_addrs ("NBDD", o->nbdd, o->nbdd_len);}static voiddhcp_option_address_parse (const char *name, const char *parm, in_addr_t *array, int *len, int msglevel){ if (*len >= N_DHCP_ADDR) { msg (msglevel, "--dhcp-option %s: maximum of %d %s servers can be specified", name, N_DHCP_ADDR, name); } else { array[(*len)++] = get_ip_addr (parm); }}#endif#if P2MPstatic voidshow_p2mp_parms (const struct options *o){ struct gc_arena gc = gc_new (); if (o->push_list) { const struct push_list *l = o->push_list; const char *printable_push_list = l->options; msg (D_SHOW_PARMS, " push_list = '%s'", printable_push_list); } SHOW_BOOL (pull); SHOW_BOOL (ifconfig_pool_defined); msg (D_SHOW_PARMS, " ifconfig_pool_start = %s", print_in_addr_t (o->ifconfig_pool_start, false, &gc)); msg (D_SHOW_PARMS, " ifconfig_pool_end = %s", print_in_addr_t (o->ifconfig_pool_end, false, &gc)); SHOW_INT (n_bcast_buf); SHOW_INT (real_hash_size); SHOW_INT (virtual_hash_size); SHOW_STR (client_connect_script); SHOW_STR (learn_address_script); SHOW_STR (client_disconnect_script); SHOW_STR (client_config_dir); SHOW_STR (tmp_dir); SHOW_BOOL (push_ifconfig_defined); msg (D_SHOW_PARMS, " push_ifconfig_local = %s", print_in_addr_t (o->push_ifconfig_local, false, &gc)); msg (D_SHOW_PARMS, " push_ifconfig_remote_netmask = %s", print_in_addr_t (o->push_ifconfig_remote_netmask, false, &gc)); SHOW_BOOL (enable_c2c); SHOW_BOOL (duplicate_cn); SHOW_INT (cf_max); SHOW_INT (cf_per); gc_free (&gc);}static voidoption_iroute (struct options *o, const char *network_str, const char *netmask_str, int msglevel){ struct iroute *ir; ALLOC_OBJ_GC (ir, struct iroute, &o->gc); ir->network = getaddr (GETADDR_HOST_ORDER, network_str, 0, NULL, NULL); ir->netbits = -1; if (netmask_str) { const in_addr_t netmask = getaddr (GETADDR_HOST_ORDER, netmask_str, 0, NULL, NULL); if (!netmask_to_netbits (ir->network, netmask, &ir->netbits)) { msg (msglevel, "Options Error: in --iroute %s %s : Bad network/subnet specification", network_str, netmask_str); return; } } ir->next = o->iroutes; o->iroutes = ir;}#endifstatic voidshow_remote_list (const struct remote_list *l){ if (l) { int i; for (i = 0; i < l->len; ++i) { msg (D_SHOW_PARMS, " remote_list[%d] = {'%s', %d}", i, l->array[i].hostname, l->array[i].port); } } else { msg (D_SHOW_PARMS, " remote_list = NULL"); }}voidoptions_detach (struct options *o){ gc_detach (&o->gc); o->routes = NULL;#if P2MP if (o->push_list) /* clone push_list */ { const struct push_list *old = o->push_list; ALLOC_OBJ_GC (o->push_list, struct push_list, &o->gc); strcpy (o->push_list->options, old->options); }#endif}static voidrol_check_alloc (struct options *options){ if (!options->routes) options->routes = new_route_option_list (&options->gc);}voidshow_settings (const struct options *o){ msg (D_SHOW_PARMS, "Current Parameter Settings:"); SHOW_STR (config); SHOW_INT (mode);#ifdef TUNSETPERSIST SHOW_BOOL (persist_config); SHOW_INT (persist_mode);#endif#ifdef USE_CRYPTO SHOW_BOOL (show_ciphers); SHOW_BOOL (show_digests); SHOW_BOOL (genkey);#ifdef USE_SSL SHOW_BOOL (askpass); SHOW_BOOL (show_tls_ciphers);#endif#endif SHOW_INT (proto); SHOW_STR (local); show_remote_list (o->remote_list); SHOW_BOOL (remote_random); SHOW_INT (local_port); SHOW_INT (remote_port); SHOW_BOOL (remote_float); SHOW_STR (ipchange); SHOW_BOOL (bind_local); SHOW_STR (dev); SHOW_STR (dev_type); SHOW_STR (dev_node); SHOW_BOOL (tun_ipv6); SHOW_STR (ifconfig_local); SHOW_STR (ifconfig_remote_netmask); SHOW_BOOL (ifconfig_noexec); SHOW_BOOL (ifconfig_nowarn);#ifdef HAVE_GETTIMEOFDAY SHOW_INT (shaper);#endif SHOW_INT (tun_mtu); SHOW_BOOL (tun_mtu_defined); SHOW_INT (link_mtu); SHOW_BOOL (link_mtu_defined); SHOW_INT (tun_mtu_extra); SHOW_BOOL (tun_mtu_extra_defined); SHOW_INT (fragment); SHOW_INT (mtu_discover_type); SHOW_INT (mtu_test); SHOW_BOOL (mlock); SHOW_INT (inactivity_timeout); SHOW_INT (ping_send_timeout); SHOW_INT (ping_rec_timeout); SHOW_INT (ping_rec_timeout_action); SHOW_BOOL (ping_timer_remote); SHOW_BOOL (persist_tun); SHOW_BOOL (persist_local_ip); SHOW_BOOL (persist_remote_ip); SHOW_BOOL (persist_key); SHOW_INT (mssfix); #if PASSTOS_CAPABILITY SHOW_BOOL (passtos);#endif SHOW_INT (resolve_retry_seconds); SHOW_INT (connect_retry_seconds); SHOW_STR (username); SHOW_STR (groupname); SHOW_STR (chroot_dir); SHOW_STR (cd_dir); SHOW_STR (writepid); SHOW_STR (up_script); SHOW_STR (down_script); SHOW_BOOL (up_restart); SHOW_BOOL (up_delay); SHOW_BOOL (daemon); SHOW_INT (inetd); SHOW_BOOL (log); SHOW_INT (nice); SHOW_INT (verbosity); SHOW_INT (mute); SHOW_BOOL (gremlin); SHOW_STR (status_file); SHOW_INT (status_file_update_freq); SHOW_BOOL (occ); SHOW_INT (rcvbuf); SHOW_INT (sndbuf); SHOW_STR (http_proxy_server); SHOW_INT (http_proxy_port); SHOW_STR (http_proxy_auth_method); SHOW_STR (http_proxy_auth_file); SHOW_BOOL (http_proxy_retry); SHOW_STR (socks_proxy_server); SHOW_INT (socks_proxy_port); SHOW_BOOL (socks_proxy_retry);#ifdef USE_LZO SHOW_BOOL (comp_lzo); SHOW_BOOL (comp_lzo_adaptive);#endif SHOW_STR (route_script); SHOW_STR (route_default_gateway); SHOW_BOOL (route_noexec); SHOW_INT (route_delay); SHOW_BOOL (route_delay_defined); if (o->routes) print_route_options (o->routes, D_SHOW_PARMS);#ifdef USE_CRYPTO SHOW_STR (shared_secret_file); SHOW_INT (key_direction); SHOW_BOOL (ciphername_defined); SHOW_STR (ciphername); SHOW_BOOL (authname_defined); SHOW_STR (authname); SHOW_INT (keysize); SHOW_BOOL (engine); SHOW_BOOL (replay); SHOW_INT (replay_window); SHOW_INT (replay_time); SHOW_STR (packet_id_file); SHOW_BOOL (use_iv); SHOW_BOOL (test_crypto);#ifdef USE_SSL SHOW_BOOL (tls_server);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -