Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
5c10d2de
Commit
5c10d2de
authored
Feb 28, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
client: use sockaddr_to_string()
Removed the sockaddr_to_tmp_string() hack, use the new function sockaddr_to_string() instead.
parent
e085deb9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
47 deletions
+9
-47
client.c
src/client.c
+7
-45
client.h
src/client.h
+1
-1
listen.c
src/listen.c
+1
-1
No files found.
src/client.c
View file @
5c10d2de
...
...
@@ -20,6 +20,7 @@
#include "command.h"
#include "conf.h"
#include "listen.h"
#include "socket_util.h"
#include "permission.h"
#include "event_pipe.h"
#include "idle.h"
...
...
@@ -250,51 +251,10 @@ static void client_close(struct client *client)
g_free
(
client
);
}
static
const
char
*
sockaddr_to_tmp_string
(
const
struct
sockaddr
*
addr
)
{
const
char
*
hostname
;
switch
(
addr
->
sa_family
)
{
#ifdef HAVE_TCP
case
AF_INET
:
hostname
=
(
const
char
*
)
inet_ntoa
(((
const
struct
sockaddr_in
*
)
addr
)
->
sin_addr
);
if
(
!
hostname
)
hostname
=
"error getting ipv4 address"
;
break
;
#ifdef HAVE_IPV6
case
AF_INET6
:
{
static
char
host
[
INET6_ADDRSTRLEN
+
1
];
memset
(
host
,
0
,
INET6_ADDRSTRLEN
+
1
);
if
(
inet_ntop
(
AF_INET6
,
(
const
void
*
)
&
(((
const
struct
sockaddr_in6
*
)
addr
)
->
sin6_addr
),
host
,
INET6_ADDRSTRLEN
))
{
hostname
=
(
const
char
*
)
host
;
}
else
{
hostname
=
"error getting ipv6 address"
;
}
}
break
;
#endif
#endif
/* HAVE_TCP */
#ifdef HAVE_UN
case
AF_UNIX
:
hostname
=
"local connection"
;
break
;
#endif
/* HAVE_UN */
default:
hostname
=
"unknown"
;
}
return
hostname
;
}
void
client_new
(
int
fd
,
const
struct
sockaddr
*
addr
,
int
uid
)
void
client_new
(
int
fd
,
const
struct
sockaddr
*
sa
,
size_t
sa_length
,
int
uid
)
{
struct
client
*
client
;
char
*
remote
;
if
(
num_clients
>=
client_max_connections
)
{
g_warning
(
"Max Connections Reached!"
);
...
...
@@ -308,9 +268,11 @@ void client_new(int fd, const struct sockaddr *addr, int uid)
client_init
(
client
,
fd
);
client
->
uid
=
uid
;
remote
=
sockaddr_to_string
(
sa
,
sa_length
,
NULL
);
g_log
(
G_LOG_DOMAIN
,
LOG_LEVEL_SECURE
,
"[%u] opened from %s"
,
client
->
num
,
sockaddr_to_tmp_string
(
addr
)
);
"[%u] opened from %s"
,
client
->
num
,
remote
);
g_free
(
remote
);
}
static
int
client_process_line
(
struct
client
*
client
,
char
*
line
)
...
...
src/client.h
View file @
5c10d2de
...
...
@@ -30,7 +30,7 @@ struct sockaddr;
void
client_manager_init
(
void
);
void
client_manager_deinit
(
void
);
void
client_new
(
int
fd
,
const
struct
sockaddr
*
addr
,
int
uid
);
void
client_new
(
int
fd
,
const
struct
sockaddr
*
sa
,
size_t
sa_length
,
int
uid
);
bool
client_is_expired
(
const
struct
client
*
client
);
...
...
src/listen.c
View file @
5c10d2de
...
...
@@ -455,7 +455,7 @@ listen_in_event(G_GNUC_UNUSED GIOChannel *source,
if
(
fd
>=
0
)
{
set_nonblocking
(
fd
);
client_new
(
fd
,
&
sockAddr
,
get_remote_uid
(
fd
));
client_new
(
fd
,
&
sockAddr
,
socklen
,
get_remote_uid
(
fd
));
}
else
if
(
fd
<
0
&&
errno
!=
EINTR
)
{
g_warning
(
"Problems accept()'ing"
);
}
...
...
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