test_client.lua 549 B

123456789101112131415161718192021222324
  1. mooni2p = require("mooni2p")
  2. local session_name = "testclient"
  3. local target = arg[1]
  4. if target == nil then
  5. print(string.format("missing target. usage: lua5.3 %s target.i2p", arg[0]))
  6. else
  7. -- create client SAM session
  8. local session_sock = assert(mooni2p.create_session(session_name))
  9. -- connect to remote I2P destination
  10. local sock = assert(mooni2p.stream_connect(session_name, target))
  11. sock:send("PING\n")
  12. local data = sock:receive("*l")
  13. print(data)
  14. sock:send("STOP\n")
  15. sock:close()
  16. -- shutdown SAM session
  17. session_sock:close()
  18. end