Class: Yast::SquidACLClass
- Inherits:
-
Module
- Object
- Module
- Yast::SquidACLClass
- Defined in:
- ../../src/modules/SquidACL.rb
Instance Method Summary (collapse)
- - (Object) getKeys(m)
-
- (Object) GetOptions(id_acl_type)
Returns values from widget as list of options in correct form to store them into Squid module.
-
- (Object) GetTypesToComboBox
Returns list of terms in form: [
item(
id(key), acl_map[“name”]:“”), `item(… ) ] Returned list is preferably to place in UI::ComboBox as list of all available types of ACLs. -
- (Object) InitWidget(id_acl_type, id_item, help_widget_id)
Initialize widget of acl identified by id_acl_type.
- - (Object) main
-
- (Object) Replace(widget_id, id_acl_type)
Replace widget with id widget_id by widget acl_map[“widget”].
-
- (Object) SupportedACLs
Returns list of supported ACLs.
-
- (Object) Verify(id_acl_type)
This function call verification function joined with acl type identified by id_acl_type.
Instance Method Details
- (Object) getKeys(m)
384 385 386 387 388 389 |
# File '../../src/modules/SquidACL.rb', line 384 def getKeys(m) m = deep_copy(m) ret = [] Builtins.foreach(m) { |key, value| ret = Builtins.add(ret, key) } deep_copy(ret) end |
- (Object) GetOptions(id_acl_type)
Returns values from widget as list of options in correct form to store them into Squid module.
469 470 471 472 473 474 475 476 |
# File '../../src/modules/SquidACL.rb', line 469 def GetOptions(id_acl_type) func = Convert.convert( Ops.get(Ops.get(@acl_map, id_acl_type, {}), "options"), :from => "any", :to => "list <string> ()" ) func.call end |
- (Object) GetTypesToComboBox
Returns list of terms in form:
[ item(
id(key), acl_map["name"]:""), `item(... )
]
Returned list is preferably to place in UI::ComboBox as list of
all
available types of ACLs.
403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 |
# File '../../src/modules/SquidACL.rb', line 403 def GetTypesToComboBox items = [] Builtins.foreach(@acl) do |value| items = Builtins.add( items, Item( Id(value), Ops.get_string(Ops.get(@acl_map, value, {}), "name", "") ) ) end deep_copy(items) end |
- (Object) InitWidget(id_acl_type, id_item, help_widget_id)
Initialize widget of acl identified by id_acl_type. If id_item is not nil, function initialize widgets by default values from module Squid.
423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 |
# File '../../src/modules/SquidACL.rb', line 423 def InitWidget(id_acl_type, id_item, ) = deep_copy() if != nil UI.ChangeWidget( Id(), :Value, Ops.get_string(Ops.get(@acl_map, id_acl_type, {}), "help", "") ) end func = Convert.convert( Ops.get(Ops.get(@acl_map, id_acl_type, {}), "widget_init"), :from => "any", :to => "void (integer)" ) func.call(id_item) nil end |
- (Object) main
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 |
# File '../../src/modules/SquidACL.rb', line 32 def main Yast.import "UI" textdomain "squid" Yast.include self, "squid/SquidACL_local_functions.rb" #** # Unsupported ACLS: # * * * * * * * * * * * # ident, ident_regex, # src_as, dst_as, # proxy_auth, proxy_auth_regex, # snmp_community, # max_user_ip, # external, # urllogin, urlgroup # user_cert, ca_cert # ext_user # map of acl definition. format: # $[ # "type" : $[ "name" : "Name shown in dialogs", # "widget" : `WidgetDescribingThisType, # "widget_init" : FunctionWithInitsOfWidget, # "verification" : FunctionCalledToVerificateContentsOfWidget, # "options" : FunctionThatReturnsListOfOptions # ] # ] # # widget_init prototype: void FuncName(integer id_item) # verification prototype: boolean FuncName() # options prototype: list<string> FuncName() @acl_map = { "src" => { "name" => "src", "widget" => Frame( _("src"), VBox( #`TextEntry(`id("acl_addr1"), _("IP Address 1"), ""), #`Label(" - "), TextEntry( Id("acl_addr"), _("IP Address or Range of IP Addresses"), "" ), #`Label("/"), TextEntry(Id("acl_mask"), _("Network Mask"), "") ) ), "widget_init" => fun_ref(method(:srcWidgetInit), "void (integer)"), "verification" => fun_ref(method(:srcVerif), "boolean ()"), "options" => fun_ref(method(:srcOptions), "list <string> ()"), "help" => _("The IP address of the requesting client.") }, "dst" => { "name" => "dst", "widget" => Frame( _("dst"), VBox( TextEntry(Id("acl_addr"), _("IP Address"), ""), TextEntry(Id("acl_mask"), _("Network Mask"), "") ) ), "widget_init" => fun_ref(method(:dstWidgetInit), "void (integer)"), "verification" => fun_ref(method(:dstVerif), "boolean ()"), "options" => fun_ref(method(:dstOptions), "list <string> ()"), "help" => _("Destination IP Address.") }, "myip" => { "name" => "myip", "widget" => Frame( _("myip"), VBox( TextEntry(Id("acl_addr"), _("Local IP Address"), ""), TextEntry(Id("acl_mask"), _("Network Mask"), "") ) ), "widget_init" => fun_ref(method(:dstWidgetInit), "void (integer)"), "verification" => fun_ref(method(:dstVerif), "boolean ()"), "options" => fun_ref(method(:dstOptions), "list <string> ()"), "help" => _( "The local IP address on which the client connection exists." ) }, "srcdomain" => { "name" => "srcdomain", "widget" => Frame( _("srcdomain"), VBox(TextEntry(Id("acl_domain"), _("Clients Domain Name"), "")) ), "widget_init" => fun_ref( method(:srcdomainWidgetInit), "void (integer)" ), "verification" => fun_ref(method(:srcdomainVerif), "boolean ()"), "options" => fun_ref( method(:srcdomainOptions), "list <string> ()" ), "help" => _("This type matches the client's domain name.") }, "dstdomain" => { "name" => "dstdomain", "widget" => Frame( _("dstdomain"), VBox(TextEntry(Id("acl_domain"), _("Destination Domain"), "")) ), "widget_init" => fun_ref( method(:srcdomainWidgetInit), "void (integer)" ), "verification" => fun_ref(method(:srcdomainVerif), "boolean ()"), "options" => fun_ref( method(:srcdomainOptions), "list <string> ()" ), "help" => _( "This refers to the destination domain, i.e. the source domain where the origin server is located." ) }, "srcdom_regex" => regexp( "srcdom_regex", "srcdom_regex", _("Matches the client domain name.") ), "dstdom_regex" => regexp( "dstdom_regex", "dstdom_regex", _("Provides match for destination domain.") ), "time" => { "name" => "time", "widget" => Frame( _("time"), VBox( HWeight( 1, MinHeight( 8, MultiSelectionBox( Id("acl_days"), _("Days"), [ Item(Id("M"), _("Monday")), Item(Id("T"), _("Tuesday")), Item(Id("W"), _("Wednesday")), Item(Id("H"), _("Thursday")), Item(Id("F"), _("Friday")), Item(Id("A"), _("Saturday")), Item(Id("S"), _("Sunday")) ] ) ) ), HWeight( 1, HBox( TextEntry( Id("acl_from"), Opt(:shrinkable), _("From (H:M)"), "" ), TextEntry(Id("acl_to"), Opt(:shrinkable), _("To (H:M)"), "") ) ) ) ), "widget_init" => fun_ref(method(:timeWidgetInit), "void (integer)"), "verification" => fun_ref(method(:timeVerif), "boolean ()"), "options" => fun_ref(method(:timeOptions), "list <string> ()"), "help" => "" }, "url_regex" => regexp( "url_regex", "url_regex", _("Matches using a regular expression on the complete URL.") ), "urlpath_regex" => regexp( "urlpath_regex", "urlpath_regex", _( "Matches the URL path minus any protocol, port, and host name information" ) ), "port" => { "name" => "port", "widget" => Frame( _("port"), TextEntry(Id("acl_port"), _("Port Number or Range of Ports"), "") ), "widget_init" => fun_ref(method(:portWidgetInit), "void (integer)"), "verification" => fun_ref(method(:portVerif), "boolean ()"), "options" => fun_ref(method(:portOptions), "list <string> ()"), "help" => _("Matches the destination port for the request.") }, "myport" => { "name" => "myport", "widget" => Frame( _("myport"), TextEntry(Id("acl_port"), _("Port Number"), "") ), "widget_init" => fun_ref(method(:myportWidgetInit), "void (integer)"), "verification" => fun_ref(method(:myportVerif), "boolean ()"), "options" => fun_ref(method(:portOptions), "list <string> ()"), "help" => _("Provides match for local TCP port number.") }, "proto" => { "name" => "proto", "widget" => Frame( _("proto"), TextEntry(Id("acl_proto"), _("Protocol"), "") ), "widget_init" => fun_ref(method(:protoWidgetInit), "void (integer)"), "verification" => fun_ref(method(:protoVerif), "boolean ()"), "options" => fun_ref(method(:protoOptions), "list <string> ()"), "help" => _("Matches the protocol of the request.") }, "method" => { "name" => "method", "widget" => Frame( _("method"), ComboBox( Id("acl_method"), _("HTTP Method"), [ Item(Id("GET"), "GET"), Item(Id("HEAD"), "HEAD"), Item(Id("POST"), "POST"), Item(Id("PUT"), "PUT"), Item(Id("DELETE"), "DELETE"), Item(Id("TRACE"), "TRACE"), Item(Id("CONNECT"), "CONNECT") ] ) ), "widget_init" => fun_ref(method(:methodWidgetInit), "void (integer)"), "verification" => fun_ref(method(:methodVerif), "boolean ()"), "options" => fun_ref(method(:methodOptions), "list <string> ()"), "help" => _( "This type matches the HTTP method in the request headers." ) }, "browser" => regexp( "browser", "browser", _( "A regular expression that matches the client's browser type based on the user agent header." ) ), "maxconn" => { "name" => "maxconn", "widget" => Frame( "maxconn", IntField( Id("acl_connections"), _("Maximum Number of HTTP Connections"), 0, 999999, 0 ) ), "widget_init" => fun_ref( method(:maxconnWidgetInit), "void (integer)" ), "verification" => fun_ref(method(:maxconnVerif), "boolean ()"), "options" => fun_ref(method(:maxconnOptions), "list <string> ()"), "help" => _( "Matches when the client's IP address has more than the specified number of HTTP connections established." ) }, "referer_regex" => regexp( "referer_regex", "referer_regex", _("Matches Referer header.") ), "req_header" => { "name" => "req_header", "widget" => Frame( "req_header", VBox( TextEntry(Id("acl_header_name"), _("Header Name"), ""), TextEntry(Id("acl_regexp"), _("Regular Expression(s)"), ""), Left( CheckBox( Id("acl_regexp_case_insensitive"), _("Case Insensitive"), false ) ) ) ), "widget_init" => fun_ref(method(:headerWidgetInit), "void (integer)"), "verification" => fun_ref(method(:headerVerif), "boolean ()"), "options" => fun_ref(method(:headerOptions), "list <string> ()"), "help" => _( "Regular expression matching any of the known request headers." ) }, "rep_header" => { "name" => "rep_header", "widget" => Frame( "rep_header", VBox( TextEntry(Id("acl_header_name"), _("Header Name"), ""), TextEntry(Id("acl_regexp"), _("Regular Expression(s)"), ""), Left( CheckBox( Id("acl_regexp_case_insensitive"), _("Case Insensitive"), false ) ) ) ), "widget_init" => fun_ref(method(:headerWidgetInit), "void (integer)"), "verification" => fun_ref(method(:headerVerif), "boolean ()"), "options" => fun_ref(method(:headerOptions), "list <string> ()"), "help" => _( "Regular expression matching the mime type of the reply received by squid. Can\nbe used to detect file download or some types of HTTP tunnelling requests.\n" ) }, "req_mime_type" => regexp( "req_mime_type", "req_mime_type", _("Match the mime type of the request generated by the client.") ), "rep_mime_type" => regexp( "rep_mime_type", "rep_mime_type", _("Match the mime type of the reply received by Squid.") ), "arp" => { "name" => "arp", "widget" => Frame( "arp", TextEntry(Id("acl_mac"), _("MAC Address"), "") ), "widget_init" => fun_ref(method(:arpWidgetInit), "void (integer)"), "verification" => fun_ref(method(:arpVerif), "boolean ()"), "options" => fun_ref(method(:arpOptions), "list <string> ()"), "help" => _("Ethernet (MAC) address matching.") } } # List of available acls. # Also specify order of acls. # Values must corespond with keys in acl_map. @acl = Builtins.sort(getKeys(@acl_map)) end |
- (Object) Replace(widget_id, id_acl_type)
Replace widget with id widget_id by widget acl_map[“widget”].
443 444 445 446 447 448 449 450 451 |
# File '../../src/modules/SquidACL.rb', line 443 def Replace(, id_acl_type) = deep_copy() UI.ReplaceWidget( Id(), Ops.get_term(Ops.get(@acl_map, id_acl_type, {}), "widget", Empty()) ) nil end |
- (Object) SupportedACLs
Returns list of supported ACLs. It's necessary to have saved unsupported ACLs but do not handle with them.
395 396 397 |
# File '../../src/modules/SquidACL.rb', line 395 def SupportedACLs deep_copy(@acl) end |
- (Object) Verify(id_acl_type)
This function call verification function joined with acl type identified by id_acl_type. Returns return value of verification function.
457 458 459 460 461 462 463 464 |
# File '../../src/modules/SquidACL.rb', line 457 def Verify(id_acl_type) func = Convert.convert( Ops.get(Ops.get(@acl_map, id_acl_type, {}), "verification"), :from => "any", :to => "boolean ()" ) func.call end |