Module: Yast::DnsServerDialogMainInclude

Defined in:
../../src/include/dns-server/dialog-main.rb

Instance Method Summary (collapse)

Instance Method Details

- (String) ChangeIPToLocalEquivalent(ip_address)

Gets an IP address and returns it's local equivalent: 127.0.0.1 for IPv4, ::1 for IPv6. If a given string is neither IPv4 nor IPv6, nil is returned.

Parameters:

  • string

    IP to transform

Returns:

  • (String)

    transformed IP



1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
# File '../../src/include/dns-server/dialog-main.rb', line 1049

def ChangeIPToLocalEquivalent(ip_address)
  ret = nil

  if IP.Check4(ip_address)
    ret = "127.0.0.1"
  elsif IP.Check6(ip_address)
    ret = "::1"
  else
    ret = nil
  end

  Builtins.y2warning("Transforming forwarder IP %1 to %2", ip_address, ret)

  if ret == nil
    # An error message, %1 is replaced with a variable IP
    Report.Error(
      Builtins.sformat(_("Cannot find local equivalent for IP %1."), ret)
    )
  else
    # TRANSLATORS: A warning message, %1 is replaced with the input IP, %2 with the output IP
    Report.Warning(
      Builtins.sformat(
        _(
          "Forwarding DNS queries to itself would create an infinite loop.\n" +
            "IP address %1 is currently used by this server, so it has\n" +
            "been changed to its local equivalent %2."
        ),
        ip_address,
        ret
      )
    )
  end

  ret
end

- (Object) CheckOptionValue(option, value)



1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
# File '../../src/include/dns-server/dialog-main.rb', line 1344

def CheckOptionValue(option, value)
  # any value should be set
  if value == nil || value == ""
    if !Popup.YesNo(
        # TRANSLATORS: Popup question
        _("Really set this\noption without any value?\n")
      )
      return false
    end 
    # it is a YES or NO type
  elsif OptionsIsYesNoType(option)
    # it has not a yes/no value
    if !Builtins.regexpmatch(value, "^ *[yY][eE][sS] *$") &&
        !Builtins.regexpmatch(value, "^ *[nN][oO] *$")
      if !Popup.ContinueCancel(
          Builtins.sformat(
            # TRANSLATORS: Popup question. Please, do not translate 'yes' and 'no' strings. %1 is a name of the option, %2 is the value of the option.
            _(
              "Option %1 can only have a yes or no value set.\nReally set it to %2?\n"
            ),
            option,
            value
          )
        )
        return false
      end
    end 
    # it must be a number
  elsif OptionsIsNumberType(option)
    # if has not a number value
    if !Builtins.regexpmatch(value, "^ *[0123456789] *$")
      if !Popup.ContinueCancel(
          Builtins.sformat(
            # TRANSLATORS: Popup question. %1 is a name of the option, %2 is the value of the option.
            _("Option %1 can only be a number.\nReally set it to %2?\n"),
            option,
            value
          )
        )
        return false
      end
    end
  elsif !DnsRoutines.CheckQuoting(value)
    if !Popup.ContinueCancel(
        Builtins.sformat(
          # TRANSLATORS: Popup question. %1 is the value of the option.
          _(
            "Quotes are not used correctly in this option.\nReally set it to %1?\n"
          ),
          value
        )
      )
      return false
    end
  elsif !DnsRoutines.CheckBrackets(value)
    if !Popup.ContinueCancel(
        Builtins.sformat(
          # TRANSLATORS: Popup question. %1 is the value of the option.
          _(
            "Brackets are not used correctly in this option.\nReally set it to %1?\n"
          ),
          value
        )
      )
      return false
    end
  end

  true
end

- (Object) confirmAbort

Ask for exit without saving

Returns:

  • event that should be handled, nil if user canceled the exit



2344
2345
2346
2347
2348
2349
2350
2351
# File '../../src/include/dns-server/dialog-main.rb', line 2344

def confirmAbort
  Popup.YesNo(
    # Yes-No popup
    _(
      "All changes will be lost.\nReally leave the DNS server configuration without saving?"
    )
  )
end

- (Object) confirmAbortIfChanged

Check whether settings were changed and if yes, ask for exit without saving

Returns:

  • event that should be handled, nil if user canceled the exit



2356
2357
2358
2359
# File '../../src/include/dns-server/dialog-main.rb', line 2356

def confirmAbortIfChanged
  return true if !DnsServer.WasModified
  confirmAbort
end

- (Object) CurrentlyUsedIPs(including_local)

Returns list of IPs currently used by the system.

Parameters:

  • boolean

    whether local addresses should be returned as well (the default is false)



1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
# File '../../src/include/dns-server/dialog-main.rb', line 1025

def CurrentlyUsedIPs(including_local)
  cmd = "ip addr show | grep 'inet\\(6\\)\\?' | sed 's/^[ \\t]\\+inet\\(6\\)\\?[ \\t]\\+\\([^\\/]\\+\\)\\/.*$/\\2/'"
  cmd_ret = Convert.to_map(SCR.Execute(path(".target.bash_output"), cmd))

  if cmd_ret == nil || Ops.get_integer(cmd_ret, "exit", -1) != 0
    Builtins.y2error("Cannot get list of used IPs: %1", cmd_ret)
    return nil
  end

  used_ips = String.NewlineItems(Ops.get_string(cmd_ret, "stdout", ""))

  # Filtering out all local IPs
  used_ips = Builtins.filter(used_ips) do |used_ip|
    !Builtins.regexpmatch(used_ip, "127.0.0..*") && used_ip != "::1"
  end if including_local != true

  deep_copy(used_ips)
end

- (Yast::Term) Expert_ACLs_Dialog

Dialog Expert Settings - ACLs

Returns:

  • (Yast::Term)

    for Get_ExpertDialog()



1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
# File '../../src/include/dns-server/dialog-main.rb', line 1747

def Expert_ACLs_Dialog
  dialog =
    #`Top (
    VBox(
      VSquash(
        # Frame label - adding ACL-optiopn
        Frame(
          _("Option Setup"),
          VBox(
            HBox(
              HWeight(
                9,
                VBox(
                  HBox(
                    HWeight(
                      3,
                      # Textentry - adding ACL-optiopn - name
                      InputField(
                        Id("new_acl_name"),
                        Opt(:hstretch),
                        _("&Name")
                      )
                    ),
                    HWeight(
                      5,
                      # Textentry - adding ACL-optiopn - value
                      InputField(
                        Id("new_acl_value"),
                        Opt(:hstretch),
                        _("&Value")
                      )
                    )
                  )
                )
              ),
              HWeight(
                2,
                VBox(
                  VStretch(),
                  VSquash(
                    PushButton(
                      Id("add_acl"),
                      Opt(:hstretch),
                      Label.AddButton
                    )
                  )
                )
              )
            ),
            VSpacing(0.5)
          )
        )
      ),
      VSpacing(1),
      VBox(
        # Table header - ACL-options listing
        Left(Label(_("Current ACL List"))),
        HBox(
          HWeight(
            9,
            Table(
              Id("acl_listing_table"),
              Header(
                # Table header item - ACL-options
                _("ACL"),
                # Table header item - ACL-options
                _("Value")
              ),
              [
                # FIXME: real ACL data (list)
                Item(Id(1), "can_acfr", nil),
                Item(Id(2), "can_query", nil)
              ]
            )
          ),
          HWeight(
            2,
            VBox(
              VSquash(
                PushButton(
                  Id("delete_acl"),
                  Opt(:hstretch),
                  Label.DeleteButton
                )
              ),
              VStretch()
            )
          )
        )
      )
    )
  #);
  deep_copy(dialog)
end

- (Yast::Term) Expert_Logging_Dialog

Dialog Expert Settings - Logging

Returns:

  • (Yast::Term)

    for Get_ExpertDialog()



1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
# File '../../src/include/dns-server/dialog-main.rb', line 1479

def Expert_Logging_Dialog
  dialog = Top(
    HBox(
      HWeight(
        5,
        # Table header - logging options
        Frame(
          _("Log Type"),
          Top(
            VBox(
              VSquash(
                RadioButtonGroup(
                  Id("log_type"),
                  VBox(
                    # Radiobutton - log type
                    Left(
                      RadioButton(
                        Id("log_type_system"),
                        Opt(:notify),
                        _("&System Log"),
                        true
                      )
                    ),
                    # Radiobutton - log type
                    Left(
                      RadioButton(
                        Id("log_type_file"),
                        Opt(:notify),
                        _("&File")
                      )
                    )
                  )
                )
              ),
              VSpacing(0.5),
              HBox(
                HSpacing(3),
                VBox(
                  VWeight(
                    25,
                    HBox(
                      InputField(
                        Id("logfile_path"),
                        Opt(:hstretch),
                        Label.FileName
                      ),
                      VBox(
                        VStretch(),
                        # Pushbutton - browse filesystem for logfile
                        PushButton(
                          Id("browse_logfile_path"),
                          Label.BrowseButton
                        )
                      )
                    )
                  ),
                  # IntField - max. log size
                  VWeight(
                    25,
                    IntField(
                      Id("max_size"),
                      _("Maximum &Size (MB)"),
                      0,
                      4096,
                      0
                    )
                  ),
                  # IntField - max. log age
                  VWeight(
                    25,
                    IntField(
                      Id("max_versions"),
                      _("Maximum &Versions"),
                      0,
                      100,
                      0
                    )
                  ),
                  VStretch()
                )
              )
            )
          )
        )
      ),
      HSpacing(1),
      HWeight(
        3,
        # Frame label - additional-logging
        Frame(
          _("Additional Logging"),
          Top(
            VBox(
              # Checkbox - additional-logging
              Left(
                CheckBox(Id("l_named_queries"), _("Log All DNS &Queries"))
              ),
              # Checkbox - additional-logging
              Left(CheckBox(Id("l_zone_updates"), _("Log Zone &Updates"))),
              # Checkbox - additional-logging
              Left(
                CheckBox(Id("l_zone_transfers"), _("Log Zone &Transfers"))
              ),
              VStretch()
            )
          )
        )
      )
    )
  )
  deep_copy(dialog)
