From e88c8439b919809fafcbbbc1fd51198abea220c0 Mon Sep 17 00:00:00 2001

From: =?UTF-8?q?Jaakko=20Kera=CC=88nen?= jaakko.keranen@iki.fi

Date: Sat, 24 Aug 2024 11:40:12 +0300

Subject: [PATCH 1/1] Added Misfin-to-email forwarder extension; bumped version

to 0.9

The Misfin module implements reception of B and C variants of the

protocol, sending the messages to the configured email address if

certificates pass validity and TOFU checks.


gmcapsule/init.py | 6 +-

gmcapsule/gemini.py | 30 +++--

gmcapsule/modules/80_misfin.py | 215 +++++++++++++++++++++++++++++++++

3 files changed, 238 insertions(+), 13 deletions(-)

create mode 100644 gmcapsule/modules/80_misfin.py

diff --git a/gmcapsule/init.py b/gmcapsule/init.py

index a16c800..27e3a2f 100644

--- a/gmcapsule/init.py

+++ b/gmcapsule/init.py

@@ -502,13 +502,13 @@ import shlex

import subprocess

from pathlib import Path

-from .gemini import Server, Cache, Context, Identity

+from .gemini import Server, Cache, Context, Identity, GeminiError

from .markdown import to_gemtext as markdown_to_gemtext

-version = '0.8.0'

+version = '0.9.0'

all = [

 'get_mime_type', 'markdown_to_gemtext'

]

diff --git a/gmcapsule/gemini.py b/gmcapsule/gemini.py

index 329c641..c5cea90 100644

--- a/gmcapsule/gemini.py

+++ b/gmcapsule/gemini.py

@@ -376,14 +376,10 @@ def handle_gemini_or_titan_request(request_data):

         if expected_size > max_upload_size and max_upload_size > 0:

             report_error(stream, 59, "Maximum content length exceeded")

             return

             report_error(stream, 59, "Invalid content length")

             return

     else:

         # Edit requests do not contain data.

         if len(data):

@@ -720,6 +716,16 @@ class RequestData:

     self.identity = identity

     self.request = request

class RequestParser(threading.Thread):

 """Thread that parses incoming requests from clients."""

@@ -763,11 +769,15 @@ class RequestParser(threading.Thread):

 def process_request(self, stream, from_addr):

     data = bytes()

     MAX_RECV = MAX_LEN + 2  # includes terminator "\r\n"

     request = None

     incoming = safe_recv(stream, MAX_RECV)

     try:

         while len(data) < MAX_RECV:

             data += incoming

@@ -776,12 +786,11 @@ class RequestParser(threading.Thread):

                 request = data[:crlf_pos].decode('utf-8')

                 data = data[crlf_pos + 2:]

                 break

                 # At this point we should have received the line terminator.

                 self.log(from_addr, 'sent a malformed request')

                 report_error(stream, 59, "Request exceeds maximum length")

                 return

             incoming = safe_recv(stream, MAX_RECV - len(data))

             if len(incoming) <= 0:

                 break

@@ -789,7 +798,8 @@ class RequestParser(threading.Thread):

         report_error(stream, 59, "Request contains malformed UTF-8")

         return

         report_error(stream, 59, "Bad request")

         return

diff --git a/gmcapsule/modules/80_misfin.py b/gmcapsule/modules/80_misfin.py

new file mode 100644

index 0000000..626981e

--- /dev/null

+++ b/gmcapsule/modules/80_misfin.py

@@ -0,0 +1,215 @@

+# Copyright (c) 2024 Jaakko Keränen jaakko.keranen@iki.fi

+# License: BSD-2-Clause

+"""Misfin Email Bridge"""

+import gmcapsule

+import hashlib

+import re

+import subprocess

+from pathlib import Path

+from OpenSSL import SSL, crypto

+def get_fingerprint(x509_cert):

+def parse_identity(cert) -> tuple:

+class MisfinError (Exception):

+class Recipient:

+class MisfinHandler:

+def init(context):

--

2.25.1

Proxy Information
Original URL
gemini://git.skyjake.fi/gmcapsule/main/patch/e88c8439b919809fafcbbbc1fd51198abea220c0.patch
Status Code
Success (20)
Meta
text/plain
Capsule Response Time
30.224019 milliseconds
Gemini-to-HTML Time
5.047226 milliseconds

This content has been proxied by September (ba2dc).