Compare commits

..

12 Commits

Author SHA1 Message Date
0e17e72283 Main file added 2020-11-15 20:45:46 +01:00
63d65cf786 Ignore data folder symlink 2020-04-26 16:01:25 +02:00
063cc375df Always print progress bar at 100% 2020-04-19 20:41:36 +02:00
dc596cfac6 Typo 2020-04-19 16:26:33 +02:00
5eb3d9d874 create_certificate script provided 2020-04-19 00:06:05 +02:00
d131688794 Handle SSL exceptions 2020-04-17 21:39:36 +02:00
8063d3c4df Simplify timed_input definition 2020-04-17 20:13:05 +02:00
54e5e0fc3b Serious bug silently bypassing SSL context fixed. Previous versions do not really support SSL! 2020-04-17 16:20:34 +02:00
57d3efc3b5 Implemented non-unix timed_input function 2020-04-15 16:26:45 +02:00
942536d66a New version 2020-04-13 23:12:13 +02:00
63626b329f Prevent bad behaviour when terminal windows is too small 2020-04-13 23:06:47 +02:00
c4b4e14dc0 First working version 2020-04-13 21:00:00 +02:00
5 changed files with 12 additions and 5 deletions

1
.gitignore vendored
View File

@@ -5,6 +5,7 @@
# Data folder
data/
data
# Byte-compiled / optimized / DLL files
__pycache__/

View File

@@ -13,6 +13,6 @@ __author__ = "Davide Testa"
__email__ = "davide@davte.it"
__credits__ = []
__license__ = "GNU General Public License v3.0"
__version__ = "0.0.8"
__version__ = "0.0.10"
__maintainer__ = "Davide Testa"
__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)
)
if not input_data:
continue
break
file_to_receive.write(input_data)
print() # New line after sys.stdout.write

View File

@@ -73,7 +73,7 @@ class Server:
def set_ssl_context(self, ssl_context: ssl.SSLContext):
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:
try:
# Wait one second if buffer is full
@@ -82,7 +82,6 @@ class Server:
continue
input_data = await reader.read(self.buffer_chunk_size)
if connection_token not in self.buffers:
print("Here!")
break
self.buffers[connection_token].append(input_data)
except ConnectionResetError as e:
@@ -91,7 +90,7 @@ class Server:
except Exception as e:
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
errors = 0
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
consecutive_interruptions += 1
if consecutive_interruptions > 3:
logging.error("Too many interruptions...")
break
await asyncio.sleep(.5)
continue
@@ -167,6 +167,7 @@ class Server:
else:
return 0 # On success, return 0
# On exception, disconnect and return 1
logging.error("Disconnecting...")
self.disconnect(connection_token=connection_token)
return 1