end

- (Yast::Term) ExpertBasicOptionsDialog

Dialog Expert Settings - Basic Options

Returns:

  • (Yast::Term)

    for Get_ExpertDialog()



1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
# File '../../src/include/dns-server/dialog-main.rb', line 1140

def ExpertBasicOptionsDialog
  dialog =
    # `Top (
    VBox(
      VSquash(
        # Frame label for Basic-Options
        Frame(
          _("Add or Change Option"),
          VBox(
            HBox(
              HWeight(
                9,
                Bottom(
                  VBox(
                    HBox(
                      HWeight(
                        3,
                        # Combobox for choosing the basic-option
                        ComboBox(
                          Id("basic_option_selection"),
                          Opt(:editable),
                          _("O&ption"),
                          @global_options_add_items
                        )
                      ),
                      HWeight(
                        5,
                        # Textentry for setting the basic-option value
                        InputField(
                          Id("basic_option_value"),
                          Opt(:hstretch),
                          _("&Value"),
                          ""
                        )
                      )
                    )
                  )
                )
              ),
              HWeight(
                2,
                Bottom(
                  VBox(
                    VSquash(
                      PushButton(
                        Id("add_basic_option"),
                        Opt(:hstretch),
                        Label.AddButton
                      )
                    ),
                    # Pushbutton for changing the basic-option
                    VSquash(
                      PushButton(
                        Id("change_basic_option"),
                        Opt(:hstretch),
                        _("C&hange")
                      )
                    )
                  )
                )
              )
            ),
            VSpacing(0.5)
          )
        )
      ),
      VSpacing(0.5),
      VBox(
        # Table label for basic-options listing
        Left(Label(_("Current Options"))),
        HBox(
          HWeight(
            9,
            Table(
              Id("basic_options_table"),
              Opt(:notify, :immediate, :vstretch),
              Header(
                # Table header item - basic-options listing
                _("Option"),
                # Table header item - basic-options listing
                _("Value")
              ),
              []
            )
          ),
          HWeight(
            2,
            VBox(
              VSquash(
                PushButton(
                  Id("delete_basic_option"),
                  Opt(:hstretch),
                  Label.DeleteButton
                )
              ),
              VStretch()
            )
          )
        )
      )
    )
  #);
  deep_copy(dialog)
end

- (Yast::Term) ExpertForwardersDialog

Dialog Expert Settings - Forwarders

Returns:

  • (Yast::Term)

    for Get_ExpertDialog()



742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
# File '../../src/include/dns-server/dialog-main.rb', line 742

def ExpertForwardersDialog
  dialog = VBox(
    # label
    VBox(
      HBox(
        ComboBox(
          Id("forwarder_policy"),
          Opt(:notify),
          # T: ComboBox label
          _("Local DNS Resolution &Policy"),
          [
            # T: ComboBox item
            Item(Id(:nomodify), _("Merging forwarders is disabled")),
            # T: ComboBox item
            Item(Id(:auto),     _("Automatic merging")),
            # T: ComboBox item
            Item(Id(:static),   _("Merging forwarders is enabled")),
            # T: ComboBox item
            Item(Id(:custom),   _("Custom configuration"))
          ]
        ),
        HSpacing(1),
        InputField(Id("custom_policy"), Opt(:hstretch), _("Custom policy"))
      ),
      VSpacing(1),
      Left(
        ComboBox(
          Id("forwarder"),
          # T: ComboBox label
          _("Local DNS Resolution &Forwarder"),
          [
            # T: ComboBox item
            Item(Id(:resolver), _("Using system name servers")),
            # T: ComboBox item
            Item(Id(:bind),     _("This name server (bind)")),
            # T: ComboBox item
            Item(Id(:dnsmasq),  _("Local dnsmasq server")),
          ]
        )
      )
    ),
    VSpacing(1),
    # Frame label for DNS-Forwarders options
    VSquash(
      Frame(
        # Frame label for DNS-Forwarders adding IP
        _("Add IP Address"),
        VBox(
          HBox(
            HWeight(
              9,
              # Textentry for DNS-Forwarders adding IP
              InputField(
                Id("forwarders_new_ip_address"),
                Opt(:hstretch),
                _("IPv4 or IPv6 A&ddress"),
                ""
              )
            ),
            HWeight(
              2,
              Bottom(
                PushButton(
                  Id("forwarders_add_ip_address"),
                  Opt(:hstretch),
                  Label.AddButton
                )
              )
            )
          ),
          VSpacing(0.5)
        )
      )
    ),
    VSpacing(0.5),
    HBox(
      HWeight(
        9,
        ReplacePoint(
          Id("forwarders_list_rp"),
          SelectionBox(
            Id("forwarders_list"),
            Opt(:hstretch),
            # Selectionbox for listing current DNS-Forwarders
            _("Forwarder &List"),
            []
          )
        )
      ),
      HWeight(
        2,
        VBox(
          VSquash(VSpacing(1)),
          VSquash(
            PushButton(
              Id("forwarders_delete_ip_address"),
              Opt(:hstretch),
              Label.DeleteButton
            )
          ),
          VStretch()
        )
      )
    )
  )
  deep_copy(dialog)
end

- (Yast::Term) ExpertStartUpDialog

Dialog Expert Settings - Start Up

Returns:

  • (Yast::Term)

    for Get_ExpertDialog()



575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
# File '../../src/include/dns-server/dialog-main.rb', line 575

def ExpertStartUpDialog
  dialog = Top(
    VBox(
      # Frame label (DNS starting)
      Frame(
        _("Start-Up"),
        Left(
          RadioButtonGroup(
            Id("dns_server_type"),
            VBox(
              # Radiobutton label
              Left(RadioButton(Id(:on), _("Now and When Booting"))),
              # Radiobutton label
              Left(RadioButton(Id(:off), _("Only Manually"))),
              VSpacing(1)
            )
          )
        )
      ),
      VSpacing(1),
      # check box
      Left(
        CheckBox(Id("use_ldap"), Opt(:notify), _("&LDAP Support Active"))
      ),
      VSpacing(1),
      # Frame label (stoping starting DNS server)
      Frame(
        _("Switch On and Off"),
        Left(
          HSquash(
            VBox(
              HBox(
                # Current status
                Label(_("Current Status: ")),
                ReplacePoint(
                  Id("service_status_rp"),
                  # service status - label
                  Label(_("DNS server is running."))
                ),
                HStretch()
              ),
              # Pushbutton for starting the DNS server
              PushButton(
                Id("start_dns_now"),
                Opt(:hstretch),
                _("&Start DNS Server Now")
              ),
              # Pushbutton for stopping the DNS server
              PushButton(
                Id("stop_dns_now"),
                Opt(:hstretch),
                _("S&top DNS Server Now")
              )
            )
          )
        )
      )
    )
  )
  deep_copy(dialog)
end

- (Yast::Term) ExpertZonesDialog

Dialog Expert Settings - ZonesZones

Returns:

  • (Yast::Term)

    for Get_ExpertDialog()



2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
# File '../../src/include/dns-server/dialog-main.rb', line 2030

def ExpertZonesDialog
  dialog = VBox(
    VSquash(
      # frame label
      Frame(
        _("Add New Zone "),
        HBox(
          HWeight(
            9,
            # Frame label - DNS adding zone
            VBox(
              #`VSpacing ( 0.5 ),
              HBox(
                # Textentry - DNS adding zone - Name
                InputField(
                  Id("new_zone_name"),
                  Opt(:hstretch),
                  _("Name"),
                  "example.com"
                ),
                # Combobox - DNS adding zone - Type
                ComboBox(
                  Id("new_zone_type"),
                  _("Type"),
                  [
                    # Combobox - DNS adding zone - Type Master
                    Item(Id("master"), _("Master")),
                    # Combobox - DNS adding zone - Type Slave
                    Item(Id("slave"), _("Slave")),
                    # Combobox - DNS adding zone - Type Slave
                    Item(Id("forward"), _("Forward"))
                  ]
                )
              ),
              VSpacing(0.5)
            )
          ),
          HWeight(
            2,
            VBox(
              VSpacing(1),
              #`VSquash (
              PushButton(Id("add_zone"), Opt(:hstretch), Label.AddButton),
              #),
              VSpacing(0.5)
            )
          )
        )
      )
    ),
    VSpacing(1),
    VBox(
      # Table header - DNS listing zones
      Left(Label(_("Configured DNS Zones"))),
      HBox(
        VStretch(Opt(:vstretch)),
        HWeight(
          9,
          Table(
            Id("zones_list_table"),
            Opt(:vstretch),
            Header(
              # Table header item - DNS listing zones
              _("Zone"),
              # Table header item - DNS listing zones
              _("Type")
            ),
            []
          )
        ),
        HWeight(
          2,
          VBox(
            VSquash(
              PushButton(
                Id("delete_zone"),
                Opt(:hstretch),
                Label.DeleteButton
              )
            ),
            VSquash(
              PushButton(Id("edit_zone"), Opt(:hstretch), Label.EditButton)
            ),
            VStretch()
          )
        )
      )
    )
  )

  deep_copy(dialog)
