add a rand: special case for OptAddress options

git-svn-id: file:///home/svn/framework3/trunk@11071 4d416f70-5f16-0410-b530-b9f4589650da
This commit is contained in:
Joshua Drake 2010-11-19 18:31:14 +00:00
parent b42a04a7aa
commit fe9710b836
1 changed files with 10 additions and 0 deletions

View File

@ -344,6 +344,16 @@ class OptAddressRange < OptBase
path = $1
return false if not File.exists?(path) or File.directory?(path)
return File.readlines(path).map{ |s| s.strip}.join(" ")
elsif (value =~ /^rand:(.*)/)
count = $1.to_i
return false if count < 1
ret = ''
count.times {
ret << " " if not ret.empty?
ip = "%u.%u.%u.%u" % [1+rand(0xfe),1+rand(0xfe),1+rand(0xfe),1+rand(0xfe)]
ret << ip
}
return ret
end
return value
end