Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
P
proxy-in-proxychains
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
proxy-in-proxychains
Commits
a6a5b493
Commit
a6a5b493
authored
Oct 28, 2016
by
jerome.poulin
Committed by
Jérôme Poulin
Oct 28, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use systemd notify system to start daemon and give status.
parent
dca4e2e9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
1 deletion
+19
-1
proxy.c
proxy.c
+19
-1
No files found.
proxy.c
View file @
a6a5b493
...
...
@@ -42,6 +42,9 @@
#include <sys/socket.h>
#include <unistd.h>
#include <wait.h>
#ifdef USE_SYSTEMD
#include <systemd/sd-daemon.h>
#endif
#define BUF_SIZE 16384
...
...
@@ -72,6 +75,7 @@ int create_connection();
int
parse_options
(
int
argc
,
char
*
argv
[]);
int
server_sock
,
client_sock
,
remote_sock
,
remote_port
=
0
;
int
connections_processed
=
0
;
char
*
remote_host
,
*
cmd_in
,
*
cmd_out
;
bool
foreground
=
FALSE
;
...
...
@@ -175,9 +179,17 @@ int create_socket(int port) {
return
server_sock
;
}
void
update_connection_count
()
{
#ifdef USE_SYSTEMD
sd_notifyf
(
0
,
"STATUS=Ready. %d connections processed.
\n
"
,
connections_processed
);
#endif
}
/* Handle finished child process */
void
sigchld_handler
(
int
signal
)
{
while
(
waitpid
(
-
1
,
NULL
,
WNOHANG
)
>
0
);
update_connection_count
();
}
/* Handle term signal */
...
...
@@ -192,13 +204,19 @@ void server_loop() {
struct
sockaddr_in
client_addr
;
socklen_t
addrlen
=
sizeof
(
client_addr
);
#ifdef USE_SYSTEMD
sd_notify
(
0
,
"READY=1
\n
"
);
#endif
while
(
TRUE
)
{
update_connection_count
();
client_sock
=
accept
(
server_sock
,
(
struct
sockaddr
*
)
&
client_addr
,
&
addrlen
);
if
(
fork
()
==
0
)
{
// handle client connection in a separate process
close
(
server_sock
);
handle_client
(
client_sock
,
client_addr
);
exit
(
0
);
}
}
else
connections_processed
++
;
close
(
client_sock
);
}
...
...
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