Update README

This commit is contained in:
2026-06-28 17:19:47 +00:00
commit 42dab0a26f
69 changed files with 7817 additions and 0 deletions

View File

@ -0,0 +1,59 @@
import paramiko, os, sys, io, socket
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
SSH_HOST = os.environ.get('GFIL_SSH_HOST', '')
SSH_USER = os.environ.get('GFIL_SSH_USER', 'root')
SSH_PASS = os.environ.get('GFIL_SSH_PASS', '')
PROXY = os.environ.get('GFIL_HTTP_PROXY', '')
if PROXY:
ph, pp = PROXY.split(':')
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(20)
sock.connect((ph, int(pp)))
sock.sendall(f'CONNECT {SSH_HOST}:22 HTTP/1.1\r\nHost: {SSH_HOST}:22\r\n\r\n'.encode())
resp = sock.recv(4096).decode()
if '200' not in resp:
print('Proxy failed: ' + resp[:100])
sys.exit(1)
else:
sock = None
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
kw = dict(hostname=SSH_HOST, username=SSH_USER, password=SSH_PASS, timeout=20, banner_timeout=30)
if sock:
kw['sock'] = sock
ssh.connect(**kw)
print('SSH connected via proxy!')
ssh.exec_command('mkdir -p /var/www/blog/tools', timeout=10)
sftp = ssh.open_sftp()
tools_dir = r'D:\GFIL_BLOG\tools'
for f in os.listdir(tools_dir):
if f.endswith('.html'):
sftp.put(os.path.join(tools_dir, f), '/var/www/blog/tools/' + f)
print('OK /tools/' + f)
output_dir = r'D:\GFIL_BLOG\output'
count = 0
for root, dirs, files in os.walk(output_dir):
for f in files:
if f.endswith('.html') or f.endswith('.xml') or f.endswith('.txt'):
local = os.path.join(root, f)
rel = os.path.relpath(local, output_dir)
rel = rel.replace(chr(92), '/')
remote = '/var/www/blog/' + rel
rdir = os.path.dirname(remote)
try:
ssh.exec_command('mkdir -p ' + rdir, timeout=5)
sftp.put(local, remote)
count += 1
except:
pass
sftp.close()
ssh.exec_command('chmod -R 644 /var/www/blog/*.html /var/www/blog/tools/*.html 2>/dev/null', timeout=10)
ssh.close()
print(str(count) + ' files uploaded')