-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconnect.h
208 lines (179 loc) · 6.56 KB
/
connect.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
/**************************************************************************/
// connect.h - connection_data class
/***************************************************************************
* The Dawn of Time v1.69r (c)1997-2004 Michael Garratt *
* >> A number of people have contributed to the Dawn codebase, with the *
* majority of code written by Michael Garratt - www.dawnoftime.org *
* >> To use this source code, you must fully comply with the dawn license *
* in licenses.txt... In particular, you may not remove this copyright *
* notice. *
**************************************************************************/
#ifndef CONNECT_H
#define CONNECT_H
/**************************************************************************/
//typedef unsigned int SOCKET;
/**************************************************************************/
#ifdef __CYGWIN__ // cygwin zlib support disabled due to compile errors
# define DISABLE_MCCP
#endif
#ifndef DISABLE_MCCP // define this in your project to disable MCCP
# ifdef WIN32
# ifdef WIN32_MCCP_ENABLED
# define MCCP_ENABLED
# endif
# endif
# ifdef unix
# ifdef HAVE_ZLIB
# define MCCP_ENABLED
# endif
# endif
#endif // DISABLE_MCCP
#ifdef MCCP_ENABLED
# include <zlib.h>
# define COMPRESS_BUF_SIZE (16384)
# ifdef WIN32
# pragma comment( lib, "zlib.lib")
# endif
#endif
#define INBUF_SIZE (4*MSL)
/**************************************************************************/
// connection (channel) class.
// bm_connection_data
class connection_data
{
public:
int write(const char *txt, int length ); // write to the socket, passing thru MCCP where appropriate
int write_colour(const char *txt, int length ); // write to the socket in colour, passing thru MCCP where appropriate
void check_completed_detect_and_mccp_turnon();
bool send_outbuf(); // called by process_output
void advertise_supported_telnet_options(); // send info on stuff like MCCP support etc (IAC signals basically)
void close_socket();
int process_telnet_options(int i);
void process_client2server_mxp_message(int end_of_line_index);
char *mxp_version;
char *mxp_supports;
char *mxp_options;
char *terminal_type; // retrieved according to RFC 930/1060
bool flush_output();
void make_connected_socket_invalid();
private:
void send_will_telnet_option( unsigned char option_value);
public:
connection_data * next;
// snoop
connection_data * snoop_by;
connection_data * command_snoop;
// web related connection data
web_request_data *web_request;
// character and switch
char_data * character;
char_data * original;
bool valid;
int connected_socket;
sh_int connected_state;
bool fcommand;
char inbuf [INBUF_SIZE];
char incomm [MIL*2]; // *2 to prevent buffer overflows
char inlast [MIL*2];
int repeat;
// holds data to be sent to connection (after colour parsing in write_into_buffer)
char * outbuf;
int outsize;
int outtop;
char * showstr_head;
char * showstr_point;
void * pEdit;
char ** pString;
int editor;
int * changed_flag;
// ip addresses relating to the connection
PROTOCOL_TYPE protocol; // PROTOCOL_IPV4 or PROTOCOL_IPV6
CONNECTION_TYPE contype;
// ip and dns information about the connected socket
char * local_ip;
int local_port;
char * local_tcp_pair; // ipv4:port or [ipv6]:port
char * remote_ip;
int remote_port;
char * remote_tcp_pair; // ipv4:port or [ipv6]:port
char * remote_hostname; // what the ip address resolves to
// ident results for the connected socket
char * ident_username; // username according to ident resolver
char * ident_raw_result; // raw ident response
bool ident_confirmed; // true if we know who we are talking to
bool resolved; // set to true when match_hnames returns
int connected_state_pulse_counter;// used to prevent it taking longer than 60 seconds
char * ip; // required for old code for nw
bool newbie_creating;
bool multiple_logins;
bool warned_about_idle;
time_t idle_since; // records the time of their last input
// colour system
COLOUR_TYPE colour_mode;
COLOUR_MEMORY_TYPE colour_memory;
bool parse_colour;
bool flashing_disabled;
// visual debugging system
bool visual_debugging_enabled;
bool visual_debug_hexoutput;
bool visual_debug_flush_before_prompt;
bool visual_debug_strip_prompt;
bool visual_debug_user;
int visual_debug_column_width;
int visual_debug_buffer_size;
char *visual_debug_buffer;
// condensing system
int condense_lastlen;
int condense_count;
char condense_buffer[MAX_CONDENSE_LENGTH];
// MUDFTP stuff
char * username;
struct
{
char * filename; // Filename being written to
char * data; // Data being written
short int lines_left; // Lines left
short int lines_sent; // Lines sent so far
ftp_mode mode; // FTP_xxx
bool inuse;
} ftp;
// Speedwalking
char *speedwalk_buf;
char *speedwalk_head;
// Remort system
sh_int creation_remort_number;
// multiple attempts at a password
unsigned char wrong_password_count;
int flags;
sh_int advertised_options_count;
bool mxp_enabled; // mxp enabled status
#ifdef MCCP_ENABLED
bool begin_compression();
bool continue_compression(); // for after a hotreboot
bool end_compression();
// mccp support
z_stream * out_compress;
unsigned char * out_compress_buf;
#endif // MCCP_ENABLED
short mccp_version; // has to be included in non MCCP_ENABLED versions
// of the mud because a previous copy of the mud
// may be MCCP enabled and transfer an mccp_version
// value across a hotreboot - Kal
unsigned int bytes_sent;
unsigned int bytes_sent_before_compression;
unsigned int bytes_sent_after_compression;
};
// connection flags
#define CONNECTFLAG_MSP_DETECTED (A)
#define CONNECTFLAG_MXP_DETECTED (B)
#define CONNECTFLAG_MXP_SECURE_PREFIX_EACH_LINE (C)
#define CONNECTFLAG_START_MCCP (D)
#define CONNECTFLAG_ANSWERED_MCCP1 (E)
#define CONNECTFLAG_ANSWERED_MCCP2 (F)
#define CONNECTFLAG_ANSWERED_MSP (G)
#define CONNECTFLAG_ANSWERED_MXP (H)
#define CONNECTFLAG_ANSWERED_MXP_VERSION (I)
#define CONNECTFLAG_USER_TAG_SENT (J)
#define CONNECTFLAG_MXP_LINKCOL_RECOMMENDATION_SENT (K)
#define CONNECTFLAG_ANSWERED_TELOPT_TERM_TYPE (L)
#endif // CONNECT_H