end

- (Object) GetZonesWithAclUsed(acl_name)

Returns zones where acl is used



1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
# File '../../src/include/dns-server/dialog-main.rb', line 1899

def GetZonesWithAclUsed(acl_name)
  zones_touched = []

  zones = DnsServer.FetchZones
  Builtins.foreach(zones) do |zone|
    Builtins.foreach(Ops.get_list(zone, "options", [])) do |option|
      if Ops.get_string(option, "key", "") == "allow-transfer"
        Builtins.foreach(
          Builtins.splitstring(Ops.get_string(option, "value", ""), "; {}")
        ) do |used_acl|
          if used_acl == acl_name
            zones_touched = Builtins.add(
              zones_touched,
              Ops.get_string(zone, "zone", "")
            )
          end
        end
      end
    end
  end

  Builtins.toset(zones_touched)
end

- (Object) HandleExpertAclPage(key, event)

Handle events in a tab of a dialog



1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
# File '../../src/include/dns-server/dialog-main.rb', line 1941

def HandleExpertAclPage(key, event)
  event = deep_copy(event)
  ret = Ops.get(event, "ID")
  index = Convert.to_integer(
    UI.QueryWidget(Id("acl_listing_table"), :CurrentItem)
  )
  if ret == "delete_acl"
    a = Ops.get(@acl, index, "")
    while Builtins.substring(a, 0, 1) == " " ||
        Builtins.substring(a, 0, 1) == "\t"
      a = Builtins.substring(a, 1)
    end
    s = Builtins.splitstring(a, " \t")
    a = Ops.get(s, 0, "")

    # Testing if ACL is used
    return nil if !ReallyRemoveACL(a)

    zones = DnsServer.FetchZones
    zones = Builtins.maplist(zones) do |z|
      options = Ops.get_list(z, "options", [])
      options = Builtins.maplist(options) do |o|
        if Ops.get_string(o, "key", "") == "allow-transfer"
          keys = Builtins.splitstring(
            Ops.get_string(o, "value", ""),
            "; {}"
          )
          keys = Builtins.filter(keys) { |k| k != "" }
          keys = Builtins.filter(keys) { |k| k != a }
          Ops.set(
            o,
            "value",
            Builtins.sformat("{ %1; }", Builtins.mergestring(keys, "; "))
          )
        end
        deep_copy(o)
      end
      Ops.set(z, "options", options)
      deep_copy(z)
    end
    DnsServer.StoreZones(zones)

    Ops.set(@acl, index, nil)
    @acl = Builtins.filter(@acl) { |a2| a2 != nil }
    RedrawAclPage()
  elsif ret == "add_acl"
    n = Convert.to_string(UI.QueryWidget(Id("new_acl_name"), :Value))
    v = Convert.to_string(UI.QueryWidget(Id("new_acl_value"), :Value))
    if n != nil && Builtins.regexpmatch(n, "^[ \t]*[a-z0-9_-]+[ \t]*$") &&
        v != nil &&
        Builtins.regexpmatch(v, "[^ \t\\{\\};]")
      # strip leading & trailing spaces
      # as well as a trailing ';' char
      if Builtins.regexpmatch(v, "^[ \t]+.*$")
        v = Builtins.regexpsub(v, "^[ \t]+(.*)$", "\\1")
      end
      if Builtins.regexpmatch(v, "^.*[ \t]+$")
        v = Builtins.regexpsub(v, "^(.*)[ \t]+$", "\\1")
      end
      if Builtins.regexpmatch(v, "^.*[ \t]*;$")
        v = Builtins.regexpsub(v, "^(.*)[ \t]*;$", "\\1")
      end

      # should be a block begining with a '{'
      v = Ops.add("{ ", v) if !Builtins.regexpmatch(v, "^\\{")

      # make sure, there is a block end '}'
      # note: ';' after '}' is added later
      if !Builtins.regexpmatch(v, "\\}$")
        # terminate list with ';' if needed
        v = Ops.add(v, ";") if !Builtins.regexpmatch(v, ";$")
        v = Ops.add(v, " }")
      end
      # testing for ACL duplicity
      if IsAclDefined(n, @acl)
        UI.SetFocus(Id("new_acl_name"))
        # An error popup message
        Popup.Message(_("The specified ACL entry already exists."))
      else
        @acl = Builtins.add(@acl, Builtins.sformat("%1 %2", n, v))
        RedrawAclPage()
      end
    end
  end
  nil
end

- (Object) HandleExpertBasicOptionsPage(key, event)

Handle events in a tab of a dialog



1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
# File '../../src/include/dns-server/dialog-main.rb', line 1416

def HandleExpertBasicOptionsPage(key, event)
  event = deep_copy(event)
  ret = Ops.get(event, "ID")
  index = Convert.to_integer(
    UI.QueryWidget(Id("basic_options_table"), :CurrentItem)
  )
  current_key = Convert.to_string(
    UI.QueryWidget(Id("basic_option_selection"), :Value)
  )
  current_value = Convert.to_string(
    UI.QueryWidget(Id("basic_option_value"), :Value)
  )
  if ret == "basic_options_table"
    ReinitializeOptionAddWidgets()
  elsif ret == "delete_basic_option"
    return nil if !Confirm.DeleteSelected

    Ops.set(@options, index, nil)
    @options = Builtins.filter(@options) { |o| o != nil }
    RedrawOptionsTableWidget()
    return nil
  elsif ret == "add_basic_option"
    # testing options for right values
    return nil if !CheckOptionValue(current_key, current_value)

    # option is unique and was set yet
    if IsUniqueOption(current_key) && OptionIsSetYet(current_key)
      if !Popup.ContinueCancel(
          Builtins.sformat(
            # Popup question, %1 is the name of the option
            _(
              "Option %1 should be set only once.\nReally add another one?\n"
            ),
            current_key
          )
        )
        return nil
      end
      Builtins.y2warning("Added unique option '%1' more times", current_key)
    end

    @options = Builtins.add(
      @options,
      { "key" => current_key, "value" => current_value }
    )
    RedrawOptionsTableWidget()
    return nil
  elsif ret == "change_basic_option"
    # testing options for right values
    return nil if !CheckOptionValue(current_key, current_value)

    Ops.set(@options, [index, "key"], current_key)
    Ops.set(@options, [index, "value"], current_value)
    RedrawOptionsTableWidget()
    return nil
  end

  nil
end

- (Object) HandleExpertForwardersPage(key, event)

Handle events in a tab of a dialog



1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
# File '../../src/include/dns-server/dialog-main.rb', line 1086

def HandleExpertForwardersPage(key, event)
  event = deep_copy(event)
  ret = Ops.get(event, "ID")

  if ret == "forwarders_add_ip_address"
    new_addr = Convert.to_string(
      UI.QueryWidget(Id("forwarders_new_ip_address"), :Value)
    )
    # both IPv4 and IPv6
    if !IP.Check(new_addr)
      Report.Error(
        Ops.add(
          Ops.add(
            Ops.add(_("Invalid IPv4 or IPv6 address.") + "\n", IP.Valid4),
            "\n"
          ),
          _(
            "A valid IPv6 address consists of letters a-f, numbers,\nand colons."
          )
        )
      )
      return nil
    end

    used_ips = CurrentlyUsedIPs(false)
    if Builtins.contains(used_ips, new_addr)
      new_addr = ChangeIPToLocalEquivalent(new_addr)
      return nil if new_addr == nil
    end

    if Builtins.contains(@forwarders, new_addr)
      # error report
      Report.Error(_("The specified forwarder is already present."))
      return nil
    end
    @forwarders = Builtins.add(@forwarders, new_addr)
  elsif ret == "forwarders_delete_ip_address"
    old_addr = Convert.to_string(
      UI.QueryWidget(Id("forwarders_list"), :CurrentItem)
    )
    Builtins.y2error("DA: %1", old_addr)
    @forwarders = Builtins.filter(@forwarders) { |f| f != old_addr }
  elsif ret == "forwarder_policy"
    handlePolicy(
      Convert.to_symbol(UI.QueryWidget(Id("forwarder_policy"), :Value))
    )
  end

  RedrawForwardersListWidget()
  nil
end

- (Object) HandleExpertLoggingPage(key, event)



1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
# File '../../src/include/dns-server/dialog-main.rb', line 1723

def HandleExpertLoggingPage(key, event)
  event = deep_copy(event)
  ret = Ops.get(event, "ID")
  if ret == "log_type_system" || ret == "log_type_file"
    en = UI.QueryWidget(Id("log_type"), :CurrentButton) == "log_type_file"
    Builtins.foreach(
      ["logfile_path", "browse_logfile_path", "max_size", "max_versions"]
    ) { |w| UI.ChangeWidget(Id(w), :Enabled, en) }
  elsif ret == "browse_logfile_path"
    fn = Convert.to_string(UI.QueryWidget(Id("logfile_path"), :Value))
    fn = UI.AskForSaveFileName(
      fn,
      "",
      # popup headline
      _("Select File for Log")
    )
    UI.ChangeWidget(Id("logfile_path"), :Value, fn) if fn != nil
  end
  nil
