Compare commits
12 Commits
a381805c3c
...
main
Author | SHA1 | Date | |
---|---|---|---|
0e17e72283
|
|||
63d65cf786 | |||
063cc375df | |||
dc596cfac6 | |||
5eb3d9d874 | |||
d131688794 | |||
8063d3c4df | |||
54e5e0fc3b | |||
57d3efc3b5 | |||
942536d66a | |||
63626b329f | |||
c4b4e14dc0 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -5,6 +5,7 @@
|
||||
|
||||
# Data folder
|
||||
data/
|
||||
data
|
||||
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
|
@@ -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
6
filebridging/__main__.py
Normal 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()
|
@@ -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
|
||||
|
@@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user