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
f532b9ae
Commit
f532b9ae
authored
Oct 28, 2016
by
Krzysztof Kliś
Committed by
GitHub
Oct 28, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3 from ticpu/systemd
Use systemd notify system to start daemon and give status.
parents
7d97d1ae
a6a5b493
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 @
f532b9ae
...
...
@@ -43,6 +43,9 @@
#include <sys/socket.h>
#include <unistd.h>
#include <wait.h>
#ifdef USE_SYSTEMD
#include <systemd/sd-daemon.h>
#endif
#define BUF_SIZE 16384
...
...
@@ -73,6 +76,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
;
...
...
@@ -176,9 +180,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 */
...
...
@@ -193,13 +205,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