Sean Middleditch | b9e4864 | 2009-03-12 23:33:27 -0400 | [diff] [blame] | 1 | ===================================================================== |
| 2 | libtelnet - TELNET protocol handling library |
| 3 | ===================================================================== |
| 4 | |
Sean Middleditch | 892c5f1 | 2009-03-14 13:39:07 -0400 | [diff] [blame] | 5 | http://github.com/elanthis/libtelnet |
| 6 | |
| 7 | Sean Middleditch |
| 8 | sean@sourcemud.org |
Sean Middleditch | b9e4864 | 2009-03-12 23:33:27 -0400 | [diff] [blame] | 9 | |
| 10 | --------------------------------------------------------------------- |
| 11 | The author or authors of this code dedicate any and all copyright |
| 12 | interest in this code to the public domain. We make this dedication |
| 13 | for the benefit of the public at large and to the detriment of our |
| 14 | heirs and successors. We intend this dedication to be an overt act of |
| 15 | relinquishment in perpetuity of all present and future rights to this |
| 16 | code under copyright law. |
| 17 | --------------------------------------------------------------------- |
| 18 | |
Sean Middleditch | 9d2f98a | 2009-03-14 05:24:56 -0400 | [diff] [blame] | 19 | *** TODO *** |
| 20 | |
| 21 | - RFC 1143 option negotiation algorithm |
| 22 | - automatic MCCP2 handling (controllable by host app) |
Sean Middleditch | 9d2f98a | 2009-03-14 05:24:56 -0400 | [diff] [blame] | 23 | ? MCCP1 |
| 24 | ? ZMP parsing |
| 25 | ? MSSP parsing |
| 26 | ? ENVIRON/NEW-ENVIRON parsing |
| 27 | ? telnet-status testing tool |
Sean Middleditch | 9d2f98a | 2009-03-14 05:24:56 -0400 | [diff] [blame] | 28 | |
Sean Middleditch | b9e4864 | 2009-03-12 23:33:27 -0400 | [diff] [blame] | 29 | I. INTRODUCTION |
| 30 | ===================================================================== |
| 31 | |
| 32 | libtelnet provides safe and correct handling of the core TELNET |
| 33 | protocol. It does not include any "smarts," and all use of the |
| 34 | protocol (such as deciding which options to support, enabling |
| 35 | and disabling options, or processing subrequests) must be implemented |
| 36 | by the application author. |
| 37 | |
Sean Middleditch | 892c5f1 | 2009-03-14 13:39:07 -0400 | [diff] [blame] | 38 | For more information on the TELNET protocol, see: |
| 39 | |
| 40 | http://www.faqs.org/rfcs/rfc854.html |
| 41 | |
Sean Middleditch | b9e4864 | 2009-03-12 23:33:27 -0400 | [diff] [blame] | 42 | II. LIBTELNET API |
| 43 | ===================================================================== |
| 44 | |
Sean Middleditch | 892c5f1 | 2009-03-14 13:39:07 -0400 | [diff] [blame] | 45 | The libtelnet API contains several distinct parts. The first part is |
| 46 | the basic initialization and deinitialization routines. The second |
| 47 | part is a single function for pushing received data into the |
| 48 | libtelnet processor. The third part is the libtelnet_send_*() |
| 49 | functions, which generate TELNET commands and ensure data is properly |
Sean Middleditch | 637df7f | 2009-03-15 12:57:32 -0400 | [diff] [blame] | 50 | formatted before sending over the wire. The final part is the event |
| 51 | handler interface. |
Sean Middleditch | 892c5f1 | 2009-03-14 13:39:07 -0400 | [diff] [blame] | 52 | |
| 53 | IIa. Initialization |
| 54 | |
| 55 | struct libtelnet_t; |
| 56 | This structure represents the state of the TELNET protocol for a |
| 57 | single connection. Each connection utilizing TELNET must have |
| 58 | its own libtelnet_t structure, which is passed to all libtelnet |
| 59 | API calls. |
| 60 | |
| 61 | void libtelnet_init(struct libtelnet_t *telnet, |
Sean Middleditch | 637df7f | 2009-03-15 12:57:32 -0400 | [diff] [blame] | 62 | libtelnet_event_handler_t handler, enum libtelnet_mode_t mode); |
Sean Middleditch | 892c5f1 | 2009-03-14 13:39:07 -0400 | [diff] [blame] | 63 | The libtelnet_init() function is responsible for initializing |
| 64 | the data in a libtelnet_t structure. It must be called |
| 65 | immediately after establishing a connection and before any other |
| 66 | libtelnet API calls are made. |
| 67 | |
Sean Middleditch | 637df7f | 2009-03-15 12:57:32 -0400 | [diff] [blame] | 68 | The handler parameter must be a function matching the |
| 69 | libtelnet_event_handler_t definition. More information about |
| 70 | events can be found in section IId. |
Sean Middleditch | 3032302 | 2009-03-14 21:45:28 -0400 | [diff] [blame] | 71 | |
Sean Middleditch | f66a7ee | 2009-03-15 11:54:07 -0400 | [diff] [blame] | 72 | The mode parameter must be one of LIBTELNET_MODE_SERVER, |
| 73 | LIBTELNET_MODE_CLIENT, or LIBTELNET_MODE_PROXY. These slightly |
| 74 | alter the behavior of libtelnet in certain instances. If you are |
| 75 | implementing a TELNET server, use the SERVER mode. If you are |
| 76 | implementing a client, use the CLIENT mode. The PROXY mode |
| 77 | enables special behavior for telnet-proxy (or similar |
| 78 | applications). |
Sean Middleditch | 892c5f1 | 2009-03-14 13:39:07 -0400 | [diff] [blame] | 79 | |
| 80 | boid libtelnet_free(struct libtelnet_t *telnet); |
| 81 | Releases any internal memory allocated by libtelnet. This must |
| 82 | be called whenever a connection is closed, or you will incur |
| 83 | memory leaks. |
| 84 | |
| 85 | IIb. Receiving Data |
| 86 | |
| 87 | void libtelnet_push(struct libtelnet_t *telnet, |
| 88 | unsigned char *buffer, unsigned int size, void *user_data); |
| 89 | When your application receives data over the socket from the |
| 90 | remote end, it must pass the received bytes into this function. |
Sean Middleditch | 637df7f | 2009-03-15 12:57:32 -0400 | [diff] [blame] | 91 | |
| 92 | As the TELNET stream is parsed, events will be generated and |
| 93 | passed to the event handler given to libtelnet_init(). Of |
| 94 | particular interest for data receiving is the LIBTELNET_EV_DATA |
| 95 | event, which is triggered for any regular data such as user |
| 96 | input or server process output. |
Sean Middleditch | 892c5f1 | 2009-03-14 13:39:07 -0400 | [diff] [blame] | 97 | |
| 98 | IIc. Sending Data |
| 99 | |
Sean Middleditch | 637df7f | 2009-03-15 12:57:32 -0400 | [diff] [blame] | 100 | All of the libtelnet_send_*() functions will invoke the |
| 101 | LIBTELNET_EV_SEND event. The user_data parameter to each of these |
| 102 | functions is passed through to the callback. |
| 103 | |
| 104 | Note: it is very important that ALL data sent to the remote end of |
| 105 | the connection be passed through libtelnet. All user input or |
| 106 | process output that you wish to send over the wire should be given |
| 107 | to libtelnet_send_data(). Do NOT send or buffer unprocessed output |
| 108 | data directly! |
Sean Middleditch | 892c5f1 | 2009-03-14 13:39:07 -0400 | [diff] [blame] | 109 | |
| 110 | void libtelnet_send_command(struct libtelnet_t *telnet, |
| 111 | unsigned char cmd, void *user_data); |
| 112 | Sends a single "simple" TELNET command, such as the GO-AHEAD |
| 113 | commands (255 249). |
| 114 | |
| 115 | void libtelnet_send_negotiate(struct libtelnet_t *telnet, |
| 116 | unsigned char cmd, unsigned char opt, void *user_data); |
| 117 | Sends a TELNET negotiation command. The cmd parameter must be |
| 118 | one of LIBTELNET_WILL, LIBTELNET_DONT, LIBTELNET_DO, or |
| 119 | LIBTELNET_DONT. The opt parameter is the option to |
| 120 | negotiate. |
| 121 | |
| 122 | void libtelnet_send_data(struct libtelnet_t *telnet, |
| 123 | unsigned char *buffer, unsigned int size, void *user_data); |
| 124 | Sends raw data, which would be either the process output from |
| 125 | a server or the user input from a client. |
| 126 | |
| 127 | void libtelnet_send_subnegotiation(struct libtelnet_t *telnet, |
| 128 | unsigned char opt, unsigned char *buffer, unsigned int size, |
| 129 | void *user_data); |
| 130 | Sends a TELNET sub-negotiation command. The opt parameter |
| 131 | is the sub-negotiation option. |
| 132 | |
Sean Middleditch | 637df7f | 2009-03-15 12:57:32 -0400 | [diff] [blame] | 133 | IId. Event Handling |
Sean Middleditch | 892c5f1 | 2009-03-14 13:39:07 -0400 | [diff] [blame] | 134 | |
Sean Middleditch | 637df7f | 2009-03-15 12:57:32 -0400 | [diff] [blame] | 135 | libtelnet relies on an event-handling mechanism for processing |
| 136 | the parsed TELNET protocol stream as well as for buffering and |
| 137 | sending output data. |
Sean Middleditch | 892c5f1 | 2009-03-14 13:39:07 -0400 | [diff] [blame] | 138 | |
Sean Middleditch | 637df7f | 2009-03-15 12:57:32 -0400 | [diff] [blame] | 139 | When you initialize a libtelnet_t structure with libtelnet_init() |
| 140 | you had to pass in an event handler function. This function must |
| 141 | meet the following prototype: |
Sean Middleditch | 3032302 | 2009-03-14 21:45:28 -0400 | [diff] [blame] | 142 | |
Sean Middleditch | 637df7f | 2009-03-15 12:57:32 -0400 | [diff] [blame] | 143 | void (libtelnet_t *telnet, libtelnet_event_t *event, |
| 144 | void *user_data); |
| 145 | |
| 146 | The libtelnet_event_t structure has the following definition: |
| 147 | |
| 148 | struct libtelnet_event_t { |
| 149 | enum libtelnet_event_type_t type; |
| 150 | unsigned char command; |
| 151 | unsigned char telopt; |
| 152 | unsigned char *buffer; |
| 153 | unsigned int size; |
| 154 | }; |
| 155 | |
| 156 | The enumeration values of libtelnet_event_type_t are described in |
| 157 | detail below. Whenever the the event handler is invoked, the |
| 158 | application must look at the event->type value and do any |
| 159 | necessary processing. |
| 160 | |
| 161 | The only event that MUST be implemented is LIBTELNET_EV_SEND. |
| 162 | Most applications will also always want to implement the event |
| 163 | LIBTELNET_EV_DATA. |
| 164 | |
| 165 | Here is an example event handler implementation which includes |
| 166 | handlers for several important events. |
| 167 | |
| 168 | void my_event_handler(struct libtelnet_t *telnet, |
| 169 | libtelnet_event_t *ev, void *user_data) { |
| 170 | struct user_info *user = (struct user_info *)user_data; |
| 171 | |
| 172 | switch (ev->type) { |
| 173 | case LIBTELNET_EV_DATA: |
| 174 | process_user_input(user, event->buffer, event->size); |
| 175 | break; |
| 176 | case LIBTELNET_EV_SEND: |
| 177 | write_to_descriptor(user, event->buffer, event->size); |
| 178 | break; |
| 179 | case LIBTELNET_EV_ERROR: |
| 180 | fatal_error("TELNET error: %s", event->buffer); |
| 181 | break; |
| 182 | } |
Sean Middleditch | 3032302 | 2009-03-14 21:45:28 -0400 | [diff] [blame] | 183 | } |
| 184 | |
Sean Middleditch | 637df7f | 2009-03-15 12:57:32 -0400 | [diff] [blame] | 185 | LIBTELNET_EV_DATA: |
| 186 | The DATA event is triggered whenever regular data (not part of |
| 187 | any special TELNET command) is received. For a client, this |
| 188 | will be process output from the server. For a server, this will |
| 189 | be input typed by the user. |
Sean Middleditch | 3032302 | 2009-03-14 21:45:28 -0400 | [diff] [blame] | 190 | |
Sean Middleditch | 637df7f | 2009-03-15 12:57:32 -0400 | [diff] [blame] | 191 | The event->buffer value will contain the bytes received and the |
| 192 | event->size value will contain the number of bytes received. |
| 193 | Note that event->buffer is not NUL terminated! |
Sean Middleditch | 3032302 | 2009-03-14 21:45:28 -0400 | [diff] [blame] | 194 | |
Sean Middleditch | 637df7f | 2009-03-15 12:57:32 -0400 | [diff] [blame] | 195 | NOTE: there is no guarantee that user input or server output |
| 196 | will be received in whole lines. If you wish to process data |
| 197 | a line at a time, you are responsible for buffering the data and |
| 198 | checking for line terminators yourself! |
| 199 | |
| 200 | LIBTELNET_EV_SEND: |
| 201 | This event is sent whenever libtelnet has generated data that |
| 202 | must be sent over the wire to the remove end. Generally that |
| 203 | means calling send() or adding the data to your application's |
| 204 | output buffer. |
Sean Middleditch | 3032302 | 2009-03-14 21:45:28 -0400 | [diff] [blame] | 205 | |
Sean Middleditch | 637df7f | 2009-03-15 12:57:32 -0400 | [diff] [blame] | 206 | The event->buffer value will contain the bytes to send and the |
| 207 | event->size value will contain the number of bytes to send. |
| 208 | Note that event->buffer is not NUL terminated, and may include |
| 209 | NUL characters in its data, so always use event->size! |
Sean Middleditch | 3032302 | 2009-03-14 21:45:28 -0400 | [diff] [blame] | 210 | |
Sean Middleditch | 637df7f | 2009-03-15 12:57:32 -0400 | [diff] [blame] | 211 | NOTE: Your SEND event handler must send or buffer the data in |
| 212 | its raw form as provided by libtelnet. If you wish to perform |
| 213 | any kind of preprocessing on data you want to send to the other |
| 214 | |
| 215 | LIBTELNET_EV_IAC: |
| 216 | The IAC event is triggered whenever a simple IAC command is |
| 217 | received, such as the IAC EOR (end of record, also called |
| 218 | go ahead or GA) command. |
Sean Middleditch | 892c5f1 | 2009-03-14 13:39:07 -0400 | [diff] [blame] | 219 | |
Sean Middleditch | 637df7f | 2009-03-15 12:57:32 -0400 | [diff] [blame] | 220 | The command received is in the event->command value. |
Sean Middleditch | 892c5f1 | 2009-03-14 13:39:07 -0400 | [diff] [blame] | 221 | |
Sean Middleditch | 637df7f | 2009-03-15 12:57:32 -0400 | [diff] [blame] | 222 | The necessary processing depends on the specific commands; see |
| 223 | the TELNET RFC for more information. |
| 224 | |
| 225 | LIBTELNET_EV_NEGOTIATE: |
| 226 | The NEGOTIATE event is sent when a TELNET neogitiation command |
| 227 | is received. |
Sean Middleditch | 892c5f1 | 2009-03-14 13:39:07 -0400 | [diff] [blame] | 228 | |
Sean Middleditch | 637df7f | 2009-03-15 12:57:32 -0400 | [diff] [blame] | 229 | The event->command value will be one of LIBTELNET_WILL, |
| 230 | LIBTELNET_WONT, LIBTELNET_DO, or LIBTELNET_DONT. The |
| 231 | event->telopt value will contain the option value being |
| 232 | negotiated. |
Sean Middleditch | 892c5f1 | 2009-03-14 13:39:07 -0400 | [diff] [blame] | 233 | |
| 234 | libtelnet does not currently manage negotiation for you. For |
| 235 | best practice in implementing TELNET negotiation, see: |
| 236 | |
| 237 | http://www.faqs.org/rfcs/rfc1143.html |
| 238 | |
Sean Middleditch | 637df7f | 2009-03-15 12:57:32 -0400 | [diff] [blame] | 239 | LIBTELNET_EV_SUBNEGOTIATION: |
| 240 | Triggered whenever a TELNET sub-negotiation has been received. |
Sean Middleditch | 892c5f1 | 2009-03-14 13:39:07 -0400 | [diff] [blame] | 241 | Sub-negotiations include the NAWS option for communicating |
| 242 | terminal size to a server, the NEW-ENVIRON and TTYPE options |
| 243 | for negotiating terminal features, and MUD-centric protocols |
| 244 | such as ZMP, MSSP, and MCCP2. |
| 245 | |
Sean Middleditch | 637df7f | 2009-03-15 12:57:32 -0400 | [diff] [blame] | 246 | The event->telopt value is the option under sub-negotiation. |
| 247 | The remaining data (if any) is passed in event->buffer and |
| 248 | event->size. Note that most subnegotiation commands can |
| 249 | include embedded NUL bytes in the subnegotiation data, and |
| 250 | the data event->buffer is not NUL terminated, so always use |
| 251 | the event->size value! |
Sean Middleditch | 892c5f1 | 2009-03-14 13:39:07 -0400 | [diff] [blame] | 252 | |
Sean Middleditch | 637df7f | 2009-03-15 12:57:32 -0400 | [diff] [blame] | 253 | The meaning and necessary processing for subnegotiations are |
| 254 | defined in various TELNET RFCs and other informal |
| 255 | specifications. A subnegotiation should never be sent unless |
| 256 | the specific option has been enabled through the use of the |
| 257 | telnet negotiation feature. |
Sean Middleditch | 892c5f1 | 2009-03-14 13:39:07 -0400 | [diff] [blame] | 258 | |
Sean Middleditch | 637df7f | 2009-03-15 12:57:32 -0400 | [diff] [blame] | 259 | LIBTELNET_EV_COMPRESS |
| 260 | The COMPRESS event notifies the app that COMPRESS2/MCCP2 |
| 261 | compression has begun or ended. Only servers can send compressed |
| 262 | data, and hence only clients will receive compressed data. |
Sean Middleditch | b9e4864 | 2009-03-12 23:33:27 -0400 | [diff] [blame] | 263 | |
Sean Middleditch | 637df7f | 2009-03-15 12:57:32 -0400 | [diff] [blame] | 264 | The event->command value will be 1 if compression has started and |
| 265 | will be 0 if compression has ended. |
| 266 | |
| 267 | LIBTELNET_EV_ERROR |
| 268 | This event is called whenever an error occurs while trying to |
| 269 | process the TELNET protocol. This includes both invalid protocol |
| 270 | sequences (which are rare) and out of memory conditions. |
| 271 | |
| 272 | With few exceptions, an error is non-recoverable, and the only |
| 273 | solid course of action is to close the connection. This is |
| 274 | especially true for any errors involving the COMPRESS2 option. |
| 275 | |
| 276 | The event->buffer value will contain a NUL terminated string |
| 277 | explaining the error, and the event->size value containers the |
| 278 | length of the string. |
| 279 | |
| 280 | FIXME: we should pass the error code in one of the fields, and |
| 281 | better document which errors are definitely non-recoverable and |
| 282 | which are maybe-recoverable (mostly those are just IAC-in-SB |
| 283 | errors... every other error is related to MCCP2 and usually |
| 284 | results in being unable to further read the stream). |
| 285 | |
| 286 | III. INTEGRATING LIBTELNET WITH COMMON MUDS |
Sean Middleditch | b9e4864 | 2009-03-12 23:33:27 -0400 | [diff] [blame] | 287 | ===================================================================== |
| 288 | |
Sean Middleditch | 637df7f | 2009-03-15 12:57:32 -0400 | [diff] [blame] | 289 | FIXME: fill in some notes about how to splice in libtelnet with |
| 290 | common Diku/Merc/Circle/etc. MUD codebases. |
Sean Middleditch | b9e4864 | 2009-03-12 23:33:27 -0400 | [diff] [blame] | 291 | |
Sean Middleditch | 892c5f1 | 2009-03-14 13:39:07 -0400 | [diff] [blame] | 292 | IV. SAFETY AND CORRECTNESS CONSIDERATIONS |
Sean Middleditch | b9e4864 | 2009-03-12 23:33:27 -0400 | [diff] [blame] | 293 | ===================================================================== |
| 294 | |
Sean Middleditch | 892c5f1 | 2009-03-14 13:39:07 -0400 | [diff] [blame] | 295 | Your existing application may make heavy use of its own output |
| 296 | buffering and transmission commands, including hand-made routines |
| 297 | for sending TELNET commands and sub-negotiation requests. There are |
| 298 | at times subtle issues that need to be handled when communication |
| 299 | over the TELNET protocol, not least of which is the need to escape |
| 300 | any byte value 0xFF with a special TELNET command. |
Sean Middleditch | b9e4864 | 2009-03-12 23:33:27 -0400 | [diff] [blame] | 301 | |
Sean Middleditch | 892c5f1 | 2009-03-14 13:39:07 -0400 | [diff] [blame] | 302 | For these reasons, it is very important that applications making use |
| 303 | of libtelnet always make use of the libtelnet_send_*() family of |
| 304 | functions for all data being sent over the TELNET connection. |
| 305 | |
Sean Middleditch | 637df7f | 2009-03-15 12:57:32 -0400 | [diff] [blame] | 306 | In particular, if you are writing a client, all user input must be |
| 307 | passed through to libtelnet_send_data(). This also includes any |
| 308 | input generated automatically by scripts, triggers, or macros. |
| 309 | |
| 310 | For a server, any and all output -- including ANSI/VT100 escape |
| 311 | codes, regular text, newlines, and so on -- must be passed through |
| 312 | to libtelnet_send_data(). |
| 313 | |
| 314 | Any TELNET commands that are to be sent must be given to one of the |
| 315 | following: libtelnet_send_command, libtelnet_send_negotiate, or |
| 316 | libtelnet_send_subnegotiation(). |
| 317 | |
| 318 | If you are attempting to enable COMPRESS2/MCCP2, you must use the |
| 319 | libtelnet_begin_compress2() function. |
| 320 | |
Sean Middleditch | 892c5f1 | 2009-03-14 13:39:07 -0400 | [diff] [blame] | 321 | V. MCCP2 COMPRESSION |
Sean Middleditch | b9e4864 | 2009-03-12 23:33:27 -0400 | [diff] [blame] | 322 | ===================================================================== |
| 323 | |
Sean Middleditch | 892c5f1 | 2009-03-14 13:39:07 -0400 | [diff] [blame] | 324 | The MCCP2 (COMPRESS2) TELNET extension allows for the compression of |
| 325 | all traffic sent from server to client. For more information: |
| 326 | |
| 327 | http://www.mudbytes.net/index.php?a=articles&s=mccp |
| 328 | |
Sean Middleditch | 637df7f | 2009-03-15 12:57:32 -0400 | [diff] [blame] | 329 | In order for libtelnet to support MCCP2, zlib must be installed and |
| 330 | enabled when compiling libtelnet. Use -DHAVE_ZLIB to enable zlib |
| 331 | when compiling libtelnet.c and pass -lz to the linker to link in the |
| 332 | zlib shared library. |
| 333 | |
Sean Middleditch | 892c5f1 | 2009-03-14 13:39:07 -0400 | [diff] [blame] | 334 | libtelnet transparently supports MCCP2. For a server to support |
| 335 | MCCP2, the application must begin negotiation of the COMPRESS2 |
| 336 | option using libtelnet_send_negotiate(), for example: |
| 337 | |
| 338 | libtelnet_send_negotiate(&telnet, LIBTELNET_WILL, |
| 339 | LIBTELNET_OPTION_COMPRESS2, user_data); |
| 340 | |
Sean Middleditch | 637df7f | 2009-03-15 12:57:32 -0400 | [diff] [blame] | 341 | If a favorable DO COMPRESS2 is sent back from the client (processed |
| 342 | in a LIBTELNET_EV_NEGOTIATE event, with event->command equal to |
| 343 | LIBTELNET_DO and event->telopt equal to LIBTELNET_TELOPT_COMPRESS2), |
| 344 | then the server application can begin compression at any time by |
| 345 | calling libtelnet_begin_compress2(). |
Sean Middleditch | 892c5f1 | 2009-03-14 13:39:07 -0400 | [diff] [blame] | 346 | |
Sean Middleditch | 637df7f | 2009-03-15 12:57:32 -0400 | [diff] [blame] | 347 | If a connection is in PROXY mode and COMPRESS2 support is enabled |
| 348 | then libtelnet will automatically detect the start of a COMPRESS2 |
| 349 | stream, in either the sending or receiving direction. |
Sean Middleditch | 892c5f1 | 2009-03-14 13:39:07 -0400 | [diff] [blame] | 350 | |
| 351 | VI. TELNET PROXY UTILITY |
| 352 | ===================================================================== |
| 353 | |
| 354 | The telnet-proxy utility is a small application that serves both as |
| 355 | a testbed for libtelnet and as a powerful debugging tool for TELNET |
| 356 | servers and clients. |
| 357 | |
| 358 | To use telnet-proxy, you must first compile it using: |
| 359 | |
| 360 | $ make |
| 361 | |
| 362 | If you do not have zlib installed and wish to disable MCCP2 support |
| 363 | then you must first edit the Makefile and remove the -DHAVE_ZLIB and |
| 364 | the -lz from the compile flags. |
| 365 | |
Sean Middleditch | d88f183 | 2009-03-15 01:06:17 -0400 | [diff] [blame] | 366 | To run telnet-proxy, you simply give it the server's host name or |
| 367 | IP address, the server's port number, and the port number that |
| 368 | telnet-proxy should listen on. For example, to connect to the server |
| 369 | on mud.example.com port 7800 and to listen on port 5000, run: |
Sean Middleditch | 892c5f1 | 2009-03-14 13:39:07 -0400 | [diff] [blame] | 370 | |
Sean Middleditch | d88f183 | 2009-03-15 01:06:17 -0400 | [diff] [blame] | 371 | $ ./telnet-proxy mud.example.com 7800 5000 |
Sean Middleditch | 892c5f1 | 2009-03-14 13:39:07 -0400 | [diff] [blame] | 372 | |
| 373 | You can then connect to the host telnet-proxy is running on (e.g. |
Sean Middleditch | d88f183 | 2009-03-15 01:06:17 -0400 | [diff] [blame] | 374 | 127.0.0.1) on port 500 and you will automatically be proxied into |
| 375 | mud.example.com. |
Sean Middleditch | 892c5f1 | 2009-03-14 13:39:07 -0400 | [diff] [blame] | 376 | |
| 377 | telnet-proxy will display status information about the data |
Sean Middleditch | aefcd0c | 2009-03-15 13:16:44 -0400 | [diff] [blame] | 378 | passing through both ends of the tunnel. telnet-proxy can only |
| 379 | support a single tunnel at a time. It will continue running until |
| 380 | an error occurs or a terminating signal is sent to the proxy |
| 381 | process. |