Added webdav.

This commit is contained in:
2025-03-29 07:13:23 +01:00
parent fe1b3d6d19
commit 29139d5d0c
54 changed files with 1022 additions and 669 deletions
+12 -5
View File
@@ -1,7 +1,9 @@
import asyncio
import asyncssh
import os
import logging
import os
import asyncssh
asyncssh.set_debug_level(2)
logging.basicConfig(level=logging.DEBUG)
# Configuration for SFTP server
@@ -11,6 +13,7 @@ PASSWORD = "woeii"
HOST = "localhost"
PORT = 2225
class MySFTPServer(asyncssh.SFTPServer):
def __init__(self, chan):
super().__init__(chan)
@@ -31,8 +34,10 @@ class MySFTPServer(asyncssh.SFTPServer):
full_path = os.path.join(self.root, path.lstrip("/"))
return await super().listdir(full_path)
class MySSHServer(asyncssh.SSHServer):
"""Custom SSH server to handle authentication"""
def connection_made(self, conn):
print(f"New connection from {conn.get_extra_info('peername')}")
@@ -46,11 +51,12 @@ class MySSHServer(asyncssh.SSHServer):
return True # Support password authentication
def validate_password(self, username, password):
print(username,password)
print(username, password)
return True
return username == USERNAME and password == PASSWORD
async def start_sftp_server():
os.makedirs(SFTP_ROOT, exist_ok=True) # Ensure the root directory exists
@@ -59,11 +65,12 @@ async def start_sftp_server():
host=HOST,
port=PORT,
server_host_keys=["ssh_host_key"],
process_factory=MySFTPServer
process_factory=MySFTPServer,
)
print(f"SFTP server running on {HOST}:{PORT}")
await asyncio.Future() # Keep running forever
if __name__ == "__main__":
try:
asyncio.run(start_sftp_server())