end

- (Object) HandleExpertStartUpPage(key, event)

Handle events in a tab of a dialog



695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
# File '../../src/include/dns-server/dialog-main.rb', line 695

def HandleExpertStartUpPage(key, event)
  event = deep_copy(event)
  ret = Ops.get(event, "ID")
  if ret == "start_dns_now"
    status = DnsServer.StartDnsService
    if !status
      # error report
      Report.Error(Message.CannotStartService("named"))
    else
      Builtins.sleep(500)
      UpdateServiceStatusWidget()
    end
  elsif ret == "stop_dns_now"
    status = DnsServer.StopDnsService
    if !status
      # error report
      Report.Error(Message.CannotStopService("named"))
    else
      Builtins.sleep(500)
      UpdateServiceStatusWidget()
    end
  elsif ret == "use_ldap"
    # yes-no popup
    #	if (! Popup::YesNo (
    popup = _(
      "All your changes will be lost. Settings will\n" +
        "be reread from new data storage.\n" +
        "Continue?\n"
    ) #))
    #	{
    #	    return nil;
    #	}
    use_ldap = Convert.to_boolean(UI.QueryWidget(Id("use_ldap"), :Value))
    successful = DnsServer.SetUseLdap(use_ldap)
    if successful && !Mode.config
      DnsServer.InitYapiConfigOptions({ "use_ldap" => use_ldap })
      # error reported in SetUseLdap
      DnsServer.LdapInit(true, false)
      DnsServer.CleanYapiConfigOptions
    end
    use_ldap = DnsServer.GetUseLdap
    UI.ChangeWidget(Id("use_ldap"), :Value, use_ldap)
  end
  nil
end

- (Object) HandleExpertZonesPage(key, event)

Handle events in a tab of a dialog



2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
# File '../../src/include/dns-server/dialog-main.rb', line 2235

def HandleExpertZonesPage(key, event)
  event = deep_copy(event)
  ret = Ops.get(event, "ID")
  index = Convert.to_integer(
    UI.QueryWidget(Id("zones_list_table"), :CurrentItem)
  )

  if ret == "delete_zone"
    # Confirm deleting zone
    return nil if !Confirm.DeleteSelected

    Ops.set(@zones, index, nil)
    @zones = Builtins.filter(@zones) { |z| z != nil }
    DnsServer.StoreZones(@zones)
    RedrawZonesListWidget()
    return nil
  elsif ret == "add_zone"
    zone_name = Convert.to_string(
      UI.QueryWidget(Id("new_zone_name"), :Value)
    )
    zone_type = Convert.to_string(
      UI.QueryWidget(Id("new_zone_type"), :Value)
    )



    # IPv6 zone name in forward format
    # e.g., "3ffe:ffff::210:a4ff:fe01:1/48"
    if Builtins.regexpmatch(zone_name, "^[:0-9A-Fa-f]+/[0-9]+$")
      zone_name = TransformToReverseIPv6ZoneName(zone_name) 
      # e.g., "3ffe:ffff::210:a4ff:fe01:1" without bits
    elsif IP.Check6(zone_name)
      zone_name = TransformToReverseIPv6ZoneName(Ops.add(zone_name, "/64"))
    end

    # Do not add the final dot to the zone name
    if Builtins.regexpmatch(zone_name, "\\.+$")
      zone_name = Builtins.regexpsub(zone_name, "(.*)\\.+$", "\\1")
    end

    encoded_zone_name = Punycode.EncodeDomainName(zone_name)

    # zone validation
    if Hostname.CheckDomain(encoded_zone_name) != true
      UI.SetFocus(Id("new_zone_name"))
      # FIXME: another message!
      Popup.Error(Hostname.ValidDomain)
      return nil
    end

    zones_same = Builtins.filter(@zones) do |z2|
      Ops.get_string(z2, "zone", "") == encoded_zone_name
    end
    if Builtins.size(zones_same) != 0
      UI.SetFocus(Id("new_zone_name"))
      # error report
      Popup.Error(
        _("A zone with the specified name is already configured.")
      )
      return nil
    end

    DnsServer.StoreZones(@zones)
    DnsServer.SelectZone(-1)
    z = DnsServer.FetchCurrentZone
    z = Convert.convert(
      Builtins.union(
        z,
        { "zone" => encoded_zone_name, "type" => zone_type }
      ),
      :from => "map",
      :to   => "map <string, any>"
    )

    Builtins.y2milestone("Created zone: %1 (%2)", z, zone_name)
    DnsServer.StoreCurrentZone(z)
    DnsServer.StoreZone
    @zones = DnsServer.FetchZones
    RedrawZonesListWidget()

    # fixing bug #45950, slave zone _MUST_ have master server
    if zone_type == "slave"
      DnsServer.SelectZone(Ops.subtract(Builtins.size(@zones), 1))
      @current_zone = DnsServer.FetchCurrentZone
      return :edit_zone
    end
  elsif ret == "edit_zone"
    # next time, the initial screen will be "zones"
    @initial_screen = "zones"
    DnsServer.SelectZone(index)
    @current_zone = DnsServer.FetchCurrentZone
    return :edit_zone
  end

  nil
end

- (Object) handlePolicy(policy)



915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
# File '../../src/include/dns-server/dialog-main.rb', line 915

def handlePolicy(policy)
  if policy == :nomodify
    UI.ChangeWidget(Id("custom_policy"), :Enabled, false)
    UI.ChangeWidget(Id("custom_policy"), :Value, "")
    UI.ChangeWidget(Id("forwarders_new_ip_address"), :Enabled, false)
    UI.ChangeWidget(Id("forwarders_add_ip_address"), :Enabled, false)
    UI.ChangeWidget(Id("forwarder"), :Enabled, false)
  else
    if policy == :custom
      # preinitialize with STATIC
      UI.ChangeWidget(Id("custom_policy"), :Value, "STATIC")
      UI.ChangeWidget(Id("custom_policy"), :Enabled, true)
    else
      if policy == :static
        UI.ChangeWidget(Id("custom_policy"), :Value, "STATIC")
      elsif policy == :auto
        UI.ChangeWidget(Id("custom_policy"), :Value, "auto")
      end
      UI.ChangeWidget(Id("custom_policy"), :Enabled, false)
    end

    UI.ChangeWidget(Id("forwarders_new_ip_address"), :Enabled, true)
    UI.ChangeWidget(Id("forwarders_add_ip_address"), :Enabled, true)
    UI.ChangeWidget(Id("forwarder"), :Enabled, true)
  end

  nil
end

- (Object) InitDNSSErverIcon(key)

Sets the dialog icon



662
663
664
665
666
# File '../../src/include/dns-server/dialog-main.rb', line 662

def InitDNSSErverIcon(key)
  SetDNSSErverIcon()

  nil
end

- (Object) InitExpertAclPage(key)

Initialize the tab of the dialog



1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
# File '../../src/include/dns-server/dialog-main.rb', line 1866

def InitExpertAclPage(key)
  SetDNSSErverIcon()
  @acl = DnsServer.GetAcl
  UI.ChangeWidget(
    Id("new_acl_name"),
    :ValidChars,
    "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-"
  )
  RedrawAclPage()

  nil
end

- (Object) InitExpertBasicOptionsPage(key)

Initialize the tab of the dialog



1295
1296
1297
1298
1299
1300
1301
1302
# File '../../src/include/dns-server/dialog-main.rb', line 1295

def InitExpertBasicOptionsPage(key)
  SetDNSSErverIcon()
  @options = DnsServer.GetGlobalOptions
  @current_option_index = 0
  RedrawOptionsTableWidget()

  nil
end

- (Object) InitExpertForwardersPage(key)

Initialize the tab of the dialog



958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
# File '../../src/include/dns-server/dialog-main.rb', line 958

def InitExpertForwardersPage(key)
  SetDNSSErverIcon()

  UI.ChangeWidget(Id("custom_policy"), :Enabled, false)
  policy = DnsServer.GetNetconfigDNSPolicy
  policy_symb = :Empty

  if policy == nil || policy == ""
    policy_symb = :nomodify
  elsif policy == "auto" || policy == "STATIC *"
    policy_symb = :auto
  elsif policy == "STATIC"
    policy_symb = :static
  else
    policy_symb = :custom
  end

  UI.ChangeWidget(Id("forwarder_policy"), :Value, policy_symb)
  handlePolicy(policy_symb)
  initialize_local_forwarder
  ReadForwarders()
  RedrawForwardersListWidget()
  ValidCharsForwardersPage()

  nil
end

- (Object) InitExpertLoggingPage(key)

Initialize the tab of the dialog



1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
# File '../../src/include/dns-server/dialog-main.rb', line 1593

