Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
N
noVNC
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
rasky
noVNC
Commits
ee26cbf2
Commit
ee26cbf2
authored
Jun 17, 2010
by
Joel Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Argument processing fixes. Misc proxy fixes.
parent
6ee61a4c
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
33 deletions
+28
-33
Makefile
utils/Makefile
+1
-5
websocket.c
utils/websocket.c
+6
-5
websocket.h
utils/websocket.h
+2
-3
wsproxy.c
utils/wsproxy.c
+16
-18
wsproxy.py
utils/wsproxy.py
+3
-2
No files found.
utils/Makefile
View file @
ee26cbf2
wsproxy
:
wsproxy.o websocket.o
$(CC)
$^
-l
ssl
-l
resolv
-o
$@
#websocket.o: websocket.c
# $(CC) -c $^ -o $@
#
#wsproxy.o: wsproxy.c
# $(CC) -c $^ -o $@
websocket.o wsproxy.o
:
websocket.h
clean
:
rm
-f
wsproxy wsproxy.o websocket.o
...
...
utils/websocket.c
View file @
ee26cbf2
...
...
@@ -296,12 +296,13 @@ ws_ctx_t *do_handshake(int sock) {
return
NULL
;
}
else
if
(
bcmp
(
handshake
,
"
\x16
"
,
1
)
==
0
)
{
// SSL
if
(
!
settings
.
cert
)
{
return
NULL
;
}
ws_ctx
=
ws_socket_ssl
(
sock
,
settings
.
cert
);
if
(
!
ws_ctx
)
{
return
NULL
;
}
scheme
=
"wss"
;
printf
(
" using SSL socket
\n
"
);
}
else
if
(
settings
.
ssl_only
)
{
printf
(
"Non-SSL connection disallowed"
);
printf
(
"Non-SSL connection disallowed
\n
"
);
close
(
sock
);
return
NULL
;
}
else
{
...
...
@@ -401,10 +402,6 @@ void start_server() {
struct
sockaddr_in
serv_addr
,
cli_addr
;
ws_ctx_t
*
ws_ctx
;
if
(
settings
.
daemon
)
{
daemonize
();
}
/* Initialize buffers */
bufsize
=
65536
;
if
(
!
(
tbuf
=
malloc
(
bufsize
))
)
...
...
@@ -416,6 +413,10 @@ void start_server() {
if
(
!
(
cbuf_tmp
=
malloc
(
bufsize
))
)
{
fatal
(
"malloc()"
);
}
if
(
settings
.
daemon
)
{
daemonize
();
}
lsock
=
socket
(
AF_INET
,
SOCK_STREAM
,
0
);
if
(
lsock
<
0
)
{
error
(
"ERROR creating listener socket"
);
}
bzero
((
char
*
)
&
serv_addr
,
sizeof
(
serv_addr
));
...
...
utils/websocket.h
View file @
ee26cbf2
#include <openssl/ssl.h>
#include <unistd.h>
typedef
struct
{
int
sockfd
;
...
...
@@ -13,8 +12,8 @@ typedef struct {
void
(
*
handler
)(
ws_ctx_t
*
);
int
ssl_only
;
int
daemon
;
char
record
[
1024
]
;
char
cert
[
1024
]
;
char
*
record
;
char
*
cert
;
}
settings_t
;
typedef
struct
{
...
...
utils/wsproxy.c
View file @
ee26cbf2
...
...
@@ -7,6 +7,7 @@
*/
#include <stdio.h>
#include <errno.h>
#include <limits.h>
#include <getopt.h>
#include <sys/socket.h>
#include <netinet/in.h>
...
...
@@ -198,8 +199,8 @@ void proxy_handler(ws_ctx_t *ws_ctx) {
int
tsock
=
0
;
struct
sockaddr_in
taddr
;
if
(
settings
.
record
)
{
recordfd
=
open
(
settings
.
record
,
O_WRONLY
|
O_CREAT
|
O_
TRUNC
,
if
(
settings
.
record
&&
settings
.
record
[
0
]
!=
'\0'
)
{
recordfd
=
open
(
settings
.
record
,
O_WRONLY
|
O_CREAT
|
O_
APPEND
,
S_IRUSR
|
S_IWUSR
|
S_IRGRP
|
S_IROTH
);
}
...
...
@@ -238,7 +239,7 @@ void proxy_handler(ws_ctx_t *ws_ctx) {
int
main
(
int
argc
,
char
*
argv
[])
{
int
listen_port
,
c
,
option_index
=
0
;
int
listen_port
,
fd
,
c
,
option_index
=
0
;
static
int
ssl_only
=
0
,
foreground
=
0
;
char
*
found
;
static
struct
option
long_options
[]
=
{
...
...
@@ -250,8 +251,8 @@ int main(int argc, char *argv[])
{
0
,
0
,
0
,
0
}
};
settings
.
record
[
0
]
=
'\0'
;
s
trcpy
(
settings
.
cert
,
"self.pem"
);
settings
.
record
=
NULL
;
s
ettings
.
cert
=
realpath
(
"self.pem"
,
NULL
);
while
(
1
)
{
c
=
getopt_long
(
argc
,
argv
,
"fr:c:"
,
...
...
@@ -269,10 +270,18 @@ int main(int argc, char *argv[])
foreground
=
1
;
break
;
case
'r'
:
memcpy
(
settings
.
record
,
optarg
,
sizeof
(
settings
.
record
));
if
((
fd
=
open
(
optarg
,
O_CREAT
,
S_IRUSR
|
S_IWUSR
|
S_IRGRP
|
S_IROTH
))
<
-
1
)
{
fatal
(
"Could not access %s
\n
"
,
optarg
);
}
close
(
fd
);
settings
.
record
=
realpath
(
optarg
,
NULL
);
break
;
case
'c'
:
memcpy
(
settings
.
cert
,
optarg
,
sizeof
(
settings
.
cert
));
settings
.
cert
=
realpath
(
optarg
,
NULL
);
if
(
!
settings
.
cert
)
{
fatal
(
"No cert file at %s
\n
"
,
optarg
);
}
break
;
default:
usage
();
...
...
@@ -314,17 +323,6 @@ int main(int argc, char *argv[])
usage
();
}
/* Initialize buffers */
bufsize
=
65536
;
if
(
!
(
tbuf
=
malloc
(
bufsize
))
)
{
fatal
(
"malloc()"
);
}
if
(
!
(
cbuf
=
malloc
(
bufsize
))
)
{
fatal
(
"malloc()"
);
}
if
(
!
(
tbuf_tmp
=
malloc
(
bufsize
))
)
{
fatal
(
"malloc()"
);
}
if
(
!
(
cbuf_tmp
=
malloc
(
bufsize
))
)
{
fatal
(
"malloc()"
);
}
settings
.
handler
=
proxy_handler
;
start_server
();
...
...
utils/wsproxy.py
View file @
ee26cbf2
...
...
@@ -101,7 +101,7 @@ def proxy_handler(client):
if
settings
[
'record'
]:
print
"Opening record file:
%
s"
%
settings
[
'record'
]
rec
=
open
(
settings
[
'record'
],
'
w
'
)
rec
=
open
(
settings
[
'record'
],
'
a
'
)
print
"Connecting to:
%
s:
%
s"
%
(
target_host
,
target_port
)
tsock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
...
...
@@ -152,5 +152,6 @@ if __name__ == '__main__':
settings
[
'cert'
]
=
os
.
path
.
abspath
(
options
.
cert
)
settings
[
'ssl_only'
]
=
options
.
ssl_only
settings
[
'daemon'
]
=
options
.
daemon
if
options
.
record
:
settings
[
'record'
]
=
os
.
path
.
abspath
(
options
.
record
)
start_server
()
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