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
/**************************************************************************/
/* */
/* Copyright (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */
/* */
/* NXSSH, NX protocol compression and NX extensions to this software */
/* are copyright of NoMachine. Redistribution and use of the present */
/* software is allowed according to terms specified in the file LICENSE */
/* which comes in the source distribution. */
/* */
/* Check http://www.nomachine.com/licensing.html for applicability. */
/* */
/* NX and NoMachine are trademarks of Medialogic S.p.A. */
/* */
/* All rights reserved. */
/* */
/**************************************************************************/
/*
* Do we share the debug log with the proxy?
*/
extern int nx_proxy_log;
/*
* Do we check for the incoming command? This flag
* should be bound to a command line parameter.
*/
extern int nx_check_switch;
/*
* Did we receive the command? Switch is executed at
* the time the first channel receives the command,
* thus it is important to note that port forwarding
* should always be disabled when enabling the check.
*/
extern int nx_switch_received;
/*
* Parameters read from the switch command.
*/
extern char nx_switch_cookie[256];
extern char nx_switch_host[256];
extern int nx_switch_proxy;
extern int nx_switch_port;
extern int nx_switch_in;
extern int nx_switch_out;
extern char nx_switch_mode[256];
extern char nx_switch_options[1024];
extern int nx_switch_internal;
extern int nx_switch_forward;
/*
* Buffer the input while looking for the command.
* The buffering happens by flushing the input when
* a newline is received. This means that all input
* should be terminated with a newline or it will
* remain in the buffer and will never be sent to
* the packet interface.
*/
int nx_check_channel_input(Channel *channel, char *data, int *length, int limit);
/*
* Init buffer
*/
void nx_proxy_init();
/*
* Replace the select() with the version managing
* the NX descriptors.
*/
int nx_proxy_select(int maxfds, fd_set *readfds, fd_set *writefds,
fd_set *exceptfds, struct timeval *timeout);
/*
* Connect to the NX transport.
*/
int nx_open_proxy_connection();
/*
* Wait for the NX transport to terminate.
*/
int nx_close_proxy_connection();
/*
* If cookie was passed, manage authentication.
*/
int nx_check_proxy_authentication(int proxy_fd);
/*
* Reassign the descriptors.
*/
int nx_switch_client_side_descriptors(Channel *channel, int proxy_fd);
/*
* Reassign the descriptors.
*/
int nx_switch_forward_descriptors(Channel *channel);
/*
* Forward port to remote sshd.
*/
int nx_switch_forward_port(Channel *channel);
/*
* Used in ssh.c to monitor the standard input
* until the switch command is received.
*/
int nx_check_standard_input();
/*
* Used in ssh.c. Connect to the proxy and run the
* restricted loop forwarding the traffic to the
* local proxy.
*/
void nx_switch_server_side_descriptors();
/*
* Set the preferred options for using the socket
* with NX.
*/
void nx_set_socket_options(int fd, int blocking);
/*
* Wrappers used to get and set the environment.
*/
const char *nx_get_environment(const char *name);
int nx_set_environment(const char *name, const char *value);