def InitExpertLoggingPage(key)
  SetDNSSErverIcon()
  channel = DnsServerAPI.GetLoggingChannel
  if Ops.get(channel, "destination") == "file"
    UI.ChangeWidget(Id("log_type"), :CurrentButton, "log_type_file")
    UI.ChangeWidget(
      Id("max_versions"),
      :Value,
      Builtins.tointeger(Ops.get(channel, "versions", "0"))
    )
    UI.ChangeWidget(
      Id("logfile_path"),
      :Value,
      Ops.get(channel, "filename", "")
    )

    sz = 0
    su = ""
    # if size is defined and
    if Ops.get(channel, "size") != nil &&
        Ops.greater_than(
          Builtins.tointeger(Ops.get(channel, "size", "0")),
          0
        )
      sz = Builtins.tointeger(
        Builtins.regexpsub(
          Ops.get(channel, "size", ""),
          "([0123456789]+)",
          "\\1"
        )
      )
      # size is only number, no unit assigned
      if Ops.get(channel, "size") != Builtins.tostring(sz)
        su = Builtins.tolower(
          Builtins.regexpsub(
            Ops.get(channel, "size", ""),
            "[0123456789]+([kKmMgG])",
            "\\1"
          )
        )
      end
    end
    if su != nil
      # no unit = in Bytes
      if su == ""
        sz = Builtins.tointeger(
          Ops.add(
            Convert.convert(
              Ops.divide(Ops.divide(sz, 1024), 1024),
              :from => "integer",
              :to   => "float"
            ),
            0.5
          )
        )
      elsif su == "k"
        sz = Builtins.tointeger(
          Ops.add(
            Convert.convert(
              Ops.divide(sz, 1024),
              :from => "integer",
              :to   => "float"
            ),
            0.5
          )
        )
      # else if (su == "m") {} # M is the default unit
      elsif su == "g"
        sz = Ops.multiply(sz, 1024)
      end
    end
    UI.ChangeWidget(Id("max_size"), :Value, sz) if sz != nil
  else
    UI.ChangeWidget(Id("log_type"), :CurrentButton, "log_type_system")
  end

  categories = DnsServerAPI.GetLoggingCategories
  if Builtins.contains(categories, "queries")
    UI.ChangeWidget(Id("l_named_queries"), :Value, true)
  end
  if Builtins.contains(categories, "xfer-in")
    UI.ChangeWidget(Id("l_zone_updates"), :Value, true)
  end
  if Builtins.contains(categories, "xfer-out")
    UI.ChangeWidget(Id("l_zone_transfers"), :Value, true)
  end

  HandleExpertLoggingPage(key, { "ID" => "log_type_system" })

  nil
end

- (Object) InitExpertStartUpPage(key)

Initialize the tab of the dialog



669
670
671
672
673
674
675
676
677
678
679
680
681
682
# File '../../src/include/dns-server/dialog-main.rb', line 669

def InitExpertStartUpPage(key)
  SetDNSSErverIcon()
  auto_start = DnsServer.GetStartService
  UI.ChangeWidget(
    Id("dns_server_type"),
    :CurrentButton,
    auto_start ? :on : :off
  )
  use_ldap = DnsServer.GetUseLdap
  UI.ChangeWidget(Id("use_ldap"), :Value, use_ldap)
  UpdateServiceStatusWidget()

  nil
end

- (Object) InitExpertZonesPage(key)

Initialize the tab of the dialog



2187
2188
2189
2190
2191
2192
2193
# File '../../src/include/dns-server/dialog-main.rb', line 2187

def InitExpertZonesPage(key)
  SetDNSSErverIcon()
  @zones = DnsServer.FetchZones
  RedrawZonesListWidget()

  nil
end

- (Object) initialize_dns_server_dialog_main(include_target)



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
# File '../../src/include/dns-server/dialog-main.rb', line 14

