Onionr/src/lan/client/__init__.py

46 lines
1.3 KiB
Python
Raw Normal View History

"""Onionr - Private P2P Communication.
LAN transport client thread
"""
2020-03-23 05:37:49 +00:00
from typing import List
from onionrcrypto.cryptoutils.randomshuffle import random_shuffle
2020-03-23 05:37:49 +00:00
from utils.bettersleep import better_sleep
from onionrutils.basicrequests import do_post_request, do_get_request
"""
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
class Client:
2020-03-23 08:39:57 +00:00
def __init__(self):
self.peers = []
self.lookup_time = {}
self.poll_delay = 10
def get_lookup_time(self, peer):
try:
return self.lookup_time[peer]
except KeyError:
return 0
2020-03-23 05:37:49 +00:00
def start(self):
while True:
self.peers = random_shuffle(self.peers)
2020-03-31 09:00:48 +00:00
better_sleep(self.poll_delay)