Compare commits

...

10 Commits

Author SHA1 Message Date
ca49fb3037
Main file added 2020-11-15 20:46:34 +01:00
60c87ecb19 Merge master branch 2020-04-19 20:43:35 +02:00
25cf7271f4 Test 10 2020-04-19 20:00:29 +02:00
8b07741c59 Test 9 2020-04-19 19:58:37 +02:00
14992dd19b Test 8 2020-04-19 19:56:43 +02:00
f52429fc4d Test 7 2020-04-19 19:54:52 +02:00
bd8eb7da4c Test 6 2020-04-19 19:45:48 +02:00
f56fc6d60c Test 5 2020-04-19 19:42:55 +02:00
f6e65d5495 Test 4 2020-04-19 19:42:18 +02:00
05cc3cb8e6 Test 3 2020-04-19 19:41:06 +02:00
4 changed files with 11 additions and 5 deletions

View File

@ -13,6 +13,6 @@ __author__ = "Davide Testa"
__email__ = "davide@davte.it" __email__ = "davide@davte.it"
__credits__ = [] __credits__ = []
__license__ = "GNU General Public License v3.0" __license__ = "GNU General Public License v3.0"
__version__ = "0.0.8" __version__ = "0.0.10"
__maintainer__ = "Davide Testa" __maintainer__ = "Davide Testa"
__contact__ = "t.me/davte" __contact__ = "t.me/davte"

6
filebridging/__main__.py Normal file
View File

@ -0,0 +1,6 @@
mode = input("Do you want to run a filebridging (S)erver or (C)lient?\t\t")
if mode.lower().startswith('s'):
from .server import main
else:
from .client import main
main()

View File

@ -436,7 +436,6 @@ class Client:
force=(new_progress == 100) force=(new_progress == 100)
) )
if not input_data: if not input_data:
continue
break break
file_to_receive.write(input_data) file_to_receive.write(input_data)
print() # New line after sys.stdout.write print() # New line after sys.stdout.write

View File

@ -73,7 +73,7 @@ class Server:
def set_ssl_context(self, ssl_context: ssl.SSLContext): def set_ssl_context(self, ssl_context: ssl.SSLContext):
self._ssl_context = ssl_context self._ssl_context = ssl_context
async def run_reader(self, reader, connection_token): async def run_reader(self, reader: asyncio.StreamReader, connection_token):
while 1: while 1:
try: try:
# Wait one second if buffer is full # Wait one second if buffer is full
@ -82,7 +82,6 @@ class Server:
continue continue
input_data = await reader.read(self.buffer_chunk_size) input_data = await reader.read(self.buffer_chunk_size)
if connection_token not in self.buffers: if connection_token not in self.buffers:
print("Here!")
break break
self.buffers[connection_token].append(input_data) self.buffers[connection_token].append(input_data)
except ConnectionResetError as e: except ConnectionResetError as e:
@ -91,7 +90,7 @@ class Server:
except Exception as e: except Exception as e:
logging.error(f"Unexpected exception:\n{e}", exc_info=True) logging.error(f"Unexpected exception:\n{e}", exc_info=True)
async def run_writer(self, writer, connection_token): async def run_writer(self, writer: asyncio.StreamWriter, connection_token):
consecutive_interruptions = 0 consecutive_interruptions = 0
errors = 0 errors = 0
while connection_token in self.buffers: while connection_token in self.buffers:
@ -101,6 +100,7 @@ class Server:
# Slow down if buffer is empty; after 1.5 s of silence, break # Slow down if buffer is empty; after 1.5 s of silence, break
consecutive_interruptions += 1 consecutive_interruptions += 1
if consecutive_interruptions > 3: if consecutive_interruptions > 3:
logging.error("Too many interruptions...")
break break
await asyncio.sleep(.5) await asyncio.sleep(.5)
continue continue
@ -167,6 +167,7 @@ class Server:
else: else:
return 0 # On success, return 0 return 0 # On success, return 0
# On exception, disconnect and return 1 # On exception, disconnect and return 1
logging.error("Disconnecting...")
self.disconnect(connection_token=connection_token) self.disconnect(connection_token=connection_token)
return 1 return 1