You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
3.1 KiB

  1. From cb9dcde3874441bf66d52b70ac8b0d6f6bb557d9 Mon Sep 17 00:00:00 2001
  2. From: Nikos Mavrogiannopoulos <nmav@gnutls.org>
  3. Date: Sun, 30 Nov 2014 11:30:08 +0100
  4. Subject: [PATCH] Notify the client that the server may have a dynamic DNS
  5. address
  6. That is send "X-CSTP-DynDNS: true", in CSTP headers if the
  7. server is configured as having a dynamic DNS address.
  8. ---
  9. doc/sample.config | 5 +++++
  10. src/config.c | 2 ++
  11. src/ocserv-args.def | 5 +++++
  12. src/vpn.h | 1 +
  13. src/worker-vpn.c | 7 +++++++
  14. 5 files changed, 20 insertions(+)
  15. diff --git a/doc/sample.config b/doc/sample.config
  16. index a39e573..e07e36a 100644
  17. --- a/doc/sample.config
  18. +++ b/doc/sample.config
  19. @@ -51,6 +51,11 @@ max-same-clients = 2
  20. # hostname.
  21. #listen-host = [IP|HOSTNAME]
  22. +# When the server has a dynamic DNS address (that may change),
  23. +# should set that to true to ask the client to resolve again on
  24. +# reconnects.
  25. +#listen-host-is-dyndns = true
  26. +
  27. # TCP and UDP port number
  28. tcp-port = 443
  29. udp-port = 443
  30. diff --git a/src/config.c b/src/config.c
  31. index 2721a45..0b7e029 100644
  32. --- a/src/config.c
  33. +++ b/src/config.c
  34. @@ -60,6 +60,7 @@ static struct cfg_options available_options[] = {
  35. { .name = "custom-header", .type = OPTION_MULTI_LINE, .mandatory = 0 },
  36. { .name = "split-dns", .type = OPTION_MULTI_LINE, .mandatory = 0 },
  37. { .name = "listen-host", .type = OPTION_STRING, .mandatory = 0 },
  38. + { .name = "listen-host-is-dyndns", .type = OPTION_BOOLEAN, .mandatory = 0 },
  39. { .name = "tcp-port", .type = OPTION_NUMERIC, .mandatory = 0 },
  40. { .name = "udp-port", .type = OPTION_NUMERIC, .mandatory = 0 },
  41. { .name = "keepalive", .type = OPTION_NUMERIC, .mandatory = 0 },
  42. @@ -403,6 +404,7 @@ unsigned force_cert_auth;
  43. * reload_cfg_file();
  44. */
  45. READ_STRING("listen-host", config->name);
  46. + READ_TF("listen-host-is-dyndns", config->is_dyndns, 0);
  47. READ_NUMERIC("tcp-port", config->port);
  48. READ_NUMERIC("udp-port", config->udp_port);
  49. diff --git a/src/ocserv-args.def b/src/ocserv-args.def
  50. index cdc60bd..146e59a 100644
  51. --- a/src/ocserv-args.def
  52. +++ b/src/ocserv-args.def
  53. @@ -126,6 +126,11 @@ max-same-clients = 2
  54. # hostname.
  55. #listen-host = [IP|HOSTNAME]
  56. +# When the server has a dynamic DNS address (that may change),
  57. +# should set that to true to ask the client to resolve again on
  58. +# reconnects.
  59. +#listen-host-is-dyndns = true
  60. +
  61. # TCP and UDP port number
  62. tcp-port = 3333
  63. udp-port = 3333
  64. diff --git a/src/vpn.h b/src/vpn.h
  65. index a460370..03721e1 100644
  66. --- a/src/vpn.h
  67. +++ b/src/vpn.h
  68. @@ -188,6 +188,7 @@ struct cfg_st {
  69. char *name; /* server name */
  70. unsigned int port;
  71. unsigned int udp_port;
  72. + unsigned int is_dyndns;
  73. char* unix_conn_file;
  74. char *pin_file;
  75. diff --git a/src/worker-vpn.c b/src/worker-vpn.c
  76. index 364cbff..4cb5d99 100644
  77. --- a/src/worker-vpn.c
  78. +++ b/src/worker-vpn.c
  79. @@ -1650,6 +1650,13 @@ static int connect_handler(worker_st * ws)
  80. "X-CSTP-Smartcard-Removal-Disconnect: true\r\n");
  81. SEND_ERR(ret);
  82. + if (ws->config->is_dyndns != 0) {
  83. + ret =
  84. + cstp_puts(ws,
  85. + "X-CSTP-DynDNS: true\r\n");
  86. + SEND_ERR(ret);
  87. + }
  88. +
  89. if (ws->config->rekey_time > 0) {
  90. unsigned method;
  91. --
  92. 2.1.3