fake-tncc.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/usr/bin/env python3
  2. #
  3. # Copyright © 2021 Joachim Kuebart <joachim.kuebart@gmail.com>
  4. #
  5. # This file is part of openconnect.
  6. #
  7. # This is free software; you can redistribute it and/or
  8. # modify it under the terms of the GNU Lesser General Public License
  9. # as published by the Free Software Foundation; either version 2.1 of
  10. # the License, or (at your option) any later version.
  11. #
  12. # This library is distributed in the hope that it will be useful, but
  13. # WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. # Lesser General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU Lesser General Public License
  18. # along with this program. If not, see <http://www.gnu.org/licenses/>
  19. import os
  20. def main():
  21. """
  22. Reply "success" when we receive "hostchecker".
  23. """
  24. io = os.fdopen(0, "r+b", buffering=0)
  25. started = False
  26. for line in io:
  27. line = line.decode("ascii").rstrip()
  28. if line == "start":
  29. started = True
  30. if started and line == "Cookie=hostchecker":
  31. io.write(b"200\n3\nsuccess\n\n\n")
  32. started = False
  33. if __name__ == "__main__":
  34. main()