📜 ⬆️ ⬇️

Java about fido

In this post we will talk about the OpenSource project, designed to make life fidoshnika better, and at the same time give the opportunity to use Fido on mobile devices with Java.

Story


As I already wrote , in 2010 I received the nodal number 2: 5020/848. Not having enough tasks at work, I was experiencing a “creative hunger”, and I was looking for where I could apply my strength. And found! In less than a month, a certain amount of software was written that gave various additional features to users of my site - access to Fido via a forum or NNTP, broadcasting incoming and outgoing mail to email and much more.
By the time this zoo started to work steadily, I practically lost interest in the development of the hub and looked through the mail a couple of times a month.
In 2011, I had the idea to rewrite a part of my software in Java and run it as a separate node, for which I even received the node number 2: 5020/849, but the matter did not go further than the project.
And just a month ago, one person asked me to send him the source code for the software that manages users on my site. To send them raw would be ugly, so the code had to be properly cleaned. And then, looking at all this code, I decided that since the algorithms were all invented, why not rewrite it all in Java, as I planned a year ago? Well, that rushed ...

For impatient


For those who are not interested in technical details, I will immediately tell you the essence:
Currently, jNode is a one-instance application that performs the functions of a mailer (accepts and sends mail), tosser (manages messages in echo conferences) and tracker (manages netmail messages).
Putting jNode as a nodal system, the operator by and large does not need anything else - the system will automatically receive and transmit mail according to the settings.
In the future we plan to make a web-based management interface, but for now you can simply write queries to the selected database :)
In the near future it is planned to fork from the project for the end-user fido client.
If you want to - join the development.

Technical details


Below are samples from the code with a brief description of what and why.
It will be interesting only to those who are planning a close acquaintance with FTN or with this project .

Java version: 1.7
Libraries: ORMLite 4, JBDC driver for the selected DBMS.
License: Apache License 2.0
Where to get: github
')
0. FTN uses LE-short fields. Turn over:
public static short revShort(short v) { return (short) ((short) ((short) (v >> 8) & 0xff) | (short) (v << 8)); } 

1. FTN-address of the form Z: N / FP @ D. We do not use a domain, we consider standard “fidonet”.
 public class FtnAddress { private int zone; private int net; private int node; private int point; } 

2. A packet is a data array containing a header and N messages.
 public class FtnPkt { private FtnAddress fromAddr; private FtnAddress toAddr; private String password; private List<FtnMessage> messages; private Date date; } 

3. Message - contains from / to, attributes, subject and message text.
 public class FtnMessage { private boolean isNetmail; private Date date; private String fromName; private String toName; private FtnAddress fromAddr; private FtnAddress toAddr; private String area; private String subject; private String text; private List<Ftn2D> seenby; private List<Ftn2D> path; } 

4. ORMLite - wrote a singleton manager to work with and get Dao.
 public class ORMManager { private static ORMManager self = new ORMManager(); private boolean started = false; private Dao<X, ?> daoX; public static ORMManager getInstanse() { return self; } public void start(Hashtable<String, String> settings) throws SQLException { if (!started) { ConnectionSource source = new JdbcConnectionSource(JDBC_URL, JDBC_USER, JDBC_PASS); daoX = DaoManager.createDao(source, X.class); if (!daoX.isTableExists()) { TableUtils.createTable(source, X.class); } started = true; } } public static Dao<X, ?> x() { return getInstanse().daoX; } } 

5. FtnTosser - here are collected methods for converting a package-> base and base-> package.
All methods are static. Maybe this is architecturally wrong, but I did not see any other option.
Two main methods:
 public class FtnTosser { public static void tossIncoming(Message[] received) { //    } public static List<Message> getMessagesForLink(Link link) { //    } } 

6. ProtocolConnector - interface for protocol connection. So far only binkp is implemented, but who knows - what if other protocols for Fido appear in the future?
It receives only InputStream as input, knows nothing about sockets, it can also read from a file for example.
 public interface ProtocolConnector { //     (  ) public void initOutgoing(Connector connector); //     (  ) public void initIncoming(Connector connector); // ,      public void avalible(InputStream is); // Frame -    byte[] getBytes() //       public Frame[] getFrames(); // true    public boolean closed(); // true     public boolean canSend(); //     public void reset(); //  message  Frame[]   public void send(Message message); // ,       public void eob(); //    public Message[] getReceived(); } 


7. Connector - deals directly with the network. At the input receives the ProtocolConnector and the address (if we are a client) or the socket after accept'a (if we are a server).
Makes reset init for the ProtocolConnector (hereinafter referred to as PC). If canSend () then receives messages for the link (FtnTosser.getMessagesForLink (Link link)) and makes PC.send (); at the end of the message does PC.eob ().
After PC.closed () returns true, it processes the received messages (FtnTosser.tossIncoming (PC.getReceived ());

Conclusion


If you have read this far, it means you are interested in something modern Fido.
Try to join this old, but still quite lively network.
Perhaps you will find there something interesting for yourself.
Let me remind you that you can get access including from me .

Source: https://habr.com/ru/post/151572/


All Articles