cluster/identd/ident: add basic ident protocol client
This is the first pass at an ident protocol client. In the end, we want
to implement an ident protocol server for our in-cluster identd, but
starting out with a client helps me getting familiar with the protocol,
and will allow the server implementation to be tested against the
client.
Change-Id: Ic37b84577321533bab2f2fbf7fb53409a5defb95
diff --git a/cluster/identd/ident/request.go b/cluster/identd/ident/request.go
new file mode 100644
index 0000000..9727893
--- /dev/null
+++ b/cluster/identd/ident/request.go
@@ -0,0 +1,20 @@
+package ident
+
+import (
+ "fmt"
+)
+
+// Request is an ident protocol request, as seen by the client or server.
+type Request struct {
+ // ClientPort is the port number on the client side of the indent protocol,
+ // ie. the port local to the ident client.
+ ClientPort uint16
+ // ServerPort is the port number on the server side of the ident protocol,
+ // ie. the port local to the ident server.
+ ServerPort uint16
+}
+
+// encode encodes ths Request as per RFC1413, including the terminating \r\n.
+func (r *Request) encode() []byte {
+ return []byte(fmt.Sprintf("%d,%d\r\n", r.ServerPort, r.ClientPort))
+}