Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
wsssh
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexlab
wsssh
Commits
de7f84c5
Commit
de7f84c5
authored
Jan 19, 2026
by
Stefy Lanza (nextime / spora )
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add debug logging to web proxy for troubleshooting connection issues
parent
c1447922
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
1 deletion
+14
-1
web_proxy.c
wssshd2/web_proxy.c
+14
-1
No files found.
wssshd2/web_proxy.c
View file @
de7f84c5
...
@@ -450,10 +450,13 @@ static int handle_proxy_request(int client_fd, wssshd_state_t *state, const wsss
...
@@ -450,10 +450,13 @@ static int handle_proxy_request(int client_fd, wssshd_state_t *state, const wsss
bool
use_ssl
=
false
;
bool
use_ssl
=
false
;
if
(
strcmp
(
service_type
,
"https"
)
==
0
)
{
if
(
strcmp
(
service_type
,
"https"
)
==
0
)
{
use_ssl
=
true
;
use_ssl
=
true
;
printf
(
"[WEB-PROXY] Service type 'https', using SSL
\n
"
);
}
else
if
(
strcmp
(
service_type
,
"web"
)
==
0
)
{
}
else
if
(
strcmp
(
service_type
,
"web"
)
==
0
)
{
use_ssl
=
true
;
// Try HTTPS first for 'web'
use_ssl
=
true
;
// Try HTTPS first for 'web'
printf
(
"[WEB-PROXY] Service type 'web', trying SSL first
\n
"
);
}
else
{
printf
(
"[WEB-PROXY] Service type '%s', using plain TCP
\n
"
,
service_type
);
}
}
// 'http' leaves use_ssl = false
// Find or create wsssht process
// Find or create wsssht process
wsssht_process_t
*
proc
=
find_or_create_wsssht_process
(
hostname
,
service_type
,
client
->
client_id
,
config
->
domain
);
wsssht_process_t
*
proc
=
find_or_create_wsssht_process
(
hostname
,
service_type
,
client
->
client_id
,
config
->
domain
);
...
@@ -476,20 +479,26 @@ static int handle_proxy_request(int client_fd, wssshd_state_t *state, const wsss
...
@@ -476,20 +479,26 @@ static int handle_proxy_request(int client_fd, wssshd_state_t *state, const wsss
addr
.
sin_addr
.
s_addr
=
htonl
(
INADDR_LOOPBACK
);
addr
.
sin_addr
.
s_addr
=
htonl
(
INADDR_LOOPBACK
);
addr
.
sin_port
=
htons
(
proc
->
port
);
addr
.
sin_port
=
htons
(
proc
->
port
);
printf
(
"[WEB-PROXY] Connecting to wsssht on localhost:%d
\n
"
,
proc
->
port
);
if
(
connect
(
tunnel_fd
,
(
struct
sockaddr
*
)
&
addr
,
sizeof
(
addr
))
<
0
)
{
if
(
connect
(
tunnel_fd
,
(
struct
sockaddr
*
)
&
addr
,
sizeof
(
addr
))
<
0
)
{
perror
(
"[WEB-PROXY] Failed to connect to wsssht"
);
close
(
tunnel_fd
);
close
(
tunnel_fd
);
send_http_error
(
client_fd
,
502
,
"Bad Gateway"
);
send_http_error
(
client_fd
,
502
,
"Bad Gateway"
);
return
-
1
;
return
-
1
;
}
}
printf
(
"[WEB-PROXY] Connected to wsssht
\n
"
);
// SSL setup if needed
// SSL setup if needed
SSL_CTX
*
ssl_ctx
=
NULL
;
SSL_CTX
*
ssl_ctx
=
NULL
;
SSL
*
tunnel_ssl
=
NULL
;
SSL
*
tunnel_ssl
=
NULL
;
if
(
use_ssl
)
{
if
(
use_ssl
)
{
printf
(
"[WEB-PROXY] Setting up SSL connection
\n
"
);
ssl_ctx
=
create_ssl_context
();
ssl_ctx
=
create_ssl_context
();
if
(
!
ssl_ctx
)
{
if
(
!
ssl_ctx
)
{
printf
(
"[WEB-PROXY] Failed to create SSL context
\n
"
);
if
(
strcmp
(
service_type
,
"web"
)
==
0
)
{
if
(
strcmp
(
service_type
,
"web"
)
==
0
)
{
use_ssl
=
false
;
// Fallback to HTTP
use_ssl
=
false
;
// Fallback to HTTP
printf
(
"[WEB-PROXY] Falling back to plain TCP
\n
"
);
}
else
{
}
else
{
close
(
tunnel_fd
);
close
(
tunnel_fd
);
send_http_error
(
client_fd
,
502
,
"Bad Gateway"
);
send_http_error
(
client_fd
,
502
,
"Bad Gateway"
);
...
@@ -498,14 +507,18 @@ static int handle_proxy_request(int client_fd, wssshd_state_t *state, const wsss
...
@@ -498,14 +507,18 @@ static int handle_proxy_request(int client_fd, wssshd_state_t *state, const wsss
}
else
{
}
else
{
tunnel_ssl
=
create_ssl_connection
(
ssl_ctx
,
tunnel_fd
,
0
);
tunnel_ssl
=
create_ssl_connection
(
ssl_ctx
,
tunnel_fd
,
0
);
if
(
!
tunnel_ssl
)
{
if
(
!
tunnel_ssl
)
{
printf
(
"[WEB-PROXY] SSL connection failed
\n
"
);
SSL_CTX_free
(
ssl_ctx
);
SSL_CTX_free
(
ssl_ctx
);
if
(
strcmp
(
service_type
,
"web"
)
==
0
)
{
if
(
strcmp
(
service_type
,
"web"
)
==
0
)
{
use_ssl
=
false
;
// Fallback to HTTP
use_ssl
=
false
;
// Fallback to HTTP
printf
(
"[WEB-PROXY] Falling back to plain TCP
\n
"
);
}
else
{
}
else
{
close
(
tunnel_fd
);
close
(
tunnel_fd
);
send_http_error
(
client_fd
,
502
,
"Bad Gateway"
);
send_http_error
(
client_fd
,
502
,
"Bad Gateway"
);
return
-
1
;
return
-
1
;
}
}
}
else
{
printf
(
"[WEB-PROXY] SSL connection established
\n
"
);
}
}
}
}
}
}
...
...
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