Comments (10)
I'm implementing handshake phase support https://github.com/okkez/influent/tree/support-fluentd-handshake
But it is work in progress.
Do you like this?
Feel free to comment, please.
from influent.
I think that NioForwardConnection with handshake support is a finite state machine, so it looks nice that
onReadable
branches into switch (state)
.
So your plan is good.
In detail,
- HELO is the first message of the protocol and it is sent by a server. So it should be fired in constructor
onReadable
is invoked when the server is received some packets, but the client never send messages untilHELO
is received- Stores the HELO message in
responses(the variable name became bad……)
and invokeeventLoop.enableInterestSet(key, SelectionKey.OP_WRITE)
- Messages for handshake may be arrived partially, so it should be parsed incrementally
- For instance, a ping message may be divided to two packets and
onReadable
is invoked twice - Probably, it is good that msgpack array is parsed by MsgpackStreamUnpacker at first
- https://github.com/okkez/influent/blob/support-fluentd-handshake/influent-java/src/main/java/influent/forward/NioForwardConnection.java#L202-L212
- not
onReadable -> checkPing
butonReadable -> unpacker.feed -> checkPing
- For instance, a ping message may be divided to two packets and
from influent.
from influent.
There are three conversions.
- Fluentd domain object <-> An array of Msgpack
- An array of Msgpack <-> ByteBuffer
- Encoding is easy since an array of msgpack has full information needed for binary representation from the beginning
- Decoding is a bit difficult since TCP stack may send one array of msgpack as multiple packets
NioTcpChannel#read
may receive only a part of binary of one array of msgpack- Explanation in Japanese
- java.util.ByteBuffer <-> socket buffer
- Write/Read ByteBuffers to/from TCP stack
- Influent is implemented by non-blocking API of NIO
Array of Msgpack <-> ByteBuffer
is already provided by MessageBufferPacker and MsgpackStreamUnpacker.
So we can support handshake phase by implementing handshake logic and Fluentd domain object <-> An array of Msgpack
conversion.
from influent.
We need IP address checking like following:
- https://github.com/fluent/fluentd/blob/v0.14.20/lib/fluent/plugin/in_forward.rb#L132-L141
- https://github.com/fluent/fluentd/blob/v0.14.20/lib/fluent/plugin/in_forward.rb#L415
But Java standard libraries don't have such utilities as far as I know.
Do you have any idea for remote address checking?
from influent.
I feel that it is simple to implement such a logic.
But it is also OK to use third party library if it is light(not such Netty).
from influent.
Thank you for comments!
I could not find out tiny library. So I've implemented InetNetwork class with reference to Apache James.
from influent.
I found Apache Commons Net.
https://commons.apache.org/proper/commons-net/apidocs/org/apache/commons/net/util/SubnetUtils.html
How about SubnetInfo#isInRange
?
from influent.
I think commons-net is large, it is 300KB.
https://mvnrepository.com/artifact/commons-net/commons-net/3.6
commons-net does not support IPv6, but I've implemented both IPv4 and IPv6.
from influent.
Created #32
from influent.
Related Issues (8)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from influent.