Skip to content

Commit

Permalink
split protos by commas, and ranges by :
Browse files Browse the repository at this point in the history
Want to be able express ports, protos, etc, with compressed syntax
eventually. One day I'd like to be able to express this at a high
level

allowed_protos = 6,16,icmp,49:51,hipl

and then do it in ONE iptables rule, rather than 8.
  • Loading branch information
Dave Taht committed Dec 30, 2011
1 parent 75aad8c commit 311ae1c
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/proto_split.lua
@@ -0,0 +1,26 @@
#!/usr/bin/lua

-- split

-- FIXME we want to construct a two dimensional table
-- then join it

function proto_split(s,max)
c = 1
t = split(',',s)
p = 0
for i,v in ipairs(t) do
c = c + (p = # split(':',v))
if c > max then
n = n + 1
s[n] = v
c = p
else
s[n] = s[n] .. "," .. v
end
end
return(s)
end

t = proto_split("a,b,c,d,e,f,g,h,i:j",4)
print(# t)
15 changes: 15 additions & 0 deletions src/testenv.lua
@@ -0,0 +1,15 @@
#!/usr/bin/lua

require 'ceroenv'
ceroenv.wtf()
env = ceroenv.new()
ceroenv.show()

PPREREQ= {sch_sfq,sch_red,cls_flow,cls_none}
if ceroenv.prereq(PPREREQ) ~= nil then
print("Awesome")
end


-- print(ceroenv.ge("SHELL"))
-- print(ceroenv.env["QMODEL"])

0 comments on commit 311ae1c

Please sign in to comment.