def initialize_dns_server_dialog_main(include_target)
  textdomain "dns-server"

  Yast.import "DnsServer"
  Yast.import "IP"
  Yast.import "Hostname"
  Yast.import "Popup"
  Yast.import "Label"
  Yast.import "CWM"
  Yast.import "Wizard"
  Yast.import "DialogTree"
  Yast.import "CWMServiceStart"
  Yast.import "Mode"
  Yast.import "Report"
  Yast.import "CWMFirewallInterfaces"
  Yast.import "Message"
  Yast.import "DnsRoutines"
  Yast.import "CWMTsigKeys"
  Yast.import "DnsTsigKeys"
  Yast.import "Confirm"
  Yast.import "DnsServerAPI"
  Yast.import "Punycode"
  Yast.import "DnsServerHelperFunctions"
  Yast.import "String"

  # String defines the initial screen for the expert dialog
  @initial_screen = "start_up"

  @global_options_add_items = Builtins.sort(
    [
      "additional-from-auth",
      "additional-from-cache",
      "allow-query",
      "allow-recursion",
      "allow-transfer",
      "also-notify",
      "auth-nxdomain",
      "blackhole",
      "check-names",
      "cleaning-interval",
      "coresize",
      "datasize",
      "deallocate-on-exit",
      "dialup",
      "directory",
      "dump-file",
      "fake-iquery",
      "fetch-glue",
      "files",
      "forward",
      "forwarders",
      "has-old-clients",
      "heartbeat-interval",
      "host-statistics",
      "host-statistics-max",
      "hostname",
      "interface-interval",
      "lame-ttl",
      "listen-on",
      "listen-on-v6",
      "maintain-ixfr-base",
      "match-mapped-addresses",
      "max-cache-size",
      "max-cache-ttl",
      "max-ixfr-log-size",
      "max-ncache-ttl",
      "max-refresh-time",
      "max-retry-time",
      "max-transfer-idle-in",
      "max-transfer-idle-out",
      "max-transfer-time-in",
      "max-transfer-time-out",
      "memstatistics-file",
      "min-refresh-time",
      "min-retry-time",
      "min-roots",
      "minimal-responses",
      "multiple-cnames",
      "named-xfer",
      "notify",
      "pid-file",
      "port",
      "preferred-glue",
      "provide-ixfr",
      "query-source",
      "random-device",
      "recursion",
      "recursive-clients",
      "request-ixfr",
      "rfc2308-type1",
      "rrset-order",
      "serial-queries",
      "serial-query-rate",
      "sig-validity-interval",
      "sortlist",
      "stacksize",
      "statistics-file",
      "statistics-interval",
      "suppress-initial-notify",
      "tcp-clients",
      "tkey-dhkey",
      "tkey-domain",
      "topology",
      "transfer-format",
      "transfer-source",
      "transfers-in",
      "transfers-out",
      "transfers-per-ns",
      "treat-cr-as-space",
      "use-id-pool",
      "use-ixfr",
      "version",
      "zone-statistics"
    ]
  )

  @global_options_unique_items = Builtins.sort(
    [
      "additional-from-auth",
      "additional-from-cache",
      "auth-nxdomain",
      "cleaning-interval",
      "coresize",
      "datasize",
      "deallocate-on-exit",
      "dialup",
      "directory",
      "dump-file",
      "fake-iquery",
      "fetch-glue",
      "files",
      "forward",
      "has-old-clients",
      "heartbeat-interval",
      "host-statistics",
      "interface-interval",
      "lame-ttl",
      "maintain-ixfr-base",
      "match-mapped-addresses",
      "max-cache-size",
      "max-cache-ttl",
      "max-ixfr-log-size",
      "max-ncache-ttl",
      "max-refresh-time",
      "max-retry-time",
      "max-transfer-idle-in",
      "max-transfer-idle-out",
      "max-transfer-time-in",
      "max-transfer-time-out",
      "memstatistics-file",
      "min-refresh-time",
      "min-retry-time",
      "min-roots",
      "minimal-responses",
      "multiple-cnames",
      "named-xfer",
      "notify",
      "pid-file",
      "port",
      "provide-ixfr",
      "random-device",
      "recursion",
      "recursive-clients",
      "request-ixfr",
      "rfc2308-type1",
      "serial-queries",
      "serial-query-rate",
      "sig-validity-interval",
      "stacksize",
      "statistics-file",
      "statistics-interval",
      "tcp-clients",
      "tkey-dhkey",
      "tkey-domain",
      "transfer-format",
      "transfers-in",
      "transfers-out",
      "transfers-per-ns",
      "treat-cr-as-space",
      "use-id-pool",
      "use-ixfr",
      "version",
      "zone-statistics"
    ]
  )

  @global_options_yesno_items = Builtins.sort(
    [
      "zone-statistics",
      "auth-nxdomain",
      "deallocate-on-exit",
      "fake-iquery",
      "fetch-glue",
      "has-old-clients",
      "host-statistics",
      "minimal-responses",
      "multiple-cnames",
      "recursion",
      "rfc2308-type1",
      "use-id-pool",
      "maintain-ixfr-base",
      "use-ixfr",
      "provide-ixfr",
      "request-ixfr",
      "treat-cr-as-space",
      "additional-from-auth",
      "additional-from-cache",
      "match-mapped-addresses"
    ]
  )

  @global_options_number_items = Builtins.sort(
    [
      "max-transfer-time-in",
      "max-transfer-time-out",
      "max-transfer-idle-in",
      "max-transfer-idle-out",
      "tcp-clients",
      "recursive-clients",
      "serial-query-rate",
      "serial-queries",
      "transfers-in",
      "transfers-out",
      "transfers-per-ns",
      "max-ixfr-log-size",
      "cleaning-interval",
      "heartbeat-interval",
      "interface-interval",
      "statistics-interval",
      "lame-ttl",
      "max-ncache-ttl",
      "max-cache-ttl",
      "sig-validity-interval",
      "min-roots",
      "min-refresh-time",
      "max-refresh-time",
      "min-retry-time",
      "max-retry-time"
    ]
  )

  # Dialog label DNS - expert settings
  @dns_server_label = _("DNS Server")

  @new_widgets = {
    "auto_start_up" => CWMServiceStart.CreateAutoStartWidget(
      {
        "get_service_auto_start" => fun_ref(
          DnsServer.method(:GetStartService),
          "boolean ()"
        ),
        "set_service_auto_start" => fun_ref(
          DnsServer.method(:SetStartService),
          "void (boolean)"
        ),
        # radio button (starting DNS service - option 1)
        "start_auto_button"      => _(
          "When &Booting"
        ),
        # radio button (starting DNS service - option 2)
        "start_manual_button"    => _(
          "&Manually"
        ),
        "help"                   => Builtins.sformat(
          CWMServiceStart.AutoStartHelpTemplate,
          # part of help text, used to describe radiobuttons (matching starting DNS service but without "&")
          _("When Booting"),
          # part of help text, used to describe radiobuttons (matching starting DNS service but without "&")
          _("Manually")
        )
      }
    ),
    "start_stop"    => CWMServiceStart.CreateStartStopWidget(
      {
        "service_id"                => "named",
        # label - service status, informative text
        "service_running_label"     => _(
          "DNS server is running."
        ),
        # label - service status, informative text
        "service_not_running_label" => _(
          "DNS server is not running."
        ),
        # push button (DNS service handling)
        "start_now_button"          => _(
          "&Start DNS Server Now"
        ),
        # push button (DNS service handling)
        "stop_now_button"           => _(
          "S&top DNS Server Now"
        ),
        "save_now_action"           => fun_ref(
          method(:SaveAndRestart),
          "void ()"
        ),
        # push button (DNS service handling)
        "save_now_button"           => _(
          "Save Settings and Reload DNS Server &Now"
        ),
        "help"                      => Builtins.sformat(
          CWMServiceStart.StartStopHelpTemplate(true),
          # part of help text, used to describe pusbuttons (matching DNS service handling but without "&")
          _("Start DNS Server Now"),
          # part of help text, used to describe pusbuttons (matching DNS service handling but without "&")
          _("Stop DNS Server Now"),
          # part of help text, used to describe pusbuttons (matching DNS service handling but without "&")
          _("Save Settings and Reload DNS Server Now")
        )
      }
    ),
    "firewall"      => CWMFirewallInterfaces.CreateOpenFirewallWidget(
      { "services" => ["service:bind"], "display_details" => true }
    ),
    "use_ldap"      => CWMServiceStart.CreateLdapWidget(
      {
        "get_use_ldap"      => fun_ref(
          DnsServer.method(:GetUseLdap),
          "boolean ()"
        ),
        "set_use_ldap"      => fun_ref(
          DnsServer.method(:SetUseLdap),
          "boolean (boolean)"
        ),
        # TRANSLATORS: checkbox label, turning LDAP support on or off
        "use_ldap_checkbox" => _(
          "&LDAP Support Active"
        ),
        "help"              => CWMServiceStart.EnableLdapHelp
      }
    ),
    "forwarders"    => {
      "widget"        => :custom,
      "custom_widget" => VBox(),
      "init"          => fun_ref(
        method(:InitExpertForwardersPage),
        "void (string)"
      ),
      "handle"        => fun_ref(
        method(:HandleExpertForwardersPage),
        "symbol (string, map)"
      ),
      "store"         => fun_ref(
        method(:StoreExpertForwardersPage),
        "void (string, map)"
      ),
      "help"          => Ops.get_string(@HELPS, "forwarders", "")
    },
    "basic_options" => {
      "widget"        => :custom,
      "custom_widget" => VBox(),
      "init"          => fun_ref(
        method(:InitExpertBasicOptionsPage),
        "void (string)"
      ),
      "handle"        => fun_ref(
        method(:HandleExpertBasicOptionsPage),
        "symbol (string, map)"
      ),
      "store"         => fun_ref(
        method(:StoreExpertBasicOptionsPage),
        "void (string, map)"
      ),
      "help"          => Ops.get_string(@HELPS, "basic_options", "")
    },
    "logging"       => {
      "widget"        => :custom,
      "custom_widget" => VBox(),
      "init"          => fun_ref(
        method(:InitExpertLoggingPage),
        "void (string)"
      ),
      "handle"        => fun_ref(
        method(:HandleExpertLoggingPage),
        "symbol (string, map)"
      ),
      "store"         => fun_ref(
        method(:StoreExpertLoggingPage),
        "void (string, map)"
      ),
      "help"          => Ops.get_string(@HELPS, "logging", "")
    },
    "acls"          => {
      "widget"        => :custom,
      "custom_widget" => VBox(),
      "init"          => fun_ref(
        method(:InitExpertAclPage),
        "void (string)"
      ),
      "handle"        => fun_ref(
        method(:HandleExpertAclPage),
        "symbol (string, map)"
      ),
      "store"         => fun_ref(
        method(:StoreExpertAclPage),
        "void (string, map)"
      ),
      "help"          => Ops.get_string(@HELPS, "acls", "")
    },
    "tsig_keys"     => CWMTsigKeys.CreateWidget(
      {
        "get_keys_info" => fun_ref(
          DnsTsigKeys.method(:GetTSIGKeys),
          "map <string, any> ()"
        ),
        "set_keys_info" => fun_ref(
          DnsTsigKeys.method(:SetTSIGKeys),
          "void (map <string, any>)"
        )
      }
    ),
    "keys"          => {
      "widget"        => :custom,
      "custom_widget" => VBox(),
      "help"          => Ops.get_string(@HELPS, "keys", "")
    },
    "zones"         => {
      "widget"        => :custom,
      "custom_widget" => VBox(),
      "init"          => fun_ref(
        method(:InitExpertZonesPage),
        "void (string)"
      ),
      "handle"        => fun_ref(
        method(:HandleExpertZonesPage),
        "symbol (string, map)"
      ),
      "store"         => fun_ref(
        method(:StoreExpertZonesPage),
        "void (string, map)"
      ),
      "help"          => Ops.get_string(@HELPS, "zones", "")
    },
    "set_icon"      => {
      "widget"        => :custom,
      "custom_widget" => Empty(),
      "init"          => fun_ref(
        method(:InitDNSSErverIcon),
        "void (string)"
      ),
      "help"          => " "
    }
  }

  @tabs = {
    "start_up"      => {
      # FIXME: new startup
      "contents"        => VBox(
        "auto_start_up",
        VSpacing(),
        "firewall",
        "use_ldap",
        VSpacing(),
        "start_stop",
        VStretch()
      ),
      # Dialog Label - DNS - expert settings
      "caption"         => Ops.add(
        Ops.add(@dns_server_label, ": "),
        _("Start-Up")
      ),
      # Tree Menu Item - DNS - expert settings
      "tree_item_label" => _(
        "Start-Up"
      ),
      # FIXME: new startup
      "widget_names"    => DnsServer.ExpertUI ?
        # expert mode
        ["auto_start_up", "firewall", "use_ldap", "start_stop"] :
        # simple mode
        ["auto_start_up", "firewall", "start_stop", "set_icon"]
    },
    "forwarders"    => {
      "contents"        => ExpertForwardersDialog(),
      # Dialog Label - DNS - expert settings
      "caption"         => Ops.add(
        Ops.add(@dns_server_label, ": "),
        _("Forwarders")
      ),
      # Tree Menu Item - DNS - expert settings
      "tree_item_label" => _(
        "Forwarders"
      ),
      "widget_names"    => ["forwarders"]
    },
    "basic_options" => {
      "contents"        => ExpertBasicOptionsDialog(),
      # Dialog Label - DNS - expert settings
      "caption"         => Ops.add(
        Ops.add(@dns_server_label, ": "),
        _("Basic Options")
      ),
      # Tree Menu Item - DNS - expert settings
      "tree_item_label" => _(
        "Basic Options"
      ),
      "widget_names"    => ["basic_options"]
    },
    "logging"       => {
      "contents"        => Expert_Logging_Dialog(),
      # Dialog Label - DNS - expert settings
      "caption"         => Ops.add(
        Ops.add(@dns_server_label, ": "),
        _("Logging")
      ),
      "tree_item_label" => _("Logging"),
      # Tree Menu Item - DNS - expert settings
      "widget_names"    => [
        "logging"
      ]
    },
    "acls"          => {
      "contents"        => Expert_ACLs_Dialog(),
      # Dialog Label - DNS - expert settings
      "caption"         => Ops.add(
        Ops.add(@dns_server_label, ": "),
        _("ACLs")
      ),
      # Tree Menu Item - DNS - expert settings
      "tree_item_label" => _(
        "ACLs"
      ),
      "widget_names"    => ["acls"]
    },
    "keys"          => {
      "contents"        => HBox(
        HSpacing(2),
        VBox(VSpacing(1), "tsig_keys", VSpacing(1)),
        HSpacing(2)
      ),
      # Dialog Label - DNS - expert settings
      "caption"         => Ops.add(
        Ops.add(@dns_server_label, ": "),
        _("TSIG Keys")
      ),
      # Tree Menu Item - DNS - expert settings
      "tree_item_label" => _(
        "TSIG Keys"
      ),
      "widget_names"    => ["tsig_keys"],
      "widget_descr"    => @new_widgets
    },
    "zones"         => {
      "contents"        => ExpertZonesDialog(),
      # Dialog Label - DNS - expert settings
      "caption"         => Ops.add(
        Ops.add(@dns_server_label, ": "),
        _("DNS Zones")
      ),
      # Tree Menu Item - DNS - expert settings
      "tree_item_label" => _(
        "DNS Zones"
      ),
      "widget_names"    => ["zones"]
    }
  }

  @functions = { :abort => fun_ref(method(:confirmAbort), "boolean ()") }
