tor-dam

tor distributed announce mechanism (not a dht)
git clone https://git.parazyd.org/tor-dam
Log | Files | Refs | README | LICENSE

echo_recv.py (1219B)


      1 #!/usr/bin/env python3
      2 # Copyright (c) 2017-2021 Ivan Jelincic <parazyd@dyne.org>
      3 #
      4 # This file is part of tor-dam
      5 #
      6 # This program is free software: you can redistribute it and/or modify
      7 # it under the terms of the GNU General Public License as published by
      8 # the Free Software Foundation, either version 3 of the License, or
      9 # (at your option) any later version.
     10 #
     11 # This program is distributed in the hope that it will be useful,
     12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
     13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     14 # GNU General Public License for more details.
     15 #
     16 # You should have received a copy of the GNU General Public License
     17 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
     18 
     19 from argparse import ArgumentParser
     20 from socket import socket, AF_INET, SOCK_STREAM
     21 
     22 parser = ArgumentParser()
     23 parser.add_argument('-l', '--listen', default='127.0.0.1')
     24 parser.add_argument('-p', '--port', default=5000)
     25 args = parser.parse_args()
     26 
     27 s = socket(AF_INET, SOCK_STREAM)
     28 s.bind((args.listen, args.port))
     29 s.listen(1)
     30 
     31 conn, ddr = s.accept()
     32 while 1:
     33     data = conn.recv(1024)
     34     if not data:
     35         break
     36     print(data)
     37     conn.send(data)
     38 conn.close()