Показать сообщение отдельно
  #5  
Старый 05.03.2024, 18:42
Dmitry Protasoff
Guest
 
Сообщений: n/a
По умолчанию Пишем парсилку ФТН адресов с помощью ChatGPT

Dmitry Protasoff написал(а) к Egor Glukhov в Mar 24 14:32:42 по местному времени:

Нello, Egor!

Tuesday March 05 2024 12:22, you wrote to Nil A:

EG> Просил её накодить мейлер binkp'шный - ожидаемо получил "RTFM и кодь
EG> сам". А говорили, погромисты теперь не нужны будут. ;)

Я не понимаю, кого или чего вы с Ником спрашиваете?!
Я вот попросил написать binkp mailer и она мне его написала (я сказал - на любом языке, был выбран питон):

Creating a Binkp mailer for the Fidonet network involves understanding both the Binkp protocol and the structure of Fidonet messages. The Binkp protocol is a TCP/IP-based protocol designed for transferring FidoNet mail between systems. It's a relatively straightforward protocol, and implementing a basic mailer can be done in various programming languages. For this example, I'll use Python due to its readability and the availability of libraries for network programming.

A simple Binkp mailer will need to handle a few key tasks:

Establish a TCP connection to a remote Binkp server.
Authenticate with the server (if necessary).
Transfer message packets.
Нandle acknowledgments and retries for reliable delivery.
Close the connection properly.

Below is a simplified implementation that covers these steps. Note that this example focuses on establishing a connection and sending a predefined message packet. It doesn't cover more advanced features like encryption, compression, or full session management.

-+-
import socket
import sys

def send_packet(sock, packet):
"""Send a packet over the socket."""
try:
sock.sendall(packet)
except socket.error as e:
print(f"Socket error: {e}")
sys.exit(1)

def receive_ack(sock):
"""Wait for an acknowledgment."""
return sock.recv(1024)

def main(serverip, server_port, packetpath):
"""Main function to send a Fidonet packet using Binkp."""
try:
# Establish a TCP connection
with socket.socket(socket.AFINET, socket.SOCKSTREAM) as sock:
sock.connect((serverip, serverport))

# Authenticate with the server (simple version, adjust as needed)
# This step varies greatly depending on server configuration
send_packet(sock, b"CRAM-MD5")
if b"OK" not in receive_ack(sock):
print("Authentication failed.")
return

# Send the Fidonet packet
with open(packet_path, "rb") as f:
packet = f.read()
send_packet(sock, packet)

# Wait for acknowledgment
if b"ACK" in receive_ack(sock):
print("Packet sent successfully.")
else:
print("Failed to receive acknowledgment.")

except socket.error as e:
print(f"Failed to connect or send data: {e}")

if _name__ == "__main_":
if len(sys.argv) != 4:
print("Usage: python binkpmailer.py SERVER_IP SERVER_PORT PACKETPATН")
sys.exit(1)

server_ip, _server_port, _packetpath = sys.argv[1], int(sys.argv[2]), sys.argv[3]
main(server_ip, _server_port, _packetpath)
-+-

To use this script, you'll need to replace SERVERIP, SERVER_PORT, and PACKETPATН with the IP address and port of the Binkp server you're connecting to, and the path to the Fidonet packet you wish to send, respectively.

This example is highly simplified and designed to illustrate the basic process. A fully-featured Binkp mailer would need to handle multiple sessions, encryption, packet assembly, and disassembly, as well as more complex session management and error handling. For a production environment, it's crucial to refer to the Binkp specification and implement all the required features and security measures.


Best regards,
dp.

--- GoldED+/LNX 1.1.5-b20230304
Ответить с цитированием