end

- (Object) initialize_local_forwarder



944
945
946
947
948
949
950
951
952
953
954
955
# File '../../src/include/dns-server/dialog-main.rb', line 944

def initialize_local_forwarder
  local_forwarder = DnsServer.GetLocalForwarder

  if local_forwarder != DnsServerUIClass::PREFERRED_LOCAL_FORWARDER && DnsServer.first_run
    Builtins.y2milestone(
      "Current local forwarder: #{local_forwarder}, proposing new: #{DnsServerUIClass::PREFERRED_LOCAL_FORWARDER}"
    )
    local_forwarder = DnsServerUIClass::PREFERRED_LOCAL_FORWARDER
  end

  UI.ChangeWidget(Id("forwarder"), :Value, local_forwarder.to_sym)
end

- (Object) IsAclDefined(new_name, acls)

Testing for acls duplicity

Returns:

  • true if the name is duplicate



1889
1890
1891
1892
1893
1894
1895
1896
# File '../../src/include/dns-server/dialog-main.rb', line 1889

def IsAclDefined(new_name, acls)
  acls = deep_copy(acls)
  return true if Builtins.foreach(acls) do |acl|
    splitted = Builtins.splitstring(acl, " \t")
    next true if new_name == Ops.get(splitted, 0, "")
  end == true
  false
end

- (Object) IsUniqueOption(option)

Return if the option must be unique in configuration or not



1313
1314
1315
1316
# File '../../src/include/dns-server/dialog-main.rb', line 1313

def IsUniqueOption(option)
  # global_options_unique_items is a list of known unique records
  Builtins.contains(@global_options_unique_items, option)
end

- (Object) OptionIsSetYet(option)

Returns if the option was set yet



1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
# File '../../src/include/dns-server/dialog-main.rb', line 1319

def OptionIsSetYet(option)
  if Ops.greater_than(
      Builtins.size(
        # filters all records whith key = option
        Builtins.filter(@options) do |option_record|
          Ops.get(option_record, "key") == option
        end # options are list, size returns count of records
      ),
      0
    )
    return true
  end
  false
end

- (Object) OptionsIsNumberType(option)

Returns if the option must be a number



1340
1341
1342
# File '../../src/include/dns-server/dialog-main.rb', line 1340

def OptionsIsNumberType(option)
  Builtins.contains(@global_options_number_items, option)
end

- (Object) OptionsIsYesNoType(option)

Returns if the option must be “yes” or “no”



1335
1336
1337
# File '../../src/include/dns-server/dialog-main.rb', line 1335

def OptionsIsYesNoType(option)
  Builtins.contains(@global_options_yesno_items, option)
end

- (Object) ReadForwarders



880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
# File '../../src/include/dns-server/dialog-main.rb', line 880

def ReadForwarders
  options = DnsServer.GetGlobalOptions
  Builtins.foreach(options) do |o|
    if Ops.get_string(o, "key", "") == "forwarders"
      @forwarders = Builtins.splitstring(
        Ops.get_string(o, "value", ""),
        " "
      )
      @forwarders = Builtins.filter(@forwarders) do |f|
        !Builtins.issubstring(f, "{") && !Builtins.issubstring(f, "}") &&
          f != ""
      end
      @forwarders = Builtins.maplist(@forwarders) do |f|
        i = Builtins.findfirstof(f, ";")
        f = Builtins.substring(f, 0, i) if i != nil
        f
      end
    end
  end

  nil
end

- (Object) ReallyRemoveACL(acl_name)

Really remove used ACL? (dialog)



1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
# File '../../src/include/dns-server/dialog-main.rb', line 1924

def ReallyRemoveACL(acl_name)
  zones_where_acl_used = GetZonesWithAclUsed(acl_name)

  if Ops.greater_than(Builtins.size(zones_where_acl_used), 0)
    return Popup.ContinueCancel(
      Builtins.sformat(
        # A popup question, %1 is number of zones
        _("This ACL is used by %1 zones.\nReally remove it?\n"),
        Builtins.size(zones_where_acl_used)
      )
    )
  else
    return true
  end
end

- (Object) RedrawAclPage



1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
# File '../../src/include/dns-server/dialog-main.rb', line 1842

def RedrawAclPage
  index = -1
  items = Builtins.maplist(@acl) do |a|
    index = Ops.add(index, 1)
    while Builtins.substring(a, 0, 1) == " " ||
        Builtins.substring(a, 0, 1) == "\t"
      a = Builtins.substring(a, 1)
    end
    s = Builtins.splitstring(a, " \t")
    type = Ops.get(s, 0, "")
    Ops.set(s, 0, "")
    a = Builtins.mergestring(s, " ")
    while Builtins.substring(a, 0, 1) == " " ||
        Builtins.substring(a, 0, 1) == "\t"
      a = Builtins.substring(a, 1)
    end
    Item(Id(index), type, a)
  end
  UI.ChangeWidget(Id("acl_listing_table"), :Items, items)

  nil
end

- (Object) RedrawForwardersListWidget



850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
# File '../../src/include/dns-server/dialog-main.rb', line 850

def RedrawForwardersListWidget
  UI.ReplaceWidget(
    Id("forwarders_list_rp"),
    SelectionBox(
      Id("forwarders_list"),
      Opt(:hstretch),
      # Selectionbox for listing current DNS-Forwarders
      _("Forwarder &List"),
      @forwarders
    )
  )
  enabled = :nomodify !=
    Convert.to_symbol(UI.QueryWidget(Id("forwarder_policy"), :Value))
  UI.ChangeWidget(
    Id("forwarders_delete_ip_address"),
    :Enabled,
    @forwarders != [] && enabled
  )
  UI.ChangeWidget(Id("forwarders_list"), :Enabled, enabled)
  if @forwarders != [] && enabled
    UI.ChangeWidget(
      Id("forwarders_list"),
      :CurrentItem,
      Ops.get(@forwarders, 0, "")
    )
  end

  nil
end

- (Object) RedrawOptionsTableWidget



1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
# File '../../src/include/dns-server/dialog-main.rb', line 1268

def RedrawOptionsTableWidget
  current = Convert.to_integer(
    UI.QueryWidget(Id("basic_options_table"), :CurrentItem)
  )
  index = -1
  UI.ChangeWidget(
    Id("basic_options_table"),
    :Items,
    Builtins.maplist(@options) do |o|
      index = Ops.add(index, 1)
      Item(Id(index), Ops.get_string(o, "key", ""), Ops.get(o, "value"))
    end
  )
  if current != nil && Ops.less_than(current, Builtins.size(@options))
    UI.ChangeWidget(Id("basic_options_table"), :CurrentItem, current)
  end
  UI.ChangeWidget(
    Id("delete_basic_option"),
    :Enabled,
    Ops.greater_than(Builtins.size(@options), 0)
  )
  ReinitializeOptionAddWidgets()

  nil
end

- (Object) RedrawZonesListWidget



2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
# File '../../src/include/dns-server/dialog-main.rb', line 2123

def RedrawZonesListWidget
  # Translating of all zone names at once
  encoded_zone_names = Builtins.maplist(@zones) do |z|
    Ops.get_string(z, "zone", "")
  end
  decoded_zone_names = Punycode.DocodeDomainNames(encoded_zone_names)
  index = -1
  # Creating map $[encoded:decoded]
  enc_to_dec = Builtins.listmap(encoded_zone_names) do |enc_zone|
    index = Ops.add(index, 1)
    { enc_zone => Ops.get(decoded_zone_names, index, "") }
  end

  index = -1
  items = Builtins.maplist(@zones) do |z|
    index = Ops.add(index, 1)
    zone_name = Ops.get_string(z, "zone", "")
    # filtering out default zones
    next Item() if DnsServerHelperFunctions.IsInternalZone(zone_name)
    type_trans = ""
    case Ops.get_string(z, "type", "master")
      when "master"
        # TRANSLATORS: Table item - Server type
        type_trans = _("Master")
      when "slave"
        # TRANSLATORS: Table item - Server type
        type_trans = _("Slave")
      when "stub"
        # TRANSLATORS: Table item - Server type
        type_trans = _("Slave")
      when "forward"
        # TRANSLATORS: Table item - Server type
        type_trans = _("Forward")
      else
        Builtins.y2warning("Unknown zone type %1", type_trans)
    end
    Item(Id(index), Ops.get(enc_to_dec, zone_name, zone_name), type_trans)
  end

  # Filtering out empty items
  items = Builtins.filter(items) { |i| i != Item() }

  # Sorting by the zone name (might have different sorting than UI)
  items = Builtins.sort(items) do |x, y|
    Ops.less_than(Ops.get_string(x, 1, ""), Ops.get_string(y, 1, ""))
  end

  UI.ChangeWidget(Id("zones_list_table"), :Items, items)
  UI.SetFocus(Id("zones_list_table"))
  UI.ChangeWidget(
    Id("delete_zone"),
    :Enabled,
    Ops.greater_than(Builtins.size(items), 0)
  )
  UI.ChangeWidget(
    Id("edit_zone"),
    :Enabled,
    Ops.greater_than(Builtins.size(items), 0)
  )

  nil
