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
5c34ce4b
Commit
5c34ce4b
authored
14 years ago
by
Joel Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More arg processing fixes.
parent
ee26cbf2
master
app
binary
feature/ikvm-support
feature/more-perf-improvements
feature/new-zlib-impl
issue-70
mobile
novnc-legacy
refactor/modularized
tests/travis-container
tests/update-deps
tmp-branch/throw-error-on-error
xpra
v0.5.1
v0.5
v0.4
v0.3
v0.2
v0.1
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
18 deletions
+28
-18
wsproxy.c
utils/wsproxy.c
+25
-18
wsproxy.py
utils/wsproxy.py
+3
-0
No files found.
utils/wsproxy.c
View file @
5c34ce4b
...
...
@@ -32,10 +32,10 @@ Traffic Legend:\n\
char
USAGE
[]
=
"Usage: [--record FILE] [--ssl-only] "
\
"[source_addr:]source_port target_addr:target_port"
;
void
usage
()
{
fprintf
(
stderr
,
"%s
\n
"
,
USAGE
);
#define usage(fmt, args...) \
fprintf(stderr, "%s\n\n", USAGE); \
fprintf(stderr, fmt , ## args); \
exit(1);
}
char
target_host
[
256
];
int
target_port
;
...
...
@@ -217,7 +217,7 @@ void proxy_handler(ws_ctx_t *ws_ctx) {
/* Resolve target address */
if
(
resolve_host
(
&
taddr
.
sin_addr
,
target_host
)
<
-
1
)
{
fatal
(
"Could not resolve target address"
);
error
(
"Could not resolve target address"
);
}
if
(
connect
(
tsock
,
(
struct
sockaddr
*
)
&
taddr
,
sizeof
(
taddr
))
<
0
)
{
...
...
@@ -272,7 +272,7 @@ int main(int argc, char *argv[])
case
'r'
:
if
((
fd
=
open
(
optarg
,
O_CREAT
,
S_IRUSR
|
S_IWUSR
|
S_IRGRP
|
S_IROTH
))
<
-
1
)
{
fatal
(
"Could not access %s
\n
"
,
optarg
);
usage
(
"Could not access %s
\n
"
,
optarg
);
}
close
(
fd
);
settings
.
record
=
realpath
(
optarg
,
NULL
);
...
...
@@ -280,23 +280,18 @@ int main(int argc, char *argv[])
case
'c'
:
settings
.
cert
=
realpath
(
optarg
,
NULL
);
if
(
!
settings
.
cert
)
{
fatal
(
"No cert file at %s
\n
"
,
optarg
);
usage
(
"No cert file at %s
\n
"
,
optarg
);
}
break
;
default:
usage
();
usage
(
"Invalid option %c
\n
"
,
c
);
}
}
settings
.
ssl_only
=
ssl_only
;
settings
.
daemon
=
foreground
?
0
:
1
;
printf
(
" ssl_only: %d
\n
"
,
settings
.
ssl_only
);
printf
(
" daemon: %d
\n
"
,
settings
.
daemon
);
printf
(
" record: %s
\n
"
,
settings
.
record
);
printf
(
" cert: %s
\n
"
,
settings
.
cert
);
if
((
argc
-
optind
)
!=
2
)
{
usage
();
usage
(
"Invalid number of arguments
\n
"
);
}
found
=
strstr
(
argv
[
optind
],
":"
);
...
...
@@ -308,8 +303,8 @@ int main(int argc, char *argv[])
settings
.
listen_port
=
strtol
(
argv
[
optind
],
NULL
,
10
);
}
optind
++
;
if
(
(
errno
!=
0
)
||
(
listen_port
==
0
)
)
{
usage
();
if
(
listen_port
==
0
)
{
usage
(
"Could not parse listen_port
\n
"
);
}
found
=
strstr
(
argv
[
optind
],
":"
);
...
...
@@ -317,12 +312,24 @@ int main(int argc, char *argv[])
memcpy
(
target_host
,
argv
[
optind
],
found
-
argv
[
optind
]);
target_port
=
strtol
(
found
+
1
,
NULL
,
10
);
}
else
{
usage
();
usage
(
"Target argument must be host:port
\n
"
);
}
if
(
target_port
==
0
)
{
usage
(
"Could not parse target port
\n
"
);
}
if
((
errno
!=
0
)
||
(
target_port
==
0
))
{
usage
();
if
(
ssl_only
)
{
printf
(
"cert: %s
\n
"
,
settings
.
cert
);
if
(
!
settings
.
cert
||
!
access
(
settings
.
cert
))
{
usage
(
"SSL only and cert file not found
\n
"
);
}
}
//printf(" ssl_only: %d\n", settings.ssl_only);
//printf(" daemon: %d\n", settings.daemon);
//printf(" record: %s\n", settings.record);
//printf(" cert: %s\n", settings.cert);
settings
.
handler
=
proxy_handler
;
start_server
();
...
...
This diff is collapsed.
Click to expand it.
utils/wsproxy.py
View file @
5c34ce4b
...
...
@@ -146,6 +146,9 @@ if __name__ == '__main__':
try
:
target_port
=
int
(
target_port
)
except
:
parser
.
error
(
"Error parsing target port"
)
if
options
.
ssl_only
and
not
os
.
path
.
exists
(
options
.
cert
):
parser
.
error
(
"SSL only and
%
s not found"
%
options
.
cert
)
settings
[
'listen_host'
]
=
host
settings
[
'listen_port'
]
=
port
settings
[
'handler'
]
=
proxy_handler
...
...
This diff is collapsed.
Click to expand it.
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