completed MCCP2 support
diff --git a/telnet-proxy.c b/telnet-proxy.c
index 9a38af6..218d860 100644
--- a/telnet-proxy.c
+++ b/telnet-proxy.c
@@ -181,15 +181,6 @@
printf("%s IAC %s %d (%s)\e[0m\n", conn->name, get_cmd(cmd),
(int)opt, get_opt(opt));
- /* FIXME: HACK: allow MCCP2 from server without passing it
- * through to client. this is temporary until libtelnet supports
- * the server-end of MCCP2.
- */
- if (cmd == LIBTELNET_WILL && opt == LIBTELNET_OPTION_COMPRESS2) {
- libtelnet_send_negotiate(&conn->telnet, LIBTELNET_DO, opt, conn);
- return;
- }
-
libtelnet_send_negotiate(&conn->remote->telnet, cmd, opt,
conn->remote);
}
@@ -209,6 +200,13 @@
conn->remote);
}
+void libtelnet_compress_cb(struct libtelnet_t *telnet, char enabled,
+ void *user_data) {
+ struct conn_t *conn = (struct conn_t*)user_data;
+
+ printf("%s COMPRESSION %s\e[0m\n", conn->name, enabled ? "ON" : "OFF");
+}
+
void libtelnet_error_cb(struct libtelnet_t *telnet,
enum libtelnet_error_t error, void *user_data) {
struct conn_t *conn = (struct conn_t*)user_data;
@@ -296,9 +294,13 @@
client.name = "\e[34mCLIENT";
client.remote = &server;
- /* initialize telnet boxes */
- libtelnet_init(&server.telnet);
- libtelnet_init(&client.telnet);
+ /* initialize telnet boxes
+ * NOTE: we set the server connect to the CLIENT mode because we
+ * are acting as a client of the server; likewise, we set the
+ * client connection to SERVER mode becauser we are acting as a
+ * server to the client. */
+ libtelnet_init(&server.telnet, LIBTELNET_MODE_CLIENT);
+ libtelnet_init(&client.telnet, LIBTELNET_MODE_SERVER);
/* initialize poll descriptors */
memset(pfd, 0, sizeof(pfd));