M Makefile => Makefile +16 -16
@@ 34,33 34,33 @@ test/%: test/%.lua
lua $<
test_argv_empty: test/argv/empty.lua knockoff
- ./knockoff $< > /dev/null
+ ./knockoff watch $< > /dev/null
test_argv_ab: test/argv/ab.lua knockoff
- ./knockoff $< -a yes -b 2 > /dev/null
- ./knockoff -a yes $< -b 2 > /dev/null
- ./knockoff -a yes -b 2 $< > /dev/null
- ./knockoff -a -b 2 $< > /dev/null
+ ./knockoff watch $< -a yes -b 2 > /dev/null
+ ./knockoff watch -a yes $< -b 2 > /dev/null
+ ./knockoff watch -a yes -b 2 $< > /dev/null
+ ./knockoff watch -a -b 2 $< > /dev/null
-KO_PORTS_A != ./knockoff examples/simple_choose ports A
-KO_PORTS_B != ./knockoff examples/simple_choose ports B
+KO_PORTS_A != ./knockoff ports examples/simple_choose A
+KO_PORTS_B != ./knockoff ports examples/simple_choose B
test_examples/simple_choose_A: knockoff
- ./knockoff examples/simple_choose simulate $(KO_PORTS_A) -args
+ ./knockoff simulate examples/simple_choose $(KO_PORTS_A) -args
test_examples/simple_choose_B: knockoff
- ./knockoff examples/simple_choose simulate $(KO_PORTS_B) -args
+ ./knockoff simulate examples/simple_choose $(KO_PORTS_B) -args
-KO_PORTS_SIMPLE != ./knockoff examples/simple ports
+KO_PORTS_SIMPLE != ./knockoff ports examples/simple
test_examples/simple: knockoff
- ./knockoff examples/simple simulate $(KO_PORTS_SIMPLE) -args
+ ./knockoff simulate examples/simple $(KO_PORTS_SIMPLE) -args
-KO_PORTS_SHA2 != ./knockoff examples/sha2 ports
+KO_PORTS_SHA2 != ./knockoff ports examples/sha2
test_examples/sha2: knockoff
- ./knockoff examples/sha2 simulate $(KO_PORTS_SHA2) -args
+ ./knockoff simulate examples/sha2 $(KO_PORTS_SHA2) -args
test_examples_script:
- ./knockoff examples/sha2 script test.address -args > /dev/null
- ./knockoff examples/simple script test.address -args > /dev/null
- ./knockoff examples/simple_choose script test.address A -args > /dev/null
+ ./knockoff script examples/sha2 test.address -args > /dev/null
+ ./knockoff script examples/simple test.address -args > /dev/null
+ ./knockoff script examples/simple_choose test.address A -args > /dev/null
test_examples: test_examples/simple_choose_A test_examples/simple_choose_A \
test_examples/simple test_examples/sha2
M README.md => README.md +5 -5
@@ 34,7 34,7 @@ On *both* the server and knocker side,
cp /etc/knockoff/examples/sha2.lua /etc/knockoff/$SERVERNAME.lua
-Change `local secret` value to the secret you agreed on.
+Change `local secret = ..` value to the secret you agreed on.
Change the element in the
`interfaces` list to the interface you want to sniff of the current device.
@@ 46,11 46,11 @@ Change the element in the
(in `$SERVERNAME.lua`)Change the `local port` value to the port you need open,
or just change the `success` function directly.
-To run the knocking-sniffer, as root, `knockoff $SERVERNAME -v 2`
+To run the knocking-sniffer, as root, `knockoff watch $SERVERNAME -v 2`
(`-v` just increases verbosity somewhat)
## Client side
-To knock the server: `knockoff $SERVERNAME knock $IP`, and then within ten
+To knock the server: `knockoff knock $SERVERNAME $IP`, and then within ten
seconds connect.
# Other options
@@ 61,8 61,8 @@ There is support for different events after a knock. The above assumes the
end-event is simply `success`. For instance `example/simple_choose.lua` has
multiple outcomes, `A` and `B`, i.e.
- ./knockoff example/simple_choose knock $ip A # Trigger A
- ./knockoff example/simple_choose ports B # Show port sequence for B.
+ ./knockoff knock example/simple_choose $ip A # Trigger A
+ ./knockoff ports example/simple_choose B # Show port sequence for B.
See `doc/features.md` for more other options. (todo list of some which don't
exist yet)
M src/inbuild.lua => src/inbuild.lua +12 -10
@@ 104,19 104,20 @@ elseif args[1] == 'version' or args.version then
return
end
-if args[1] and string.match(args[1], "^.+[.]lua$") then
- args.config_file = args[1]
-else
- args.config_file = include_file(args[1])
+if args[2] and string.match(args[2], "^.+[.]lua$") then
+ -- .lua indicates local file!
+ args.config_file = args[2]
+else -- Otherwise, figure out the file.
+ args.config_file = include_file(args[2])
if not args.config_file then
- log(0, "Configuration %s doesnt exist.", args[1])
+ log(0, "Configuration %s doesnt exist.", args[2])
env.dont_run = true
return
end
end
env.include = include
-env.include_file = include_file
+env.include_file = include_file
function env.seq(name)
local got = include("seqs/" .. name)
@@ 169,6 170,7 @@ function env.mk_watcher(definitions)
if rawget(own_ips_dict, dst) then -- Some `rawget`/`rawset` for speed.
log(2, "%s" .. string.rep("\t%s", 6),
t, proto, src, sport, dst, dport, dlen)
+
local cur = rawget(active, src)
if not cur then
cur = initial_maybe_new(start,
@@ 373,17 375,17 @@ local commands = {
end
}
-local fun = commands[args[2]]
-if fun then
+local fun = commands[args[1]]
+if fun then -- Various functions other than the listener loop.
local success, err_msg = pcall(fun)
if not success then
log(0, "ERR: %s", err_msg)
end
-elseif args[2]=='watch' or args[2]==nil then
+elseif args[1]=='watch' then -- The listening loop.
run_main(true)
watcher = type(watcher)=='table' and watcher.watcher or watcher
else -- TODO suggest what it could be?
- log(0, "%s is not any of the commands. (try `knockoff help`)", args[2])
+ log(0, "%s is not any of the commands. (try `knockoff help`)", args[1])
assert(false)
end