2020-03-11 09:46:42 +00:00
|
|
|
"""Onionr - Private P2P Communication.
|
|
|
|
|
|
|
|
LAN manager
|
|
|
|
"""
|
|
|
|
from typing import TYPE_CHECKING
|
|
|
|
from threading import Thread
|
|
|
|
if TYPE_CHECKING:
|
|
|
|
from toomanyobjs import TooMany
|
|
|
|
|
|
|
|
from .client import Client
|
|
|
|
from .discover import learn_services, advertise_service
|
|
|
|
"""
|
|
|
|
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 LANManager:
|
|
|
|
"""Initialize and start/top LAN transport threads."""
|
|
|
|
|
|
|
|
def __init__(self, too_many: "TooMany"):
|
|
|
|
self.too_many = too_many
|
2020-03-16 07:28:41 +00:00
|
|
|
self.peers: "exploded IP Address string" = []
|
2020-03-14 04:47:44 +00:00
|
|
|
|
2020-03-11 09:46:42 +00:00
|
|
|
|
|
|
|
def start(self):
|
2020-03-23 08:39:57 +00:00
|
|
|
Thread(target=learn_services, args=[self.too_many.get(Client)], daemon=True).start()
|
2020-03-11 09:46:42 +00:00
|
|
|
Thread(target=advertise_service, daemon=True).start()
|
|
|
|
|