summaryrefslogtreecommitdiffstats
path: root/plugins/t
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/t')
0 files changed, 0 insertions, 0 deletions
diff --git a/plugins/netutils.c b/plugins/netutils.c
index 0044046..4804218 100644
--- a/plugins/netutils.c
+++ b/plugins/netutils.c
@@ -167,11 +167,13 @@ np_net_connect (const char *host_name, int port, int *sd, int proto)
167 char port_str[6], host[MAX_HOST_ADDRESS_LENGTH]; 167 char port_str[6], host[MAX_HOST_ADDRESS_LENGTH];
168 size_t len; 168 size_t len;
169 int socktype, result; 169 int socktype, result;
170 bool is_socket;
170 171
171 socktype = (proto == IPPROTO_UDP) ? SOCK_DGRAM : SOCK_STREAM; 172 socktype = (proto == IPPROTO_UDP) ? SOCK_DGRAM : SOCK_STREAM;
173 bool is_socket = (host_name[0] == '/');
172 174
173 /* as long as it doesn't start with a '/', it's assumed a host or ip */ 175 /* as long as it doesn't start with a '/', it's assumed a host or ip */
174 if(host_name[0] != '/'){ 176 if (!is_socket){
175 memset (&hints, 0, sizeof (hints)); 177 memset (&hints, 0, sizeof (hints));
176 hints.ai_family = address_family; 178 hints.ai_family = address_family;
177 hints.ai_protocol = proto; 179 hints.ai_protocol = proto;
@@ -253,7 +255,11 @@ np_net_connect (const char *host_name, int port, int *sd, int proto)
253 return econn_refuse_state; 255 return econn_refuse_state;
254 break; 256 break;
255 case STATE_CRITICAL: /* user did not set econn_refuse_state */ 257 case STATE_CRITICAL: /* user did not set econn_refuse_state */
256 printf ("%s\n", strerror(errno)); 258 if (is_socket)
259 printf("connect to socket %s: %s\n", host_name, strerror(errno));
260 else
261 printf("connect to address %s and port %d: %s\n",
262 host_name, port, strerror(errno));
257 return econn_refuse_state; 263 return econn_refuse_state;
258 break; 264 break;
259 default: /* it's a logic error if we do not end up in STATE_(OK|WARNING|CRITICAL) */ 265 default: /* it's a logic error if we do not end up in STATE_(OK|WARNING|CRITICAL) */
@@ -262,7 +268,11 @@ np_net_connect (const char *host_name, int port, int *sd, int proto)
262 } 268 }
263 } 269 }
264 else { 270 else {
265 printf ("%s\n", strerror(errno)); 271 if (is_socket)
272 printf("connect to socket %s: %s\n", host_name, strerror(errno));
273 else
274 printf("connect to address %s and port %d: %s\n",
275 host_name, port, strerror(errno));
266 return STATE_CRITICAL; 276 return STATE_CRITICAL;
267 } 277 }
268} 278}