1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-03-31 02:32:49 -05:00

Rename SocketPeerInfo to SocketEndpointInfo.

I'm preparing to be able to ask about the other end of the connection
too, so the first step is to give this data structure a neutral name
that can refer to either. No functional change yet.
This commit is contained in:
Simon Tatham 2024-06-26 06:35:40 +01:00
parent 431838747b
commit f454c84a23
25 changed files with 61 additions and 61 deletions

2
defs.h
View File

@ -104,7 +104,7 @@ typedef struct SockAddr SockAddr;
typedef struct Socket Socket; typedef struct Socket Socket;
typedef struct Plug Plug; typedef struct Plug Plug;
typedef struct SocketPeerInfo SocketPeerInfo; typedef struct SocketEndpointInfo SocketEndpointInfo;
typedef struct DeferredSocketOpener DeferredSocketOpener; typedef struct DeferredSocketOpener DeferredSocketOpener;
typedef struct DeferredSocketOpenerVtable DeferredSocketOpenerVtable; typedef struct DeferredSocketOpenerVtable DeferredSocketOpenerVtable;

View File

@ -39,7 +39,7 @@ static const char *sk_error_socket_error(Socket *s)
return es->error; return es->error;
} }
static SocketPeerInfo *sk_error_peer_info(Socket *s) static SocketEndpointInfo *sk_error_peer_info(Socket *s)
{ {
return NULL; return NULL;
} }

View File

