Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Main
Synchronet
Commits
01a7a558
Commit
01a7a558
authored
Aug 09, 2013
by
rswindell
Browse files
More telnet_gate/rlogin_gate() merging.
parent
c1b9677b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
195 deletions
+1
-195
src/sbbs3/telgate.cpp
src/sbbs3/telgate.cpp
+1
-195
No files found.
src/sbbs3/telgate.cpp
View file @
01a7a558
...
...
@@ -144,7 +144,7 @@ void sbbs_t::telnet_gate(char* destaddr, ulong mode, char* name, char* passwd)
/* Text/NVT mode by default */
request_telnet_opt
(
TELNET_DONT
,
TELNET_BINARY_TX
,
3000
);
if
(
mode
&
(
TG_PASSTHRU
|
TG_RLOGIN
))
if
(
!
(
telnet_mode
&
TELNET_MODE_OFF
)
&&
(
mode
&
TG_PASSTHRU
))
telnet_mode
|=
TELNET_MODE_GATE
;
// Pass-through telnet commands
while
(
online
)
{
...
...
@@ -276,197 +276,3 @@ void sbbs_t::telnet_gate(char* destaddr, ulong mode, char* name, char* passwd)
lprintf
(
LOG_INFO
,
"Node %d Telnet gate to %s finished"
,
cfg
.
node_num
,
destaddr
);
}
void
sbbs_t
::
rlogin_gate
(
char
*
destaddr
,
char
*
alias
,
char
*
pass
,
ulong
mode
)
{
char
*
p
;
uchar
buf
[
512
];
int
i
;
int
rd
;
uint
attempts
;
ulong
l
;
bool
gotline
;
ushort
port
=
513
;
ulong
ip_addr
;
ulong
save_console
;
SOCKET
remote_socket
;
SOCKADDR_IN
addr
;
/* if port was specified with address, use it */
p
=
strchr
(
destaddr
,
':'
);
if
(
p
!=
NULL
)
{
*
p
=
0
;
port
=
atoi
(
p
+
1
);
}
ip_addr
=
resolve_ip
(
destaddr
);
if
(
ip_addr
==
INADDR_NONE
)
{
lprintf
(
LOG_NOTICE
,
"!RLOGIN Failed to resolve address: %s"
,
destaddr
);
bprintf
(
"!Failed to resolve address: %s
\r\n
"
,
destaddr
);
return
;
}
if
((
remote_socket
=
open_socket
(
SOCK_STREAM
,
client
.
protocol
))
==
INVALID_SOCKET
)
{
errormsg
(
WHERE
,
ERR_OPEN
,
"socket"
,
0
);
return
;
}
/* todo: figure this shit out */
memset
(
&
addr
,
0
,
sizeof
(
addr
));
addr
.
sin_addr
.
s_addr
=
htonl
(
startup
->
telnet_interface
);
addr
.
sin_family
=
AF_INET
;
if
((
i
=
bind
(
remote_socket
,
(
struct
sockaddr
*
)
&
addr
,
sizeof
(
addr
)))
!=
0
)
{
lprintf
(
LOG_NOTICE
,
"!RLOGIN ERROR %d (%d) binding to socket %d"
,
i
,
ERROR_VALUE
,
remote_socket
);
bprintf
(
"!ERROR %d (%d) binding to socket
\r\n
"
,
i
,
ERROR_VALUE
);
close_socket
(
remote_socket
);
return
;
}
memset
(
&
addr
,
0
,
sizeof
(
addr
));
addr
.
sin_addr
.
s_addr
=
ip_addr
;
addr
.
sin_family
=
AF_INET
;
addr
.
sin_port
=
htons
(
port
);
if
((
i
=
connect
(
remote_socket
,
(
struct
sockaddr
*
)
&
addr
,
sizeof
(
addr
)))
!=
0
)
{
lprintf
(
LOG_NOTICE
,
"!RLOGIN ERROR %d (%d) connecting to server: %s"
,
i
,
ERROR_VALUE
,
destaddr
);
bprintf
(
"!ERROR %d (%d) connecting to server: %s
\r\n
"
,
i
,
ERROR_VALUE
,
destaddr
);
close_socket
(
remote_socket
);
return
;
}
l
=
1
;
if
((
i
=
ioctlsocket
(
remote_socket
,
FIONBIO
,
&
l
))
!=
0
)
{
lprintf
(
LOG_NOTICE
,
"!RLOGIN ERROR %d (%d) disabling socket blocking"
,
i
,
ERROR_VALUE
);
close_socket
(
remote_socket
);
return
;
}
lprintf
(
LOG_INFO
,
"Node %d %s gate to %s port %u on socket %d"
,
cfg
.
node_num
,
"RLogin"
,
destaddr
,
port
,
remote_socket
);
/* rlogin handshake */
lprintf
(
LOG_NOTICE
,
"!RLOGIN terminal: %s"
,
terminal
);
p
=
(
char
*
)
buf
;
*
(
p
++
)
=
0
;
if
(
alias
!=
NULL
)
{
p
+=
sprintf
(
p
,
"%s"
,
alias
);
}
else
{
p
+=
sprintf
(
p
,
"%s"
,
useron
.
alias
);
}
p
++
;
// Add NULL
if
(
pass
!=
NULL
)
{
p
+=
sprintf
(
p
,
"%s"
,
pass
);
}
else
{
p
+=
sprintf
(
p
,
"%s"
,
useron
.
pass
);
}
p
++
;
// Add NULL
p
+=
sprintf
(
p
,
"%s/57600"
,
terminal
);
p
++
;
// Add NULL
l
=
p
-
(
char
*
)
buf
;
sendsocket
(
remote_socket
,(
char
*
)
buf
,
l
);
while
(
online
)
{
if
(
!
(
mode
&
TG_NOCHKTIME
))
gettimeleft
();
rd
=
RingBufRead
(
&
inbuf
,
buf
,
sizeof
(
buf
));
if
(
rd
)
{
if
(
telnet_remote_option
[
TELNET_BINARY_TX
]
!=
TELNET_WILL
)
{
if
(
*
buf
==
0x1d
)
{
// ^]
save_console
=
console
;
console
&=~
CON_RAW_IN
;
// Allow Ctrl-U/Ctrl-P
CRLF
;
while
(
online
)
{
SYNC
;
mnemonics
(
"
\1
n
\r\n\1
h
\1
bTelnet Gate:
\1
y~D
\1
wisconnect, "
"
\1
y~E
\1
wcho toggle,
\1
y~L
\1
wist Users,
\1
y~P
\1
wrivate message, "
"
\1
y~Q
\1
wuit: "
);
switch
(
getkeys
(
"DELPQ"
,
0
))
{
case
'D'
:
closesocket
(
remote_socket
);
break
;
case
'E'
:
mode
^=
TG_ECHO
;
bprintf
(
text
[
EchoIsNow
]
,
mode
&
TG_ECHO
?
text
[
ON
]
:
text
[
OFF
]);
continue
;
case
'L'
:
whos_online
(
true
);
continue
;
case
'P'
:
nodemsg
();
continue
;
}
break
;
}
attr
(
LIGHTGRAY
);
console
=
save_console
;
}
else
if
(
*
buf
<
' '
&&
mode
&
TG_CTRLKEYS
)
handle_ctrlkey
(
*
buf
,
K_NONE
);
gotline
=
false
;
if
(
mode
&
TG_LINEMODE
&&
buf
[
0
]
!=
'\r'
)
{
ungetkey
(
buf
[
0
]);
l
=
K_CHAT
;
if
(
!
(
mode
&
TG_ECHO
))
l
|=
K_NOECHO
;
rd
=
getstr
((
char
*
)
buf
,
sizeof
(
buf
)
-
1
,
l
);
if
(
!
rd
)
continue
;
strcat
((
char
*
)
buf
,
crlf
);
rd
+=
2
;
gotline
=
true
;
}
if
(
!
gotline
&&
mode
&
TG_ECHO
)
{
RingBufWrite
(
&
outbuf
,
buf
,
rd
);
}
}
for
(
attempts
=
0
;
attempts
<
60
&&
online
;
attempts
++
)
{
if
((
i
=
sendsocket
(
remote_socket
,(
char
*
)
buf
,
rd
))
>=
0
)
break
;
if
(
ERROR_VALUE
!=
EWOULDBLOCK
)
break
;
mswait
(
500
);
}
if
(
i
<
0
)
{
lprintf
(
LOG_NOTICE
,
"!RLOGIN ERROR %d sending on socket %d"
,
ERROR_VALUE
,
remote_socket
);
break
;
}
}
rd
=
recv
(
remote_socket
,(
char
*
)
buf
,
sizeof
(
buf
),
0
);
if
(
rd
<
0
)
{
if
(
ERROR_VALUE
==
EWOULDBLOCK
)
{
if
(
mode
&
TG_NODESYNC
)
{
SYNC
;
}
else
{
// Check if the node has been interrupted
getnodedat
(
cfg
.
node_num
,
&
thisnode
,
0
);
if
(
thisnode
.
misc
&
NODE_INTR
)
break
;
}
YIELD
();
continue
;
}
lprintf
(
LOG_NOTICE
,
"!RLOGIN ERROR %d receiving on socket %d"
,
ERROR_VALUE
,
remote_socket
);
break
;
}
if
(
!
rd
)
{
lprintf
(
LOG_INFO
,
"Node %d RLogin gate disconnected"
,
cfg
.
node_num
);
break
;
}
RingBufWrite
(
&
outbuf
,
buf
,
rd
);
}
close_socket
(
remote_socket
);
lprintf
(
LOG_INFO
,
"Node %d RLogin gate to %s finished"
,
cfg
.
node_num
,
destaddr
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment