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 folder
|
||||||
data/
|
data/
|
||||||
|
data
|
||||||
|
|
||||||
# Byte-compiled / optimized / DLL files
|
# Byte-compiled / optimized / DLL files
|
||||||
__pycache__/
|
__pycache__/
|
||||||
|
@@ -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
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)
|
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
|
||||||
|
@@ -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
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user