@ -34,7 +34,7 @@ struct SocketVtable {
void (*set_frozen) (Socket *s, bool is_frozen); void (*set_frozen) (Socket *s, bool is_frozen);
/* ignored by tcp, but vital for ssl */ /* ignored by tcp, but vital for ssl */
const char *(*socket_error) (Socket *s); const char *(*socket_error) (Socket *s);
SocketPeerInfo *(*peer_info) (Socket *s); SocketEndpointInfo *(*peer_info) (Socket *s);
}; };
typedef union { void *p; int i; } accept_ctx_t; typedef union { void *p; int i; } accept_ctx_t;
@ -292,23 +292,23 @@ static inline void sk_set_frozen(Socket *s, bool is_frozen)
{ s->vt->set_frozen(s, is_frozen); } { s->vt->set_frozen(s, is_frozen); }
/* /*
* Return a structure giving some information about the other end of * Return a structure giving some information about one end of
* the socket. May be NULL, if nothing is available at all. If it is * the socket. May be NULL, if nothing is available at all. If it is
* not NULL, then it is dynamically allocated, and should be freed by * not NULL, then it is dynamically allocated, and should be freed by
* a call to sk_free_peer_info(). See below for the definition. * a call to sk_free_endpoint_info(). See below for the definition.
*/ */
static inline SocketPeerInfo *sk_peer_info(Socket *s) static inline SocketEndpointInfo *sk_peer_info(Socket *s)
{ return s->vt->peer_info(s); } { return s->vt->peer_info(s); }
/* /*
* The structure returned from sk_peer_info, and a function to free * The structure returned from sk_endpoint_info, and a function to free
* one (in utils). * one (in utils).
*/ */
struct SocketPeerInfo { struct SocketEndpointInfo {
int addressfamily; int addressfamily;
/* /*
* Text form of the IPv4 or IPv6 address of the other end of the * Text form of the IPv4 or IPv6 address of the specified end of the
* socket, if available, in the standard text representation. * socket, if available, in the standard text representation.
*/ */
const char *addr_text; const char *addr_text;
@ -337,7 +337,7 @@ struct SocketPeerInfo {
*/ */
const char *log_text; const char *log_text;
}; };
void sk_free_peer_info(SocketPeerInfo *pi); void sk_free_endpoint_info(SocketEndpointInfo *ei);
/* /*
* Simple wrapper on getservbyname(), needed by portfwd.c. Returns the * Simple wrapper on getservbyname(), needed by portfwd.c. Returns the

View File

@ -1885,7 +1885,7 @@ static int pageant_listen_accepting(Plug *plug,
plug, struct pageant_listen_state, plug); plug, struct pageant_listen_state, plug);
struct pageant_conn_state *pc; struct pageant_conn_state *pc;
const char *err; const char *err;
SocketPeerInfo *peerinfo; SocketEndpointInfo *peerinfo;
pc = snew(struct pageant_conn_state); pc = snew(struct pageant_conn_state);
pc->plug.vt = &pageant_connection_plugvt; pc->plug.vt = &pageant_connection_plugvt;
@ -1914,7 +1914,7 @@ static int pageant_listen_accepting(Plug *plug,
pageant_listener_client_log(pl->plc, "c#%"SIZEu": new connection", pageant_listener_client_log(pl->plc, "c#%"SIZEu": new connection",
pc->conn_index); pc->conn_index);
} }
sk_free_peer_info(peerinfo); sk_free_endpoint_info(peerinfo);
pageant_register_client(&pc->pc); pageant_register_client(&pc->pc);

View File

@ -123,7 +123,7 @@ static const char *sshproxy_socket_error(Socket *s)
return sp->errmsg; return sp->errmsg;
} }
static SocketPeerInfo *sshproxy_peer_info(Socket *s) static SocketEndpointInfo *sshproxy_peer_info(Socket *s)
{ {
return NULL; return NULL;
} }

View File

@ -72,7 +72,7 @@ struct psocks_connection {
static SshChannel *psocks_lportfwd_open( static SshChannel *psocks_lportfwd_open(
ConnectionLayer *cl, const char *hostname, int port, ConnectionLayer *cl, const char *hostname, int port,
const char *description, const SocketPeerInfo *pi, Channel *chan); const char *description, const SocketEndpointInfo *pi, Channel *chan);
static const ConnectionLayerVtable psocks_clvt = { static const ConnectionLayerVtable psocks_clvt = {
.lportfwd_open = psocks_lportfwd_open, .lportfwd_open = psocks_lportfwd_open,
@ -154,7 +154,7 @@ static void psocks_connection_establish(void *vctx);
static SshChannel *psocks_lportfwd_open( static SshChannel *psocks_lportfwd_open(
ConnectionLayer *cl, const char *hostname, int port, ConnectionLayer *cl, const char *hostname, int port,
const char *description, const SocketPeerInfo *pi, Channel *chan) const char *description, const SocketEndpointInfo *pi, Channel *chan)
{ {
psocks_state *ps = container_of(cl, psocks_state, cl); psocks_state *ps = container_of(cl, psocks_state, cl);
psocks_connection *conn = snew(psocks_connection); psocks_connection *conn = snew(psocks_connection);

8
ssh.h
View File

@ -225,7 +225,7 @@ struct ConnectionLayerVtable {
* PortFwdManager */ * PortFwdManager */
SshChannel *(*lportfwd_open)( SshChannel *(*lportfwd_open)(
ConnectionLayer *cl, const char *hostname, int port, ConnectionLayer *cl, const char *hostname, int port,
const char *description, const SocketPeerInfo *peerinfo, const char *description, const SocketEndpointInfo *peerinfo,
Channel *chan); Channel *chan);
/* Initiate opening of a 'session'-type channel */ /* Initiate opening of a 'session'-type channel */
@ -234,7 +234,7 @@ struct ConnectionLayerVtable {
/* Open outgoing channels for X and agent forwarding. (Used in the /* Open outgoing channels for X and agent forwarding. (Used in the
* SSH server.) */ * SSH server.) */
SshChannel *(*serverside_x11_open)(ConnectionLayer *cl, Channel *chan, SshChannel *(*serverside_x11_open)(ConnectionLayer *cl, Channel *chan,
const SocketPeerInfo *pi); const SocketEndpointInfo *pi);
SshChannel *(*serverside_agent_open)(ConnectionLayer *cl, Channel *chan); SshChannel *(*serverside_agent_open)(ConnectionLayer *cl, Channel *chan);
/* Add an X11 display for ordinary X forwarding */ /* Add an X11 display for ordinary X forwarding */
@ -324,12 +324,12 @@ static inline void ssh_rportfwd_remove(
{ cl->vt->rportfwd_remove(cl, rpf); } { cl->vt->rportfwd_remove(cl, rpf); }
static inline SshChannel *ssh_lportfwd_open( static inline SshChannel *ssh_lportfwd_open(
ConnectionLayer *cl, const char *host, int port, ConnectionLayer *cl, const char *host, int port,
const char *desc, const SocketPeerInfo *pi, Channel *chan) const char *desc, const SocketEndpointInfo *pi, Channel *chan)
{ return cl->vt->lportfwd_open(cl, host, port, desc, pi, chan); } { return cl->vt->lportfwd_open(cl, host, port, desc, pi, chan); }
static inline SshChannel *ssh_session_open(ConnectionLayer *cl, Channel *chan) static inline SshChannel *ssh_session_open(ConnectionLayer *cl, Channel *chan)
{ return cl->vt->session_open(cl, chan); } { return cl->vt->session_open(cl, chan); }
static inline SshChannel *ssh_serverside_x11_open( static inline SshChannel *ssh_serverside_x11_open(
ConnectionLayer *cl, Channel *chan, const SocketPeerInfo *pi) ConnectionLayer *cl, Channel *chan, const SocketEndpointInfo *pi)
{ return cl->vt->serverside_x11_open(cl, chan, pi); } { return cl->vt->serverside_x11_open(cl, chan, pi); }
static inline SshChannel *ssh_serverside_agent_open( static inline SshChannel *ssh_serverside_agent_open(
ConnectionLayer *cl, Channel *chan) ConnectionLayer *cl, Channel *chan)

View File

@ -531,7 +531,7 @@ struct ssh_rportfwd *ssh1_rportfwd_alloc(
} }
SshChannel *ssh1_serverside_x11_open( SshChannel *ssh1_serverside_x11_open(
ConnectionLayer *cl, Channel *chan, const SocketPeerInfo *pi) ConnectionLayer *cl, Channel *chan, const SocketEndpointInfo *pi)
{ {
unreachable("Should never be called in the client"); unreachable("Should never be called in the client");
} }

View File

@ -315,7 +315,7 @@ static void ssh1sesschan_send_exit_signal(
} }
SshChannel *ssh1_serverside_x11_open( SshChannel *ssh1_serverside_x11_open(
ConnectionLayer *cl, Channel *chan, const SocketPeerInfo *pi) ConnectionLayer *cl, Channel *chan, const SocketEndpointInfo *pi)
{ {
struct ssh1_connection_state *s = struct ssh1_connection_state *s =
container_of(cl, struct ssh1_connection_state, cl); container_of(cl, struct ssh1_connection_state, cl);

View File

@ -48,7 +48,7 @@ static void ssh1_rportfwd_remove(
ConnectionLayer *cl, struct ssh_rportfwd *rpf); ConnectionLayer *cl, struct ssh_rportfwd *rpf);
static SshChannel *ssh1_lportfwd_open( static SshChannel *ssh1_lportfwd_open(
ConnectionLayer *cl, const char *hostname, int port, ConnectionLayer *cl, const char *hostname, int port,
const char *description, const SocketPeerInfo *pi, Channel *chan); const char *description, const SocketEndpointInfo *pi, Channel *chan);
static struct X11FakeAuth *ssh1_add_x11_display( static struct X11FakeAuth *ssh1_add_x11_display(
ConnectionLayer *cl, int authtype, struct X11Display *disp); ConnectionLayer *cl, int authtype, struct X11Display *disp);
static bool ssh1_agent_forwarding_permitted(ConnectionLayer *cl); static bool ssh1_agent_forwarding_permitted(ConnectionLayer *cl);
@ -641,7 +641,7 @@ static struct X11FakeAuth *ssh1_add_x11_display(
static SshChannel *ssh1_lportfwd_open( static SshChannel *ssh1_lportfwd_open(
ConnectionLayer *cl, const char *hostname, int port, ConnectionLayer *cl, const char *hostname, int port,
const char *description, const SocketPeerInfo *pi, Channel *chan) const char *description, const SocketEndpointInfo *pi, Channel *chan)
{ {
struct ssh1_connection_state *s = struct ssh1_connection_state *s =
container_of(cl, struct ssh1_connection_state, cl); container_of(cl, struct ssh1_connection_state, cl);

View File

@ -111,7 +111,7 @@ struct ssh_rportfwd *ssh1_rportfwd_alloc(
int addressfamily, const char *log_description, PortFwdRecord *pfr, int addressfamily, const char *log_description, PortFwdRecord *pfr,
ssh_sharing_connstate *share_ctx); ssh_sharing_connstate *share_ctx);
SshChannel *ssh1_serverside_x11_open( SshChannel *ssh1_serverside_x11_open(
ConnectionLayer *cl, Channel *chan, const SocketPeerInfo *pi); ConnectionLayer *cl, Channel *chan, const SocketEndpointInfo *pi);
SshChannel *ssh1_serverside_agent_open(ConnectionLayer *cl, Channel *chan); SshChannel *ssh1_serverside_agent_open(ConnectionLayer *cl, Channel *chan);
void ssh1_connection_direction_specific_setup( void ssh1_connection_direction_specific_setup(

View File

@ -156,7 +156,7 @@ bool ssh2_connection_parse_global_request(
PktOut *ssh2_portfwd_chanopen( PktOut *ssh2_portfwd_chanopen(
struct ssh2_connection_state *s, struct ssh2_channel *c, struct ssh2_connection_state *s, struct ssh2_channel *c,
const char *hostname, int port, const char *hostname, int port,
const char *description, const SocketPeerInfo *peerinfo) const char *description, const SocketEndpointInfo *peerinfo)
{ {
PacketProtocolLayer *ppl = &s->ppl; /* for ppl_logevent */ PacketProtocolLayer *ppl = &s->ppl; /* for ppl_logevent */
PktOut *pktout; PktOut *pktout;
@ -321,7 +321,7 @@ SshChannel *ssh2_session_open(ConnectionLayer *cl, Channel *chan)
} }
SshChannel *ssh2_serverside_x11_open( SshChannel *ssh2_serverside_x11_open(
ConnectionLayer *cl, Channel *chan, const SocketPeerInfo *pi) ConnectionLayer *cl, Channel *chan, const SocketEndpointInfo *pi)
{ {
unreachable("Should never be called in the client"); unreachable("Should never be called in the client");
} }

View File

@ -109,7 +109,7 @@ bool ssh2_connection_parse_global_request(
PktOut *ssh2_portfwd_chanopen( PktOut *ssh2_portfwd_chanopen(
struct ssh2_connection_state *s, struct ssh2_channel *c, struct ssh2_connection_state *s, struct ssh2_channel *c,
const char *hostname, int port, const char *hostname, int port,
const char *description, const SocketPeerInfo *pi) const char *description, const SocketEndpointInfo *pi)
{ {
PacketProtocolLayer *ppl = &s->ppl; /* for ppl_logevent */ PacketProtocolLayer *ppl = &s->ppl; /* for ppl_logevent */
PktOut *pktout; PktOut *pktout;
@ -158,7 +158,7 @@ SshChannel *ssh2_session_open(ConnectionLayer *cl, Channel *chan)
} }
SshChannel *ssh2_serverside_x11_open( SshChannel *ssh2_serverside_x11_open(
ConnectionLayer *cl, Channel *chan, const SocketPeerInfo *pi) ConnectionLayer *cl, Channel *chan, const SocketEndpointInfo *pi)
{ {
struct ssh2_connection_state *s = struct ssh2_connection_state *s =
container_of(cl, struct ssh2_connection_state, cl); container_of(cl, struct ssh2_connection_state, cl);

View File

@ -33,7 +33,7 @@ static const PacketProtocolLayerVtable ssh2_connection_vtable = {
static SshChannel *ssh2_lportfwd_open( static SshChannel *ssh2_lportfwd_open(
ConnectionLayer *cl, const char *hostname, int port, ConnectionLayer *cl, const char *hostname, int port,
const char *description, const SocketPeerInfo *pi, Channel *chan); const char *description, const SocketEndpointInfo *pi, Channel *chan);
static struct X11FakeAuth *ssh2_add_x11_display( static struct X11FakeAuth *ssh2_add_x11_display(
ConnectionLayer *cl, int authtype, struct X11Display *x11disp); ConnectionLayer *cl, int authtype, struct X11Display *x11disp);
static struct X11FakeAuth *ssh2_add_sharing_x11_display( static struct X11FakeAuth *ssh2_add_sharing_x11_display(
@ -1461,7 +1461,7 @@ static void ssh2channel_hint_channel_is_simple(SshChannel *sc)
static SshChannel *ssh2_lportfwd_open( static SshChannel *ssh2_lportfwd_open(
ConnectionLayer *cl, const char *hostname, int port, ConnectionLayer *cl, const char *hostname, int port,
const char *description, const SocketPeerInfo *pi, Channel *chan) const char *description, const SocketEndpointInfo *pi, Channel *chan)
{ {
struct ssh2_connection_state *s = struct ssh2_connection_state *s =
container_of(cl, struct ssh2_connection_state, cl); container_of(cl, struct ssh2_connection_state, cl);

View File

@ -159,7 +159,7 @@ PktOut *ssh2_chanopen_init(struct ssh2_channel *c, const char *type);
PktOut *ssh2_portfwd_chanopen( PktOut *ssh2_portfwd_chanopen(
struct ssh2_connection_state *s, struct ssh2_channel *c, struct ssh2_connection_state *s, struct ssh2_channel *c,
const char *hostname, int port, const char *hostname, int port,
const char *description, const SocketPeerInfo *peerinfo); const char *description, const SocketEndpointInfo *peerinfo);
struct ssh_rportfwd *ssh2_rportfwd_alloc( struct ssh_rportfwd *ssh2_rportfwd_alloc(
ConnectionLayer *cl, ConnectionLayer *cl,
@ -170,7 +170,7 @@ void ssh2_rportfwd_remove(
ConnectionLayer *cl, struct ssh_rportfwd *rpf); ConnectionLayer *cl, struct ssh_rportfwd *rpf);
SshChannel *ssh2_session_open(ConnectionLayer *cl, Channel *chan); SshChannel *ssh2_session_open(ConnectionLayer *cl, Channel *chan);
SshChannel *ssh2_serverside_x11_open( SshChannel *ssh2_serverside_x11_open(
ConnectionLayer *cl, Channel *chan, const SocketPeerInfo *pi); ConnectionLayer *cl, Channel *chan, const SocketEndpointInfo *pi);
SshChannel *ssh2_serverside_agent_open(ConnectionLayer *cl, Channel *chan); SshChannel *ssh2_serverside_agent_open(ConnectionLayer *cl, Channel *chan);
void ssh2channel_send_exit_status(SshChannel *c, int status); void ssh2channel_send_exit_status(SshChannel *c, int status);

View File

@ -152,7 +152,7 @@ static SshChannel *wrap_lportfwd_open(
ConnectionLayer *cl, const char *hostname, int port, ConnectionLayer *cl, const char *hostname, int port,
Socket *s, Channel *chan) Socket *s, Channel *chan)
{ {
SocketPeerInfo *pi; SocketEndpointInfo *pi;
char *description; char *description;
SshChannel *toret; SshChannel *toret;
@ -163,7 +163,7 @@ static SshChannel *wrap_lportfwd_open(
description = dupstr("forwarding"); description = dupstr("forwarding");
} }
toret = ssh_lportfwd_open(cl, hostname, port, description, pi, chan); toret = ssh_lportfwd_open(cl, hostname, port, description, pi, chan);
sk_free_peer_info(pi); sk_free_endpoint_info(pi);
sfree(description); sfree(description);
return toret; return toret;

View File

@ -383,7 +383,7 @@ static int xfwd_accepting(Plug *p, accept_fn_t constructor, accept_ctx_t ctx)
Plug *plug; Plug *plug;
Channel *chan; Channel *chan;
Socket *s; Socket *s;
SocketPeerInfo *pi; SocketEndpointInfo *pi;
const char *err; const char *err;
chan = portfwd_raw_new(sess->c->cl, &plug, false); chan = portfwd_raw_new(sess->c->cl, &plug, false);
@ -394,7 +394,7 @@ static int xfwd_accepting(Plug *p, accept_fn_t constructor, accept_ctx_t ctx)
} }
pi = sk_peer_info(s); pi = sk_peer_info(s);
portfwd_raw_setup(chan, s, ssh_serverside_x11_open(sess->c->cl, chan, pi)); portfwd_raw_setup(chan, s, ssh_serverside_x11_open(sess->c->cl, chan, pi));
sk_free_peer_info(pi); sk_free_endpoint_info(pi);
return 0; return 0;
} }

View File

@ -1909,7 +1909,7 @@ static int share_listen_accepting(Plug *plug,
plug, struct ssh_sharing_state, plug); plug, struct ssh_sharing_state, plug);
struct ssh_sharing_connstate *cs; struct ssh_sharing_connstate *cs;
const char *err; const char *err;
SocketPeerInfo *peerinfo; SocketEndpointInfo *peerinfo;
/* /*
* A new downstream has connected to us. * A new downstream has connected to us.
@ -1956,7 +1956,7 @@ static int share_listen_accepting(Plug *plug,
log_downstream(cs, "connected%s%s", log_downstream(cs, "connected%s%s",
(peerinfo && peerinfo->log_text ? " from " : ""), (peerinfo && peerinfo->log_text ? " from " : ""),
(peerinfo && peerinfo->log_text ? peerinfo->log_text : "")); (peerinfo && peerinfo->log_text ? peerinfo->log_text : ""));
sk_free_peer_info(peerinfo); sk_free_endpoint_info(peerinfo);
return 0; return 0;
} }

View File

@ -488,7 +488,7 @@ static size_t sk_net_write(Socket *s, const void *data, size_t len);
static size_t sk_net_write_oob(Socket *s, const void *data, size_t len); static size_t sk_net_write_oob(Socket *s, const void *data, size_t len);
static void sk_net_write_eof(Socket *s); static void sk_net_write_eof(Socket *s);
static void sk_net_set_frozen(Socket *s, bool is_frozen); static void sk_net_set_frozen(Socket *s, bool is_frozen);
static SocketPeerInfo *sk_net_peer_info(Socket *s); static SocketEndpointInfo *sk_net_peer_info(Socket *s);
static const char *sk_net_socket_error(Socket *s); static const char *sk_net_socket_error(Socket *s);
static const SocketVtable NetSocket_sockvt = { static const SocketVtable NetSocket_sockvt = {
@ -1494,7 +1494,7 @@ static void sk_net_set_frozen(Socket *sock, bool is_frozen)
uxsel_tell(s); uxsel_tell(s);
} }
static SocketPeerInfo *sk_net_peer_info(Socket *sock) static SocketEndpointInfo *sk_net_peer_info(Socket *sock)
{ {
NetSocket *s = container_of(sock, NetSocket, sock); NetSocket *s = container_of(sock, NetSocket, sock);
union sockaddr_union addr; union sockaddr_union addr;
@ -1502,12 +1502,12 @@ static SocketPeerInfo *sk_net_peer_info(Socket *sock)
#ifndef NO_IPV6 #ifndef NO_IPV6
char buf[INET6_ADDRSTRLEN]; char buf[INET6_ADDRSTRLEN];
#endif #endif
SocketPeerInfo *pi; SocketEndpointInfo *pi;
if (getpeername(s->s, &addr.sa, &addrlen) < 0) if (getpeername(s->s, &addr.sa, &addrlen) < 0)
return NULL; return NULL;
pi = snew(SocketPeerInfo); pi = snew(SocketEndpointInfo);
pi->addressfamily = ADDRTYPE_UNSPEC; pi->addressfamily = ADDRTYPE_UNSPEC;
pi->addr_text = NULL; pi->addr_text = NULL;
pi->port = -1; pi->port = -1;

View File

@ -299,12 +299,12 @@ static int server_accepting(Plug *p, accept_fn_t constructor, accept_ctx_t ctx)
if ((err = sk_socket_error(s)) != NULL) if ((err = sk_socket_error(s)) != NULL)
return 1; return 1;
SocketPeerInfo *pi = sk_peer_info(s); SocketEndpointInfo *pi = sk_peer_info(s);
char *msg = dupprintf("new connection from %s", pi->log_text); char *msg = dupprintf("new connection from %s", pi->log_text);
log_to_stderr(inst->id, msg); log_to_stderr(inst->id, msg);
sfree(msg); sfree(msg);
sk_free_peer_info(pi); sk_free_endpoint_info(pi);
sk_set_frozen(s, false); sk_set_frozen(s, false);
ssh_server_start(plug, s); ssh_server_start(plug, s);

View File

@ -514,13 +514,13 @@ static int server_accepting(Plug *p, accept_fn_t constructor, accept_ctx_t ctx)
if ((err = sk_socket_error(s)) != NULL) if ((err = sk_socket_error(s)) != NULL)
return 1; return 1;
SocketPeerInfo *pi = sk_peer_info(s); SocketEndpointInfo *pi = sk_peer_info(s);
if (pi->addressfamily != ADDRTYPE_LOCAL && !sk_peer_trusted(s)) { if (pi->addressfamily != ADDRTYPE_LOCAL && !sk_peer_trusted(s)) {
fprintf(stderr, "rejected connection to serv#%u " fprintf(stderr, "rejected connection to serv#%u "
"from %s (untrustworthy peer)\n", "from %s (untrustworthy peer)\n",
cfg->config_id, pi->log_text); cfg->config_id, pi->log_text);
sk_free_peer_info(pi); sk_free_endpoint_info(pi);
sk_close(s); sk_close(s);
next_id = old_next_id; next_id = old_next_id;
return 1; return 1;
@ -530,7 +530,7 @@ static int server_accepting(Plug *p, accept_fn_t constructor, accept_ctx_t ctx)
cfg->config_id, pi->log_text); cfg->config_id, pi->log_text);
log_to_stderr(inst->id, msg); log_to_stderr(inst->id, msg);
sfree(msg); sfree(msg);
sk_free_peer_info(pi); sk_free_endpoint_info(pi);
sk_set_frozen(s, false); sk_set_frozen(s, false);
ssh_server_start(plug, s); ssh_server_start(plug, s);

View File

@ -1,14 +1,14 @@
/* /*
* Free a SocketPeerInfo, and everything that dangles off it. * Free a SocketEndpointInfo, and everything that dangles off it.
*/ */
#include "putty.h" #include "putty.h"
void sk_free_peer_info(SocketPeerInfo *pi) void sk_free_endpoint_info(SocketEndpointInfo *ei)
{ {
if (pi) { if (ei) {
sfree((char *)pi->addr_text); sfree((char *)ei->addr_text);
sfree((char *)pi->log_text); sfree((char *)ei->log_text);
sfree(pi); sfree(ei);
} }
} }

View File

@ -296,7 +296,7 @@ static const char *sk_handle_socket_error(Socket *s)
return hs->error; return hs->error;
} }
static SocketPeerInfo *sk_handle_peer_info(Socket *s) static SocketEndpointInfo *sk_handle_peer_info(Socket *s)
{ {
HandleSocket *hs = container_of(s, HandleSocket, sock); HandleSocket *hs = container_of(s, HandleSocket, sock);
ULONG pid; ULONG pid;
@ -326,7 +326,7 @@ static SocketPeerInfo *sk_handle_peer_info(Socket *s)
*/ */
if (p_GetNamedPipeClientProcessId && if (p_GetNamedPipeClientProcessId &&
p_GetNamedPipeClientProcessId(hs->send_H, &pid)) { p_GetNamedPipeClientProcessId(hs->send_H, &pid)) {
SocketPeerInfo *pi = snew(SocketPeerInfo); SocketEndpointInfo *pi = snew(SocketEndpointInfo);
pi->addressfamily = ADDRTYPE_LOCAL; pi->addressfamily = ADDRTYPE_LOCAL;
pi->addr_text = NULL; pi->addr_text = NULL;
pi->port = -1; pi->port = -1;
@ -431,7 +431,7 @@ static void sk_handle_deferred_set_frozen(Socket *s, bool is_frozen)
hs->frozen = is_frozen; hs->frozen = is_frozen;
} }
static SocketPeerInfo *sk_handle_deferred_peer_info(Socket *s) static SocketEndpointInfo *sk_handle_deferred_peer_info(Socket *s)
{ {
return NULL; return NULL;
} }

View File

@ -63,7 +63,7 @@ static const char *sk_namedpipeserver_socket_error(Socket *s)
return ps->error; return ps->error;
} }
static SocketPeerInfo *sk_namedpipeserver_peer_info(Socket *s) static SocketEndpointInfo *sk_namedpipeserver_peer_info(Socket *s)
{ {
return NULL; return NULL;
} }

View File

@ -821,7 +821,7 @@ static size_t sk_net_write_oob(Socket *s, const void *data, size_t len);
static void sk_net_write_eof(Socket *s); static void sk_net_write_eof(Socket *s);
static void sk_net_set_frozen(Socket *s, bool is_frozen); static void sk_net_set_frozen(Socket *s, bool is_frozen);
static const char *sk_net_socket_error(Socket *s); static const char *sk_net_socket_error(Socket *s);
static SocketPeerInfo *sk_net_peer_info(Socket *s); static SocketEndpointInfo *sk_net_peer_info(Socket *s);
static const SocketVtable NetSocket_sockvt = { static const SocketVtable NetSocket_sockvt = {
.plug = sk_net_plug, .plug = sk_net_plug,
@ -1747,7 +1747,7 @@ static const char *sk_net_socket_error(Socket *sock)
return s->error; return s->error;
} }
static SocketPeerInfo *sk_net_peer_info(Socket *sock) static SocketEndpointInfo *sk_net_peer_info(Socket *sock)
{ {
NetSocket *s = container_of(sock, NetSocket, sock); NetSocket *s = container_of(sock, NetSocket, sock);
#ifdef NO_IPV6 #ifdef NO_IPV6
@ -1757,12 +1757,12 @@ static SocketPeerInfo *sk_net_peer_info(Socket *sock)
char buf[INET6_ADDRSTRLEN]; char buf[INET6_ADDRSTRLEN];
#endif #endif
int addrlen = sizeof(addr); int addrlen = sizeof(addr);
SocketPeerInfo *pi; SocketEndpointInfo *pi;
if (p_getpeername(s->s, (struct sockaddr *)&addr, &addrlen) < 0) if (p_getpeername(s->s, (struct sockaddr *)&addr, &addrlen) < 0)
return NULL; return NULL;
pi = snew(SocketPeerInfo); pi = snew(SocketEndpointInfo);
pi->addressfamily = ADDRTYPE_UNSPEC; pi->addressfamily = ADDRTYPE_UNSPEC;
pi->addr_text = NULL; pi->addr_text = NULL;
pi->port = -1; pi->port = -1;