diff options
Diffstat (limited to 'src/setup/gnunet-setup-options.c')
-rw-r--r-- | src/setup/gnunet-setup-options.c | 160 |
1 files changed, 158 insertions, 2 deletions
diff --git a/src/setup/gnunet-setup-options.c b/src/setup/gnunet-setup-options.c index 2f885ca6..9495e824 100644 --- a/src/setup/gnunet-setup-options.c +++ b/src/setup/gnunet-setup-options.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include "gnunet-setup-options.h" | 27 | #include "gnunet-setup-options.h" |
28 | #include "gnunet-setup-exit-services.h" | 28 | #include "gnunet-setup-exit-services.h" |
29 | #include <gnunet/gnunet_util_lib.h> | 29 | #include <gnunet/gnunet_util_lib.h> |
30 | #include <gnunet/gnunet_tun_lib.h> | ||
30 | #include <gdk/gdkkeysyms.h> | 31 | #include <gdk/gdkkeysyms.h> |
31 | 32 | ||
32 | 33 | ||
@@ -500,6 +501,104 @@ highlight_port_collisions (const void *cls, | |||
500 | 501 | ||
501 | 502 | ||
502 | /** | 503 | /** |
504 | * Check IPv4 exit policy for syntactic correctness. | ||
505 | * | ||
506 | * @param cls closure (unused) | ||
507 | * @param widget widget whose state was changed | ||
508 | */ | ||
509 | static void | ||
510 | validate_v4_policy (const void *cls, | ||
511 | GObject *widget) | ||
512 | { | ||
513 | GtkEntry *entry; | ||
514 | GdkColor color; | ||
515 | GdkColor *pcolor; | ||
516 | gboolean invalid; | ||
517 | const char *text; | ||
518 | char *r; | ||
519 | char *tooltip; | ||
520 | |||
521 | entry = GTK_ENTRY (widget); | ||
522 | text = gtk_entry_get_text (entry); | ||
523 | r = GNUNET_TUN_ipv4policy2regex (text); | ||
524 | invalid = ( (strlen (text) > 0) && | ||
525 | ( (NULL == r) || | ||
526 | (text[strlen(text)-1] != ';') ) ); | ||
527 | gdk_color_parse (INVALID_INPUT_COLOR, &color); | ||
528 | if (invalid) | ||
529 | { | ||
530 | pcolor = &color; | ||
531 | GNUNET_asprintf (&tooltip, | ||
532 | _("Invalid policy.")); | ||
533 | } | ||
534 | else | ||
535 | { | ||
536 | pcolor = NULL; | ||
537 | tooltip = GNUNET_strdup (""); | ||
538 | } | ||
539 | gtk_widget_modify_bg (GTK_WIDGET (widget), | ||
540 | GTK_STATE_NORMAL, pcolor); | ||
541 | gtk_widget_modify_bg (GTK_WIDGET (widget), | ||
542 | GTK_STATE_ACTIVE, pcolor); | ||
543 | gtk_widget_modify_bg (GTK_WIDGET (widget), | ||
544 | GTK_STATE_SELECTED, pcolor); | ||
545 | gtk_widget_set_tooltip_text (GTK_WIDGET (widget), | ||
546 | tooltip); | ||
547 | GNUNET_free (tooltip); | ||
548 | GNUNET_free_non_null (r); | ||
549 | } | ||
550 | |||
551 | |||
552 | /** | ||
553 | * Check IPv6 exit policy for syntactic correctness. | ||
554 | * | ||
555 | * @param cls closure (unused) | ||
556 | * @param widget widget whose state was changed | ||
557 | */ | ||
558 | static void | ||
559 | validate_v6_policy (const void *cls, | ||
560 | GObject *widget) | ||
561 | { | ||
562 | GtkEntry *entry; | ||
563 | GdkColor color; | ||
564 | GdkColor *pcolor; | ||
565 | gboolean invalid; | ||
566 | const char *text; | ||
567 | char *r; | ||
568 | char *tooltip; | ||
569 | |||
570 | entry = GTK_ENTRY (widget); | ||
571 | text = gtk_entry_get_text (entry); | ||
572 | r = GNUNET_TUN_ipv6policy2regex (text); | ||
573 | invalid = ( (strlen (text) > 0) && | ||
574 | ( (NULL == r) || | ||
575 | (text[strlen(text)-1] != ';') ) ); | ||
576 | gdk_color_parse (INVALID_INPUT_COLOR, &color); | ||
577 | if (invalid) | ||
578 | { | ||
579 | pcolor = &color; | ||
580 | GNUNET_asprintf (&tooltip, | ||
581 | _("Invalid policy.")); | ||
582 | } | ||
583 | else | ||
584 | { | ||
585 | pcolor = NULL; | ||
586 | tooltip = GNUNET_strdup (""); | ||
587 | } | ||
588 | gtk_widget_modify_bg (GTK_WIDGET (widget), | ||
589 | GTK_STATE_NORMAL, pcolor); | ||
590 | gtk_widget_modify_bg (GTK_WIDGET (widget), | ||
591 | GTK_STATE_ACTIVE, pcolor); | ||
592 | gtk_widget_modify_bg (GTK_WIDGET (widget), | ||
593 | GTK_STATE_SELECTED, pcolor); | ||
594 | gtk_widget_set_tooltip_text (GTK_WIDGET (widget), | ||
595 | tooltip); | ||
596 | GNUNET_free (tooltip); | ||
597 | GNUNET_free_non_null (r); | ||
598 | } | ||
599 | |||
600 | |||
601 | /** | ||
503 | * Initialize a toggle button based on the existence of a word | 602 | * Initialize a toggle button based on the existence of a word |
504 | * in an option value. | 603 | * in an option value. |
505 | * | 604 | * |
@@ -755,6 +854,33 @@ static struct GNUNET_SETUP_VisibilitySpecification hide_exit_options[] = { | |||
755 | 854 | ||
756 | 855 | ||
757 | /** | 856 | /** |
857 | * Hide DNS "exit" options if DNS exit is not in use. | ||
858 | */ | ||
859 | static struct GNUNET_SETUP_VisibilitySpecification hide_dns_exit_options[] = { | ||
860 | {"GNUNET_setup_dns_resolver_hbox", "^YES$", NULL}, | ||
861 | {NULL, NULL, NULL} | ||
862 | }; | ||
863 | |||
864 | |||
865 | /** | ||
866 | * Hide IPv4 "exit" options if IPv4 exit is not in use. | ||
867 | */ | ||
868 | static struct GNUNET_SETUP_VisibilitySpecification hide_v4_exit_options[] = { | ||
869 | {"GNUNET_SETUP_exit_policy_v4_hbox", "^YES$", NULL}, | ||
870 | {NULL, NULL, NULL} | ||
871 | }; | ||
872 | |||
873 | |||
874 | /** | ||
875 | * Hide IPv6 "exit" options if IPv6 exit is not in use. | ||
876 | */ | ||
877 | static struct GNUNET_SETUP_VisibilitySpecification hide_v6_exit_options[] = { | ||
878 | {"GNUNET_SETUP_exit_policy_v6_hbox", "^YES$", NULL}, | ||
879 | {NULL, NULL, NULL} | ||
880 | }; | ||
881 | |||
882 | |||
883 | /** | ||
758 | * Hide "hostlist" server options if hostlist server is not in use. | 884 | * Hide "hostlist" server options if hostlist server is not in use. |
759 | */ | 885 | */ |
760 | static struct GNUNET_SETUP_VisibilitySpecification | 886 | static struct GNUNET_SETUP_VisibilitySpecification |
@@ -1826,7 +1952,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = { | |||
1826 | &load_yes_no, | 1952 | &load_yes_no, |
1827 | &save_yes_no, NULL, | 1953 | &save_yes_no, NULL, |
1828 | NULL, NULL, | 1954 | NULL, NULL, |
1829 | NULL}, | 1955 | hide_dns_exit_options}, |
1830 | 1956 | ||
1831 | { | 1957 | { |
1832 | "GNUNET_setup_exit_interface_name_entry", | 1958 | "GNUNET_setup_exit_interface_name_entry", |
@@ -1902,7 +2028,7 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = { | |||
1902 | &load_yes_no, | 2028 | &load_yes_no, |
1903 | &save_yes_no, NULL, | 2029 | &save_yes_no, NULL, |
1904 | NULL, NULL, | 2030 | NULL, NULL, |
1905 | NULL}, | 2031 | hide_v4_exit_options}, |
1906 | 2032 | ||
1907 | { | 2033 | { |
1908 | "GNUNET_setup_exit_enable_ipv6_exit_checkbutton", | 2034 | "GNUNET_setup_exit_enable_ipv6_exit_checkbutton", |
@@ -1915,9 +2041,39 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = { | |||
1915 | &load_yes_no, | 2041 | &load_yes_no, |
1916 | &save_yes_no, NULL, | 2042 | &save_yes_no, NULL, |
1917 | NULL, NULL, | 2043 | NULL, NULL, |
2044 | hide_v6_exit_options}, | ||
2045 | |||
2046 | |||
2047 | { | ||
2048 | "GNUNET_SETUP_exit_policy_v4_entry", | ||
2049 | "changed", | ||
2050 | "exit", | ||
2051 | "EXIT_RANGE_IPV4_POLICY", | ||
2052 | gettext_noop | ||
2053 | ("Which IPv4 addresses and ports do you allow other users to send traffic towards (via the Exit interface)"), | ||
2054 | "https://gnunet.org/configuration-exit", | ||
2055 | &load_text, | ||
2056 | &save_text, NULL, | ||
2057 | &validate_v4_policy, NULL, | ||
2058 | NULL}, | ||
2059 | |||
2060 | |||
2061 | { | ||
2062 | "GNUNET_SETUP_exit_policy_v6_entry", | ||
2063 | "changed", | ||
2064 | "exit", | ||
2065 | "EXIT_RANGE_IPV6_POLICY", | ||
2066 | gettext_noop | ||
2067 | ("Which IPv6 addresses and ports do you allow other users to send traffic towards (via the Exit interface)"), | ||
2068 | "https://gnunet.org/configuration-exit", | ||
2069 | &load_text, | ||
2070 | &save_text, NULL, | ||
2071 | &validate_v6_policy, NULL, | ||
1918 | NULL}, | 2072 | NULL}, |
1919 | 2073 | ||
1920 | 2074 | ||
2075 | |||
2076 | |||
1921 | /* Namestore TAB */ | 2077 | /* Namestore TAB */ |
1922 | 2078 | ||
1923 | { | 2079 | { |