end

- (Object) ReinitializeOptionAddWidgets



1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
# File '../../src/include/dns-server/dialog-main.rb', line 1245

def ReinitializeOptionAddWidgets
  current_opt = Convert.to_integer(
    UI.QueryWidget(Id("basic_options_table"), :CurrentItem)
  )
  o = Ops.get(@options, current_opt, {})
  if o == {}
    UI.ChangeWidget(Id("basic_option_value"), :Value, "")
  else
    UI.ChangeWidget(
      Id("basic_option_value"),
      :Value,
      Ops.get_string(o, "value", "")
    )
    UI.ChangeWidget(
      Id("basic_option_selection"),
      :Value,
      Ops.get_string(o, "key", "")
    )
  end

  nil
end

- (Symbol) runExpertDialog

Dialog Expert Settings

Returns:

  • (Symbol)

    for the wizard sequencer



2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
# File '../../src/include/dns-server/dialog-main.rb', line 2363

def runExpertDialog
  expert_dialogs = [
    "start_up",
    "forwarders",
    "basic_options",
    "logging",
    "acls",
    "keys",
    "zones"
  ]
  normal_dialog = ["start_up", "forwarders", "logging", "zones"]

  DialogTree.ShowAndRun(
    {
      "ids_order"      => DnsServer.ExpertUI ? expert_dialogs : normal_dialog,
      "initial_screen" => @initial_screen,
      "screens"        => @tabs,
      "widget_descr"   => @new_widgets,
      "back_button"    => "",
      "abort_button"   => Label.CancelButton,
      "next_button"    => Label.OKButton,
      "functions"      => @functions
    }
  )
end

- (Object) SaveAndRestart



2332
2333
2334
2335
2336
2337
2338
2339
2340
# File '../../src/include/dns-server/dialog-main.rb', line 2332

def SaveAndRestart
  Wizard.CreateDialog
  Wizard.RestoreHelp(Ops.get_string(@HELPS, "write", ""))
  DnsServer.Write
  Builtins.sleep(1000)
  UI.CloseDialog

  nil
end

- (Object) StoreExpertAclPage(key, event)

Store settings of a tab of a dialog



1880
1881
1882
1883
1884
1885
# File '../../src/include/dns-server/dialog-main.rb', line 1880

def StoreExpertAclPage(key, event)
  event = deep_copy(event)
  DnsServer.SetAcl(@acl)

  nil
end

- (Object) StoreExpertBasicOptionsPage(key, event)

Store settings of a tab of a dialog



1305
1306
1307
1308
1309
1310
# File '../../src/include/dns-server/dialog-main.rb', line 1305

def StoreExpertBasicOptionsPage(key, event)
  event = deep_copy(event)
  DnsServer.SetGlobalOptions(@options)

  nil
end

- (Object) StoreExpertForwardersPage(key, event)

Store settings of a tab of a dialog



986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
# File '../../src/include/dns-server/dialog-main.rb', line 986

def StoreExpertForwardersPage(key, event)
  event = deep_copy(event)

  policy = Convert.to_symbol(UI.QueryWidget(Id("forwarder_policy"), :Value))
  new_dns_policy = case policy
    when :custom   then UI.QueryWidget(Id("custom_policy"), :Value)
    when :auto     then "auto"
    when :static   then "static"
    when :nomodify then ""
    else raise ArgumentError.new("Unknown forwarder_policy '#{policy}'")
  end
  DnsServer.SetNetconfigDNSPolicy(new_dns_policy)

  forwarder = (UI.QueryWidget(Id("forwarder"), :Value)).to_s
  if ! DnsServer.SetLocalForwarder(forwarder)
    Report.Error(_("Cannot set local forwarder to %{forwarder}") % { 'forwarder' => forwarder })
  end

  options = DnsServer.GetGlobalOptions
  options = Builtins.filter(options) do |o|
    Ops.get_string(o, "key", "") != "forwarders" # && o["key"]:"" != "forward"
  end
  if @forwarders != []
    forwarders_str = Builtins.mergestring(@forwarders, "; ")
    forwarders_str = Builtins.sformat("{ %1; }", forwarders_str)
    options = Builtins.add(
      options,
      { "key" => "forwarders", "value" => forwarders_str }
    )
  end

  DnsServer.SetGlobalOptions(options)

  nil
end

- (Object) StoreExpertLoggingPage(key, event)

Store settings of a tab of a dialog



1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
# File '../../src/include/dns-server/dialog-main.rb', line 1686

def StoreExpertLoggingPage(key, event)
  event = deep_copy(event)
  used_categories = []
  if Convert.to_boolean(UI.QueryWidget(Id("l_named_queries"), :Value))
    used_categories = Builtins.add(used_categories, "queries")
  end
  if Convert.to_boolean(UI.QueryWidget(Id("l_zone_updates"), :Value))
    used_categories = Builtins.add(used_categories, "xfer-in")
  end
  if Convert.to_boolean(UI.QueryWidget(Id("l_zone_transfers"), :Value))
    used_categories = Builtins.add(used_categories, "xfer-out")
  end
  DnsServerAPI.SetLoggingCategories(used_categories)

  use_file = UI.QueryWidget(Id("log_type"), :CurrentButton) == "log_type_file"
  if use_file
    DnsServerAPI.SetLoggingChannel(
      {
        "destination" => "file",
        "filename"    => Convert.to_string(
          UI.QueryWidget(Id("logfile_path"), :Value)
        ),
        "size"        => Ops.add(
          Builtins.tostring(UI.QueryWidget(Id("max_size"), :Value)),
          "M"
        ),
        "versions"    => Builtins.tostring(
          UI.QueryWidget(Id("max_versions"), :Value)
        )
      }
    )
  else
    DnsServerAPI.SetLoggingChannel({ "destination" => "syslog" })
  end

  nil
end

- (Object) StoreExpertStartUpPage(key, event)

Store settings of a tab of a dialog



685
686
687
688
689
690
691
692
# File '../../src/include/dns-server/dialog-main.rb', line 685

def StoreExpertStartUpPage(key, event)
  event = deep_copy(event)
  auto_start = UI.QueryWidget(Id("dns_server_type"), :CurrentButton) == :on
  use_ldap = Convert.to_boolean(UI.QueryWidget(Id("use_ldap"), :Value))
  DnsServer.SetStartService(auto_start)

  nil
end

- (Object) StoreExpertZonesPage(key, event)

Store settings of a tab of a dialog



2196
2197
2198
2199
# File '../../src/include/dns-server/dialog-main.rb', line 2196

def StoreExpertZonesPage(key, event)
  event = deep_copy(event)
  nil
end

- (Object) TransformToReverseIPv6ZoneName(zone_name)



2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
# File '../../src/include/dns-server/dialog-main.rb', line 2201

def TransformToReverseIPv6ZoneName(zone_name)
  if !Builtins.regexpmatch(zone_name, "^[:0-9A-Fa-f]+/[0-9]+$")
    Builtins.y2error("No a required format: %1", zone_name)
    return zone_name
  end

  zone_translated = Builtins.regexpsub(
    zone_name,
    "^([:0-9A-Fa-f]+)/[0-9]+$",
    "\\1"
  )
  zone_bits = Builtins.tointeger(
    Builtins.regexpsub(zone_name, "^[:0-9A-Fa-f]+/([0-9]+)$", "\\1")
  )

  zone_translated = DnsServerAPI.GetReverseIPforIPv6(zone_translated)
  zone_bits = 128 if Ops.greater_than(zone_bits, 128)
  zone_bits = Ops.divide(zone_bits, 4)

  zone_translated = Builtins.substring(
    zone_translated,
    Ops.multiply(2, zone_bits)
  )

  Builtins.y2milestone(
    "Guessing zone: '%1' from '%2'",
    zone_translated,
    zone_name
  )

  zone_translated
end

- (Object) UpdateServiceStatusWidget



637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
# File '../../src/include/dns-server/dialog-main.rb', line 637

def UpdateServiceStatusWidget
  if Mode.config
    UI.ChangeWidget(Id("start_dns_now"), :Enabled, false)
    UI.ChangeWidget(Id("stop_dns_now"), :Enabled, false)
    UI.ReplaceWidget(Id("service_status_rp"), Label(""))
  else
    status = DnsServer.GetDnsServiceStatus
    UI.ChangeWidget(Id("start_dns_now"), :Enabled, !status)
    UI.ChangeWidget(Id("stop_dns_now"), :Enabled, status)
    UI.ReplaceWidget(
      Id("service_status_rp"),
      Label(
        status ?
          # service sttus - label
          _("DNS server is running.") :
          # service sttus - label
          _("DNS server is not running.")
      )
    )
  end

  nil
end

- (Object) ValidCharsForwardersPage

Setting `ValidChars for the dialog



904
905
906
907
908
909
910
911
912
913
# File '../../src/include/dns-server/dialog-main.rb', line 904

def ValidCharsForwardersPage
  # setting `ValidChars
  UI.ChangeWidget(
    Id("forwarders_new_ip_address"),
    :ValidChars,
    Ops.add(IP.ValidChars4, IP.ValidChars6)
  )

  nil
end