本文簡要介紹ruby語言中 ACL類
的用法。
簡單的訪問控製列表。
訪問控製列表由“allow”和“deny”兩半組成,用於控製訪問。使用 “all” 或 “*” 匹配任何地址。要匹配特定地址,請使用 IPAddr
可以理解的任何地址或地址掩碼。
例子:
list = %w[
deny all
allow 192.168.1.1
allow ::ffff:192.168.1.2
allow 192.168.1.3
]
# From Socket#peeraddr, see also ACL#allow_socket?
addr = ["AF_INET", 10, "lc630", "192.168.1.3"]
acl = ACL.new
p acl.allow_addr?(addr) # => true
acl = ACL.new(list, ACL::DENY_ALLOW)
p acl.allow_addr?(addr) # => true
相關用法
- Ruby ACL.new用法及代碼示例
- Ruby ACL.allow_addr?用法及代碼示例
- Ruby Array.push用法及代碼示例
- Ruby Array.hash用法及代碼示例
- Ruby ARGF.path用法及代碼示例
- Ruby Addrinfo.ip_address用法及代碼示例
- Ruby Array permutation()用法及代碼示例
- Ruby Array.to_a用法及代碼示例
- Ruby Array.to_h用法及代碼示例
- Ruby Array.to_s用法及代碼示例
- Ruby Array class fill()用法及代碼示例
- Ruby Array.array + other_array用法及代碼示例
- Ruby Array product()用法及代碼示例
- Ruby Array zip()用法及代碼示例
- Ruby Array concat()用法及代碼示例
- Ruby Array類用法及代碼示例
- Ruby Addrinfo.connect_from用法及代碼示例
- Ruby Array.take()用法及代碼示例
- Ruby Array.reject!用法及代碼示例
- Ruby ASN1Data.new用法及代碼示例
- Ruby Array.flatten!用法及代碼示例
- Ruby Array.reject用法及代碼示例
- Ruby Array compact!()用法及代碼示例
- Ruby ASN1.decode_all用法及代碼示例
- Ruby Array reject!()用法及代碼示例
注:本文由純淨天空篩選整理自ruby-lang.org大神的英文原創作品 ACL類。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。