Hello, Egor!
Tuesday March 05 2024 12:22, you wrote to Nil A:
Просил её накодить мейлер binkp'шный - ожидаемо получил "RTFM и кодь
сам". А говорили, погромисты теперь не нужны будут. ;)
Я не понимаю, кого или чего вы с Hиком спрашиваете?!
Я вот попросил написать 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.
Handle 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(server_ip, server_port, packet_path):
"""Main function to send a Fidonet packet using Binkp."""
try:
# Establish a TCP connection
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
sock.connect((server_ip, server_port))
# 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 binkp_mailer.py SERVER_IP SERVER_PORT PACKET_PATH")
sys.exit(1)
_server_ip, _server_port, _packet_path = sys.argv[1], int(sys.argv[2]), sys.argv[3]
main(_server_ip, _server_port, _packet_path)
-+-
To use this script, you'll need to replace SERVER_IP, SERVER_PORT, and PACKET_PATH 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
* Origin: All is good in St. John's Wood (2:5001/100.1)